linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] fs: forbid invalid project ID
@ 2021-06-28 12:38 Wang Shilong
  2021-06-28 22:34 ` Dave Chinner
  0 siblings, 1 reply; 3+ messages in thread
From: Wang Shilong @ 2021-06-28 12:38 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-xfs, linux-ext4, linux-f2fs-devel, wangshilong1991

fileattr_set_prepare() should check if project ID
is valid, otherwise dqget() will return NULL for
such project ID quota.

Signed-off-by: Wang Shilong <wshilong@ddn.com>
---
v1->v2: try to fix in the VFS
---
 fs/ioctl.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/ioctl.c b/fs/ioctl.c
index 1e2204fa9963..5db5b218637b 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -845,6 +845,9 @@ static int fileattr_set_prepare(struct inode *inode,
 	if (fa->fsx_cowextsize == 0)
 		fa->fsx_xflags &= ~FS_XFLAG_COWEXTSIZE;
 
+	if (!projid_valid(KPROJIDT_INIT(fa->fsx_projid)))
+		return -EINVAL;
+
 	return 0;
 }
 
-- 
2.27.0


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

* Re: [PATCH v2] fs: forbid invalid project ID
  2021-06-28 12:38 [PATCH v2] fs: forbid invalid project ID Wang Shilong
@ 2021-06-28 22:34 ` Dave Chinner
  2021-07-01 15:37   ` Wang Shilong
  0 siblings, 1 reply; 3+ messages in thread
From: Dave Chinner @ 2021-06-28 22:34 UTC (permalink / raw)
  To: Wang Shilong; +Cc: linux-fsdevel, linux-xfs, linux-ext4, linux-f2fs-devel

On Mon, Jun 28, 2021 at 08:38:01AM -0400, Wang Shilong wrote:
> fileattr_set_prepare() should check if project ID
> is valid, otherwise dqget() will return NULL for
> such project ID quota.
> 
> Signed-off-by: Wang Shilong <wshilong@ddn.com>
> ---
> v1->v2: try to fix in the VFS
> ---
>  fs/ioctl.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/fs/ioctl.c b/fs/ioctl.c
> index 1e2204fa9963..5db5b218637b 100644
> --- a/fs/ioctl.c
> +++ b/fs/ioctl.c
> @@ -845,6 +845,9 @@ static int fileattr_set_prepare(struct inode *inode,
>  	if (fa->fsx_cowextsize == 0)
>  		fa->fsx_xflags &= ~FS_XFLAG_COWEXTSIZE;
>  
> +	if (!projid_valid(KPROJIDT_INIT(fa->fsx_projid)))
> +		return -EINVAL;

This needs to go further up in this function in the section where
project IDs passed into this function are validated. Projids are
only allowed to be changed when current_user_ns() == &init_user_ns,
so this needs to be associated with that verification context.

This check should also use make_kprojid(), please, not open code
KPROJIDT_INIT.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

* Re: [PATCH v2] fs: forbid invalid project ID
  2021-06-28 22:34 ` Dave Chinner
@ 2021-07-01 15:37   ` Wang Shilong
  0 siblings, 0 replies; 3+ messages in thread
From: Wang Shilong @ 2021-07-01 15:37 UTC (permalink / raw)
  To: Dave Chinner
  Cc: linux-fsdevel, linux-xfs, Ext4 Developers List, linux-f2fs-devel

On Tue, Jun 29, 2021 at 6:34 AM Dave Chinner <david@fromorbit.com> wrote:
>
> On Mon, Jun 28, 2021 at 08:38:01AM -0400, Wang Shilong wrote:
> > fileattr_set_prepare() should check if project ID
> > is valid, otherwise dqget() will return NULL for
> > such project ID quota.
> >
> > Signed-off-by: Wang Shilong <wshilong@ddn.com>
> > ---
> > v1->v2: try to fix in the VFS
> > ---
> >  fs/ioctl.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/fs/ioctl.c b/fs/ioctl.c
> > index 1e2204fa9963..5db5b218637b 100644
> > --- a/fs/ioctl.c
> > +++ b/fs/ioctl.c
> > @@ -845,6 +845,9 @@ static int fileattr_set_prepare(struct inode *inode,
> >       if (fa->fsx_cowextsize == 0)
> >               fa->fsx_xflags &= ~FS_XFLAG_COWEXTSIZE;
> >
> > +     if (!projid_valid(KPROJIDT_INIT(fa->fsx_projid)))
> > +             return -EINVAL;
>
> This needs to go further up in this function in the section where
> project IDs passed into this function are validated. Projids are
> only allowed to be changed when current_user_ns() == &init_user_ns,
> so this needs to be associated with that verification context.
>
> This check should also use make_kprojid(), please, not open code
> KPROJIDT_INIT.

You are right, let me send a V3

>
> Cheers,
>
> Dave.
> --
> Dave Chinner
> david@fromorbit.com

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

end of thread, other threads:[~2021-07-01 15:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-28 12:38 [PATCH v2] fs: forbid invalid project ID Wang Shilong
2021-06-28 22:34 ` Dave Chinner
2021-07-01 15:37   ` Wang Shilong

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).