diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2019-06-30 08:49:20 -0700 |
---|---|---|
committer | Darrick J. Wong <darrick.wong@oracle.com> | 2019-06-30 08:49:20 -0700 |
commit | 8af74d044d73ac24fa7148183d79d79bcaf20bcd (patch) | |
tree | b2c75ade63915864d29a4ff8f6b35b43d13397dd | |
parent | 3437d21bc1300691337cd57d022c54885319516a (diff) |
vfs: only allow FSSETXATTR to set DAX flag on files and dirsvfs-fix-ioctl-checking-1
The DAX flag only applies to files and directories, so don't let it get
set for other types of files.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Jan Kara <jack@suse.cz>
-rw-r--r-- | fs/inode.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/inode.c b/fs/inode.c index 0cbce5a0a23c..446d05e25f39 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -2239,6 +2239,14 @@ int vfs_ioc_fssetxattr_check(struct inode *inode, const struct fsxattr *old_fa, !S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode)) return -EINVAL; + /* + * It is only valid to set the DAX flag on regular files and + * directories on filesystems. + */ + if ((fa->fsx_xflags & FS_XFLAG_DAX) && + !(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode))) + return -EINVAL; + /* Extent size hints of zero turn off the flags. */ if (fa->fsx_extsize == 0) fa->fsx_xflags &= ~(FS_XFLAG_EXTSIZE | FS_XFLAG_EXTSZINHERIT); |