From patchwork Wed Nov 18 19:18:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 11915719 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC991C6379D for ; Wed, 18 Nov 2020 19:19:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A5762220B for ; Wed, 18 Nov 2020 19:19:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=osandov-com.20150623.gappssmtp.com header.i=@osandov-com.20150623.gappssmtp.com header.b="SXRyxESn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727342AbgKRTTe (ORCPT ); Wed, 18 Nov 2020 14:19:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727324AbgKRTTd (ORCPT ); Wed, 18 Nov 2020 14:19:33 -0500 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9948FC0613D4 for ; Wed, 18 Nov 2020 11:19:33 -0800 (PST) Received: by mail-pl1-x644.google.com with SMTP id t18so1550541plo.0 for ; Wed, 18 Nov 2020 11:19:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8Juha+13op+j4M860hObsmkFcXreLNLajnjj5oyj6Fc=; b=SXRyxESnxqWtvijXr4ME6DRo29Bb+r4IbukyFtWQhUiOeWuZMiGoqk8zT99vU9CfIs sFsL4VFXw2Tdeu6ztQjIN8SWzVcjYb5tSsuwX2M7LgIRx5Vsjp0xhYMqn57o+cyV2Wcc Gd5uTWmqj4v7p5sN5d7gLtojV66ED7tqqRR5lXMvzAaTJksLxc6da5hefoE8IqFedSCV ZBQmOGce5/4zoRzCiE8Jo82GHMms5/lfwKHOoA2VmDX8VgTzqdPXpFhoCMXQqoxjNZFq XWGHYeHvM8PzVrbopREJ9MeummLpqJn5ttjLSbS+YtpopW8KYFNKXrNVcy0oyTa95rGD zRSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8Juha+13op+j4M860hObsmkFcXreLNLajnjj5oyj6Fc=; b=VzJzrivg9+Cf4a0OJXdJiJG5mwKE2GzgcHEGZs7RlNIzrMIgG06rWiaozGLVthoxYn nUQ1vqzM8x60oiYAwNPuNLLK2qy7YX+0j0c9Avzjn3jUt//HnPbq6A1hIk2521i/CR1f 1Zwf6FmSj6oHQgCwR2+V6w2yTHrOs/duePU32nDZCA3Q/AWMHMfepCvO9oQ3k3JexK4r yCIhtwuhinb7dcziu2uH4hFUJ/IigpJJWZCzwv7dENzpEmfRxGudhs9Ubu6NHuaC2CcM jDI7V9/dlRhcaAz71Nu9UiV1O6diNPxhlV7HbvZ3o3Yv4pcKbIYu1vkRCNaIPCLsWee0 Gu3A== X-Gm-Message-State: AOAM5309iJOnEiRZ2R+8zsCU9a+KmcyfyzQa19XKfmIBnIk12GjV9OY3 Rb3cOK7x7sBsCdK9M1BJnMtIig== X-Google-Smtp-Source: ABdhPJwtVAIOFL011TKnuC2lFW9Qq26zYzRJ4/EAzUsgjlotJzQpQnLq3yrQQp7SThqbk1uJ/r1pkw== X-Received: by 2002:a17:902:8ec7:b029:d8:e603:304c with SMTP id x7-20020a1709028ec7b02900d8e603304cmr5393411plo.85.1605727173156; Wed, 18 Nov 2020 11:19:33 -0800 (PST) Received: from relinquished.tfbnw.net ([2620:10d:c090:400::5:8b43]) by smtp.gmail.com with ESMTPSA id l9sm3197221pjy.10.2020.11.18.11.19.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Nov 2020 11:19:32 -0800 (PST) From: Omar Sandoval To: linux-btrfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v2 07/13] btrfs-progs: receive: open files with O_CLOEXEC Date: Wed, 18 Nov 2020 11:18:54 -0800 Message-Id: <41f3e3f92372f48037c7cee18af808d4cc5352c5.1605723745.git.osandov@osandov.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: Omar Sandoval Opening with O_ALLOW_ENCODED also requires O_CLOEXEC. Let's add O_CLOEXEC now in preparation. btrfs receive doesn't exec anything, so this should be a no-op. Signed-off-by: Omar Sandoval --- cmds/receive.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmds/receive.c b/cmds/receive.c index 2aaba3ff..2c56cea6 100644 --- a/cmds/receive.c +++ b/cmds/receive.c @@ -654,7 +654,11 @@ static int open_inode_for_write(struct btrfs_receive *rctx, const char *path) rctx->write_fd = -1; } - rctx->write_fd = open(path, O_RDWR); + /* + * When opening with O_ALLOW_ENCODED, O_CLOEXEC must also be specified. + * We might as well always use it even though we don't exec anything. + */ + rctx->write_fd = open(path, O_RDWR | O_CLOEXEC); if (rctx->write_fd < 0) { ret = -errno; error("cannot open %s: %m", path);