syzbot


KASAN: use-after-free Read in j1939_tp_txtimer

Status: fixed on 2020/09/16 22:51
Subsystems: can
[Documentation on labels]
Reported-by: syzbot+5322482fe520b02aea30@syzkaller.appspotmail.com
Fix commit: cd3b3636c99f can: j1939: transport: j1939_session_tx_dat(): fix use-after-free read in j1939_tp_txtimer()
First crash: 1366d, last: 1166d
Cause bisection: introduced by (bisect log) :
commit 9d71dd0c70099914fcd063135da3c580865e924c
Author: The j1939 authors <linux-can@vger.kernel.org>
Date: Mon Oct 8 09:48:36 2018 +0000

  can: add support of SAE J1939 protocol

Crash: KASAN: use-after-free Read in j1939_session_deactivate (log)
Repro: C syz .config
  
Fix bisection: failed (error log, bisect log)
  
Discussions (7)
Title Replies (including bot) Last reply
[PATCH 5.8 000/148] 5.8.4-rc1 review 152 (152) 2020/08/24 16:54
[PATCH 5.4 000/107] 5.4.61-rc1 review 108 (108) 2020/08/24 08:31
[PATCH 5.7 000/124] 5.7.18-rc1 review 125 (125) 2020/08/24 08:30
[PATCH 3/6] can: j1939: transport: j1939_session_tx_dat(): fix use-after-free read in j1939_tp_txtimer() 1 (1) 2020/08/14 11:04
[PATCH v1 0/5] j1939 fixes 6 (6) 2020/08/07 10:52
[PATCH v1] can: j1939: transport: j1939_session_tx_dat(): fix use-after-free read in j1939_tp_txtimer() 1 (1) 2020/02/14 12:06
KASAN: use-after-free Read in j1939_tp_txtimer 0 (1) 2019/12/26 21:15
Fix bisection attempts (4)
Created Duration User Patch Repo Result
2020/05/17 02:11 0m bisect fix upstream error job log (0)
2020/04/16 21:32 35m bisect fix upstream job log (0) log
2020/03/17 15:29 36m bisect fix upstream job log (0) log
2020/02/11 06:53 36m bisect fix upstream job log (0) log

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in memcpy include/linux/string.h:380 [inline]
BUG: KASAN: use-after-free in j1939_session_tx_dat net/can/j1939/transport.c:790 [inline]
BUG: KASAN: use-after-free in j1939_xtp_txnext_transmiter net/can/j1939/transport.c:847 [inline]
BUG: KASAN: use-after-free in j1939_tp_txtimer+0x777/0x1b00 net/can/j1939/transport.c:1095
Read of size 7 at addr ffff88809073d917 by task ksoftirqd/0/9

CPU: 0 PID: 9 Comm: ksoftirqd/0 Not tainted 5.5.0-rc3-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x197/0x210 lib/dump_stack.c:118
 print_address_description.constprop.0.cold+0xd4/0x30b mm/kasan/report.c:374
 __kasan_report.cold+0x1b/0x41 mm/kasan/report.c:506
 kasan_report+0x12/0x20 mm/kasan/common.c:639
 check_memory_region_inline mm/kasan/generic.c:185 [inline]
 check_memory_region+0x134/0x1a0 mm/kasan/generic.c:192
 memcpy+0x24/0x50 mm/kasan/common.c:125
 memcpy include/linux/string.h:380 [inline]
 j1939_session_tx_dat net/can/j1939/transport.c:790 [inline]
 j1939_xtp_txnext_transmiter net/can/j1939/transport.c:847 [inline]
 j1939_tp_txtimer+0x777/0x1b00 net/can/j1939/transport.c:1095
 __run_hrtimer kernel/time/hrtimer.c:1517 [inline]
 __hrtimer_run_queues+0x364/0xe40 kernel/time/hrtimer.c:1579
 hrtimer_run_softirq+0x17e/0x270 kernel/time/hrtimer.c:1596
 __do_softirq+0x262/0x98c kernel/softirq.c:292
 run_ksoftirqd kernel/softirq.c:603 [inline]
 run_ksoftirqd+0x8e/0x110 kernel/softirq.c:595
 smpboot_thread_fn+0x6a3/0xa40 kernel/smpboot.c:165
 kthread+0x361/0x430 kernel/kthread.c:255
 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352

