possible deadlock in kcm_ioctl

6 views
Skip to first unread message

syzbot

unread,
Feb 4, 2020, 2:56:14 PM2/4/20
to syzkaller...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: 9fa690a2 Linux 4.14.169
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=155decb5e00000
kernel config: https://syzkaller.appspot.com/x/.config?x=eb55b601e76e3476
dashboard link: https://syzkaller.appspot.com/bug?extid=fc32a77073ca93da3c99
compiler: gcc (GCC) 9.0.0 20181231 (experimental)

Unfortunately, I don't have any reproducer for this crash yet.

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

Bluetooth: hci1 sending frame failed (-49)
SELinux: unrecognized netlink message: protocol=0 nlmsg_type=1 sclass=netlink_route_socket pig=15373 comm=syz-executor.4
======================================================
WARNING: possible circular locking dependency detected
4.14.169-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.3/15386 is trying to acquire lock:
((&strp->work)){+.+.}, at: [<ffffffff813caa94>] flush_work+0x84/0x730 kernel/workqueue.c:2884

but task is already holding lock:
(sk_lock-AF_INET){+.+.}, at: [<ffffffff85e2fd4d>] lock_sock include/net/sock.h:1467 [inline]
(sk_lock-AF_INET){+.+.}, at: [<ffffffff85e2fd4d>] kcm_attach net/kcm/kcmsock.c:1390 [inline]
(sk_lock-AF_INET){+.+.}, at: [<ffffffff85e2fd4d>] kcm_attach_ioctl net/kcm/kcmsock.c:1490 [inline]
(sk_lock-AF_INET){+.+.}, at: [<ffffffff85e2fd4d>] kcm_ioctl+0x35d/0x1120 net/kcm/kcmsock.c:1701

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (sk_lock-AF_INET){+.+.}:
lock_acquire+0x16f/0x430 kernel/locking/lockdep.c:3994
lock_sock_nested+0xbd/0x110 net/core/sock.c:2770
lock_sock include/net/sock.h:1467 [inline]
strp_sock_lock+0x2e/0x40 net/strparser/strparser.c:451
do_strp_work net/strparser/strparser.c:415 [inline]
strp_work+0x43/0x100 net/strparser/strparser.c:434
process_one_work+0x863/0x1600 kernel/workqueue.c:2114
worker_thread+0x5d9/0x1050 kernel/workqueue.c:2248
kthread+0x319/0x430 kernel/kthread.c:232
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:404

-> #0 ((&strp->work)){+.+.}:
check_prev_add kernel/locking/lockdep.c:1901 [inline]
check_prevs_add kernel/locking/lockdep.c:2018 [inline]
validate_chain kernel/locking/lockdep.c:2460 [inline]
__lock_acquire+0x2cb3/0x4620 kernel/locking/lockdep.c:3487
lock_acquire+0x16f/0x430 kernel/locking/lockdep.c:3994
flush_work+0xae/0x730 kernel/workqueue.c:2887
__cancel_work_timer+0x2f0/0x480 kernel/workqueue.c:2962
cancel_work_sync+0x18/0x20 kernel/workqueue.c:2998
strp_done+0x58/0xe0 net/strparser/strparser.c:519
kcm_attach net/kcm/kcmsock.c:1429 [inline]
kcm_attach_ioctl net/kcm/kcmsock.c:1490 [inline]
kcm_ioctl+0x8d9/0x1120 net/kcm/kcmsock.c:1701
sock_do_ioctl+0x64/0xb0 net/socket.c:974
sock_ioctl+0x2a6/0x470 net/socket.c:1071
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:500 [inline]
do_vfs_ioctl+0x7ae/0x1060 fs/ioctl.c:684
SYSC_ioctl fs/ioctl.c:701 [inline]
SyS_ioctl+0x8f/0xc0 fs/ioctl.c:692
do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x42/0xb7

other info that might help us debug this:

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(sk_lock-AF_INET);
lock((&strp->work));
lock(sk_lock-AF_INET);
lock((&strp->work));

*** DEADLOCK ***

