From: Nikolay Borisov Date: Wed, 12 Jul 2017 06:42:19 +0000 (+0300) Subject: btrfs: qgroups: Fix BUG_ON condition in tree level check X-Git-Tag: v4.14-rc3~14^2~92 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b6e6bca51e531989de11af7967bd32bd973d96b9;p=platform%2Fkernel%2Flinux-rpi.git btrfs: qgroups: Fix BUG_ON condition in tree level check The current code was erroneously checking for root_level > BTRFS_MAX_LEVEL. If we had a root_level of 8 then the check won't trigger and we could potentially hit a buffer overflow. The correct check should be root_level >= BTRFS_MAX_LEVEL . Signed-off-by: Nikolay Borisov Reviewed-by: Qu Wenruo Signed-off-by: David Sterba --- diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index 4ce351e..acb4898 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -1603,7 +1603,7 @@ int btrfs_qgroup_trace_subtree(struct btrfs_trans_handle *trans, struct extent_buffer *eb = root_eb; struct btrfs_path *path = NULL; - BUG_ON(root_level < 0 || root_level > BTRFS_MAX_LEVEL); + BUG_ON(root_level < 0 || root_level >= BTRFS_MAX_LEVEL); BUG_ON(root_eb == NULL); if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags))