[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200527044037.30414-1-hsiangkao@redhat.com>
Date: Wed, 27 May 2020 12:40:37 +0800
From: Gao Xiang <hsiangkao@...hat.com>
To: Alexander Viro <viro@...iv.linux.org.uk>
Cc: linux-fsdevel@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>,
Gao Xiang <hsiangkao@...hat.com>,
Stephen Smalley <sds@...ho.nsa.gov>,
Chengguang Xu <cgxu519@...ernel.net>,
Chao Yu <yuchao0@...wei.com>
Subject: [PATCH] xattr: fix EOPNOTSUPP if fs and security xattrs disabled
commit f549d6c18c0e ("[PATCH] Generic VFS fallback for security xattrs")
introduces a behavior change of listxattr path therefore listxattr(2)
won't report EOPNOTSUPP correctly if fs and security xattrs disabled.
However it was clearly recorded in manpage all the time.
Cc: Alexander Viro <viro@...iv.linux.org.uk>
Cc: Stephen Smalley <sds@...ho.nsa.gov>
Cc: Chengguang Xu <cgxu519@...ernel.net>
Cc: Chao Yu <yuchao0@...wei.com>
Signed-off-by: Gao Xiang <hsiangkao@...hat.com>
---
Noticed when reviewing Chengguang's patch for erofs [1] (together
with ext2, f2fs). I'm not sure if it's the best approach but it
seems that security_inode_listsecurity() has other users and it
mainly focus on reporting these security xattrs...
[1] https://lore.kernel.org/r/20200526090343.22794-1-cgxu519@mykernel.net
Thanks,
Gao Xiang
fs/xattr.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/fs/xattr.c b/fs/xattr.c
index 91608d9bfc6a..f339a67db521 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -352,13 +352,15 @@ vfs_listxattr(struct dentry *dentry, char *list, size_t size)
error = security_inode_listxattr(dentry);
if (error)
return error;
- if (inode->i_op->listxattr && (inode->i_opflags & IOP_XATTR)) {
- error = inode->i_op->listxattr(dentry, list, size);
- } else {
- error = security_inode_listsecurity(inode, list, size);
- if (size && error > size)
- error = -ERANGE;
- }
+
+ if (inode->i_op->listxattr && (inode->i_opflags & IOP_XATTR))
+ return inode->i_op->listxattr(dentry, list, size);
+
+ if (!IS_ENABLED(CONFIG_SECURITY))
+ return -EOPNOTSUPP;
+ error = security_inode_listsecurity(inode, list, size);
+ if (size && error > size)
+ error = -ERANGE;
return error;
}
EXPORT_SYMBOL_GPL(vfs_listxattr);
--
2.24.0
Powered by blists - more mailing lists