2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-12 15:24:00 +08:00

fs: fix reporting supported extra file attributes for statx()

statx(2) notes that any attribute that is not indicated as supported
by stx_attributes_mask has no usable value.  Commits 801e523796
("fs: move generic stat response attr handling to vfs_getattr_nosec")
and 712b2698e4 ("fs/stat: Define DAX statx attribute") sets
STATX_ATTR_AUTOMOUNT and STATX_ATTR_DAX, respectively, without setting
stx_attributes_mask, which can cause xfstests generic/532 to fail.

Fix this in the same way as commit 1b9598c8fb ("xfs: fix reporting
supported extra file attributes for statx()")

Fixes: 801e523796 ("fs: move generic stat response attr handling to vfs_getattr_nosec")
Fixes: 712b2698e4 ("fs/stat: Define DAX statx attribute")
Cc: stable@kernel.org
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
Theodore Ts'o 2021-04-17 23:03:50 -04:00
parent 4811d9929c
commit 5afa7e8b70

View File

@ -86,12 +86,20 @@ int vfs_getattr_nosec(const struct path *path, struct kstat *stat,
/* SB_NOATIME means filesystem supplies dummy atime value */ /* SB_NOATIME means filesystem supplies dummy atime value */
if (inode->i_sb->s_flags & SB_NOATIME) if (inode->i_sb->s_flags & SB_NOATIME)
stat->result_mask &= ~STATX_ATIME; stat->result_mask &= ~STATX_ATIME;
/*
* Note: If you add another clause to set an attribute flag, please
* update attributes_mask below.
*/
if (IS_AUTOMOUNT(inode)) if (IS_AUTOMOUNT(inode))
stat->attributes |= STATX_ATTR_AUTOMOUNT; stat->attributes |= STATX_ATTR_AUTOMOUNT;
if (IS_DAX(inode)) if (IS_DAX(inode))
stat->attributes |= STATX_ATTR_DAX; stat->attributes |= STATX_ATTR_DAX;
stat->attributes_mask |= (STATX_ATTR_AUTOMOUNT |
STATX_ATTR_DAX);
mnt_userns = mnt_user_ns(path->mnt); mnt_userns = mnt_user_ns(path->mnt);
if (inode->i_op->getattr) if (inode->i_op->getattr)
return inode->i_op->getattr(mnt_userns, path, stat, return inode->i_op->getattr(mnt_userns, path, stat,