On Mon, Mar 15, 2021 at 03:56:38PM +0000, 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 <realwa...@gmail.com> > --- > 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;
Please add a helper that validates the id or use btrfs_qgroup_level and check that level is 0 if that makes sense in the context of the call.