syzbot


INFO: trying to register non-static key in l2cap_sock_teardown_cb

Status: fixed on 2022/03/08 16:11
Reported-by: syzbot+a41dfef1d2e04910eb2e@syzkaller.appspotmail.com
Fix commit: 1bff51ea59a9 Bluetooth: fix use-after-free error in lock_sock_nested()
First crash: 549d, last: 242d

Cause bisection: introduced by (bisect log) :
commit 4680a7ee5db27772af40d83393fa0fb955b745b7
Author: Miklos Szeredi <mszeredi@redhat.com>
Date: Sat Oct 1 05:32:33 2016 +0000

  fuse: remove duplicate cs->offset assignment

Crash: general protection fault in batadv_iv_ogm_queue_add (log)
Repro: C syz .config

Fix bisection: fixed by (bisect log) :
commit 1bff51ea59a9afb67d2dd78518ab0582a54a472c
Author: Wang ShaoBo <bobo.shaobowang@huawei.com>
Date: Wed Sep 1 00:35:37 2021 +0000

  Bluetooth: fix use-after-free error in lock_sock_nested()

similar bugs (2):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 INFO: trying to register non-static key in l2cap_sock_teardown_cb 10 163d 505d 0/1 auto-closed as invalid on 2022/05/18 04:11
linux-4.14 INFO: trying to register non-static key in l2cap_sock_teardown_cb 9 410d 560d 0/1 auto-closed as invalid on 2021/09/13 12:54

Sample crash report:
INFO: trying to register non-static key.
the code is fine but needs lockdep annotation.
turning off the locking correctness validator.
CPU: 0 PID: 9812 Comm: kworker/0:5 Not tainted 5.11.0-rc2-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: events l2cap_chan_timeout
Call Trace:
 __dump_stack lib/dump_stack.c:79 [inline]
 dump_stack+0x107/0x163 lib/dump_stack.c:120
 assign_lock_key kernel/locking/lockdep.c:935 [inline]
 register_lock_class+0x1041/0x1100 kernel/locking/lockdep.c:1247
 __lock_acquire+0x101/0x54f0 kernel/locking/lockdep.c:4711
 lock_acquire kernel/locking/lockdep.c:5437 [inline]
 lock_acquire+0x29d/0x740 kernel/locking/lockdep.c:5402
 __raw_spin_lock_bh include/linux/spinlock_api_smp.h:135 [inline]
 _raw_spin_lock_bh+0x2f/0x40 kernel/locking/spinlock.c:175
 spin_lock_bh include/linux/spinlock.h:359 [inline]
 lock_sock_nested+0x3b/0x110 net/core/sock.c:3049
 l2cap_sock_teardown_cb+0xa1/0x660 net/bluetooth/l2cap_sock.c:1520
 l2cap_chan_del+0xbc/0xa80 net/bluetooth/l2cap_core.c:618
 l2cap_chan_close+0x1bc/0xaf0 net/bluetooth/l2cap_core.c:823
 l2cap_chan_timeout+0x17e/0x2f0 net/bluetooth/l2cap_core.c:436
 process_one_work+0x98d/0x15f0 kernel/workqueue.c:2275
 worker_thread+0x64c/0x1120 kernel/workqueue.c:2421
 kthread+0x3b1/0x4a0 kernel/kthread.c:292
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:296
==================================================================
BUG: KASAN: use-after-free in l2cap_sock_teardown_cb+0x5c9/0x660 net/bluetooth/l2cap_sock.c:1522
Read of size 8 at addr ffff88802b6ce4c8 by task kworker/0:5/9812

CPU: 0 PID: 9812 Comm: kworker/0:5 Not tainted 5.11.0-rc2-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: events l2cap_chan_timeout
Call Trace:
 __dump_stack lib/dump_stack.c:79 [inline]
 dump_stack+0x107/0x163 lib/dump_stack.c:120
 print_address_description.constprop.0.cold+0x5b/0x2f8 mm/kasan/report.c:230
 __kasan_report mm/kasan/report.c:396 [inline]
 kasan_report.cold+0x79/0xd5 mm/kasan/report.c:413
 l2cap_sock_teardown_cb+0x5c9/0x660 net/bluetooth/l2cap_sock.c:1522
 l2cap_chan_del+0xbc/0xa80 net/bluetooth/l2cap_core.c:618
 l2cap_chan_close+0x1bc/0xaf0 net/bluetooth/l2cap_core.c:823
 l2cap_chan_timeout+0x17e/0x2f0 net/bluetooth/l2cap_core.c:436
 process_one_work+0x98d/0x15f0 kernel/workqueue.c:2275
 worker_thread+0x64c/0x1120 kernel/workqueue.c:2421
 kthread+0x3b1/0x4a0 kernel/kthread.c:292
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:296

