* [PATCH] vfs: only allow SETFLAGS to set DAX flag on files and dirs
@ 2021-07-16 6:19 Jeffle Xu
2021-07-16 16:20 ` Darrick J. Wong
0 siblings, 1 reply; 3+ messages in thread
From: Jeffle Xu @ 2021-07-16 6:19 UTC (permalink / raw)
To: viro; +Cc: linux-fsdevel, linux-ext4
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.
Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
---
fs/ioctl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/ioctl.c b/fs/ioctl.c
index 1e2204fa9963..1fe73e148e2d 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -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;
--
2.27.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] vfs: only allow SETFLAGS to set DAX flag on files and dirs
2021-07-16 6:19 [PATCH] vfs: only allow SETFLAGS to set DAX flag on files and dirs Jeffle Xu
@ 2021-07-16 16:20 ` Darrick J. Wong
2021-07-19 1:47 ` JeffleXu
0 siblings, 1 reply; 3+ messages in thread
From: Darrick J. Wong @ 2021-07-16 16:20 UTC (permalink / raw)
To: Jeffle Xu; +Cc: viro, linux-fsdevel, linux-ext4
On Fri, Jul 16, 2021 at 02:19:51PM +0800, Jeffle Xu wrote:
> 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.
>
> Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
> ---
> fs/ioctl.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ioctl.c b/fs/ioctl.c
> index 1e2204fa9963..1fe73e148e2d 100644
> --- a/fs/ioctl.c
> +++ b/fs/ioctl.c
> @@ -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
> !(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)))
> return -EINVAL;
>
> --
> 2.27.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] vfs: only allow SETFLAGS to set DAX flag on files and dirs
2021-07-16 16:20 ` Darrick J. Wong
@ 2021-07-19 1:47 ` JeffleXu
0 siblings, 0 replies; 3+ messages in thread
From: JeffleXu @ 2021-07-19 1:47 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: viro, linux-fsdevel, linux-ext4
On 7/17/21 12:20 AM, Darrick J. Wong wrote:
> On Fri, Jul 16, 2021 at 02:19:51PM +0800, Jeffle Xu wrote:
>> 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.
>>
>> Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
>> ---
>> fs/ioctl.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fs/ioctl.c b/fs/ioctl.c
>> index 1e2204fa9963..1fe73e148e2d 100644
>> --- a/fs/ioctl.c
>> +++ b/fs/ioctl.c
>> @@ -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.
--
Thanks,
Jeffle
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-07-19 1:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-16 6:19 [PATCH] vfs: only allow SETFLAGS to set DAX flag on files and dirs Jeffle Xu
2021-07-16 16:20 ` Darrick J. Wong
2021-07-19 1:47 ` JeffleXu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).