Commit 057495c
btrfs: hold block group reference during entire move_existing_remap()
There is a potential use-after-free in move_existing_remap(): we're calling
btrfs_put_block_group() on dest_bg, then passing it to
btrfs_add_block_group_free_space() a few lines later.
Fix this by getting the BG at the start of the function and putting it
near the end. This also means we're not doing a lookup twice for the
same thing.
Reported-by: Chris Mason <clm@fb.com>
Link: https://lore.kernel.org/linux-btrfs/20260125123908.2096548-1-clm@meta.com/
Fixes: bbea42d ("btrfs: move existing remaps before relocating block group")
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Mark Harmstone <mark@harmstone.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>1 parent 5118130 commit 057495c
1 file changed
+4
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4185 | 4185 | | |
4186 | 4186 | | |
4187 | 4187 | | |
| 4188 | + | |
| 4189 | + | |
4188 | 4190 | | |
4189 | 4191 | | |
4190 | 4192 | | |
| |||
4295 | 4297 | | |
4296 | 4298 | | |
4297 | 4299 | | |
4298 | | - | |
4299 | | - | |
4300 | 4300 | | |
4301 | 4301 | | |
4302 | 4302 | | |
4303 | 4303 | | |
4304 | 4304 | | |
4305 | 4305 | | |
4306 | | - | |
4307 | 4306 | | |
4308 | 4307 | | |
4309 | 4308 | | |
| |||
4333 | 4332 | | |
4334 | 4333 | | |
4335 | 4334 | | |
4336 | | - | |
4337 | 4335 | | |
4338 | | - | |
4339 | 4336 | | |
4340 | 4337 | | |
4341 | 4338 | | |
4342 | 4339 | | |
| 4340 | + | |
| 4341 | + | |
4343 | 4342 | | |
4344 | 4343 | | |
4345 | 4344 | | |
| |||
0 commit comments