All of lore.kernel.org
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] f2fs: forbid U32_MAX project ID
@ 2021-06-25 12:50 Wang Shilong
  2021-06-28 12:32 ` Chao Yu
  0 siblings, 1 reply; 4+ messages in thread
From: Wang Shilong @ 2021-06-25 12:50 UTC (permalink / raw)
  To: linux-f2fs-devel; +Cc: wangshilong1991, Wang Shilong

From: Wang Shilong <wshilong@ddn.com>

U32_MAX is reserved for special purpose,
qid_has_mapping() will return false if projid is
4294967295, dqget() will return NULL for it.

So U32_MAX is unsupported Project ID, fix to forbid it.

Signed-off-by: Wang Shilong <wshilong@ddn.com>
---
 fs/f2fs/file.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index ceb575f99048..861edf3c01d5 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -3066,6 +3066,8 @@ int f2fs_fileattr_set(struct user_namespace *mnt_userns,
 	u32 iflags;
 	int err;
 
+	if (fa->fsx_projid >= U32_MAX)
+		return -EINVAL;
 	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
 		return -EIO;
 	if (!f2fs_is_checkpoint_ready(F2FS_I_SB(inode)))
-- 
2.27.0



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: forbid U32_MAX project ID
  2021-06-25 12:50 [f2fs-dev] [PATCH] f2fs: forbid U32_MAX project ID Wang Shilong
@ 2021-06-28 12:32 ` Chao Yu
  2021-06-28 12:40   ` Wang Shilong
  0 siblings, 1 reply; 4+ messages in thread
From: Chao Yu @ 2021-06-28 12:32 UTC (permalink / raw)
  To: Wang Shilong, linux-f2fs-devel; +Cc: Wang Shilong

On 2021/6/25 20:50, Wang Shilong wrote:
> From: Wang Shilong <wshilong@ddn.com>
> 
> U32_MAX is reserved for special purpose,
> qid_has_mapping() will return false if projid is
> 4294967295, dqget() will return NULL for it.
> 
> So U32_MAX is unsupported Project ID, fix to forbid it.
> 
> Signed-off-by: Wang Shilong <wshilong@ddn.com>
> ---
>   fs/f2fs/file.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index ceb575f99048..861edf3c01d5 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -3066,6 +3066,8 @@ int f2fs_fileattr_set(struct user_namespace *mnt_userns,
>   	u32 iflags;
>   	int err;
>   
> +	if (fa->fsx_projid >= U32_MAX)

unlikely()? if this is really a corner case.

> +		return -EINVAL;
>   	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
>   		return -EIO;
>   	if (!f2fs_is_checkpoint_ready(F2FS_I_SB(inode)))

I prefer to check fsx_projid here to keep line with check order in other
f2fs interfaces.

Thoughts, Shilong?

Thanks,

> 


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: forbid U32_MAX project ID
  2021-06-28 12:32 ` Chao Yu
@ 2021-06-28 12:40   ` Wang Shilong
  2021-06-28 15:44     ` Chao Yu
  0 siblings, 1 reply; 4+ messages in thread
From: Wang Shilong @ 2021-06-28 12:40 UTC (permalink / raw)
  To: Chao Yu; +Cc: Wang Shilong, linux-f2fs-devel

Hi Chao,

On Mon, Jun 28, 2021 at 8:32 PM Chao Yu <chao@kernel.org> wrote:
>
> On 2021/6/25 20:50, Wang Shilong wrote:
> > From: Wang Shilong <wshilong@ddn.com>
> >
> > U32_MAX is reserved for special purpose,
> > qid_has_mapping() will return false if projid is
> > 4294967295, dqget() will return NULL for it.
> >
> > So U32_MAX is unsupported Project ID, fix to forbid it.
> >
> > Signed-off-by: Wang Shilong <wshilong@ddn.com>
> > ---
> >   fs/f2fs/file.c | 2 ++
> >   1 file changed, 2 insertions(+)
> >
> > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> > index ceb575f99048..861edf3c01d5 100644
> > --- a/fs/f2fs/file.c
> > +++ b/fs/f2fs/file.c
> > @@ -3066,6 +3066,8 @@ int f2fs_fileattr_set(struct user_namespace *mnt_userns,
> >       u32 iflags;
> >       int err;
> >
> > +     if (fa->fsx_projid >= U32_MAX)
>
> unlikely()? if this is really a corner case.
>
> > +             return -EINVAL;
> >       if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
> >               return -EIO;
> >       if (!f2fs_is_checkpoint_ready(F2FS_I_SB(inode)))
>
> I prefer to check fsx_projid here to keep line with check order in other
> f2fs interfaces.

Just sent a v2 which tried to fix the problem in the VFS.

>
> Thoughts, Shilong?
>
> Thanks,
>
> >


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: forbid U32_MAX project ID
  2021-06-28 12:40   ` Wang Shilong
@ 2021-06-28 15:44     ` Chao Yu
  0 siblings, 0 replies; 4+ messages in thread
From: Chao Yu @ 2021-06-28 15:44 UTC (permalink / raw)
  To: Wang Shilong; +Cc: Wang Shilong, linux-f2fs-devel

On 2021/6/28 20:40, Wang Shilong wrote:
> Hi Chao,
> 
> On Mon, Jun 28, 2021 at 8:32 PM Chao Yu <chao@kernel.org> wrote:
>>
>> On 2021/6/25 20:50, Wang Shilong wrote:
>>> From: Wang Shilong <wshilong@ddn.com>
>>>
>>> U32_MAX is reserved for special purpose,
>>> qid_has_mapping() will return false if projid is
>>> 4294967295, dqget() will return NULL for it.
>>>
>>> So U32_MAX is unsupported Project ID, fix to forbid it.
>>>
>>> Signed-off-by: Wang Shilong <wshilong@ddn.com>
>>> ---
>>>    fs/f2fs/file.c | 2 ++
>>>    1 file changed, 2 insertions(+)
>>>
>>> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
>>> index ceb575f99048..861edf3c01d5 100644
>>> --- a/fs/f2fs/file.c
>>> +++ b/fs/f2fs/file.c
>>> @@ -3066,6 +3066,8 @@ int f2fs_fileattr_set(struct user_namespace *mnt_userns,
>>>        u32 iflags;
>>>        int err;
>>>
>>> +     if (fa->fsx_projid >= U32_MAX)
>>
>> unlikely()? if this is really a corner case.
>>
>>> +             return -EINVAL;
>>>        if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
>>>                return -EIO;
>>>        if (!f2fs_is_checkpoint_ready(F2FS_I_SB(inode)))
>>
>> I prefer to check fsx_projid here to keep line with check order in other
>> f2fs interfaces.
> 
> Just sent a v2 which tried to fix the problem in the VFS.

Shilong,

Agreed, and better.

Thanks,

> 
>>
>> Thoughts, Shilong?
>>
>> Thanks,
>>
>>>


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-06-28 15:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-25 12:50 [f2fs-dev] [PATCH] f2fs: forbid U32_MAX project ID Wang Shilong
2021-06-28 12:32 ` Chao Yu
2021-06-28 12:40   ` Wang Shilong
2021-06-28 15:44     ` Chao Yu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.