mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [syzbot] [block?] possible deadlock in blkdev_write_iter
@ 2026-10-29  5:12 syzbot
  2026-10-29  6:57 ` Edward Adam Davis
  2026-10-29  7:37 ` [PATCH] block: remove inode lock for buffered write Edward Adam Davis
  0 siblings, 2 replies; 5+ messages in thread
From: syzbot @ 2026-10-29  5:12 UTC (permalink / raw)
  To: axboe, linux-block, linux-kernel, syzkaller-bugs

Hello,

syzbot found the following issue on:

HEAD commit:    330517c63aa9 Merge tag 'char-misc-7.4-rc1' of git://git.ke..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=11962aa5580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=b03c85f3988bfcd5
dashboard link: https://syzkaller.appspot.com/bug?extid=39e465d3f7a1555b0f96
compiler:       gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=16949aa5580000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=105c53cd580000

Downloadable assets:
disk image (non-bootable): https://storage.googleapis.com/syzbot-assets/d900f083ada3/non_bootable_disk-330517c6.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/ecb230491807/vmlinux-330517c6.xz
kernel image: https://storage.googleapis.com/syzbot-assets/ace3132a7acc/bzImage-330517c6.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+39e465d3f7a1555b0f96@syzkaller.appspotmail.com

============================================
WARNING: possible recursive locking detected
syzkaller #0 Not tainted
--------------------------------------------
syz.2.64/6167 is trying to acquire lock:
ffff88802a5f1ee8 (&sb->s_type->i_mutex_key#9){++++}-{4:4}, at: inode_lock_shared include/linux/fs.h:1039 [inline]
ffff88802a5f1ee8 (&sb->s_type->i_mutex_key#9){++++}-{4:4}, at: blkdev_buffered_write block/fops.c:734 [inline]
ffff88802a5f1ee8 (&sb->s_type->i_mutex_key#9){++++}-{4:4}, at: blkdev_write_iter+0xd12/0x11d0 block/fops.c:812

but task is already holding lock:
ffff88802a5f1ee8 (&sb->s_type->i_mutex_key#9){++++}-{4:4}, at: inode_lock_shared include/linux/fs.h:1039 [inline]
ffff88802a5f1ee8 (&sb->s_type->i_mutex_key#9){++++}-{4:4}, at: blkdev_write_iter+0xc5e/0x11d0 block/fops.c:811

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(&sb->s_type->i_mutex_key#9);
  lock(&sb->s_type->i_mutex_key#9);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

locks held by syz.2.64/6167: 1, last CPU#2:
 #0: ffff88802a5f1ee8 (&sb->s_type->i_mutex_key#9){++++}-{4:4}, at: inode_lock_shared include/linux/fs.h:1039 [inline]
 #0: ffff88802a5f1ee8 (&sb->s_type->i_mutex_key#9){++++}-{4:4}, at: blkdev_write_iter+0xc5e/0x11d0 block/fops.c:811

stack backtrace:
CPU: 2 UID: 0 PID: 6167 Comm: syz.2.64 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x100/0x190 lib/dump_stack.c:120
 print_deadlock_bug.cold+0xbd/0xca kernel/locking/lockdep.c:3085
 check_deadlock kernel/locking/lockdep.c:3137 [inline]
 validate_chain kernel/locking/lockdep.c:3939 [inline]
 __lock_acquire+0x13f4/0x1f40 kernel/locking/lockdep.c:5288
 lock_acquire kernel/locking/lockdep.c:5942 [inline]
 lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5899
 down_read+0x94/0x4c0 kernel/locking/rwsem.c:1574
 inode_lock_shared include/linux/fs.h:1039 [inline]
 blkdev_buffered_write block/fops.c:734 [inline]
 blkdev_write_iter+0xd12/0x11d0 block/fops.c:812
 new_sync_write fs/read_write.c:595 [inline]
 vfs_write+0x6af/0x1050 fs/read_write.c:687
 ksys_write+0x12a/0x250 fs/read_write.c:739
 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
 do_syscall_64+0x123/0x790 arch/x86/entry/syscall_64.c:84
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f835bf9f559
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffd15ca3258 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f835c225fa0 RCX: 00007f835bf9f559
RDX: 00000000fffffe38 RSI: 0000200000001140 RDI: 0000000000000004
RBP: 00007f835c036b20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f835c225fac R14: 00007f835c225fa0 R15: 00007f835c225fa0
 </TASK>


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [syzbot] [block?] possible deadlock in blkdev_write_iter
  2026-10-29  5:12 [syzbot] [block?] possible deadlock in blkdev_write_iter syzbot
@ 2026-10-29  6:57 ` Edward Adam Davis
  2026-10-29  7:20   ` syzbot
  2026-10-29  7:37 ` [PATCH] block: remove inode lock for buffered write Edward Adam Davis
  1 sibling, 1 reply; 5+ messages in thread
From: Edward Adam Davis @ 2026-10-29  6:57 UTC (permalink / raw)
  To: syzbot+39e465d3f7a1555b0f96; +Cc: linux-kernel, syzkaller-bugs

From: Edward Aadm Davis <eadavis@sina.com>

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 330517c63aa9

diff --git a/block/fops.c b/block/fops.c
index 517b96c9d262..375ec2c15926 100644
--- a/block/fops.c
+++ b/block/fops.c
@@ -808,9 +808,7 @@ static ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from)
 			} else {
 				ssize_t ret2;
 
-				inode_lock_shared(bd_inode);
 				ret2 = blkdev_buffered_write(iocb, from);
-				inode_unlock_shared(bd_inode);
 				ret = direct_write_fallback(iocb, from, ret,
 							    ret2);
 				need_sync = true;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [syzbot] [block?] possible deadlock in blkdev_write_iter
  2026-10-29  6:57 ` Edward Adam Davis
@ 2026-10-29  7:20   ` syzbot
  0 siblings, 0 replies; 5+ messages in thread
From: syzbot @ 2026-10-29  7:20 UTC (permalink / raw)
  To: eadavis, linux-kernel, syzkaller-bugs

Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-by: syzbot+39e465d3f7a1555b0f96@syzkaller.appspotmail.com
Tested-by: syzbot+39e465d3f7a1555b0f96@syzkaller.appspotmail.com

Tested on:

commit:         330517c6 Merge tag 'char-misc-7.4-rc1' of git://git.ke..
git tree:       git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=1573fa81580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=b03c85f3988bfcd5
dashboard link: https://syzkaller.appspot.com/bug?extid=39e465d3f7a1555b0f96
compiler:       gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44
patch:          https://syzkaller.appspot.com/x/patch.diff?x=10ef43e0580000

Note: testing is done by a robot and is best-effort only.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] block: remove inode lock for buffered write
  2026-10-29  5:12 [syzbot] [block?] possible deadlock in blkdev_write_iter syzbot
  2026-10-29  6:57 ` Edward Adam Davis
@ 2026-10-29  7:37 ` Edward Adam Davis
  2026-10-29 15:54   ` Caleb Sander Mateos
  1 sibling, 1 reply; 5+ messages in thread
From: Edward Adam Davis @ 2026-10-29  7:37 UTC (permalink / raw)
  To: syzbot+39e465d3f7a1555b0f96
  Cc: axboe, linux-block, linux-kernel, sunjunchao, syzkaller-bugs

Commit 2fec4fd97cc3 ("block: take i_rwsem for the direct I/O write fallback")
added shared inode locking around ordinary buffered writes, but commit
1b1be9ea4e34 move the lock to blkdev_buffered_write() and didn't remove the
shared inode lock in blkdev_write_iter(), potentially hitting:

WARNING: possible recursive locking detected
--------------------------------------------
syz.2.64/6167 is trying to acquire lock:
ffff88802a5f1ee8 (&sb->s_type->i_mutex_key#9){++++}-{4:4}, at: blkdev_buffered_write block/fops.c:734 [inline]
ffff88802a5f1ee8 (&sb->s_type->i_mutex_key#9){++++}-{4:4}, at: blkdev_write_iter+0xd12/0x11d0 block/fops.c:812

but task is already holding lock:
ffff88802a5f1ee8 (&sb->s_type->i_mutex_key#9){++++}-{4:4}, at: blkdev_write_iter+0xc5e/0x11d0 block/fops.c:811

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(&sb->s_type->i_mutex_key#9);
  lock(&sb->s_type->i_mutex_key#9);

 *** DEADLOCK ***

Call Trace:
 inode_lock_shared include/linux/fs.h:1039 [inline]
 blkdev_buffered_write block/fops.c:734 [inline]
 blkdev_write_iter+0xd12/0x11d0 block/fops.c:812

Let's remove shared inode lock from blkdev_write_iter().

Fixes: 1b1be9ea4e34 ("block: take the inode lock for buffered write fallback")
Reported-by: syzbot+39e465d3f7a1555b0f96@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=39e465d3f7a1555b0f96
Tested-by: syzbot+39e465d3f7a1555b0f96@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@sina.com>
---
 block/fops.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/block/fops.c b/block/fops.c
index 517b96c9d262..375ec2c15926 100644
--- a/block/fops.c
+++ b/block/fops.c
@@ -808,9 +808,7 @@ static ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from)
 			} else {
 				ssize_t ret2;
 
-				inode_lock_shared(bd_inode);
 				ret2 = blkdev_buffered_write(iocb, from);
-				inode_unlock_shared(bd_inode);
 				ret = direct_write_fallback(iocb, from, ret,
 							    ret2);
 				need_sync = true;
-- 
2.43.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] block: remove inode lock for buffered write
  2026-10-29  7:37 ` [PATCH] block: remove inode lock for buffered write Edward Adam Davis
@ 2026-10-29 15:54   ` Caleb Sander Mateos
  0 siblings, 0 replies; 5+ messages in thread
From: Caleb Sander Mateos @ 2026-10-29 15:54 UTC (permalink / raw)
  To: Edward Adam Davis
  Cc: syzbot+39e465d3f7a1555b0f96, axboe, linux-block, linux-kernel,
	sunjunchao, syzkaller-bugs

On Thu, Oct 29, 2026 at 12:39 AM Edward Adam Davis <eadavis@sina.com> wrote:
>
> Commit 2fec4fd97cc3 ("block: take i_rwsem for the direct I/O write fallback")
> added shared inode locking around ordinary buffered writes, but commit
> 1b1be9ea4e34 move the lock to blkdev_buffered_write() and didn't remove the
> shared inode lock in blkdev_write_iter(), potentially hitting:
>
> WARNING: possible recursive locking detected
> --------------------------------------------
> syz.2.64/6167 is trying to acquire lock:
> ffff88802a5f1ee8 (&sb->s_type->i_mutex_key#9){++++}-{4:4}, at: blkdev_buffered_write block/fops.c:734 [inline]
> ffff88802a5f1ee8 (&sb->s_type->i_mutex_key#9){++++}-{4:4}, at: blkdev_write_iter+0xd12/0x11d0 block/fops.c:812
>
> but task is already holding lock:
> ffff88802a5f1ee8 (&sb->s_type->i_mutex_key#9){++++}-{4:4}, at: blkdev_write_iter+0xc5e/0x11d0 block/fops.c:811
>
> other info that might help us debug this:
>  Possible unsafe locking scenario:
>
>        CPU0
>        ----
>   lock(&sb->s_type->i_mutex_key#9);
>   lock(&sb->s_type->i_mutex_key#9);
>
>  *** DEADLOCK ***
>
> Call Trace:
>  inode_lock_shared include/linux/fs.h:1039 [inline]
>  blkdev_buffered_write block/fops.c:734 [inline]
>  blkdev_write_iter+0xd12/0x11d0 block/fops.c:812
>
> Let's remove shared inode lock from blkdev_write_iter().
>
> Fixes: 1b1be9ea4e34 ("block: take the inode lock for buffered write fallback")
> Reported-by: syzbot+39e465d3f7a1555b0f96@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=39e465d3f7a1555b0f96
> Tested-by: syzbot+39e465d3f7a1555b0f96@syzkaller.appspotmail.com
> Signed-off-by: Edward Adam Davis <eadavis@sina.com>
> ---
>  block/fops.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/block/fops.c b/block/fops.c
> index 517b96c9d262..375ec2c15926 100644
> --- a/block/fops.c
> +++ b/block/fops.c
> @@ -808,9 +808,7 @@ static ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from)
>                         } else {
>                                 ssize_t ret2;
>
> -                               inode_lock_shared(bd_inode);
>                                 ret2 = blkdev_buffered_write(iocb, from);
> -                               inode_unlock_shared(bd_inode);

Already fixed by
https://lore.kernel.org/linux-block/20261022062513.77372-1-mzx199711@gmail.com/

Best,
Caleb

>                                 ret = direct_write_fallback(iocb, from, ret,
>                                                             ret2);
>                                 need_sync = true;
> --
> 2.43.0
>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-10-29 15:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-29  5:12 [syzbot] [block?] possible deadlock in blkdev_write_iter syzbot
2026-10-29  6:57 ` Edward Adam Davis
2026-10-29  7:20   ` syzbot
2026-10-29  7:37 ` [PATCH] block: remove inode lock for buffered write Edward Adam Davis
2026-10-29 15:54   ` Caleb Sander Mateos

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®