syzbot


KASAN: use-after-free Read in j1939_xtp_rx_dat_one

Status: auto-closed as invalid on 2021/05/05 21:31
Subsystems: can
[Documentation on labels]
Reported-by: syzbot+220c1a29987a9a490903@syzkaller.appspotmail.com
First crash: 1477d, last: 1403d
Discussions (6)
Title Replies (including bot) Last reply
[PATCH 5.10 000/146] 5.10.46-rc1 review 164 (164) 2021/06/27 08:57
[PATCH 5.12 000/178] 5.12.13-rc1 review 185 (185) 2021/06/23 15:12
[PATCH 5.4 00/90] 5.4.128-rc1 review 97 (97) 2021/06/22 23:59
pull-request: can 2021-06-16 6 (6) 2021/06/16 19:50
[PATCH net v1] can: j1939: fix Use-after-Free, hold skb ref while in use 1 (1) 2021/05/21 11:57
KASAN: use-after-free Read in j1939_xtp_rx_dat_one 0 (1) 2020/10/26 14:41
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in j1939_xtp_rx_dat_one (3) can C inconclusive done 3 557d 956d 0/28 auto-obsoleted due to no activity on 2023/08/23 09:02
upstream KASAN: use-after-free Read in j1939_xtp_rx_dat_one (2) can 3 1209d 1271d 20/28 fixed on 2021/11/10 00:50

Sample crash report:
vcan0: j1939_xtp_rx_dat_one: 0x000000001da36e32: Data of RX-looped back packet (00 ff ff ff ff ff ff) doesn't match TX data (00 00 00 00 00 00 00)!
==================================================================
BUG: KASAN: use-after-free in j1939_xtp_rx_dat_one+0x108d/0x1130 net/can/j1939/transport.c:1825
Read of size 1 at addr ffff8880772076ce by task ksoftirqd/0/13

CPU: 0 PID: 13 Comm: ksoftirqd/0 Not tainted 5.11.0-rc2-syzkaller #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu.org 04/01/2014
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
 j1939_xtp_rx_dat_one+0x108d/0x1130 net/can/j1939/transport.c:1825
 j1939_xtp_rx_dat net/can/j1939/transport.c:1875 [inline]
 j1939_tp_recv+0x544/0xb40 net/can/j1939/transport.c:2057
 j1939_can_recv+0x5bc/0x7d0 net/can/j1939/main.c:101
 deliver net/can/af_can.c:574 [inline]
 can_rcv_filter+0x5d4/0x8d0 net/can/af_can.c:608
 can_receive+0x2e3/0x520 net/can/af_can.c:665
 can_rcv+0x129/0x1d0 net/can/af_can.c:696
 __netif_receive_skb_one_core+0x114/0x180 net/core/dev.c:5323
 __netif_receive_skb+0x27/0x1c0 net/core/dev.c:5437
 process_backlog+0x232/0x6c0 net/core/dev.c:6327
 napi_poll net/core/dev.c:6805 [inline]
 net_rx_action+0x461/0xe10 net/core/dev.c:6888
 __do_softirq+0x2a5/0x9f7 kernel/softirq.c:343
 run_ksoftirqd kernel/softirq.c:650 [inline]
 run_ksoftirqd+0x2d/0x50 kernel/softirq.c:642
 smpboot_thread_fn+0x655/0x9e0 kernel/smpboot.c:165
 kthread+0x3b1/0x4a0 kernel/kthread.c:292
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:296

Allocated by task 13339:
 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
 kasan_slab_alloc include/linux/kasan.h:205 [inline]
 slab_post_alloc_hook mm/slab.h:512 [inline]
 slab_alloc_node mm/slub.c:2891 [inline]
 kmem_cache_alloc_node+0x1e0/0x470 mm/slub.c:2927
 __alloc_skb+0x71/0x5a0 net/core/skbuff.c:198
 alloc_skb include/linux/skbuff.h:1099 [inline]
 alloc_skb_with_frags+0x92/0x570 net/core/skbuff.c:5849
 sock_alloc_send_pskb+0x793/0x920 net/core/sock.c:2348
 j1939_sk_alloc_skb net/can/j1939/socket.c:863 [inline]
 j1939_sk_send_loop net/can/j1939/socket.c:1045 [inline]
 j1939_sk_sendmsg+0x6bb/0x1380 net/can/j1939/socket.c:1180
 sock_sendmsg_nosec net/socket.c:652 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:672
 sock_no_sendpage+0xee/0x130 net/core/sock.c:2846
 kernel_sendpage.part.0+0x1ab/0x350 net/socket.c:3636
 kernel_sendpage net/socket.c:3633 [inline]
 sock_sendpage+0xe5/0x140 net/socket.c:945
 pipe_to_sendpage+0x2ad/0x380 fs/splice.c:364
 splice_from_pipe_feed fs/splice.c:418 [inline]
 __splice_from_pipe+0x439/0x8a0 fs/splice.c:562
 splice_from_pipe fs/splice.c:597 [inline]
 generic_splice_sendpage+0xd4/0x140 fs/splice.c:743
 do_splice_from fs/splice.c:764 [inline]
 do_splice+0xba4/0x1a90 fs/splice.c:1059
 __do_splice+0x134/0x250 fs/splice.c:1137
 __do_sys_splice fs/splice.c:1343 [inline]
 __se_sys_splice fs/splice.c:1325 [inline]
 __ia32_sys_splice+0x195/0x250 fs/splice.c:1325
 do_syscall_32_irqs_on arch/x86/entry/common.c:78 [inline]
 __do_fast_syscall_32+0x56/0x80 arch/x86/entry/common.c:137
 do_fast_syscall_32+0x2f/0x70 arch/x86/entry/common.c:160
 entry_SYSENTER_compat_after_hwframe+0x4d/0x5c

Freed by task 19:
 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]
 kmem_cache_free+0x82/0x350 mm/slub.c:3158
 kfree_skbmem+0xef/0x1b0 net/core/skbuff.c:627
 __kfree_skb net/core/skbuff.c:684 [inline]
 kfree_skb net/core/skbuff.c:701 [inline]
 kfree_skb+0x140/0x3f0 net/core/skbuff.c:695
 j1939_session_skb_drop_old net/can/j1939/transport.c:333 [inline]
 j1939_xtp_rx_cts_one net/can/j1939/transport.c:1394 [inline]
 j1939_xtp_rx_cts+0xb59/0xec0 net/can/j1939/transport.c:1433
 j1939_tp_cmd_recv net/can/j1939/transport.c:2001 [inline]
 j1939_tp_recv+0x8be/0xb40 net/can/j1939/transport.c:2067
 j1939_can_recv+0x5bc/0x7d0 net/can/j1939/main.c:101
 deliver net/can/af_can.c:574 [inline]
 can_rcv_filter+0x5d4/0x8d0 net/can/af_can.c:608
 can_receive+0x2e3/0x520 net/can/af_can.c:665
 can_rcv+0x129/0x1d0 net/can/af_can.c:696
 __netif_receive_skb_one_core+0x114/0x180 net/core/dev.c:5323
 __netif_receive_skb+0x27/0x1c0 net/core/dev.c:5437
 process_backlog+0x232/0x6c0 net/core/dev.c:6327
 napi_poll net/core/dev.c:6805 [inline]
 net_rx_action+0x461/0xe10 net/core/dev.c:6888
 __do_softirq+0x2a5/0x9f7 kernel/softirq.c:343

The buggy address belongs to the object at ffff888077207680
 which belongs to the cache skbuff_head_cache of size 232
The buggy address is located 78 bytes inside of
 232-byte region [ffff888077207680, ffff888077207768)
The buggy address belongs to the page:
page:0000000087e37b91 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x77206
head:0000000087e37b91 order:1 compound_mapcount:0
flags: 0x4fff00000010200(slab|head)
raw: 04fff00000010200 dead000000000100 dead000000000122 ffff888010389dc0
raw: 0000000000000000 0000000000190019 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff888077207580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888077207600: fb fb fb fb fb fc fc fc fc fc fc fc fc fc fc fc
>ffff888077207680: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                              ^
 ffff888077207700: fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc
 ffff888077207780: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
==================================================================

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/01/05 21:30 upstream 6207214a70bf a0234d98 .config console log report info ci-qemu-upstream-386
2020/11/14 00:18 upstream 9e6a39eae450 1bf9a662 .config console log report info ci-qemu-upstream-386
2020/10/23 19:14 upstream 0adc313c4f20 2bb6666c .config console log report info ci-qemu-upstream-386
* Struck through repros no longer work on HEAD.