Allocated by task 8493:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:401 [inline]
 ____kasan_kmalloc.constprop.0+0x82/0xa0 mm/kasan/common.c:429
 kmalloc_node include/linux/slab.h:575 [inline]
 kvmalloc_node+0x61/0xf0 mm/util.c:587
 kvmalloc include/linux/mm.h:781 [inline]
 xt_alloc_table_info+0x3c/0xa0 net/netfilter/x_tables.c:1176
 do_replace net/ipv6/netfilter/ip6_tables.c:1141 [inline]
 do_ip6t_set_ctl+0x4e5/0xb70 net/ipv6/netfilter/ip6_tables.c:1636
 nf_setsockopt+0x83/0xe0 net/netfilter/nf_sockopt.c:101
 ipv6_setsockopt+0x122/0x180 net/ipv6/ipv6_sockglue.c:1008
 tcp_setsockopt+0x136/0x2440 net/ipv4/tcp.c:3597
 __sys_setsockopt+0x2db/0x610 net/socket.c:2115
 __do_sys_setsockopt net/socket.c:2126 [inline]
 __se_sys_setsockopt net/socket.c:2123 [inline]
 __x64_sys_setsockopt+0xba/0x150 net/socket.c:2123
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Freed by task 8493:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38
 kasan_set_track+0x1c/0x30 mm/kasan/common.c:46
 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:356
 ____kasan_slab_free+0xe1/0x110 mm/kasan/common.c:362
 kasan_slab_free include/linux/kasan.h:188 [inline]
 slab_free_hook mm/slub.c:1547 [inline]
 slab_free_freelist_hook+0x5d/0x150 mm/slub.c:1580
 slab_free mm/slub.c:3142 [inline]
 kfree+0xdb/0x3b0 mm/slub.c:4124
 kvfree+0x42/0x50 mm/util.c:616
 __do_replace+0x6b7/0x8c0 net/ipv6/netfilter/ip6_tables.c:1103
 do_replace net/ipv6/netfilter/ip6_tables.c:1156 [inline]
 do_ip6t_set_ctl+0x8ec/0xb70 net/ipv6/netfilter/ip6_tables.c:1636
 nf_setsockopt+0x83/0xe0 net/netfilter/nf_sockopt.c:101
 ipv6_setsockopt+0x122/0x180 net/ipv6/ipv6_sockglue.c:1008
 tcp_setsockopt+0x136/0x2440 net/ipv4/tcp.c:3597
 __sys_setsockopt+0x2db/0x610 net/socket.c:2115
 __do_sys_setsockopt net/socket.c:2126 [inline]
 __se_sys_setsockopt net/socket.c:2123 [inline]
 __x64_sys_setsockopt+0xba/0x150 net/socket.c:2123
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

The buggy address belongs to the object at ffff88802b6ce000
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 1224 bytes inside of
 2048-byte region [ffff88802b6ce000, ffff88802b6ce800)
The buggy address belongs to the page:
page:0000000055ddf779 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x2b6c8
head:0000000055ddf779 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head)
raw: 00fff00000010200 dead000000000100 dead000000000122 ffff888010042000
raw: 0000000000000000 0000000000080008 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88802b6ce380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88802b6ce400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88802b6ce480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                              ^
 ffff88802b6ce500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88802b6ce580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (88):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-net-kasan-gce 2021/01/10 21:39 net-next 73b7a6047971 2c1f2513 .config log report syz C
