Repository navigation
Commit 298a8f9
Btrfs: fix NULL pointer crash when running balance and scrub concurrently
While running balance, scrub, fsstress concurrently we hit the
following kernel crash:
[56561.448845] BTRFS info (device sde): relocating block group 11005853696 flags 132
[56561.524077] BUG: unable to handle kernel NULL pointer dereference at 0000000000000078
[56561.524237] IP: [<ffffffffa038956d>] scrub_chunk.isra.12+0xdd/0x130 [btrfs]
[56561.524297] PGD 9be28067 PUD 7f3dd067 PMD 0
[56561.524325] Oops: 0000 [raspberrypi#1] SMP
[....]
[56561.527237] Call Trace:
[56561.527309] [<ffffffffa038980e>] scrub_enumerate_chunks+0x24e/0x490 [btrfs]
[56561.527392] [<ffffffff810abe00>] ? abort_exclusive_wait+0x50/0xb0
[56561.527476] [<ffffffffa038add4>] btrfs_scrub_dev+0x1a4/0x530 [btrfs]
[56561.527561] [<ffffffffa0368107>] btrfs_ioctl+0x13f7/0x2a90 [btrfs]
[56561.527639] [<ffffffff811c82f0>] do_vfs_ioctl+0x2e0/0x4c0
[56561.527712] [<ffffffff8109c384>] ? vtime_account_user+0x54/0x60
[56561.527788] [<ffffffff810f768c>] ? __audit_syscall_entry+0x9c/0xf0
[56561.527870] [<ffffffff811c8551>] SyS_ioctl+0x81/0xa0
[56561.527941] [<ffffffff815707f7>] tracesys+0xdd/0xe2
[...]
[56561.528304] RIP [<ffffffffa038956d>] scrub_chunk.isra.12+0xdd/0x130 [btrfs]
[56561.528395] RSP <ffff88004c0f5be8>
[56561.528454] CR2: 0000000000000078
This is because in btrfs_relocate_chunk(), we will free @bdev directly while
scrub may still hold extent mapping, and may access freed memory.
Fix this problem by wrapping freeing @bdev work into free_extent_map() which
is based on reference count.
Reported-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Chris Mason <clm@fb.com>1 parent ced96ed commit 298a8f9
3 files changed
Lines changed: 6 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
78 | 80 | | |
79 | 81 | | |
80 | 82 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2543 | 2543 | | |
2544 | 2544 | | |
2545 | 2545 | | |
2546 | | - | |
2547 | | - | |
2548 | | - | |
2549 | 2546 | | |
2550 | 2547 | | |
2551 | 2548 | | |
| |||
4301 | 4298 | | |
4302 | 4299 | | |
4303 | 4300 | | |
| 4301 | + | |
4304 | 4302 | | |
4305 | 4303 | | |
4306 | 4304 | | |
| 4305 | + | |
4307 | 4306 | | |
4308 | 4307 | | |
4309 | 4308 | | |
| |||
4346 | 4345 | | |
4347 | 4346 | | |
4348 | 4347 | | |
4349 | | - | |
4350 | 4348 | | |
4351 | 4349 | | |
4352 | 4350 | | |
| |||
4558 | 4556 | | |
4559 | 4557 | | |
4560 | 4558 | | |
4561 | | - | |
4562 | 4559 | | |
4563 | 4560 | | |
4564 | 4561 | | |
| |||
5822 | 5819 | | |
5823 | 5820 | | |
5824 | 5821 | | |
| 5822 | + | |
5825 | 5823 | | |
5826 | 5824 | | |
5827 | 5825 | | |
| |||
5846 | 5844 | | |
5847 | 5845 | | |
5848 | 5846 | | |
5849 | | - | |
5850 | 5847 | | |
5851 | 5848 | | |
5852 | 5849 | | |
5853 | 5850 | | |
5854 | 5851 | | |
5855 | 5852 | | |
5856 | 5853 | | |
5857 | | - | |
5858 | 5854 | | |
5859 | 5855 | | |
5860 | 5856 | | |
| |||
0 commit comments