Commit ffc4c922 authored by Andreas Gruenbacher's avatar Andreas Gruenbacher Committed by Al Viro

sysfs: Do not return POSIX ACL xattrs via listxattr

Commit 786534b9 introduced a regression that caused listxattr to
return the POSIX ACL attribute names even though sysfs doesn't support
POSIX ACLs.  This happens because simple_xattr_list checks for NULL
i_acl / i_default_acl, but inode_init_always initializes those fields
to ACL_NOT_CACHED ((void *)-1).  For example:
    $ getfattr -m- -d /sys
    /sys: system.posix_acl_access: Operation not supported
    /sys: system.posix_acl_default: Operation not supported
Fix this in simple_xattr_list by checking if the filesystem supports POSIX ACLs.

Fixes: 786534b9 ("tmpfs: listxattr should include POSIX ACL xattrs")
Reported-by: default avatarMarc Aurèle La France <tsi@tuyoix.net>
Tested-by: default avatarMarc Aurèle La France <tsi@tuyoix.net>
Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
Cc: stable@vger.kernel.org # v4.5+
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 5b394b2d
...@@ -948,6 +948,7 @@ ssize_t simple_xattr_list(struct inode *inode, struct simple_xattrs *xattrs, ...@@ -948,6 +948,7 @@ ssize_t simple_xattr_list(struct inode *inode, struct simple_xattrs *xattrs,
int err = 0; int err = 0;
#ifdef CONFIG_FS_POSIX_ACL #ifdef CONFIG_FS_POSIX_ACL
if (IS_POSIXACL(inode)) {
if (inode->i_acl) { if (inode->i_acl) {
err = xattr_list_one(&buffer, &remaining_size, err = xattr_list_one(&buffer, &remaining_size,
XATTR_NAME_POSIX_ACL_ACCESS); XATTR_NAME_POSIX_ACL_ACCESS);
...@@ -960,6 +961,7 @@ ssize_t simple_xattr_list(struct inode *inode, struct simple_xattrs *xattrs, ...@@ -960,6 +961,7 @@ ssize_t simple_xattr_list(struct inode *inode, struct simple_xattrs *xattrs,
if (err) if (err)
return err; return err;
} }
}
#endif #endif
spin_lock(&xattrs->lock); spin_lock(&xattrs->lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment