syzbot


possible deadlock in br_ioctl_call

Status: fixed on 2021/11/10 00:50
Reported-by: syzbot+34fe5894623c4ab1b379@syzkaller.appspotmail.com
Fix commit: 893b19587534 net: bridge: fix ioctl locking
First crash: 499d, last: 485d

Cause bisection: introduced by (bisect log) [no-op commit]:
commit 32d05468c46267db1c0128057d4fcf80332fecf8
Author: Arnd Bergmann <arnd@arndb.de>
Date: Tue Jul 27 13:44:57 2021 +0000

  tehuti: use ndo_siocdevprivate

Crash: BUG: sleeping function called from invalid context in lock_sock_nested (log)
Repro: C syz .config

Sample crash report:
netdevsim netdevsim0 netdevsim1: set [1, 0] type 2 family 0 port 6081 - 0
netdevsim netdevsim0 netdevsim2: set [1, 0] type 2 family 0 port 6081 - 0
netdevsim netdevsim0 netdevsim3: set [1, 0] type 2 family 0 port 6081 - 0
======================================================
WARNING: possible circular locking dependency detected
5.14.0-rc2-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor772/8460 is trying to acquire lock:
ffffffff8d0a9608 (br_ioctl_mutex){+.+.}-{3:3}, at: br_ioctl_call+0x3b/0xa0 net/socket.c:1089

but task is already holding lock:
ffffffff8d0cb568 (rtnl_mutex){+.+.}-{3:3}, at: dev_ioctl+0x1a7/0xee0 net/core/dev_ioctl.c:579

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (rtnl_mutex){+.+.}-{3:3}:
       __mutex_lock_common kernel/locking/mutex.c:959 [inline]
       __mutex_lock+0x12a/0x10a0 kernel/locking/mutex.c:1104
       register_netdev+0x11/0x50 net/core/dev.c:10474
       br_add_bridge+0x97/0xf0 net/bridge/br_if.c:459
       br_ioctl_stub+0x750/0x7f0 net/bridge/br_ioctl.c:390
       br_ioctl_call+0x5e/0xa0 net/socket.c:1091
       sock_ioctl+0x30c/0x640 net/socket.c:1185
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:1069 [inline]
       __se_sys_ioctl fs/ioctl.c:1055 [inline]
       __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:1055
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x44/0xae

-> #0 (br_ioctl_mutex){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3051 [inline]
       check_prevs_add kernel/locking/lockdep.c:3174 [inline]
       validate_chain kernel/locking/lockdep.c:3789 [inline]
       __lock_acquire+0x2a07/0x54a0 kernel/locking/lockdep.c:5015
       lock_acquire kernel/locking/lockdep.c:5625 [inline]
       lock_acquire+0x1ab/0x510 kernel/locking/lockdep.c:5590
       __mutex_lock_common kernel/locking/mutex.c:959 [inline]
       __mutex_lock+0x12a/0x10a0 kernel/locking/mutex.c:1104
       br_ioctl_call+0x3b/0xa0 net/socket.c:1089
       dev_ifsioc+0xc1f/0xf60 net/core/dev_ioctl.c:382
       dev_ioctl+0x1b9/0xee0 net/core/dev_ioctl.c:580
       sock_do_ioctl+0x18b/0x210 net/socket.c:1128
       sock_ioctl+0x2f1/0x640 net/socket.c:1231
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:1069 [inline]
       __se_sys_ioctl fs/ioctl.c:1055 [inline]
       __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:1055
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x44/0xae

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(rtnl_mutex);
                               lock(br_ioctl_mutex);
                               lock(rtnl_mutex);
  lock(br_ioctl_mutex);

 *** DEADLOCK ***

1 lock held by syz-executor772/8460:
 #0: ffffffff8d0cb568 (rtnl_mutex){+.+.}-{3:3}, at: dev_ioctl+0x1a7/0xee0 net/core/dev_ioctl.c:579

