Message ID | 20230919081837.1096695-1-max.kellermann@ionos.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3441828vqi; Tue, 19 Sep 2023 07:43:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH/Ky+F0anfX9sze3FwgBRsMxWJfcfmtDkOCOiV1ZMK0H08VVEXOjz63q9OqpNKVimqdR4U X-Received: by 2002:a17:903:41c3:b0:1c4:4a58:ff65 with SMTP id u3-20020a17090341c300b001c44a58ff65mr13048936ple.64.1695134621744; Tue, 19 Sep 2023 07:43:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695134621; cv=none; d=google.com; s=arc-20160816; b=owKi1VIed1vJrNzjj0l6PyS5+Wou+vJ0Mq5ij4Kup4kqmwx3pEN8A0Con5kA/L9tAE P5Nj/jqcy7X8VHosWpcGOTPcq1LWv0TCnyxnxb3LA+qK6Giql54o/oH7T9NQ5boggG9j zMEwVFTxTd4Y8tHu3JnKNr8P8dEnrSPcnqwRB+f83SH7+3lASllTeiRHAh8zH98aIlHH W6o4ugdTq2uinrSH+jO5CAmptMm2OwwuuRe+xYxlVyhJ/lFuObsGCkD5y6hW3D/z4c/N aiAW2/WHEaoIaxM8W0ojEoXjWntLOPt615QBNHphpKqXgBkL771DvwR7pzJdygniTgfR xZvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=S4D5C4k+i1eZNnOt391w1UuQt6K8OH0zFNJfwEYdVWU=; fh=AfjKoHwnNGjIFdw0THSLGZ546GBXmKdU/F7h7/erKd0=; b=E2dprkE5KgAPtAyPjSP8XAHkh0wOlDNjphyxPy0kuiv0T9O9ypiuP+iqD01RyBsY5G rJWcTek+llxDst3Py3ImjujI09RhvXxUbHexea72ZYiLtBUTgWY7Xx+aqxd3FG5aVYty bS0r+OTc8IsduhUUIjL/1xchzWYYQzP7j6IukaD8PHLndv3D2loEzr83lIP0shJqMyJ+ r/TN10p0LeU9C6gbEIN2GoiMUU+75iks9+BlbRN2dlKnOJsTNfD1NyrIRa3AxdZ5S7Zx 2Yd0v8ekG7a+2KZutSFsIxBkuH4yX8SYILoVXZo5uJWhAQa0wYzNasvJah6/T2sjzdH0 puaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=WobcBBhe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id l9-20020a170902f68900b001bf88e777f9si10561321plg.33.2023.09.19.07.43.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 07:43:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=WobcBBhe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 5F4E28029715; Tue, 19 Sep 2023 01:19:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230414AbjISIS4 (ORCPT <rfc822;toshivichauhan@gmail.com> + 26 others); Tue, 19 Sep 2023 04:18:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230429AbjISISs (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 19 Sep 2023 04:18:48 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 521EA12A for <linux-kernel@vger.kernel.org>; Tue, 19 Sep 2023 01:18:42 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-401f68602a8so59222175e9.3 for <linux-kernel@vger.kernel.org>; Tue, 19 Sep 2023 01:18:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1695111520; x=1695716320; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=S4D5C4k+i1eZNnOt391w1UuQt6K8OH0zFNJfwEYdVWU=; b=WobcBBhesTQqSlnbhexk2H1g4bS1LGtSdk3OQrg9ZNUcizwt5Cov1yiEqYDtrULg5A r6gy7DzGAjdDOslkSEQ3/aKkIrj4fBMRsffOPF3cLSQrQoUrTJlAcbIJYZvpIZmvnOj8 KtKV7Sd745CgU9RvivoKxsVGC3/iA7K0NfLNPTW3ZNRxr9101Q3+DZetFpF3XwKJNRga A1dGZhEXVcGfORsjN7d5y5+2VhFA4WshraOUNugNFP6moZLYniy46n7EnWuF0MSCXeRl rv3YQY7HmeVGYAvs5IWqWWpFD/52ZPoYBIgW3mSnUgTZXjj8bxuVKyWbICem1/QrbXDn l7+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695111520; x=1695716320; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=S4D5C4k+i1eZNnOt391w1UuQt6K8OH0zFNJfwEYdVWU=; b=kFgctYUF5ner6xp8Vy0f+uxicca8dH3VC1iHMyUgwEijB7zUODezf3dOwiNuGNrSyr 8K8mhiMEJJwpidlcDswJzZHxrEEkOKlQHDICrRaCqg9vqUAV2WOWDwOOafzUsXh13OkX /yFMyCWItN/6sFlOOlNt9ZzyeFx2Fsrz7iMMmmcTMnXYksASDu5W28AE/7h2Oekz56ks naeIrymo+UgSP/3YgMu1u4lt9XjuVd5E/4qGYt2+Ye/3CR0BLq+476xoXNk2tI3+4Ucr SiNqk5cFLzeTomuB5lw4AJns6qTpgk9DL7yRPuk0y89HY/czOj56Osxuj7hztwEAkxVE Qfpw== X-Gm-Message-State: AOJu0YxRtVek8+y8NsUjSpCWkJg8LJOWlS/wmhQmnGShS1QAHaOVEqtk BMj2tdU3NDYoDnMw/yVL7eLO0w== X-Received: by 2002:a5d:66c3:0:b0:317:c2a9:9b0c with SMTP id k3-20020a5d66c3000000b00317c2a99b0cmr9403458wrw.50.1695111520707; Tue, 19 Sep 2023 01:18:40 -0700 (PDT) Received: from heron.intern.cm-ag (p200300dc6f209c00529a4cfffe3dd983.dip0.t-ipconnect.de. [2003:dc:6f20:9c00:529a:4cff:fe3d:d983]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0031c8a43712asm14783219wrr.69.2023.09.19.01.18.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 01:18:39 -0700 (PDT) From: Max Kellermann <max.kellermann@ionos.com> To: Alexander Viro <viro@zeniv.linux.org.uk>, Christian Brauner <brauner@kernel.org> Cc: Max Kellermann <max.kellermann@ionos.com>, "J . Bruce Fields" <bfields@redhat.com>, Jan Kara <jack@suse.cz>, stable@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] linux/fs.h: fix umask on NFS with CONFIG_FS_POSIX_ACL=n Date: Tue, 19 Sep 2023 10:18:36 +0200 Message-Id: <20230919081837.1096695-1-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 19 Sep 2023 01:19:20 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777473738677618879 X-GMAIL-MSGID: 1777477481586154413 |
Series |
linux/fs.h: fix umask on NFS with CONFIG_FS_POSIX_ACL=n
|
|
Commit Message
Max Kellermann
Sept. 19, 2023, 8:18 a.m. UTC
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). Reviewed-by: J. Bruce Fields <bfields@redhat.com> Reviewed-by: Jan Kara <jack@suse.cz> Cc: stable@vger.kernel.org Signed-off-by: Max Kellermann <max.kellermann@ionos.com> --- include/linux/fs.h | 5 +++++ 1 file changed, 5 insertions(+)
Comments
On Tue, 2023-09-19 at 15:02 +0200, Christian Brauner wrote: > On Tue, Sep 19, 2023 at 10:18:36AM +0200, Max Kellermann wrote: > > 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(). > > Jeff, in light of the recent SB_NOUMASK work for nfs4 to always skip > applying the umask how would this patch fit into the picture? Would be > good to have your review here. > > > > > 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). > > > > Reviewed-by: J. Bruce Fields <bfields@redhat.com> > > Reviewed-by: Jan Kara <jack@suse.cz> > > Cc: stable@vger.kernel.org > > Signed-off-by: Max Kellermann <max.kellermann@ionos.com> > > --- > > include/linux/fs.h | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/include/linux/fs.h b/include/linux/fs.h > > index 4aeb3fa11927..c1a4bc5c2e95 100644 > > --- a/include/linux/fs.h > > +++ b/include/linux/fs.h > > @@ -2110,7 +2110,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) > > -- > > 2.39.2 > > (cc'ing Trond and Anna) To be clear, Christian is talking about this patch that I sent last week: https://lore.kernel.org/linux-fsdevel/20230911-acl-fix-v3-1-b25315333f6c@kernel.org/ At first glance, I don't see a problem with Max's patch. If anything the patch in the lore link above should keep NFSv4 working as expected if we take Max's patch. You might also need to add SB_I_NOUMASK for the NFSv3 case, but I'm not certain there.
On Tue, Sep 19, 2023 at 10:26:38AM -0400, Jeff Layton wrote: > On Tue, 2023-09-19 at 15:02 +0200, Christian Brauner wrote: > > On Tue, Sep 19, 2023 at 10:18:36AM +0200, Max Kellermann wrote: > > > 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(). > > > > Jeff, in light of the recent SB_NOUMASK work for nfs4 to always skip > > applying the umask how would this patch fit into the picture? Would be > > good to have your review here. > > > > > > > > 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). > > > > > > Reviewed-by: J. Bruce Fields <bfields@redhat.com> > > > Reviewed-by: Jan Kara <jack@suse.cz> > > > Cc: stable@vger.kernel.org > > > Signed-off-by: Max Kellermann <max.kellermann@ionos.com> > > > --- > > > include/linux/fs.h | 5 +++++ > > > 1 file changed, 5 insertions(+) > > > > > > diff --git a/include/linux/fs.h b/include/linux/fs.h > > > index 4aeb3fa11927..c1a4bc5c2e95 100644 > > > --- a/include/linux/fs.h > > > +++ b/include/linux/fs.h > > > @@ -2110,7 +2110,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) > > > -- > > > 2.39.2 > > > > > (cc'ing Trond and Anna) > > To be clear, Christian is talking about this patch that I sent last > week: > > https://lore.kernel.org/linux-fsdevel/20230911-acl-fix-v3-1-b25315333f6c@kernel.org/ > > At first glance, I don't see a problem with Max's patch. > > If anything the patch in the lore link above should keep NFSv4 working > as expected if we take Max's patch. You might also need to add No, it wouldn't, I think. If I understood your correctly last week then NFS always raised SB_POSIXACL in nfs_fill_super() to prevent the VFS from applying umasks in the VFS and in fact to not apply umask at all (at least for nfs4). If that's the case then accepting this patch would mean that the VFS wouldn't see this SB_POSIXACL flag anymore and would strip the umask in the VFS causing a regression for you.
diff --git a/include/linux/fs.h b/include/linux/fs.h index 4aeb3fa11927..c1a4bc5c2e95 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2110,7 +2110,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)