vfs: only allow SETFLAGS to set DAX flag on files and dirs
Subsystems (2)
PATCH 1/1 vfs: only allow SETFLAGS to set DAX flag on files and dirs
This is similar to commit dbc77f31e58b ("vfs: only allow FSSETXATTR to set DAX flag on files and dirs").
Though the underlying filesystems may have filtered invalid flags, e.g., ext4_mask_flags() called in ext4_fileattr_set(), also check it in VFS layer.
--- fs/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ioctl.c +1 -1
@@ -835,7 +835,7 @@ static int fileattr_set_prepare(struct inode *inode,* It is only valid to set the DAX flag on regular files and * directories on filesystems. */ -if ((fa->fsx_xflags &FS_XFLAG_DAX ) && +if ((fa->fsx_xflags &FS_XFLAG_DAX || fa->flags &FS_DAX_FL ) && !(S_ISREG (inode->i_mode) ||S_ISDIR (inode->i_mode)))return -EINVAL ;
Signature · 1 line
2.27.0
Quoted 17 lines · Jeffle Xu
This is similar to commit
dbc77f31e58b("vfs: only allow FSSETXATTR to set DAX flag on files and dirs").Though the underlying filesystems may have filtered invalid flags, e.g.,
ext4_mask_flags()called inext4_fileattr_set(), also check it in VFS layer.Signed-off-by Jeffle Xu <[email protected]>--- fs/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/ioctl.c +0
-0
fs/ioctl.c static int fileattr_set_prepare(struct inode *inode, · line 838
Quoted 5 lines
fs/ioctl.c +1
-1@@ -835,7 +835,7 @@ static int fileattr_set_prepare(struct inode *inode,* It is only valid to set the DAX flag on regular files and * directories on filesystems. */ - if ((fa->fsx_xflags & FS_XFLAG_DAX) && + if ((fa->fsx_xflags & FS_XFLAG_DAX || fa->flags & FS_DAX_FL) &&
I thought we always had to surround flag tests with separate parentheses...?
--D
Quoted 6 lines
fs/ioctl.c +0
-0!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)))return -EINVAL ;Signature · 1 line
2.27.0
Quoted 13 lines · Darrick J. Wong
Quoted 12 lines · Jeffle Xu
This is similar to commit
dbc77f31e58b("vfs: only allow FSSETXATTR to set DAX flag on files and dirs").Though the underlying filesystems may have filtered invalid flags, e.g.,
ext4_mask_flags()called inext4_fileattr_set(), also check it in VFS layer.Signed-off-by Jeffle Xu <[email protected]>--- fs/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines
fs/ioctl.c static int fileattr_set_prepare(struct inode *inode, · line 838
Quoted 10 lines
fs/ioctl.c +1
-1@@ -835,7 +835,7 @@ static int fileattr_set_prepare(struct inode *inode,* It is only valid to set the DAX flag on regular files and * directories on filesystems. */ - if ((fa->fsx_xflags & FS_XFLAG_DAX) && + if ((fa->fsx_xflags & FS_XFLAG_DAX || fa->flags & FS_DAX_FL) &&I thought we always had to surround flag tests with separate parentheses...?
Thanks.
The 'bitwise and' has a higher priority than 'logical or'. But for sure I can add parentheses to make it more readable and precise.
Signature · 2 lines
Thanks, Jeffle