From: Dave Chinner <david@fromorbit.com>
To: Wang Shilong <wangshilong1991@gmail.com>
Cc: linux-ext4@vger.kernel.org, Wang Shilong <wshilong@ddn.com>
Subject: Re: [PATCH] ext4: forbid U32_MAX project ID
Date: Mon, 28 Jun 2021 08:42:17 +1000 [thread overview]
Message-ID: <20210627224217.GL2419729@dread.disaster.area> (raw)
In-Reply-To: <20210625124033.5639-1-wangshilong1991@gmail.com>
On Fri, Jun 25, 2021 at 08:40:33AM -0400, 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.
Actually, it's INVALID_PROJID, not U32_MAX, and we already have a
check function for that:
static inline bool projid_valid(kprojid_t projid)
{
return !projid_eq(projid, INVALID_PROJID);
}
> Signed-off-by: Wang Shilong <wshilong@ddn.com>
> ---
> fs/ext4/ioctl.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
> index 31627f7dc5cd..f3a8d962c291 100644
> --- a/fs/ext4/ioctl.c
> +++ b/fs/ext4/ioctl.c
> @@ -744,6 +744,9 @@ int ext4_fileattr_set(struct user_namespace *mnt_userns,
> u32 flags = fa->flags;
> int err = -EOPNOTSUPP;
>
> + if (fa->fsx_projid >= U32_MAX)
> + return -EINVAL;
> +
This should actually be calling qid_valid() or projid_valid(),
and it should be in generic code because multiple filesystems
support project quotas. i.e this should be checked in
fileattr_set_prepare(), not in ext4 specific code.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2021-06-27 22:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-25 12:40 [PATCH] ext4: forbid U32_MAX project ID Wang Shilong
2021-06-27 22:42 ` Dave Chinner [this message]
2021-06-27 23:13 ` Wang Shilong
2021-06-28 0:39 ` Dave Chinner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210627224217.GL2419729@dread.disaster.area \
--to=david@fromorbit.com \
--cc=linux-ext4@vger.kernel.org \
--cc=wangshilong1991@gmail.com \
--cc=wshilong@ddn.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox