Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Sidong Yang <realwakka@gmail.com>
To: Qu Wenruo <quwenruo.btrfs@gmx.com>
Cc: linux-btrfs@vger.kernel.org, dsterba@suse.cz
Subject: Re: [PATCH] btrfs-progs: common: make sure that qgroup id is in range
Date: Tue, 16 Mar 2021 12:58:05 +0000	[thread overview]
Message-ID: <20210316125805.GA19669@realwakka> (raw)
In-Reply-To: <2c58bf6a-d13c-2628-bfa5-c122b7ad73a6@gmx.com>

On Tue, Mar 16, 2021 at 01:44:33PM +0800, Qu Wenruo wrote:
> 
> 
> On 2021/3/15 下午11:56, Sidong Yang wrote:
> > When user assign qgroup with qgroup id that is too big to exceeds
> > range and invade level value, and it works without any error. but
> > this action would be make undefined error. this code make sure that
> > qgroup id doesn't exceed range(0 ~ 2^48-1).
> > 
> > Signed-off-by: Sidong Yang <realwakka@gmail.com>
> 
> Shouldn't the check also happen inside the ioctl?

Yes, I checked the ioctl code in kernel. but there is only the code that
check if it is zero like !sa->qgroupid. and it just assign to
key.offset. Also it should be checked in ioctl?

> 
> Thanks,
> Qu
> > ---
> >   common/utils.c | 5 +++++
> >   1 file changed, 5 insertions(+)
> > 
> > diff --git a/common/utils.c b/common/utils.c
> > index 57e41432..a2f72550 100644
> > --- a/common/utils.c
> > +++ b/common/utils.c
> > @@ -727,6 +727,8 @@ u64 parse_qgroupid(const char *p)
> >   		id = strtoull(p, &ptr_parse_end, 10);
> >   		if (ptr_parse_end != ptr_src_end)
> >   			goto path;
> > +		if (id >> BTRFS_QGROUP_LEVEL_SHIFT)
> > +			goto err;
> >   		return id;
> >   	}
> >   	level = strtoull(p, &ptr_parse_end, 10);
> > @@ -734,6 +736,9 @@ u64 parse_qgroupid(const char *p)
> >   		goto path;
> > 
> >   	id = strtoull(s + 1, &ptr_parse_end, 10);
> > +	if (id >> BTRFS_QGROUP_LEVEL_SHIFT)
> > +		goto err;
> > +
> >   	if (ptr_parse_end != ptr_src_end)
> >   		goto  path;
> > 
> > 

  reply	other threads:[~2021-03-16 12:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-15 15:56 [PATCH] btrfs-progs: common: make sure that qgroup id is in range Sidong Yang
2021-03-15 18:22 ` David Sterba
2021-03-16  5:44 ` Qu Wenruo
2021-03-16 12:58   ` Sidong Yang [this message]
2021-03-16 13:03     ` Qu Wenruo
  -- strict thread matches above, loose matches on Subject: below --
2021-03-19 17:09 Sidong Yang

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=20210316125805.GA19669@realwakka \
    --to=realwakka@gmail.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=quwenruo.btrfs@gmx.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