Skip to content

Commit 8137836

Browse files
kdavemehmetb0
authored andcommitted
btrfs: handle invalid root reference found in may_destroy_subvol()
BugLink: https://bugs.launchpad.net/bugs/2084005 [ Upstream commit 6fbc6f4ac1f4907da4fc674251527e7dc79ffbf6 ] The may_destroy_subvol() looks up a root by a key, allowing to do an inexact search when key->offset is -1. It's never expected to find such item, as it would break the allowed range of a root id. Signed-off-by: David Sterba <dsterba@suse.com> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Koichiro Den <koichiro.den@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent 58ad759 commit 8137836

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

fs/btrfs/inode.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4390,7 +4390,14 @@ static noinline int may_destroy_subvol(struct btrfs_root *root)
43904390
ret = btrfs_search_slot(NULL, fs_info->tree_root, &key, path, 0, 0);
43914391
if (ret < 0)
43924392
goto out;
4393-
BUG_ON(ret == 0);
4393+
if (ret == 0) {
4394+
/*
4395+
* Key with offset -1 found, there would have to exist a root
4396+
* with such id, but this is out of valid range.
4397+
*/
4398+
ret = -EUCLEAN;
4399+
goto out;
4400+
}
43944401

43954402
ret = 0;
43964403
if (path->slots[0] > 0) {

0 commit comments

Comments
 (0)