syzbot


KASAN: use-after-free Read in bcm_can_tx

Status: fixed on 2022/01/29 10:00
Reported-by: syzbot+5ca851459ed04c778d1d@syzkaller.appspotmail.com
Fix commit: 632881680ba0 can: bcm: fix UAF of bcm op
First crash: 840d, last: 384d
similar bugs (2):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 KASAN: use-after-free Read in bcm_can_tx 1 919d 919d 0/1 auto-closed as invalid on 2020/11/22 07:42
linux-4.19 KASAN: use-after-free Read in bcm_can_tx (2) C error 81 3d19h 528d 0/1 upstream: reported C repro on 2021/08/20 03:44

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in bcm_can_tx+0x5c1/0x680 net/can/bcm.c:304
Read of size 4 at addr ffff8880aa316f04 by task ksoftirqd/1/17

CPU: 1 PID: 17 Comm: ksoftirqd/1 Not tainted 4.14.230-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+0x1b2/0x281 lib/dump_stack.c:58
 print_address_description.cold+0x54/0x1d3 mm/kasan/report.c:252
 kasan_report_error.cold+0x8a/0x191 mm/kasan/report.c:351
 kasan_report mm/kasan/report.c:409 [inline]
 __asan_report_load4_noabort+0x68/0x70 mm/kasan/report.c:429
 bcm_can_tx+0x5c1/0x680 net/can/bcm.c:304
 bcm_tx_timeout_tsklet+0x174/0x2a0 net/can/bcm.c:422
 tasklet_action+0x195/0x340 kernel/softirq.c:513
 __do_softirq+0x24d/0x9ff kernel/softirq.c:288
 run_ksoftirqd+0x50/0x1a0 kernel/softirq.c:670
 smpboot_thread_fn+0x5c1/0x920 kernel/smpboot.c:164
 kthread+0x30d/0x420 kernel/kthread.c:232
 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:404

Allocated by task 5895:
 save_stack mm/kasan/kasan.c:447 [inline]
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_kmalloc+0xeb/0x160 mm/kasan/kasan.c:551
 kmem_cache_alloc_trace+0x131/0x3d0 mm/slab.c:3618
 kmalloc include/linux/slab.h:488 [inline]
 kzalloc include/linux/slab.h:661 [inline]
 bcm_tx_setup net/can/bcm.c:952 [inline]
 bcm_sendmsg+0x20b6/0x3ae0 net/can/bcm.c:1388
 sock_sendmsg_nosec net/socket.c:646 [inline]
 sock_sendmsg+0xb5/0x100 net/socket.c:656
 ___sys_sendmsg+0x6c8/0x800 net/socket.c:2062
 __sys_sendmsg+0xa3/0x120 net/socket.c:2096
 SYSC_sendmsg net/socket.c:2107 [inline]
 SyS_sendmsg+0x27/0x40 net/socket.c:2103
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x46/0xbb

Freed by task 5895:
 save_stack mm/kasan/kasan.c:447 [inline]
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_slab_free+0xc3/0x1a0 mm/kasan/kasan.c:524
 __cache_free mm/slab.c:3496 [inline]
 kfree+0xc9/0x250 mm/slab.c:3815
 bcm_release+0xff/0x6c0 net/can/bcm.c:1540
 __sock_release+0xcd/0x2b0 net/socket.c:602
 sock_close+0x15/0x20 net/socket.c:1139
 __fput+0x25f/0x7a0 fs/file_table.c:210
 task_work_run+0x11f/0x190 kernel/task_work.c:113
 tracehook_notify_resume include/linux/tracehook.h:191 [inline]
 exit_to_usermode_loop+0x1ad/0x200 arch/x86/entry/common.c:164
 prepare_exit_to_usermode arch/x86/entry/common.c:199 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:270 [inline]
 do_syscall_64+0x4a3/0x640 arch/x86/entry/common.c:297
 entry_SYSCALL_64_after_hwframe+0x46/0xbb

The buggy address belongs to the object at ffff8880aa316dc0
 which belongs to the cache kmalloc-1024 of size 1024
The buggy address is located 324 bytes inside of
 1024-byte region [ffff8880aa316dc0, ffff8880aa3171c0)
The buggy address belongs to the page:
page:ffffea0002a8c580 count:1 mapcount:0 mapping:ffff8880aa316040 index:0xffff8880aa316040 compound_mapcount: 0
flags: 0xfff00000008100(slab|head)
raw: 00fff00000008100 ffff8880aa316040 ffff8880aa316040 0000000100000006
raw: ffffea00024d4420 ffffea0002acbf20 ffff88813fe80ac0 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880aa316e00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880aa316e80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880aa316f00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff8880aa316f80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880aa317000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Fix bisection attempts:
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets Title
ci2-linux-4-14 2022/01/10 19:05 linux-4.14.y bfdef05c8da4 fcdb12ba .config console log report syz C
ci2-linux-4-14 2021/12/11 18:24 linux-4.14.y c01d4d1b885d fcdb12ba .config console log report syz C
ci2-linux-4-14 2021/11/11 17:49 linux-4.14.y 0447aa205abe fcdb12ba .config console log report syz C
ci2-linux-4-14 2021/10/12 16:29 linux-4.14.y ed99bf0e81b5 fcdb12ba .config console log report syz C
ci2-linux-4-14 2021/09/12 11:40 linux-4.14.y f96eb53cbd76 fcdb12ba .config console log report syz C
ci2-linux-4-14 2021/08/13 11:11 linux-4.14.y 46914f96189b fcdb12ba .config console log report syz C
ci2-linux-4-14 2021/07/14 10:34 linux-4.14.y 4e68c9b0763f fcdb12ba .config console log report syz C
ci2-linux-4-14 2021/06/14 10:07 linux-4.14.y 3d3abdc8ebd3 fcdb12ba .config console log report syz C
ci2-linux-4-14 2021/05/15 09:37 linux-4.14.y 7d7d1c0ab3eb fcdb12ba .config console log report syz C
ci2-linux-4-14 2021/03/23 21:41 linux-4.14.y cb83ddcd5332 4a77ae0b .config console log report syz C
ci2-linux-4-14 2021/02/21 19:44 linux-4.14.y 29c52025152b 4a77ae0b .config console log report syz C
ci2-linux-4-14 2021/01/09 14:51 linux-4.14.y ec822b3e8bf4 4a77ae0b .config console log report syz C
ci2-linux-4-14 2020/12/10 14:12 linux-4.14.y 47cbf4cc32db 4a77ae0b .config console log report syz C
ci2-linux-4-14 2020/11/10 13:38 linux-4.14.y e98f3c4269fd 4a77ae0b .config console log report syz C
* Struck through repros no longer work on HEAD.
Crashes (2):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets Title
ci2-linux-4-14 2021/04/15 09:00 linux-4.14.y 958e517f4e16 fcdb12ba .config console log report syz C KASAN: use-after-free Read in bcm_can_tx
ci2-linux-4-14 2020/10/11 13:05 linux-4.14.y cbfa1702aaf6 4a77ae0b .config console log report syz C
* Struck through repros no longer work on HEAD.