diff options
| author | Deepanshu Kartikey <kartikey406@gmail.com> | 2026-06-21 09:28:41 +0530 |
|---|---|---|
| committer | Jan Kara <jack@suse.cz> | 2026-07-08 17:12:21 +0200 |
| commit | 31e5e0c8c8e2617eb9f7a20c1cf5df23f592ade2 (patch) | |
| tree | 2207ed1492097c38660a632889330f40939bda33 /tools/perf/scripts/python/export-to-sqlite.py | |
| parent | 120ec50984b8645232c2c004310dd94ceff5520e (diff) | |
udf: avoid recursive s_alloc_mutex deadlock when freeing AED blocks
udf_table_prealloc_blocks() and udf_table_new_block() call
udf_delete_aext() on the unallocated-space-table inode while holding
sbi->s_alloc_mutex. When the deleted allocation descriptor empties an
allocation-extent (AED) block, udf_delete_aext() returns that block to
free space via udf_free_blocks(). For a table-managed partition that
path is udf_free_blocks() -> udf_table_free_blocks() ->
mutex_lock(&sbi->s_alloc_mutex), i.e. the task tries to acquire a mutex
it already holds.
On a PREEMPT_RT kernel the rtmutex deadlock detector reports this as
-EDEADLK:
rtmutex deadlock detected
WARNING: kernel/locking/rtmutex.c:1698 at rt_mutex_handle_deadlock
udf_table_free_blocks fs/udf/balloc.c:376 [inline]
udf_free_blocks+0xa8c/0x1900 fs/udf/balloc.c:678
udf_delete_aext+0x4f5/0xc00 fs/udf/inode.c:2381
udf_table_prealloc_blocks fs/udf/balloc.c:544 [inline]
udf_prealloc_blocks+0xbd4/0x10e0 fs/udf/balloc.c:702
On a non-RT kernel the same path is a hard self-deadlock (or a lockdep
recursive-locking splat). It is reachable from a crafted UDF image via
the write/sendfile path.
The allocator already refuses to recurse on the add side: see the
comment in udf_table_free_blocks() explaining why it must not call
udf_add_aext() while holding s_alloc_mutex. Apply the same rule to the
delete side. Let udf_delete_aext() report the AED block it would
otherwise free through a new out-parameter, and have the two callers
that hold s_alloc_mutex free it after dropping the lock. The block is
already unlinked from the inode's descriptor chain by then, so nothing
can reference it in the meantime. All other callers pass NULL and keep
freeing the block inline, exactly as before.
The out-parameter is pre-initialised with the reserved partition number
0xFFFF, which can never name a real block, so the caller can tell
whether a block was handed back.
Reported-by: syzbot+6a680377e13041c19d50@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=6a680377e13041c19d50
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
Link: https://syzkaller.appspot.com/bug?extid=6a680377e13041c19d50
Link: https://patch.msgid.link/20260621035841.56194-1-kartikey406@gmail.com
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'tools/perf/scripts/python/export-to-sqlite.py')
0 files changed, 0 insertions, 0 deletions
