possible deadlock in __lock_task_sighand

From: syzbot
Date: Sat Aug 29 2020 - 20:08:38 EST


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=10bb5105900000
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=123a3996900000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=158b8eb6900000

The issue was bisected to:

commit 0ba9c9edcd152158a0e321a4c13ac1dfc571ff3d
Author: Jens Axboe <axboe@xxxxxxxxx>
Date: Fri Aug 7 01:41:50 2020 +0000

io_uring: use TWA_SIGNAL for task_work uncondtionally

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

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+6e8f5b555cce8fac0423@xxxxxxxxxxxxxxxxxxxxxxxxx
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:
ffff888094030058 (&sighand->siglock){....}-{2:2}, at: __lock_task_sighand+0x106/0x2d0 kernel/signal.c:1390

but task is already holding lock:
ffff888094030058 (&sighand->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(&sighand->siglock);
lock(&sighand->siglock);

*** DEADLOCK ***

May be due to missing lock nesting notation

3 locks held by syz-executor339/7010:
#0: ffff888094030058 (&sighand->siglock){....}-{2:2}, at: force_sig_info_to_task+0x6c/0x3a0 kernel/signal.c:1316
#1: ffff8880940300a0 (&sighand->signalfd_wqh){....}-{2:2}, at: __wake_up_common_lock+0xb4/0x130 kernel/sched/wait.c:122
#2: ffffffff89bd6900 (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:00007f8507d67d10 EFLAGS: 00010246
RAX: ffffffffffffffff RBX: 00000000006f0038 RCX: 0000000000000000
RDX: ffffffffffffffff RSI: 0000000600000002 RDI: 0000000000000000
RBP: 00000000006f0030 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000006f003c
R13: 00007f8507d67d10 R14: 00007f8507d67d10 R15: 0000000000000001


---
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@xxxxxxxxxxxxxxxx.

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