diff options
| author | Zhenxian Ma <mzx199711@gmail.com> | 2026-10-22 14:25:13 +0800 |
|---|---|---|
| committer | Jens Axboe <axboe@kernel.dk> | 2026-10-27 08:47:12 -0600 |
| commit | 21b88cc8bafceee6c6c82503e3b2cc6f1d0c78bf (patch) | |
| tree | 5e3c97ba2ce71c70dc0dc972a49e8691634778ef /tools/lib/python | |
| parent | 87409eedc543d288cdd49c2174f7d61eca7b8db5 (diff) | |
block: fix recursive i_rwsem locking in blkdev_write_iter()
Commit 2fec4fd97cc3 ("block: take i_rwsem for the direct I/O write
fallback") takes i_rwsem around blkdev_buffered_write() in the direct
write fallback to close a race with set_blocksize(). Commit
1b1be9ea4e34 ("block: take the inode lock for buffered write fallback")
fixes the same race by taking i_rwsem inside blkdev_buffered_write()
instead. With both commits applied, the fallback path takes i_rwsem
recursively:
blkdev_write_iter()
inode_lock_shared(bd_inode)
blkdev_buffered_write()
inode_lock_shared(inode)
syzbot reports this as:
WARNING: possible recursive locking detected
syz.0.40/6005 is trying to acquire lock:
ffff888024956f68 (&sb->s_type->i_mutex_key#10){++++}-{4:4}, at: blkdev_buffered_write+0xd7/0x160 block/fops.c:738
but task is already holding lock:
ffff888024956f68 (&sb->s_type->i_mutex_key#10){++++}-{4:4}, at: blkdev_write_iter+0x6c5/0x810 block/fops.c:815
rw_semaphore read locks are not recursive: once a writer is queued,
new readers block behind it. If set_blocksize() calls inode_lock()
between the two acquisitions, it waits for the first read lock to be
released, while the second inode_lock_shared() waits behind
set_blocksize(), and the task deadlocks.
Drop the outer locking in the fallback.
Fixes: 1b1be9ea4e34 ("block: take the inode lock for buffered write fallback")
Reported-by: syzbot+bd975ef54294bec73f0e@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=bd975ef54294bec73f0e
Cc: Tal Zussman <tz2294@columbia.edu>
Cc: Julian Sun <sunjunchao@bytedance.com>
Assisted-by: LLM
Signed-off-by: Zhenxian Ma <mzx199711@gmail.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Link: https://patch.msgid.link/20261022062513.77372-1-mzx199711@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'tools/lib/python')
0 files changed, 0 insertions, 0 deletions
