Skip to content

Commit ffc4c92

Browse files
agruenbaAl Viro
authored andcommitted
sysfs: Do not return POSIX ACL xattrs via listxattr
Commit 786534b 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: 786534b ("tmpfs: listxattr should include POSIX ACL xattrs") Reported-by: Marc Aurèle La France <tsi@tuyoix.net> Tested-by: Marc Aurèle La France <tsi@tuyoix.net> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Cc: stable@vger.kernel.org # v4.5+ Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 5b394b2 commit ffc4c92

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

‎fs/xattr.c‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -948,17 +948,19 @@ ssize_t simple_xattr_list(struct inode *inode, struct simple_xattrs *xattrs,
948948
int err = 0;
949949

950950
#ifdef CONFIG_FS_POSIX_ACL
951-
if (inode->i_acl) {
952-
err = xattr_list_one(&buffer, &remaining_size,
953-
XATTR_NAME_POSIX_ACL_ACCESS);
954-
if (err)
955-
return err;
956-
}
957-
if (inode->i_default_acl) {
958-
err = xattr_list_one(&buffer, &remaining_size,
959-
XATTR_NAME_POSIX_ACL_DEFAULT);
960-
if (err)
961-
return err;
951+
if (IS_POSIXACL(inode)) {
952+
if (inode->i_acl) {
953+
err = xattr_list_one(&buffer, &remaining_size,
954+
XATTR_NAME_POSIX_ACL_ACCESS);
955+
if (err)
956+
return err;
957+
}
958+
if (inode->i_default_acl) {
959+
err = xattr_list_one(&buffer, &remaining_size,
960+
XATTR_NAME_POSIX_ACL_DEFAULT);
961+
if (err)
962+
return err;
963+
}
962964
}
963965
#endif
964966

0 commit comments

Comments
 (0)