Re: [PATCH next] btrfs: fix deadlock in btrfs_read_chunk_tree

From: Qu Wenruo
Date: Sun Jun 29 2025 - 00:28:14 EST




在 2025/6/26 09:14, Hillf Danton 写道:
On Thu, 26 Jun 2025 06:59:14 +0930 Qu Wenruo wrote:
=E5=9C=A8 2025/6/25 22:10, Hillf Danton =E5=86=99=E9=81=93:
On Wed, 25 Jun 2025 20:19:06 +0930 Qu Wenruo wrote:
=3DE5=3D9C=3DA8 2025/6/25 09:26, Hillf Danton =3DE5=3D86=3D99=3DE9=3D81=
=3D93:
On Wed, 25 Jun 2025 06:00:09 +0930 Qu Wenruo wrote:
=3D3DE5=3D3D9C=3D3DA8 2025/6/25 00:00, Edward Adam Davis =3D3DE5=3D3D=
86=3D3D99=3D3DE9=3D
=3D3D81=3D3D93:
Remove the lock uuid_mutex outside of sget_fc() to avoid the deadloc=
k
reported by [1].
=3D3D20
[1]
-> #1 (&type->s_umount_key#41/1){+.+.}-{4:4}:
lock_acquire+0x120/0x360 kernel/locking/lockdep.c:5871
down_write_nested+0x9d/0x200 kernel/locking/rwsem.c:1693
alloc_super+0x204/0x970 fs/super.c:345
=3D20
Given kzalloc [3], the syzbot report is false positive (a known lockde=
p
issue) as nobody else should acquire s->s_umount lock.
=3D20
[3] https://web.git.kernel.org/pub/scm/linux/kernel/git/next/linux-nex=
t.=3D
git/tree/fs/super.c?id=3D3D7aacdf6feed1#n319

Not a false alert either.

sget_fc() can return an existing super block, we can race between a=3D2=
0
mount and an unmount on the same super block.

In that case it's going to cause problem.

This is already fixed in the v4 (and later v5) patchset:

https://lore.kernel.org/linux-btrfs/cover.1750724841.git.wqu@xxxxxxxx/

Can v5 survive the syzbot test?

Yes, I enabled lockdep during v5 tests.

Fine, feel free to show us the Tested-by syzbot gave you.


Here you go:

https://lore.kernel.org/linux-btrfs/685d3d4c.050a0220.2303ee.01ca.GAE@xxxxxxxxxx/

That's based on a branch with extra patches though.