From patchwork Wed Jul 3 12:47:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 11029517 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CDAA818E8 for ; Wed, 3 Jul 2019 12:48:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD3BA286E0 for ; Wed, 3 Jul 2019 12:48:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B11E428900; Wed, 3 Jul 2019 12:48:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 68D80289A2 for ; Wed, 3 Jul 2019 12:48:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727086AbfGCMsu (ORCPT ); Wed, 3 Jul 2019 08:48:50 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:37116 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727222AbfGCMr3 (ORCPT ); Wed, 3 Jul 2019 08:47:29 -0400 Received: by mail-wr1-f67.google.com with SMTP id v14so2673509wrr.4; Wed, 03 Jul 2019 05:47:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=RI/DgxnmV4iAu3TqAUK19hxYZSHJoXYPEmLHYgwhdLA=; b=c1Ga63pN8WYFieikwxkbf/j423IvTHFuSlIWFWoTlXzmbMyVCj/V5HPbjJtMtPaSox JXzV1xpnA4AnTfx3cbV1jhdJxv3GoEAGIgjDjWMgcRxVYSixIAVMwS+/Ll2dGBE68C5z V5wmptPuovuxeHUQr67RVFYN3PKyJPa8Sji8IOppBcNPREOfIsyEMuO6h9oIy+PMPdVK k4mmxwCWxy5Goxf7xawR/Ofg54YsNVCAeqOtEHHWQFkpZF2Zwn0ow8AtFLOtVKY7oOWF mJPnZH0Zs0Qi/DkPEry6e72WYwXmCXFq4q41ABJ+p/QbIYaBefQnUWQ2nBtgoUwdwUGX 1rWg== 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:mime-version :content-transfer-encoding; bh=RI/DgxnmV4iAu3TqAUK19hxYZSHJoXYPEmLHYgwhdLA=; b=I1ulqwEmnWcyf/rP2+cMpc67JDPm4hWwcmyAuQKZMlrsZY+D3GDKqY9W8lGgFWKWWI y4wf5LRsQWZsDjD8DoU40ZNtPca8XfC6oHcLBDqrAgCMprHfSoVxnDpy+LKBzeFkrqBX qEqowL7dJQWTOosUMNUk4vRxPRgXE/2L43poNn7DRTEswSzbWHeFAp0Qs2dtMMBMjXqL GkeeABYQ8z8LzusA3eugoC/rwuTPPHIvBAGnGqW0JByEy+cGAEHT5htHVA+rvb3y27Zz BG6dTwzo0qoKNAivdvED22dauZCUA0mniYxT+cQAnGIGbBJXxlLFPIVh6oOGAHzZiBJQ aTtA== X-Gm-Message-State: APjAAAVqo9HsCayU28TELDzoktxvPKjcp6Yz1hib2sQj+AgtAWJZ+ker V+o40bIx5sVEprQLC7tRvRIanGcOXSM= X-Google-Smtp-Source: APXvYqyDSUVMJmoAuLKYvuPltd15RRJwej7+QPAsNgyn4lJ1V+obPuOOc/VMQzvYJYqt7biAFvJz/A== X-Received: by 2002:adf:f591:: with SMTP id f17mr30262141wro.119.1562158047270; Wed, 03 Jul 2019 05:47:27 -0700 (PDT) Received: from heron.blarg.de (p200300DC6F443A000000000000000FD2.dip0.t-ipconnect.de. [2003:dc:6f44:3a00::fd2]) by smtp.gmail.com with ESMTPSA id o24sm5480588wmh.2.2019.07.03.05.47.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 05:47:26 -0700 (PDT) From: Max Kellermann To: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, trond.myklebust@hammerspace.com, bfields@redhat.com, gregkh@linuxfoundation.org, tytso@mit.edu, adilger.kernel@dilger.ca, hughd@google.com, anna.schumaker@netapp.com Cc: linux-kernel@vger.kernel.org, Max Kellermann Subject: [PATCH 1/4] fs/posix_acl: apply umask if superblock disables ACL support Date: Wed, 3 Jul 2019 14:47:12 +0200 Message-Id: <20190703124715.4319-1-max.kellermann@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The function posix_acl_create() applies the umask only if the inode has no ACL (= NULL) or if ACLs are not supported by the filesystem driver (= -EOPNOTSUPP). However, this happens only after after the IS_POSIXACL() check succeeeded. If the superblock doesn't enable ACL support, umask will never be applied. A filesystem which has no ACL support will of course not enable SB_POSIXACL, rendering the umask-applying code path unreachable. This fixes a bug which causes the umask to be ignored with O_TMPFILE on tmpfs: https://github.com/MusicPlayerDaemon/MPD/issues/558 https://bugs.gentoo.org/show_bug.cgi?id=686142#c3 https://bugzilla.kernel.org/show_bug.cgi?id=203625 Signed-off-by: Max Kellermann --- fs/posix_acl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/posix_acl.c b/fs/posix_acl.c index 2fd0fde16fe1..815f7b36ef94 100644 --- a/fs/posix_acl.c +++ b/fs/posix_acl.c @@ -588,9 +588,14 @@ posix_acl_create(struct inode *dir, umode_t *mode, *acl = NULL; *default_acl = NULL; - if (S_ISLNK(*mode) || !IS_POSIXACL(dir)) + if (S_ISLNK(*mode)) return 0; + if (!IS_POSIXACL(dir)) { + *mode &= ~current_umask(); + return 0; + } + p = get_acl(dir, ACL_TYPE_DEFAULT); if (!p || p == ERR_PTR(-EOPNOTSUPP)) { *mode &= ~current_umask(); From patchwork Wed Jul 3 12:47:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 11029511 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CF15114C0 for ; Wed, 3 Jul 2019 12:48:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1694286E0 for ; Wed, 3 Jul 2019 12:48:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B508F289A1; Wed, 3 Jul 2019 12:48:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 699A0286E0 for ; Wed, 3 Jul 2019 12:48:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727249AbfGCMrb (ORCPT ); Wed, 3 Jul 2019 08:47:31 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:34451 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727229AbfGCMrb (ORCPT ); Wed, 3 Jul 2019 08:47:31 -0400 Received: by mail-wr1-f67.google.com with SMTP id u18so2690192wru.1; Wed, 03 Jul 2019 05:47:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WGBdNmMdhFstnWCq77MQvrEKCKvNGnCcZG5DRBITfrc=; b=GegmEgttiGYsovo5Z7c0uiUKck3nbem4kn2meh0JkG9uLTR2JLzm0njLr+zKsnh2t9 woBKi8NlY+BgaMsK6wXH/dm8fSzindZ1+JJ1sMPeDOxjfFWiREoFhCVb/JCvUuxx+1Ez XNvHnoRRsIch9tnNxpjmF8OWk6wzQNHIYMm5/BTCWvN1hWgcc0AYyULwW9C2iyxj6TzF iImYL8VhRyEpBG9g34q5/qnkOaL4tIHU7ZtjTq8+8jipQkqPkaRpnTCvAkud9hvPAiTm EFELxKEN2/8q7zoHerudPOhdPE9g9FYNlnoV1htSOQ9D7Lkp2UIwKes13spXFJDbfqcC DMjg== 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=WGBdNmMdhFstnWCq77MQvrEKCKvNGnCcZG5DRBITfrc=; b=O+pPG6Qrtm2Wcgx6CiNFcI5TagnRRu2soscJ3O4UqaeGtfK7C5xmIudqWLoKAGrPz3 CqZJgBiOWI0AlbisQZ5oAGmcZKObInyXwZ/IUSmjlTE5Qw8md6mb+vmTsHPBcmZSTJFF +i7l135i6lBJE0cXNCSdA/O1ypPK4syU8/dMUSazoLwUQbzH1/54aHM/qBYbLPZ5E4aL 5YoqvYQwtZKyBnDrPMmEe8deIov2+OiqUnCxN4AP+rTjEphZa0v/yXs6bSdcvPNjGBeb aV5NRfmUQkg9+BegjvmlajPKJzzRJz2ZxwDPwbQNDmRH3DlEaC3ZwGGRfkRhpWHRutIq fY/g== X-Gm-Message-State: APjAAAVyE2IaGCtMj7PPaMyfN1xOKTfmzWivw1W3Gsxs1mfcYwirMRCq k3oUsoI10ZWwCsKXjjQvkrLx/kaTE7E= X-Google-Smtp-Source: APXvYqyWhDxSUDunATg4EkwKFAC5mk4qZLKupInoD5ZmrQlVwniMZW9E7GGqoCGC79KQuTaiUimPVQ== X-Received: by 2002:a5d:52cd:: with SMTP id r13mr876862wrv.349.1562158048405; Wed, 03 Jul 2019 05:47:28 -0700 (PDT) Received: from heron.blarg.de (p200300DC6F443A000000000000000FD2.dip0.t-ipconnect.de. [2003:dc:6f44:3a00::fd2]) by smtp.gmail.com with ESMTPSA id o24sm5480588wmh.2.2019.07.03.05.47.27 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 05:47:27 -0700 (PDT) From: Max Kellermann To: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, trond.myklebust@hammerspace.com, bfields@redhat.com, gregkh@linuxfoundation.org, tytso@mit.edu, adilger.kernel@dilger.ca, hughd@google.com, anna.schumaker@netapp.com Cc: linux-kernel@vger.kernel.org, Max Kellermann Subject: [PATCH 2/4] fs/ext4/acl: apply umask if ACL support is disabled Date: Wed, 3 Jul 2019 14:47:13 +0200 Message-Id: <20190703124715.4319-2-max.kellermann@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190703124715.4319-1-max.kellermann@gmail.com> References: <20190703124715.4319-1-max.kellermann@gmail.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The function ext4_init_acl() calls posix_acl_create() which is responsible for applying the umask. But without CONFIG_EXT4_FS_POSIX_ACL, ext4_init_acl() is an empty inline function, and nobody applies the umask. This fixes a bug which causes the umask to be ignored with O_TMPFILE on ext4: https://github.com/MusicPlayerDaemon/MPD/issues/558 https://bugs.gentoo.org/show_bug.cgi?id=686142#c3 https://bugzilla.kernel.org/show_bug.cgi?id=203625 Signed-off-by: Max Kellermann --- fs/ext4/acl.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/ext4/acl.h b/fs/ext4/acl.h index 9b63f5416a2f..7f3b25b3fa6d 100644 --- a/fs/ext4/acl.h +++ b/fs/ext4/acl.h @@ -67,6 +67,11 @@ extern int ext4_init_acl(handle_t *, struct inode *, struct inode *); static inline int ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir) { + /* usually, the umask is applied by posix_acl_create(), but if + ext4 ACL support is disabled at compile time, we need to do + it here, because posix_acl_create() will never be called */ + inode->i_mode &= ~current_umask(); + return 0; } #endif /* CONFIG_EXT4_FS_POSIX_ACL */ From patchwork Wed Jul 3 12:47:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 11029509 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 048E513A4 for ; Wed, 3 Jul 2019 12:48:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA2B6286E0 for ; Wed, 3 Jul 2019 12:48:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DE4E0289A1; Wed, 3 Jul 2019 12:48:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8CD6628900 for ; Wed, 3 Jul 2019 12:48:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726736AbfGCMsh (ORCPT ); Wed, 3 Jul 2019 08:48:37 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:38585 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727237AbfGCMrb (ORCPT ); Wed, 3 Jul 2019 08:47:31 -0400 Received: by mail-wm1-f66.google.com with SMTP id s15so2254366wmj.3; Wed, 03 Jul 2019 05:47:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=34BvfGgISONnsOeh6LA1EfvEoJF1pB0OtD1tUFoABIY=; b=Zj7UGvBLfC6yTB5Gy9eKUFK4/FokpCeq4rsKDYgRDe54B8HOHzYIyxJ64uFiDQbtGe dcymEX/OZ6UxckhsV0b+crR0nUn36wTE+Nv796dA6bjUx2vZ6sYWv8tDd1jR20vjkc/E axfrDwffhX5EBlB97SlhsrG4ZiFWR5FA+HDb393ZrxDa6RifAc/eJepqKP/wXmu2vzgs OYgSsKz6+0lKebUAHeQcH2lQ9xxZeLqJyHXk8w83aKszArAwC3b5GMCLtI4/PhKVlzi0 f7Z/iIPiIQgFkOYfQBg30MfEHsl2FgLmGofNPispLjwALIn7vwiuMtfBGPfrc7lxhjN7 TtWA== 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=34BvfGgISONnsOeh6LA1EfvEoJF1pB0OtD1tUFoABIY=; b=aV3Ju7Ci0hz7Dkds9DMSpbYU8QlriyHGTIJ5dB1NLbK/HfVkA2LW5SGrtbIe8nhly1 ITTYuDK1O2Rq6AfCAADVg3e29ehOMxkZQj9ctM4zwEHPtD8prVbAeItxz3aNdy+IRm1Y Sx6So0yAt6iofofJRPD6sSghXy7839nsXhqLviik74MMMAeoaaFSQ2UYdsXzseTaCOYf 0JgJSFCIgwSg8QaVE5WlgTZosxo8bQx2QVGM70wjs8aZdf/3gikehLGfOvTQJbUv6Cwl JG3gBV2T5OtUSZCvcH+DCVn5wmhJHql/ysBocZJHXrg3nunBmR6841+nsS7QbEuORfkg esrw== X-Gm-Message-State: APjAAAWqgyjhMIeH0NDCTK+crisDSBht2bF4RGSbY1P6Bh8ZX3HkF7zm /ZmjU+7bvwSuxubmBEnkEQfq+VUJWpM= X-Google-Smtp-Source: APXvYqwY7iiZHXXifbUaGvDuBuT5SumvNPFuqW5mfuxQMgeVm6A6avgkZV86OlBxMZJEk3yqS5+mew== X-Received: by 2002:a7b:cd9a:: with SMTP id y26mr8435877wmj.44.1562158049430; Wed, 03 Jul 2019 05:47:29 -0700 (PDT) Received: from heron.blarg.de (p200300DC6F443A000000000000000FD2.dip0.t-ipconnect.de. [2003:dc:6f44:3a00::fd2]) by smtp.gmail.com with ESMTPSA id o24sm5480588wmh.2.2019.07.03.05.47.28 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 05:47:28 -0700 (PDT) From: Max Kellermann To: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, trond.myklebust@hammerspace.com, bfields@redhat.com, gregkh@linuxfoundation.org, tytso@mit.edu, adilger.kernel@dilger.ca, hughd@google.com, anna.schumaker@netapp.com Cc: linux-kernel@vger.kernel.org, Max Kellermann Subject: [PATCH 3/4] linux/fs.h: fix umask on NFS with CONFIG_FS_POSIX_ACL=n Date: Wed, 3 Jul 2019 14:47:14 +0200 Message-Id: <20190703124715.4319-3-max.kellermann@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190703124715.4319-1-max.kellermann@gmail.com> References: <20190703124715.4319-1-max.kellermann@gmail.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make IS_POSIXACL() return false if POSIX ACL support is disabled and ignore SB_POSIXACL/MS_POSIXACL. Never skip applying the umask in namei.c and never bother to do any ACL specific checks if the filesystem falsely indicates it has ACLs enabled when the feature is completely disabled in the kernel. This fixes a problem where the umask is always ignored in the NFS client when compiled without CONFIG_FS_POSIX_ACL. This is a 4 year old regression caused by commit 013cdf1088d723 which itself was not completely wrong, but failed to consider all the side effects by misdesigned VFS code. Prior to that commit, there were two places where the umask could be applied, for example when creating a directory: 1. in the VFS layer in SYSCALL_DEFINE3(mkdirat), but only if !IS_POSIXACL() 2. again (unconditionally) in nfs3_proc_mkdir() The first one does not apply, because even without CONFIG_FS_POSIX_ACL, the NFS client sets MS_POSIXACL in nfs_fill_super(). After that commit, (2.) was replaced by: 2b. in posix_acl_create(), called by nfs3_proc_mkdir() There's one branch in posix_acl_create() which applies the umask; however, without CONFIG_FS_POSIX_ACL, posix_acl_create() is an empty dummy function which does not apply the umask. The approach chosen by this patch is to make IS_POSIXACL() always return false when POSIX ACL support is disabled, so the umask always gets applied by the VFS layer. This is consistent with the (regular) behavior of posix_acl_create(): that function returns early if IS_POSIXACL() is false, before applying the umask. Therefore, posix_acl_create() is responsible for applying the umask if there is ACL support enabled in the file system (SB_POSIXACL), and the VFS layer is responsible for all other cases (no SB_POSIXACL or no CONFIG_FS_POSIX_ACL). Signed-off-by: Max Kellermann --- include/linux/fs.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index dd28e7679089..299acdaaab56 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1985,7 +1985,12 @@ static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA) #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND) #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE) + +#ifdef CONFIG_FS_POSIX_ACL #define IS_POSIXACL(inode) __IS_FLG(inode, SB_POSIXACL) +#else +#define IS_POSIXACL(inode) 0 +#endif #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD) #define IS_NOCMTIME(inode) ((inode)->i_flags & S_NOCMTIME) From patchwork Wed Jul 3 12:47:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 11029501 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3003B18E8 for ; Wed, 3 Jul 2019 12:48:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2273B2873E for ; Wed, 3 Jul 2019 12:48:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 16BC5289A2; Wed, 3 Jul 2019 12:48:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9661F2873E for ; Wed, 3 Jul 2019 12:48:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727192AbfGCMrd (ORCPT ); Wed, 3 Jul 2019 08:47:33 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:38380 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725830AbfGCMrc (ORCPT ); Wed, 3 Jul 2019 08:47:32 -0400 Received: by mail-wr1-f66.google.com with SMTP id p11so2669592wro.5; Wed, 03 Jul 2019 05:47:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qXfAEOlH4aIpQXeFgILadkKYn01/VlG4XvVZEcPkJYY=; b=fu9RPMVgXVFj4PgV3KF4+X0OrajMT8XRxnmdpd+teMNXTQldmYy+3On3v8YbjNRcoh y8pu8JWKMBygejEkjCVH3FFo7TeUWFChx553OzBSnX7wB17SO+47EMJ25asq7QkekJRS lEmerh2nRBiytWP6hWYZoku/WlMGJmLTtXi4MAqZ+3BWzctnGkUN5K92UzspI6a0gvCe w2s98oiKc0aK9YThQsqY+9Mx/Fd0CP0NKNqfxWpVjuW191RQYzyMeInreFxiLzqT8ZB2 +WGt3/jdTI/5XUXWLMgohdHyulxJeidi4kLtVf6eg5Z9CewOrJyC/2f3DLPzGUQQI0gM tXOw== 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=qXfAEOlH4aIpQXeFgILadkKYn01/VlG4XvVZEcPkJYY=; b=k0U3aESoKtWqiIQMY6rxjgd7/jHC1QoEnH9934TBVkPRinVnvQqKwV/KD/+vIfCoYb 0rXVFjZyTdizShANKG4wVTbHBVHt4uKJynB9yFvfUkSjR6xbCiDsbgcIZIXtca/xx7kC KJ0OhH7hyz04Vbi0WxwTJlL37mAvc+ptRn8FushRsDqW/7xFLIASmEcx+hyJh7Zr40iX vnGQTIAqbKwvy4K4rYrbk2vB/YjbV1jIrbBU7tpjARbK4AZP6ufPQCpLeL1OeC7FFy9s dRvYy9iVn8fEpK/YEdnZZCkG5JzfbAi8nF+et1vNKKm74/0zPJrAjAP0DIkGqaD1avgb 3qmw== X-Gm-Message-State: APjAAAUH2rD5XV19NwrwPUCDanWzQd1qyCeXAfZk4IDcg1RavfWAHRQq p+mr/ziGpY/zYHmD1HSsGg9ETkkBAmo= X-Google-Smtp-Source: APXvYqxD6K+0ugAMNC/aj/0XoFB4rhxYFEfIRruIudKKenQi9Fn9L+MVPP9fnwZ3jnR+ZtZPVdDKtA== X-Received: by 2002:a5d:5186:: with SMTP id k6mr31267862wrv.30.1562158050417; Wed, 03 Jul 2019 05:47:30 -0700 (PDT) Received: from heron.blarg.de (p200300DC6F443A000000000000000FD2.dip0.t-ipconnect.de. [2003:dc:6f44:3a00::fd2]) by smtp.gmail.com with ESMTPSA id o24sm5480588wmh.2.2019.07.03.05.47.29 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 05:47:29 -0700 (PDT) From: Max Kellermann To: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, trond.myklebust@hammerspace.com, bfields@redhat.com, gregkh@linuxfoundation.org, tytso@mit.edu, adilger.kernel@dilger.ca, hughd@google.com, anna.schumaker@netapp.com Cc: linux-kernel@vger.kernel.org, Max Kellermann Subject: [PATCH 4/4] nfs/super: check NFS_CAP_ACLS instead of the NFS version Date: Wed, 3 Jul 2019 14:47:15 +0200 Message-Id: <20190703124715.4319-4-max.kellermann@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190703124715.4319-1-max.kellermann@gmail.com> References: <20190703124715.4319-1-max.kellermann@gmail.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This sets MS_POSIXACL only if ACL support is really enabled, instead of always setting MS_POSIXACL if the NFS protocol version theoretically supports ACL. The code comment says "We will [apply the umask] ourselves", but that happens in posix_acl_create() only if the kernel has POSIX ACL support. Without it, posix_acl_create() is an empty dummy function. So let's not pretend we will apply the umask if we can already know that we will never. This fixes a problem where the umask is always ignored in the NFS client when compiled without CONFIG_FS_POSIX_ACL. This is a 4 year old regression caused by commit 013cdf1088d723 which itself was not completely wrong, but failed to consider all the side effects by misdesigned VFS code. Signed-off-by: Max Kellermann --- fs/nfs/super.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/nfs/super.c b/fs/nfs/super.c index c27ac96a95bd..e799296941ec 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -2343,11 +2343,14 @@ void nfs_fill_super(struct super_block *sb, struct nfs_mount_info *mount_info) if (data && data->bsize) sb->s_blocksize = nfs_block_size(data->bsize, &sb->s_blocksize_bits); - if (server->nfs_client->rpc_ops->version != 2) { + if (NFS_SB(sb)->caps & NFS_CAP_ACLS) { /* The VFS shouldn't apply the umask to mode bits. We will do * so ourselves when necessary. */ sb->s_flags |= SB_POSIXACL; + } + + if (server->nfs_client->rpc_ops->version != 2) { sb->s_time_gran = 1; sb->s_export_op = &nfs_export_ops; } @@ -2373,7 +2376,7 @@ static void nfs_clone_super(struct super_block *sb, sb->s_time_gran = 1; sb->s_export_op = old_sb->s_export_op; - if (server->nfs_client->rpc_ops->version != 2) { + if (NFS_SB(sb)->caps & NFS_CAP_ACLS) { /* The VFS shouldn't apply the umask to mode bits. We will do * so ourselves when necessary. */