Re: possible deadlock in __lock_task_sighand

2020-08-29 Thread Jens Axboe
This is already fixed, and it went upstream yesterday.

#syz fix: io_uring: don't recurse on tsk->sighand->siglock with signalfd

-- 
Jens Axboe



possible deadlock in __lock_task_sighand

2020-08-29 Thread syzbot
Hello,

syzbot found the following issue on:

HEAD commit:abb3438d Merge tag 'm68knommu-for-v5.9-rc3' of git://git.k..
git tree:   upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=10bb510590
kernel config:  https://syzkaller.appspot.com/x/.config?x=978db74cb30aa994
dashboard link: https://syzkaller.appspot.com/bug?extid=6e8f5b555cce8fac0423
compiler:   gcc (GCC) 10.1.0-syz 20200507
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=123a399690
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=158b8eb690

The issue was bisected to:

commit 0ba9c9edcd152158a0e321a4c13ac1dfc571ff3d
Author: Jens Axboe 
Date:   Fri Aug 7 01:41:50 2020 +

io_uring: use TWA_SIGNAL for task_work uncondtionally

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=1672c54990
final oops: https://syzkaller.appspot.com/x/report.txt?x=1572c54990
console output: https://syzkaller.appspot.com/x/log.txt?x=1172c54990

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+6e8f5b555cce8fac0...@syzkaller.appspotmail.com
Fixes: 0ba9c9edcd15 ("io_uring: use TWA_SIGNAL for task_work uncondtionally")


WARNING: possible recursive locking detected
5.9.0-rc2-syzkaller #0 Not tainted

syz-executor339/7010 is trying to acquire lock:
888094030058 (>siglock){}-{2:2}, at: 
__lock_task_sighand+0x106/0x2d0 kernel/signal.c:1390

but task is already holding lock:
888094030058 (>siglock){}-{2:2}, at: 
force_sig_info_to_task+0x6c/0x3a0 kernel/signal.c:1316

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

   CPU0
   
  lock(>siglock);
  lock(>siglock);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

3 locks held by syz-executor339/7010:
 #0: 888094030058 (>siglock){}-{2:2}, at: 
force_sig_info_to_task+0x6c/0x3a0 kernel/signal.c:1316
 #1: 8880940300a0 (>signalfd_wqh){}-{2:2}, at: 
__wake_up_common_lock+0xb4/0x130 kernel/sched/wait.c:122
 #2: 89bd6900 (rcu_read_lock){}-{1:2}, at: 
__lock_task_sighand+0x0/0x2d0 kernel/signal.c:1352

stack backtrace:
CPU: 1 PID: 7010 Comm: syz-executor339 Not tainted 5.9.0-rc2-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 
01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x18f/0x20d lib/dump_stack.c:118
 print_deadlock_bug kernel/locking/lockdep.c:2391 [inline]
 check_deadlock kernel/locking/lockdep.c:2432 [inline]
 validate_chain kernel/locking/lockdep.c:3202 [inline]
 __lock_acquire.cold+0x115/0x396 kernel/locking/lockdep.c:4426
 lock_acquire+0x1f1/0xad0 kernel/locking/lockdep.c:5005
 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
 _raw_spin_lock_irqsave+0x8c/0xc0 kernel/locking/spinlock.c:159
 __lock_task_sighand+0x106/0x2d0 kernel/signal.c:1390
 lock_task_sighand include/linux/sched/signal.h:687 [inline]
 task_work_add+0x1d7/0x290 kernel/task_work.c:51
 io_req_task_work_add fs/io_uring.c:1765 [inline]
 __io_async_wake+0x415/0x980 fs/io_uring.c:4589
 __wake_up_common+0x147/0x650 kernel/sched/wait.c:93
 __wake_up_common_lock+0xd0/0x130 kernel/sched/wait.c:123
 signalfd_notify include/linux/signalfd.h:22 [inline]
 __send_signal+0x75b/0xf90 kernel/signal.c:1163
 force_sig_info_to_task+0x2a0/0x3a0 kernel/signal.c:1333
 force_sig_fault_to_task kernel/signal.c:1672 [inline]
 force_sig_fault+0xb0/0xf0 kernel/signal.c:1679
 __bad_area_nosemaphore+0x32a/0x480 arch/x86/mm/fault.c:778
 do_user_addr_fault+0x852/0xbf0 arch/x86/mm/fault.c:1257
 handle_page_fault arch/x86/mm/fault.c:1351 [inline]
 exc_page_fault+0xa8/0x160 arch/x86/mm/fault.c:1404
 asm_exc_page_fault+0x1e/0x30 arch/x86/include/asm/idtentry.h:538
RIP: 0033:0x4013f9
Code: 00 20 00 c6 04 25 3d 02 00 20 00 c6 04 25 3e 02 00 20 00 c6 04 25 3f 02 
00 20 00 48 8b 15 a7 ac 2d 00 48 8b 34 25 00 02 00 20 <8b> 8a 0c 01 00 00 48 89 
30 48 8b 34 25 08 02 00 20 c1 e1 04 48 89
RSP: 002b:7f8507d67d10 EFLAGS: 00010246
RAX:  RBX: 006f0038 RCX: 
RDX:  RSI: 00060002 RDI: 
RBP: 006f0030 R08:  R09: 
R10:  R11: 0246 R12: 006f003c
R13: 7f8507d67d10 R14: 7f8507d67d10 R15: 0001


---
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 syzkal...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
For information about bisection process see: https://goo.gl/tpsmEJ#bisection
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches