nfs: fix acl memory leak of posix_acl_create()
Subsystems (2)
PATCH v2 1/2 nfs: fix acl memory leak of posix_acl_create()
When looking into another nfs xfstests report, I found acl and default_acl in nfs3_proc_create() and nfs3_proc_mknod() error paths are possibly leaked. Fix them in advance.
---
no change.
fs/nfs/nfs3proc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/nfs3proc.c +2 -2
@@ -385,7 +385,7 @@ static void nfs3_free_createdata(struct nfs3_createdata *data)break ;case NFS3_CREATE_UNCHECKED : - goto out; + goto out_release_acls; }nfs_fattr_init (data->res.dir_attr);nfs_fattr_init (data->res.fattr);
@@ -751,7 +751,7 @@ static int nfs3_proc_readdir(struct nfs_readdir_arg *nr_arg,break ;default : status = -EINVAL ; - goto out; + goto out_release_acls; } d_alias =nfs3_do_create (dir, dentry, data);
Signature · 1 line
1.8.3.1
PATCH v2 2/2 nfs: NFSv3: fix SGID bit dropped when inheriting ACLs
generic/444 fails with NFSv3 as shown above, "
QA output created by 444
drwxrwsr-x
-drwxrwsr-x
+drwxrwxr-x
", which tests "SGID inheritance with default ACLs" fs regression and looks after the following commits:
a3bb2d558752 ("ext4: Don't clear SGID when inheriting ACLs") 073931017b49 ("posix_acl: Clear SGID bit when setting file permissions")
commit 055ffbea0596 ("[PATCH] NFS: Fix handling of the umask when an NFSv3 default acl is present.") sets acls explicitly when when files are created in a directory that has a default ACL. However, after commit a3bb2d558752 and 073931017b49, SGID can be dropped if user is not member of the owning group with set_posix_acl() called.
Since underlayfs will handle ACL inheritance when creating files in a directory that has the default ACL and the umask is supposed to be ignored for such case. Therefore, I think no need to set acls explicitly (to avoid SGID bit cleared) but only apply client umask if the default ACL of the parent directory doesn't exist.
With this patch, generic/444 can pass now.
---
v1: https://lore.kernel.org/r/[email protected]
changes since v1:
fix a build error reported by:
https://lists.01.org/hyperkitty/list/[email protected]/thread/GKZF3ZU6EI2WA45RV5QJ7OT6ZWMCW2BG/
https://lists.01.org/hyperkitty/list/[email protected]/thread/S5GPZNHDQOEUCIITEQXLMIXD5IGN5QS7/
also, some previous test results:
https://lore.kernel.org/r/YNA03%[email protected]/
and I've also tested the nfs fstests default set w/o difference.
fs/nfs/nfs3_fs.h | 5 +++++ fs/nfs/nfs3proc.c | 43 ++++++++++++++++--------------------------- 2 files changed, 21 insertions(+), 27 deletions(-)
fs/nfs/nfs3_fs.h +5 -0
@@ -18,12 +18,17 @@ extern int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl, struct posix_acl *dfacl);extern ssize_t nfs3_listxattr (struct dentry *,char *,size_t );extern const struct xattr_handler *nfs3_xattr_handlers[]; +#define nfs3_proc_getacl get_acl#else static inline int nfs3_proc_setacls (struct inode *inode,struct posix_acl *acl,struct posix_acl *dfacl) {return 0 ; } +static inline struct posix_acl *nfs3_proc_getacl (struct inode *inode,int type) +{ +return NULL ; +}#define nfs3_listxattr NULL#endif /* CONFIG_NFS_V3_ACL */
fs/nfs/nfs3proc.c +16 -27
110 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH v2 2/2] nfs: NFSv3: fix SGID bit dropped when inheriting ACLs
Quoted 19 lines · Gao Xiang
generic/444 fails with NFSv3 as shown above, "
QA output created by 444
drwxrwsr-x
-drwxrwsr-x
+drwxrwxr-x
", which tests "SGID inheritance with default ACLs" fs regression and looks after the following commits:
a3bb2d558752("ext4: Don't clear SGID when inheriting ACLs")073931017b49("posix_acl: Clear SGID bit when setting file permissions")commit
055ffbea0596("[PATCH] NFS: Fix handling of the umask when an NFSv3 default acl is present.") sets acls explicitly when when files are created in a directory that has a default ACL. However, after commita3bb2d558752and073931017b49, SGID can be dropped if user is not member of the owning group withset_posix_acl()called.
Quoted 6 lines
Since underlayfs will handle ACL inheritance when creating files in a directory that has the default ACL and the umask is supposed to be ignored for such case. Therefore, I think no need to set acls explicitly (to avoid SGID bit cleared) but only apply client umask if the default ACL of the parent directory doesn't exist.
Hmm... Has this patch been tested with a Solaris server? Your assertion above appears to be true for Linux servers, but this code needs to interoperate with non-Linux draft posix acl compatible servers too.
I've already taken the other patch in this series, since that one appears correct, and doesn't have any interoperability consequences.
Signature · 3 lines
Trond Myklebust Linux NFS client maintainer, Hammerspace [email protected]
Re: [PATCH v2 2/2] nfs: NFSv3: fix SGID bit dropped when inheriting ACLs
Hi Trond,
Quoted 27 lines · Trond Myklebust
Quoted 19 lines · Gao Xiang
generic/444 fails with NFSv3 as shown above, "
QA output created by 444
drwxrwsr-x
-drwxrwsr-x
+drwxrwxr-x
", which tests "SGID inheritance with default ACLs" fs regression and looks after the following commits:
a3bb2d558752("ext4: Don't clear SGID when inheriting ACLs")073931017b49("posix_acl: Clear SGID bit when setting file permissions")commit
055ffbea0596("[PATCH] NFS: Fix handling of the umask when an NFSv3 default acl is present.") sets acls explicitly when when files are created in a directory that has a default ACL. However, after commita3bb2d558752and073931017b49, SGID can be dropped if user is not member of the owning group withset_posix_acl()called.Quoted 6 lines
Since underlayfs will handle ACL inheritance when creating files in a directory that has the default ACL and the umask is supposed to be ignored for such case. Therefore, I think no need to set acls explicitly (to avoid SGID bit cleared) but only apply client umask if the default ACL of the parent directory doesn't exist.
Quoted 3 lines
Hmm... Has this patch been tested with a Solaris server? Your assertion above appears to be true for Linux servers, but this code needs to interoperate with non-Linux draft posix acl compatible servers too.
Sigh.. I'm not quite sure about the Solaris side since I don't have the environment. In principle, I just think ACL inheritance should be an underlayfs behavior rather than some nfs-specific behavior so I assume no risk with this patch applied.
With my premature short-time glance about illumos nfs client implementation, I don't find such setacl call (correct me if I'm missing...)
https://github.com/illumos/illumos-gate/blob/9ecd05bdc59e4a1091c51ce68cce2028d5ba6fd1/usr/src/uts/common/fs/nfs/nfs3_vnops.c#L2224
(And if someone has such Solaris environment, it would be much
helpful to check this...)
Quoted 3 lines
I've already taken the other patch in this series, since that one appears correct, and doesn't have any interoperability consequences.
Thanks all!
Thanks,
Gao Xiang
Quoted 7 lines
Signature · 4 lines
-- Trond Myklebust Linux NFS client maintainer, Hammerspace [email protected]
Quoted 3 lines · Gao Xiang
When looking into another nfs xfstests report, I found acl and
default_aclinnfs3_proc_create()andnfs3_proc_mknod()error paths are possibly leaked. Fix them in advance.
Looks fine,