stack backtrace:
CPU: 0 PID: 8460 Comm: syz-executor772 Not tainted 5.14.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:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:105
 check_noncircular+0x25f/0x2e0 kernel/locking/lockdep.c:2131
 check_prev_add kernel/locking/lockdep.c:3051 [inline]
 check_prevs_add kernel/locking/lockdep.c:3174 [inline]
 validate_chain kernel/locking/lockdep.c:3789 [inline]
 __lock_acquire+0x2a07/0x54a0 kernel/locking/lockdep.c:5015
 lock_acquire kernel/locking/lockdep.c:5625 [inline]
 lock_acquire+0x1ab/0x510 kernel/locking/lockdep.c:5590
 __mutex_lock_common kernel/locking/mutex.c:959 [inline]
 __mutex_lock+0x12a/0x10a0 kernel/locking/mutex.c:1104
 br_ioctl_call+0x3b/0xa0 net/socket.c:1089
 dev_ifsioc+0xc1f/0xf60 net/core/dev_ioctl.c:382
 dev_ioctl+0x1b9/0xee0 net/core/dev_ioctl.c:580
 sock_do_ioctl+0x18b/0x210 net/socket.c:1128
 sock_ioctl+0x2f1/0x640 net/socket.c:1231
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:1069 [inline]
 __se_sys_ioctl fs/ioctl.c:1055 [inline]
 __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:1055
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x4431f9
Code: 28 c3 e8 4a 15 00 00 66 2e 0f 1f 84 00 00 00 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 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffd0ab19648 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007ffd0ab19658 RCX: 00000000004431f9
RDX: 0000000020000000 RSI: 00000000000089a2 RDI: 0000000000000004
RBP: 0000000000000003 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffd0ab19660
R13

Crashes (4161):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-net-kasan-gce 2021/07/28 18:38 net-next 3bdc70669eb2 17d6ab15 .config log report syz C possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/11 07:40 bpf-next 874be05f525e 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/11 07:31 bpf-next 874be05f525e 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/11 05:07 bpf-next 874be05f525e 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/11 04:02 bpf-next 874be05f525e 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/11 02:59 bpf-next 874be05f525e 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/11 01:48 bpf-next 874be05f525e 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/11 00:52 bpf-next 874be05f525e 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/10 21:06 bpf-next 874be05f525e 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/10 19:30 bpf-next 874be05f525e 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/10 18:01 bpf-next 874be05f525e 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/10 16:36 bpf-next 874be05f525e 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/10 15:32 bpf-next 6aab1c81b98a 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/10 13:31 bpf-next 6aab1c81b98a 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/10 12:19 bpf-next 6aab1c81b98a 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/10 11:10 bpf-next 6aab1c81b98a 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/10 10:09 bpf-next 6aab1c81b98a 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/10 09:04 bpf-next 6aab1c81b98a 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/10 08:00 bpf-next 6aab1c81b98a 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/10 06:59 bpf-next 6aab1c81b98a 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/10 05:53 bpf-next 6aab1c81b98a 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/10 04:47 bpf-next 6aab1c81b98a 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/10 03:14 bpf-next 6aab1c81b98a 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/10 02:28 bpf-next 6aab1c81b98a 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/10 01:09 bpf-next c83ae15dc947 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/10 00:05 bpf-next c83ae15dc947 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/09 22:42 bpf-next c83ae15dc947 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/09 19:53 bpf-next c83ae15dc947 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/09 18:09 bpf-next c83ae15dc947 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/09 16:58 bpf-next c83ae15dc947 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/09 15:55 bpf-next c83ae15dc947 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/09 14:46 bpf-next c83ae15dc947 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/09 13:11 bpf-next c83ae15dc947 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/09 11:43 bpf-next c83ae15dc947 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/09 10:30 bpf-next c83ae15dc947 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/09 09:22 bpf-next c83ae15dc947 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/09 07:40 bpf-next c83ae15dc947 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/09 04:47 bpf-next c83ae15dc947 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/09 04:06 bpf-next c83ae15dc947 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/09 01:29 bpf-next c83ae15dc947 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/09 00:27 bpf-next c83ae15dc947 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/08 23:20 bpf-next c83ae15dc947 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-bpf-next-kasan-gce 2021/08/08 21:30 bpf-next c83ae15dc947 6972b106 .config log report info possible deadlock in br_ioctl_call
ci-upstream-net-kasan-gce 2021/08/05 13:06 net-next 372bbdd5bb3f 7f7bb950 .config log report info possible deadlock in br_ioctl_call
ci-upstream-net-kasan-gce 2021/07/28 10:29 net-next 3bdc70669eb2 17d6ab15 .config log report info possible deadlock in br_ioctl_call
ci-upstream-linux-next-kasan-gce-root 2021/08/06 22:19 linux-next 8d4b477da1a8 f9e341e3 .config log report info possible deadlock in br_ioctl_call
* Struck through repros no longer work on HEAD.