Allocated by task 16:
 save_stack+0x23/0x90 mm/kasan/common.c:72
 set_track mm/kasan/common.c:80 [inline]
 __kasan_kmalloc mm/kasan/common.c:513 [inline]
 __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:486
 kasan_slab_alloc+0xf/0x20 mm/kasan/common.c:521
 slab_post_alloc_hook mm/slab.h:584 [inline]
 slab_alloc_node mm/slab.c:3263 [inline]
 kmem_cache_alloc_node+0x138/0x740 mm/slab.c:3575
 __alloc_skb+0xd5/0x5e0 net/core/skbuff.c:197
 alloc_skb include/linux/skbuff.h:1049 [inline]
 j1939_tp_tx_dat_new+0x38/0x530 net/can/j1939/transport.c:568
 j1939_tp_tx_dat net/can/j1939/transport.c:606 [inline]
 j1939_session_tx_dat net/can/j1939/transport.c:791 [inline]
 j1939_xtp_txnext_transmiter net/can/j1939/transport.c:847 [inline]
 j1939_tp_txtimer+0x7a7/0x1b00 net/can/j1939/transport.c:1095
 __run_hrtimer kernel/time/hrtimer.c:1517 [inline]
 __hrtimer_run_queues+0x364/0xe40 kernel/time/hrtimer.c:1579
 hrtimer_run_softirq+0x17e/0x270 kernel/time/hrtimer.c:1596
 __do_softirq+0x262/0x98c kernel/softirq.c:292

Freed by task 16:
 save_stack+0x23/0x90 mm/kasan/common.c:72
 set_track mm/kasan/common.c:80 [inline]
 kasan_set_free_info mm/kasan/common.c:335 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/common.c:474
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:483
 __cache_free mm/slab.c:3426 [inline]
 kmem_cache_free+0x86/0x320 mm/slab.c:3694
 kfree_skbmem net/core/skbuff.c:623 [inline]
 kfree_skbmem+0xfb/0x1c0 net/core/skbuff.c:617
 __kfree_skb net/core/skbuff.c:680 [inline]
 consume_skb net/core/skbuff.c:838 [inline]
 consume_skb+0x103/0x410 net/core/skbuff.c:832
 vcan_tx+0x29f/0x7f0 drivers/net/can/vcan.c:110
 __netdev_start_xmit include/linux/netdevice.h:4447 [inline]
 netdev_start_xmit include/linux/netdevice.h:4461 [inline]
 xmit_one net/core/dev.c:3420 [inline]
 dev_hard_start_xmit+0x1a3/0x9b0 net/core/dev.c:3436
 __dev_queue_xmit+0x2b05/0x35c0 net/core/dev.c:4013
 dev_queue_xmit+0x18/0x20 net/core/dev.c:4046
 can_send+0x439/0x890 net/can/af_can.c:277
 j1939_send_one+0x29d/0x360 net/can/j1939/main.c:340
 j1939_tp_tx_dat net/can/j1939/transport.c:615 [inline]
 j1939_session_tx_dat net/can/j1939/transport.c:791 [inline]
 j1939_xtp_txnext_transmiter net/can/j1939/transport.c:847 [inline]
 j1939_tp_txtimer+0x5a9/0x1b00 net/can/j1939/transport.c:1095
 __run_hrtimer kernel/time/hrtimer.c:1517 [inline]
 __hrtimer_run_queues+0x364/0xe40 kernel/time/hrtimer.c:1579
 hrtimer_run_softirq+0x17e/0x270 kernel/time/hrtimer.c:1596
 __do_softirq+0x262/0x98c kernel/softirq.c:292

The buggy address belongs to the object at ffff88809073d840
 which belongs to the cache skbuff_head_cache of size 224
The buggy address is located 215 bytes inside of
 224-byte region [ffff88809073d840, ffff88809073d920)
The buggy address belongs to the page:
page:ffffea000241cf40 refcount:1 mapcount:0 mapping:ffff88821b774e00 index:0x0
raw: 00fffe0000000200 ffffea00026df588 ffffea00023d9308 ffff88821b774e00
raw: 0000000000000000 ffff88809073d0c0 000000010000000c 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88809073d800: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
 ffff88809073d880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88809073d900: fb fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc
                         ^
 ffff88809073d980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88809073da00: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
==================================================================

Crashes (5):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/12/26 04:30 upstream 46cf053efec6 be5c2c81 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2020/01/12 06:53 upstream ac61145a725a 4c04afaa .config console log report syz ci-upstream-kasan-gce-selinux-root
2020/02/16 06:23 linux-next 9f01828e9e16 5d7b90f1 .config console log report syz ci-upstream-linux-next-kasan-gce-root
2020/07/12 05:11 upstream a581387e415b 18d18b59 .config console log report ci-upstream-kasan-gce-root
2019/12/25 23:01 upstream 46cf053efec6 be5c2c81 .config console log report ci-upstream-kasan-gce-selinux-root
* Struck through repros no longer work on HEAD.