diff options
author | David Sterba <dsterba@suse.com> | 2024-01-24 17:37:59 +0300 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2024-03-04 18:24:47 +0300 |
commit | a4259b6c191119f270561c75eee840363f697c04 (patch) | |
tree | db8c5b88bbe8cd41c7a79de760b2021e588eb96c /fs/btrfs/extent-tree.c | |
parent | 7411055db5ce64f836aaffd422396af0075fdc99 (diff) | |
download | linux-a4259b6c191119f270561c75eee840363f697c04.tar.xz |
btrfs: handle invalid extent item reference found in check_committed_ref()
The check_committed_ref() helper looks up an extent item 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
extent item offset.
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 49437ad7248d..bd1645089d49 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -2396,7 +2396,14 @@ static noinline int check_committed_ref(struct btrfs_root *root, ret = btrfs_search_slot(NULL, extent_root, &key, path, 0, 0); if (ret < 0) goto out; - BUG_ON(ret == 0); /* Corruption */ + if (ret == 0) { + /* + * Key with offset -1 found, there would have to exist an extent + * item with such offset, but this is out of the valid range. + */ + ret = -EUCLEAN; + goto out; + } ret = -ENOENT; if (path->slots[0] == 0) |