* [PATCH v4] fs: forbid invalid project ID
@ 2021-07-10 14:39 ` Wang Shilong
0 siblings, 0 replies; 9+ messages in thread
From: Wang Shilong @ 2021-07-10 14:39 UTC (permalink / raw
To: linux-fsdevel; +Cc: linux-xfs, linux-ext4, linux-f2fs-devel, Wang Shilong
From: Wang Shilong <wshilong@ddn.com>
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>
---
v3->v3:
only check project Id if caller is allowed
to change and being changed.
v2->v3: move check before @fsx_projid is accessed
and use make_kprojid() helper.
v1->v2: try to fix in the VFS
fs/ioctl.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/fs/ioctl.c b/fs/ioctl.c
index 1e2204fa9963..d4fabb5421cd 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -817,6 +817,14 @@ static int fileattr_set_prepare(struct inode *inode,
if ((old_ma->fsx_xflags ^ fa->fsx_xflags) &
FS_XFLAG_PROJINHERIT)
return -EINVAL;
+ } else {
+ /*
+ * Caller is allowed to change the project ID. If it is being
+ * changed, make sure that the new value is valid.
+ */
+ if (old_ma->fsx_projid != fa->fsx_projid &&
+ !projid_valid(make_kprojid(&init_user_ns, fa->fsx_projid)))
+ return -EINVAL;
}
/* Check extent size hints. */
--
2.27.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v4] fs: forbid invalid project ID
2021-07-10 14:39 ` Wang Shilong
(?)
@ 2021-07-13 17:19 ` Andreas Dilger
-1 siblings, 0 replies; 9+ messages in thread
From: Andreas Dilger @ 2021-07-13 17:19 UTC (permalink / raw
To: Wang Shilong
Cc: linux-fsdevel, xfs, Ext4 Developers List, linux-f2fs-devel,
Wang Shilong
[-- Attachment #1: Type: text/plain, Size: 1298 bytes --]
On Jul 10, 2021, at 8:39 AM, Wang Shilong <wangshilong1991@gmail.com> wrote:
>
> From: Wang Shilong <wshilong@ddn.com>
>
> 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>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
> ---
> v3->v3:
> only check project Id if caller is allowed
> to change and being changed.
>
> v2->v3: move check before @fsx_projid is accessed
> and use make_kprojid() helper.
>
> v1->v2: try to fix in the VFS
> fs/ioctl.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/fs/ioctl.c b/fs/ioctl.c
> index 1e2204fa9963..d4fabb5421cd 100644
> --- a/fs/ioctl.c
> +++ b/fs/ioctl.c
> @@ -817,6 +817,14 @@ static int fileattr_set_prepare(struct inode *inode,
> if ((old_ma->fsx_xflags ^ fa->fsx_xflags) &
> FS_XFLAG_PROJINHERIT)
> return -EINVAL;
> + } else {
> + /*
> + * Caller is allowed to change the project ID. If it is being
> + * changed, make sure that the new value is valid.
> + */
> + if (old_ma->fsx_projid != fa->fsx_projid &&
> + !projid_valid(make_kprojid(&init_user_ns, fa->fsx_projid)))
> + return -EINVAL;
> }
>
> /* Check extent size hints. */
> --
> 2.27.0
>
Cheers, Andreas
[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 873 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [f2fs-dev] [PATCH v4] fs: forbid invalid project ID
2021-07-10 14:39 ` Wang Shilong
@ 2021-07-14 4:16 ` Dave Chinner
-1 siblings, 0 replies; 9+ messages in thread
From: Dave Chinner @ 2021-07-14 4:16 UTC (permalink / raw
To: Wang Shilong
Cc: linux-fsdevel, linux-xfs, linux-ext4, Wang Shilong,
linux-f2fs-devel
On Sat, Jul 10, 2021 at 10:39:59PM +0800, Wang Shilong wrote:
> From: Wang Shilong <wshilong@ddn.com>
>
> 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>
> ---
> v3->v3:
> only check project Id if caller is allowed
> to change and being changed.
>
> v2->v3: move check before @fsx_projid is accessed
> and use make_kprojid() helper.
>
> v1->v2: try to fix in the VFS
> fs/ioctl.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/fs/ioctl.c b/fs/ioctl.c
> index 1e2204fa9963..d4fabb5421cd 100644
> --- a/fs/ioctl.c
> +++ b/fs/ioctl.c
> @@ -817,6 +817,14 @@ static int fileattr_set_prepare(struct inode *inode,
> if ((old_ma->fsx_xflags ^ fa->fsx_xflags) &
> FS_XFLAG_PROJINHERIT)
> return -EINVAL;
> + } else {
> + /*
> + * Caller is allowed to change the project ID. If it is being
> + * changed, make sure that the new value is valid.
> + */
> + if (old_ma->fsx_projid != fa->fsx_projid &&
> + !projid_valid(make_kprojid(&init_user_ns, fa->fsx_projid)))
> + return -EINVAL;
> }
>
> /* Check extent size hints. */
Looks good. Thanks!
Reviewed-by: Dave Chinner <dchinner@redhat.com>
--
Dave Chinner
david@fromorbit.com
_______________________________________________
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] 9+ messages in thread
* Re: [PATCH v4] fs: forbid invalid project ID
@ 2021-07-14 4:16 ` Dave Chinner
0 siblings, 0 replies; 9+ messages in thread
From: Dave Chinner @ 2021-07-14 4:16 UTC (permalink / raw
To: Wang Shilong
Cc: linux-fsdevel, linux-xfs, linux-ext4, linux-f2fs-devel,
Wang Shilong
On Sat, Jul 10, 2021 at 10:39:59PM +0800, Wang Shilong wrote:
> From: Wang Shilong <wshilong@ddn.com>
>
> 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>
> ---
> v3->v3:
> only check project Id if caller is allowed
> to change and being changed.
>
> v2->v3: move check before @fsx_projid is accessed
> and use make_kprojid() helper.
>
> v1->v2: try to fix in the VFS
> fs/ioctl.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/fs/ioctl.c b/fs/ioctl.c
> index 1e2204fa9963..d4fabb5421cd 100644
> --- a/fs/ioctl.c
> +++ b/fs/ioctl.c
> @@ -817,6 +817,14 @@ static int fileattr_set_prepare(struct inode *inode,
> if ((old_ma->fsx_xflags ^ fa->fsx_xflags) &
> FS_XFLAG_PROJINHERIT)
> return -EINVAL;
> + } else {
> + /*
> + * Caller is allowed to change the project ID. If it is being
> + * changed, make sure that the new value is valid.
> + */
> + if (old_ma->fsx_projid != fa->fsx_projid &&
> + !projid_valid(make_kprojid(&init_user_ns, fa->fsx_projid)))
> + return -EINVAL;
> }
>
> /* Check extent size hints. */
Looks good. Thanks!
Reviewed-by: Dave Chinner <dchinner@redhat.com>
--
Dave Chinner
david@fromorbit.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [f2fs-dev] [PATCH v4] fs: forbid invalid project ID
2021-07-10 14:39 ` Wang Shilong
@ 2021-07-14 5:04 ` Darrick J. Wong
-1 siblings, 0 replies; 9+ messages in thread
From: Darrick J. Wong @ 2021-07-14 5:04 UTC (permalink / raw
To: Wang Shilong
Cc: linux-fsdevel, linux-xfs, linux-ext4, Wang Shilong,
linux-f2fs-devel
On Sat, Jul 10, 2021 at 10:39:59PM +0800, Wang Shilong wrote:
> From: Wang Shilong <wshilong@ddn.com>
>
> 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>
> ---
> v3->v3:
> only check project Id if caller is allowed
> to change and being changed.
>
> v2->v3: move check before @fsx_projid is accessed
> and use make_kprojid() helper.
>
> v1->v2: try to fix in the VFS
> fs/ioctl.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/fs/ioctl.c b/fs/ioctl.c
> index 1e2204fa9963..d4fabb5421cd 100644
> --- a/fs/ioctl.c
> +++ b/fs/ioctl.c
> @@ -817,6 +817,14 @@ static int fileattr_set_prepare(struct inode *inode,
> if ((old_ma->fsx_xflags ^ fa->fsx_xflags) &
> FS_XFLAG_PROJINHERIT)
> return -EINVAL;
> + } else {
> + /*
> + * Caller is allowed to change the project ID. If it is being
> + * changed, make sure that the new value is valid.
> + */
> + if (old_ma->fsx_projid != fa->fsx_projid &&
> + !projid_valid(make_kprojid(&init_user_ns, fa->fsx_projid)))
> + return -EINVAL;
Hmm, for XFS this is sort of a userspace-breaking change in the sense
that (technically) we've never rejected -1 before. xfs_quota won't have
anything to do with that, and (assuming I read the helper/macro
gooeyness correctly) the vfs quota code won't either, so
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
--D
> }
>
> /* Check extent size hints. */
> --
> 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 [flat|nested] 9+ messages in thread
* Re: [PATCH v4] fs: forbid invalid project ID
@ 2021-07-14 5:04 ` Darrick J. Wong
0 siblings, 0 replies; 9+ messages in thread
From: Darrick J. Wong @ 2021-07-14 5:04 UTC (permalink / raw
To: Wang Shilong
Cc: linux-fsdevel, linux-xfs, linux-ext4, linux-f2fs-devel,
Wang Shilong
On Sat, Jul 10, 2021 at 10:39:59PM +0800, Wang Shilong wrote:
> From: Wang Shilong <wshilong@ddn.com>
>
> 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>
> ---
> v3->v3:
> only check project Id if caller is allowed
> to change and being changed.
>
> v2->v3: move check before @fsx_projid is accessed
> and use make_kprojid() helper.
>
> v1->v2: try to fix in the VFS
> fs/ioctl.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/fs/ioctl.c b/fs/ioctl.c
> index 1e2204fa9963..d4fabb5421cd 100644
> --- a/fs/ioctl.c
> +++ b/fs/ioctl.c
> @@ -817,6 +817,14 @@ static int fileattr_set_prepare(struct inode *inode,
> if ((old_ma->fsx_xflags ^ fa->fsx_xflags) &
> FS_XFLAG_PROJINHERIT)
> return -EINVAL;
> + } else {
> + /*
> + * Caller is allowed to change the project ID. If it is being
> + * changed, make sure that the new value is valid.
> + */
> + if (old_ma->fsx_projid != fa->fsx_projid &&
> + !projid_valid(make_kprojid(&init_user_ns, fa->fsx_projid)))
> + return -EINVAL;
Hmm, for XFS this is sort of a userspace-breaking change in the sense
that (technically) we've never rejected -1 before. xfs_quota won't have
anything to do with that, and (assuming I read the helper/macro
gooeyness correctly) the vfs quota code won't either, so
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
--D
> }
>
> /* Check extent size hints. */
> --
> 2.27.0
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v4] fs: forbid invalid project ID
2021-07-10 14:39 ` Wang Shilong
@ 2021-07-22 8:15 ` Wang Shilong
-1 siblings, 0 replies; 9+ messages in thread
From: Wang Shilong @ 2021-07-22 8:15 UTC (permalink / raw
To: linux-fsdevel
Cc: linux-xfs, Ext4 Developers List, linux-f2fs-devel, Wang Shilong
Anyone take this patch to the tree? maybe Al Viro?
On Sat, Jul 10, 2021 at 10:40 PM Wang Shilong <wangshilong1991@gmail.com> wrote:
>
> From: Wang Shilong <wshilong@ddn.com>
>
> 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>
> ---
> v3->v3:
> only check project Id if caller is allowed
> to change and being changed.
>
> v2->v3: move check before @fsx_projid is accessed
> and use make_kprojid() helper.
>
> v1->v2: try to fix in the VFS
> fs/ioctl.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/fs/ioctl.c b/fs/ioctl.c
> index 1e2204fa9963..d4fabb5421cd 100644
> --- a/fs/ioctl.c
> +++ b/fs/ioctl.c
> @@ -817,6 +817,14 @@ static int fileattr_set_prepare(struct inode *inode,
> if ((old_ma->fsx_xflags ^ fa->fsx_xflags) &
> FS_XFLAG_PROJINHERIT)
> return -EINVAL;
> + } else {
> + /*
> + * Caller is allowed to change the project ID. If it is being
> + * changed, make sure that the new value is valid.
> + */
> + if (old_ma->fsx_projid != fa->fsx_projid &&
> + !projid_valid(make_kprojid(&init_user_ns, fa->fsx_projid)))
> + return -EINVAL;
> }
>
> /* Check extent size hints. */
> --
> 2.27.0
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [f2fs-dev] [PATCH v4] fs: forbid invalid project ID
@ 2021-07-22 8:15 ` Wang Shilong
0 siblings, 0 replies; 9+ messages in thread
From: Wang Shilong @ 2021-07-22 8:15 UTC (permalink / raw
To: linux-fsdevel
Cc: linux-xfs, Ext4 Developers List, Wang Shilong, linux-f2fs-devel
Anyone take this patch to the tree? maybe Al Viro?
On Sat, Jul 10, 2021 at 10:40 PM Wang Shilong <wangshilong1991@gmail.com> wrote:
>
> From: Wang Shilong <wshilong@ddn.com>
>
> 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>
> ---
> v3->v3:
> only check project Id if caller is allowed
> to change and being changed.
>
> v2->v3: move check before @fsx_projid is accessed
> and use make_kprojid() helper.
>
> v1->v2: try to fix in the VFS
> fs/ioctl.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/fs/ioctl.c b/fs/ioctl.c
> index 1e2204fa9963..d4fabb5421cd 100644
> --- a/fs/ioctl.c
> +++ b/fs/ioctl.c
> @@ -817,6 +817,14 @@ static int fileattr_set_prepare(struct inode *inode,
> if ((old_ma->fsx_xflags ^ fa->fsx_xflags) &
> FS_XFLAG_PROJINHERIT)
> return -EINVAL;
> + } else {
> + /*
> + * Caller is allowed to change the project ID. If it is being
> + * changed, make sure that the new value is valid.
> + */
> + if (old_ma->fsx_projid != fa->fsx_projid &&
> + !projid_valid(make_kprojid(&init_user_ns, fa->fsx_projid)))
> + return -EINVAL;
> }
>
> /* Check extent size hints. */
> --
> 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 [flat|nested] 9+ messages in thread