1 lock held by syz-executor.3/15386:
#0: (sk_lock-AF_INET){+.+.}, at: [<ffffffff85e2fd4d>] lock_sock include/net/sock.h:1467 [inline]
#0: (sk_lock-AF_INET){+.+.}, at: [<ffffffff85e2fd4d>] kcm_attach net/kcm/kcmsock.c:1390 [inline]
#0: (sk_lock-AF_INET){+.+.}, at: [<ffffffff85e2fd4d>] kcm_attach_ioctl net/kcm/kcmsock.c:1490 [inline]
#0: (sk_lock-AF_INET){+.+.}, at: [<ffffffff85e2fd4d>] kcm_ioctl+0x35d/0x1120 net/kcm/kcmsock.c:1701

stack backtrace:
CPU: 0 PID: 15386 Comm: syz-executor.3 Not tainted 4.14.169-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0x142/0x197 lib/dump_stack.c:58
print_circular_bug.isra.0.cold+0x1cc/0x28f kernel/locking/lockdep.c:1258
check_prev_add kernel/locking/lockdep.c:1901 [inline]
check_prevs_add kernel/locking/lockdep.c:2018 [inline]
validate_chain kernel/locking/lockdep.c:2460 [inline]
__lock_acquire+0x2cb3/0x4620 kernel/locking/lockdep.c:3487
lock_acquire+0x16f/0x430 kernel/locking/lockdep.c:3994
flush_work+0xae/0x730 kernel/workqueue.c:2887
__cancel_work_timer+0x2f0/0x480 kernel/workqueue.c:2962
cancel_work_sync+0x18/0x20 kernel/workqueue.c:2998
strp_done+0x58/0xe0 net/strparser/strparser.c:519
kcm_attach net/kcm/kcmsock.c:1429 [inline]
kcm_attach_ioctl net/kcm/kcmsock.c:1490 [inline]
kcm_ioctl+0x8d9/0x1120 net/kcm/kcmsock.c:1701
sock_do_ioctl+0x64/0xb0 net/socket.c:974
sock_ioctl+0x2a6/0x470 net/socket.c:1071
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:500 [inline]
do_vfs_ioctl+0x7ae/0x1060 fs/ioctl.c:684
SYSC_ioctl fs/ioctl.c:701 [inline]
SyS_ioctl+0x8f/0xc0 fs/ioctl.c:692
do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x45b399
RSP: 002b:00007f8149f71c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f8149f726d4 RCX: 000000000045b399
RDX: 0000000020000380 RSI: 00000000000089e0 RDI: 0000000000000007
RBP: 000000000075c1c0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff
R13: 00000000000006d3 R14: 00000000004c84f9 R15: 000000000075c1cc
Bluetooth: hci0 command 0x1003 tx timeout
Bluetooth: hci0 sending frame failed (-49)
Bluetooth: hci1 command 0x1003 tx timeout
Bluetooth: hci1 sending frame failed (-49)
Bluetooth: hci2 command 0x1003 tx timeout
Bluetooth: hci2 sending frame failed (-49)
Bluetooth: hci0 command 0x1001 tx timeout
Bluetooth: hci0 sending frame failed (-49)
Bluetooth: hci1 command 0x1001 tx timeout
Bluetooth: hci1 sending frame failed (-49)
Bluetooth: hci2 command 0x1001 tx timeout
Bluetooth: hci2 sending frame failed (-49)
Bluetooth: hci0 command 0x1009 tx timeout
Bluetooth: hci1 command 0x1009 tx timeout
Bluetooth: hci2 command 0x1009 tx timeout
Bluetooth: hci3: Frame reassembly failed (-84)
Bluetooth: Error in BCSP hdr checksum
Bluetooth: Error in BCSP hdr checksum


---
This bug 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 syzk...@googlegroups.com.

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

syzbot

unread,
Feb 19, 2020, 4:47:13 AM2/19/20
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following crash on:

