linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xattr: fix EOPNOTSUPP if fs and security xattrs disabled
@ 2020-05-27  4:40 Gao Xiang
  2020-06-23 10:10 ` Gao Xiang
  0 siblings, 1 reply; 2+ messages in thread
From: Gao Xiang @ 2020-05-27  4:40 UTC (permalink / raw)
  To: Alexander Viro
  Cc: linux-fsdevel, LKML, Gao Xiang, Stephen Smalley, Chengguang Xu, Chao Yu

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@zeniv.linux.org.uk>
Cc: Stephen Smalley <sds@tycho.nsa.gov>
Cc: Chengguang Xu <cgxu519@mykernel.net>
Cc: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Gao Xiang <hsiangkao@redhat.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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] xattr: fix EOPNOTSUPP if fs and security xattrs disabled
  2020-05-27  4:40 [PATCH] xattr: fix EOPNOTSUPP if fs and security xattrs disabled Gao Xiang
@ 2020-06-23 10:10 ` Gao Xiang
  0 siblings, 0 replies; 2+ messages in thread
From: Gao Xiang @ 2020-06-23 10:10 UTC (permalink / raw)
  To: Alexander Viro
  Cc: linux-fsdevel, LKML, Stephen Smalley, Chengguang Xu, Chao Yu

Friendly ping...

On Wed, May 27, 2020 at 12:40:37PM +0800, Gao Xiang wrote:
> 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@zeniv.linux.org.uk>
> Cc: Stephen Smalley <sds@tycho.nsa.gov>
> Cc: Chengguang Xu <cgxu519@mykernel.net>
> Cc: Chao Yu <yuchao0@huawei.com>
> Signed-off-by: Gao Xiang <hsiangkao@redhat.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
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-23 10:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-27  4:40 [PATCH] xattr: fix EOPNOTSUPP if fs and security xattrs disabled Gao Xiang
2020-06-23 10:10 ` Gao Xiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).