From: Darrick J. Wong Date: Mon, 1 Jul 2019 15:25:36 +0000 (-0700) Subject: vfs: only allow FSSETXATTR to set DAX flag on files and dirs X-Git-Tag: v6.6-pxa1908~11333^2 X-Git-Url: https://git.dujemihanovic.xyz/?a=commitdiff_plain;h=dbc77f31e58b2902a5e7643761c04bf69f57a32a;p=linux.git vfs: only allow FSSETXATTR to set DAX flag on files and dirs 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 Reviewed-by: Jan Kara --- 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);