HEAD commit: 98db2bf2 Linux 4.14.171
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=103ba1dde00000
kernel config: https://syzkaller.appspot.com/x/.config?x=365f8162d5a0794b
dashboard link: https://syzkaller.appspot.com/bug?extid=fc32a77073ca93da3c99
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=16166265e00000

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

batman_adv: batadv0: Interface activated: batadv_slave_1
IPv6: ADDRCONF(NETDEV_CHANGE): batadv_slave_1: link becomes ready
IPv6: ADDRCONF(NETDEV_CHANGE): veth1_to_batadv: link becomes ready
======================================================
WARNING: possible circular locking dependency detected
4.14.171-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.0/8775 is trying to acquire lock:
((&strp->work)){+.+.}, at: [<ffffffff813c5de4>] flush_work+0x84/0x730 kernel/workqueue.c:2884

but task is already holding lock:
(sk_lock-AF_INET){+.+.}, at: [<ffffffff85e2988d>] lock_sock include/net/sock.h:1467 [inline]
(sk_lock-AF_INET){+.+.}, at: [<ffffffff85e2988d>] kcm_attach net/kcm/kcmsock.c:1390 [inline]
(sk_lock-AF_INET){+.+.}, at: [<ffffffff85e2988d>] kcm_attach_ioctl net/kcm/kcmsock.c:1490 [inline]
(sk_lock-AF_INET){+.+.}, at: [<ffffffff85e2988d>] kcm_ioctl+0x35d/0x1120 net/kcm/kcmsock.c:1701
1 lock held by syz-executor.0/8775:
#0: (sk_lock-AF_INET){+.+.}, at: [<ffffffff85e2988d>] lock_sock include/net/sock.h:1467 [inline]
#0: (sk_lock-AF_INET){+.+.}, at: [<ffffffff85e2988d>] kcm_attach net/kcm/kcmsock.c:1390 [inline]
#0: (sk_lock-AF_INET){+.+.}, at: [<ffffffff85e2988d>] kcm_attach_ioctl net/kcm/kcmsock.c:1490 [inline]
#0: (sk_lock-AF_INET){+.+.}, at: [<ffffffff85e2988d>] kcm_ioctl+0x35d/0x1120 net/kcm/kcmsock.c:1701

stack backtrace:
CPU: 0 PID: 8775 Comm: syz-executor.0 Not tainted 4.14.171-syzkaller #0
RIP: 0033:0x45c449
RSP: 002b:00007f6b12516c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f6b125176d4 RCX: 000000000045c449
RDX: 0000000020000380 RSI: 00000000000089e0 RDI: 0000000000000006
RBP: 000000000076c060 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff
R13: 00000000000006d8 R14: 00000000004c95d5 R15: 000000000076c06c

syzbot

unread,
Jul 26, 2022, 4:45:35 PM7/26/22
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 9c3bf9cf362f Linux 4.14.289
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=13464ffc080000
kernel config: https://syzkaller.appspot.com/x/.config?x=e790c7879836d072
dashboard link: https://syzkaller.appspot.com/bug?extid=fc32a77073ca93da3c99
compiler: gcc version 10.2.1 20210110 (Debian 10.2.1-6)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=11ddba02080000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=15c00df6080000

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

======================================================
WARNING: possible circular locking dependency detected
4.14.289-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor205/7967 is trying to acquire lock:
((&strp->work)){+.+.}, at: [<ffffffff81367998>] flush_work+0x88/0x770 kernel/workqueue.c:2887

but task is already holding lock:
(sk_lock-AF_INET){+.+.}, at: [<ffffffff86814f98>] lock_sock include/net/sock.h:1473 [inline]
(sk_lock-AF_INET){+.+.}, at: [<ffffffff86814f98>] kcm_attach net/kcm/kcmsock.c:1390 [inline]
(sk_lock-AF_INET){+.+.}, at: [<ffffffff86814f98>] kcm_attach_ioctl net/kcm/kcmsock.c:1490 [inline]
(sk_lock-AF_INET){+.+.}, at: [<ffffffff86814f98>] kcm_ioctl+0x328/0xfb0 net/kcm/kcmsock.c:1701

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (sk_lock-AF_INET){+.+.}:
lock_sock_nested+0xb7/0x100 net/core/sock.c:2813
do_strp_work net/strparser/strparser.c:415 [inline]
strp_work+0x3e/0x100 net/strparser/strparser.c:434
process_one_work+0x793/0x14a0 kernel/workqueue.c:2117
worker_thread+0x5cc/0xff0 kernel/workqueue.c:2251
kthread+0x30d/0x420 kernel/kthread.c:232
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:404

