diff options
| author | robbieko <robbieko@synology.com> | 2026-04-13 09:52:35 +0300 |
|---|---|---|
| committer | David Sterba <dsterba@suse.com> | 2026-04-21 05:02:30 +0300 |
| commit | 653361585d251fbca0e19ac58b04ba95dd01e378 (patch) | |
| tree | deb8854064ece3b665a06998641577584d56cd9c | |
| parent | 1871ae78ffa5ce7c0458e9ba5867958c1753e425 (diff) | |
| download | linux-653361585d251fbca0e19ac58b04ba95dd01e378.tar.xz | |
btrfs: replace ASSERT with proper error handling in stripe lookup fallback
After falling back to the previous item in btrfs_delete_raid_extent(),
the code uses ASSERT(found_start <= start) to verify the found extent
actually precedes our target range. If the B-tree state is unexpected
(e.g. no overlapping extent exists), this triggers a kernel BUG/panic
in debug builds, or silently continues with wrong data otherwise.
Replace the ASSERT with a proper bounds check that returns -ENOENT if
the found extent does not actually overlap with the start position.
Signed-off-by: robbieko <robbieko@synology.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
| -rw-r--r-- | fs/btrfs/raid-stripe-tree.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/fs/btrfs/raid-stripe-tree.c b/fs/btrfs/raid-stripe-tree.c index 1a0ea2107688..d454894b9e66 100644 --- a/fs/btrfs/raid-stripe-tree.c +++ b/fs/btrfs/raid-stripe-tree.c @@ -154,7 +154,10 @@ int btrfs_delete_raid_extent(struct btrfs_trans_handle *trans, u64 start, u64 le btrfs_item_key_to_cpu(leaf, &key, slot); found_start = key.objectid; found_end = found_start + key.offset; - ASSERT(found_start <= start); + if (found_start > start || found_end <= start) { + ret = -ENOENT; + break; + } } if (key.type != BTRFS_RAID_STRIPE_KEY) |
