All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] btrfs-progs: common: make sure that qgroup id is in range
@ 2021-03-16 13:27 Sidong Yang
  2021-03-17  1:51 ` Qu Wenruo
  2021-03-17 18:36 ` David Sterba
  0 siblings, 2 replies; 7+ messages in thread
From: Sidong Yang @ 2021-03-16 13:27 UTC (permalink / raw)
  To: linux-btrfs, dsterba, Qu Wenruo; +Cc: Sidong Yang

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>
---
v2:
  Use btrfs_qgroup_level() for checking
---
 common/utils.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/common/utils.c b/common/utils.c
index 57e41432..ba0bcb24 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 (btrfs_qgroup_level(id))
+			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 (btrfs_qgroup_level(id))
+		goto err;
+
 	if (ptr_parse_end != ptr_src_end)
 		goto  path;
 
-- 
2.25.1


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

end of thread, other threads:[~2021-03-19 16:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-16 13:27 [PATCH v2] btrfs-progs: common: make sure that qgroup id is in range Sidong Yang
2021-03-17  1:51 ` Qu Wenruo
2021-03-17 18:36 ` David Sterba
2021-03-18  2:22   ` Sidong Yang
2021-03-18  2:35     ` Qu Wenruo
2021-03-18 20:34     ` David Sterba
2021-03-19 16:44       ` Sidong Yang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.