ci-upstream-kasan-gce-root 2021/10/29 12:22 upstream 411a44c24a56 2353a3ec .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-kasan-gce-root 2021/09/29 14:51 upstream a4e6f95a891a be530f6c .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-kasan-gce-root 2021/09/18 12:50 upstream 4357f03d6611 70b76c1d .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-kasan-gce-selinux-root 2021/08/22 19:53 upstream 1bdc3d5be7e1 b599f2fc .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-kasan-gce-selinux-root 2021/07/20 13:47 upstream 2734d6c1b1a0 bc48c9ab .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-kasan-gce-selinux-root 2021/06/08 10:30 upstream 614124bea77e b718257f .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-qemu-upstream 2021/06/04 20:15 upstream 16f0596fc1d7 966a236b .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-qemu-upstream 2021/06/02 09:01 upstream 231bc5390667 0740de69 .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-qemu-upstream 2021/06/02 05:24 upstream 231bc5390667 032639db .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-qemu-upstream 2021/05/12 08:08 upstream 88b06399c9c7 86294427 .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-kasan-gce-selinux-root 2021/04/29 06:38 upstream d72cd4ad4174 77e2b668 .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-kasan-gce-selinux-root 2021/04/09 20:24 upstream 17e7124aad76 6a81331a .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-kasan-gce-selinux-root 2021/03/23 23:00 upstream 7acac4b3196c e613994b .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-kasan-gce-selinux-root 2021/03/22 19:28 upstream 0d02ec6b3136 8092f30d .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-kasan-gce-smack-root 2021/03/21 08:28 upstream 812da4d39463 17810eae .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-kasan-gce-smack-root 2021/03/17 22:12 upstream 1df27313f50a fdb2bb2c .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-qemu-upstream 2021/03/01 10:30 upstream fe07bfda2fb9 4c37c133 .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-kasan-gce-root 2021/02/24 08:32 upstream c03c21ba6f4e fcc6d71b .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-qemu-upstream-386 2021/04/16 18:49 upstream 2f7b98d1e55c 7e2b734b .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-qemu-upstream-386 2021/04/13 10:00 upstream 89698becf06d bfeda1b1 .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-this-kasan-gce 2021/10/31 11:57 net 6de6e46d27ef 098b5d53 .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-this-kasan-gce 2021/10/28 13:20 net 72f898ca0ab8 be531bb4 .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-this-kasan-gce 2021/09/22 08:55 net b3f98404bd62 169724fe .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-this-kasan-gce 2021/06/26 21:38 net d6765985a42a 9d2ab5df .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-this-kasan-gce 2021/06/05 03:58 net 3822d0670c9d 500c2339 .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-this-kasan-gce 2021/05/21 13:19 net 5cb4a593821f 3c7fef33 .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-this-kasan-gce 2021/04/21 15:13 net d83b8aa5207d 95777977 .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-this-kasan-gce 2021/03/27 23:05 net 75887e881b19 a8529b82 .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-kasan-gce 2021/10/01 07:19 net-next 69508d43334e 1d849ab4 .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-kasan-gce 2021/09/17 06:47 net-next 561bed688bff 5b989942 .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-kasan-gce 2021/09/17 05:04 net-next 561bed688bff 5b989942 .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-kasan-gce 2021/09/16 00:35 net-next 5706383b30cf 07e953c1 .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-kasan-gce 2021/09/10 09:43 net-next 626bf91a292e 5ae8508a .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-kasan-gce 2021/08/08 07:01 net-next f9be84db09d2 6972b106 .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-kasan-gce 2021/07/19 09:53 net-next 0d6835ffe50c e6a17580 .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-kasan-gce 2021/07/19 01:18 net-next 0d6835ffe50c f115ae98 .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-kasan-gce 2021/05/29 07:46 net-next 38e9673ce08f 858ea628 .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-kasan-gce 2021/05/23 08:31 net-next f5120f599880 3c7fef33 .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-kasan-gce 2021/05/16 13:06 net-next 77091933e453 f54a5c09 .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-kasan-gce 2021/05/15 14:36 net-next 77091933e453 93f844de .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-kasan-gce 2021/05/15 12:11 net-next 77091933e453 93f844de .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-kasan-gce 2021/05/03 19:53 net-next 95aafe911db6 ad61f371 .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-kasan-gce 2021/04/30 18:31 net-next 95aafe911db6 77e2b668 .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-kasan-gce 2021/04/12 01:19 net-next cbd312539284 bfeda1b1 .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-kasan-gce 2021/04/06 03:06 net-next 514e1150da9c 6a81331a .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-kasan-gce 2021/04/05 08:31 net-next 7d42e84eb99d 6a81331a .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-kasan-gce 2021/04/04 20:44 net-next 7d42e84eb99d 6a81331a .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-kasan-gce 2021/04/04 12:12 net-next 428e68e1a85a 6a81331a .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-kasan-gce 2021/03/16 16:56 net-next 0f13b5e6bf28 fdb2bb2c .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-kasan-gce 2021/03/14 05:05 net-next ebc71a380435 4a003785 .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-kasan-gce 2021/03/02 10:59 net-next d310ec03a34e 92ead296 .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-kasan-gce 2021/03/02 09:59 net-next d310ec03a34e 183afb6c .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-kasan-gce 2021/03/02 06:48 net-next d310ec03a34e 183afb6c .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-kasan-gce 2021/02/27 01:04 net-next d310ec03a34e 4c37c133 .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-kasan-gce 2021/02/26 00:57 net-next d310ec03a34e 76f7fc95 .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-net-kasan-gce 2021/01/30 10:48 net-next 14e8e0f60088 fc9fd31e .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-linux-next-kasan-gce-root 2021/01/31 19:05 linux-next b01f250d83f6 fc9fd31e .config log report info INFO: trying to register non-static key in l2cap_sock_teardown_cb
ci-upstream-kasan-gce-root 2021/01/16 11:31 upstream 1d94330a437a 65a7a854 .config log report info
ci-qemu-upstream 2021/01/12 02:15 upstream a0d54b4f5b21 2c1f2513 .config log report info
ci-qemu-upstream-386 2021/01/06 02:36 upstream 6207214a70bf b1c228e1 .config log report info
ci-upstream-net-kasan-gce 2021/01/16 17:21 net-next 9ab7e76aefc9 65a7a854 .config log report info
ci-upstream-net-kasan-gce 2021/01/12 15:13 net-next c73a45965dd5 2c1f2513 .config log report info
ci-upstream-net-kasan-gce 2021/01/11 12:49 net-next 73b7a6047971 2c1f2513 .config log report info
ci-upstream-net-kasan-gce 2021/01/11 00:11 net-next 73b7a6047971 2c1f2513 .config log report info
ci-upstream-net-kasan-gce 2021/01/09 09:01 net-next 833d22f2f922 c104d4a3 .config log report info
ci-upstream-net-kasan-gce 2020/12/28 10:39 net-next 3db1a3fa9880 2242f77f .config log report info