diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2019-06-24 18:09:49 -0700 |
---|---|---|
committer | Darrick J. Wong <darrick.wong@oracle.com> | 2019-06-28 10:57:52 -0700 |
commit | 438fcad5ee4316216017772d12a3deccf7c4c686 (patch) | |
tree | b648b28af6c813b31b19a35b56c9f280c9cafffb | |
parent | c0a367a8e7f0b5f4ec830f5317da86e53b40e6e8 (diff) |
vfs: only allow FSSETXATTR to set DAX flag on files and dirsfile-ioctl-cleanups_2019-06-28
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>
-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 670d5408d022..f08711b34341 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -2259,6 +2259,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); |