-> #0 ((&strp->work)){+.+.}:
lock_acquire+0x170/0x3f0 kernel/locking/lockdep.c:3998
flush_work+0xad/0x770 kernel/workqueue.c:2890
__cancel_work_timer+0x321/0x460 kernel/workqueue.c:2965
strp_done+0x53/0xd0 net/strparser/strparser.c:519
kcm_attach net/kcm/kcmsock.c:1429 [inline]
kcm_attach_ioctl net/kcm/kcmsock.c:1490 [inline]
kcm_ioctl+0x828/0xfb0 net/kcm/kcmsock.c:1701
sock_do_ioctl net/socket.c:974 [inline]
sock_ioctl+0x2cc/0x4c0 net/socket.c:1071
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:500 [inline]
do_vfs_ioctl+0x75a/0xff0 fs/ioctl.c:684
SYSC_ioctl fs/ioctl.c:701 [inline]
SyS_ioctl+0x7f/0xb0 fs/ioctl.c:692
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x46/0xbb

other info that might help us debug this:

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(sk_lock-AF_INET);
lock((&strp->work));
lock(sk_lock-AF_INET);
lock((&strp->work));

*** DEADLOCK ***

1 lock held by syz-executor205/7967:
#0: (sk_lock-AF_INET){+.+.}, at: [<ffffffff86814f98>] lock_sock include/net/sock.h:1473 [inline]
#0: (sk_lock-AF_INET){+.+.}, at: [<ffffffff86814f98>] kcm_attach net/kcm/kcmsock.c:1390 [inline]
#0: (sk_lock-AF_INET){+.+.}, at: [<ffffffff86814f98>] kcm_attach_ioctl net/kcm/kcmsock.c:1490 [inline]
#0: (sk_lock-AF_INET){+.+.}, at: [<ffffffff86814f98>] kcm_ioctl+0x328/0xfb0 net/kcm/kcmsock.c:1701

stack backtrace:
CPU: 1 PID: 7967 Comm: syz-executor205 Not tainted 4.14.289-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/29/2022
Call Trace:
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0x1b2/0x281 lib/dump_stack.c:58
print_circular_bug.constprop.0.cold+0x2d7/0x41e kernel/locking/lockdep.c:1258
check_prev_add kernel/locking/lockdep.c:1905 [inline]
check_prevs_add kernel/locking/lockdep.c:2022 [inline]
validate_chain kernel/locking/lockdep.c:2464 [inline]
__lock_acquire+0x2e0e/0x3f20 kernel/locking/lockdep.c:3491
lock_acquire+0x170/0x3f0 kernel/locking/lockdep.c:3998
flush_work+0xad/0x770 kernel/workqueue.c:2890
__cancel_work_timer+0x321/0x460 kernel/workqueue.c:2965
strp_done+0x53/0xd0 net/strparser/strparser.c:519
kcm_attach net/kcm/kcmsock.c:1429 [inline]
kcm_attach_ioctl net/kcm/kcmsock.c:1490 [inline]
kcm_ioctl+0x828/0xfb0 net/kcm/kcmsock.c:1701
sock_do_ioctl net/socket.c:974 [inline]
sock_ioctl+0x2cc/0x4c0 net/socket.c:1071
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:500 [inline]
do_vfs_ioctl+0x75a/0xff0 fs/ioctl.c:684
SYSC_ioctl fs/ioctl.c:701 [inline]
SyS_ioctl+0x7f/0xb0 fs/ioctl.c:692
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x46/0xbb
RIP: 0033:0x7f2e26462ea9

Reply all
Reply to author
Forward
0 new messages