Skip to content

Commit 8cac96b

Browse files
kdavesmb49
authored andcommitted
btrfs: export: handle invalid inode or root reference in btrfs_get_parent()
BugLink: https://bugs.launchpad.net/bugs/2065899 [ Upstream commit 26b66d1d366a375745755ca7365f67110bbf6bd5 ] The get_parent handler looks up a parent of a given dentry, this can be either a subvolume or a directory. The search is set up with offset -1 but it's never expected to find such item, as it would break allowed range of inode number or a root id. This means it's a corruption (ext4 also returns this error code). Reviewed-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Manuel Diewald <manuel.diewald@canonical.com> Signed-off-by: Roxana Nicolescu <roxana.nicolescu@canonical.com>
1 parent 8223db2 commit 8cac96b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

fs/btrfs/export.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,15 @@ struct dentry *btrfs_get_parent(struct dentry *child)
174174
ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
175175
if (ret < 0)
176176
goto fail;
177+
if (ret == 0) {
178+
/*
179+
* Key with offset of -1 found, there would have to exist an
180+
* inode with such number or a root with such id.
181+
*/
182+
ret = -EUCLEAN;
183+
goto fail;
184+
}
177185

178-
BUG_ON(ret == 0); /* Key with offset of -1 found */
179186
if (path->slots[0] == 0) {
180187
ret = -ENOENT;
181188
goto fail;

0 commit comments

Comments
 (0)