syzbot


KASAN: use-after-free Read in j1939_session_get_by_addr

Status: fixed on 2024/01/12 12:55
Reported-by: syzbot+d9536adc269404a984f8@syzkaller.appspotmail.com
Fix commit: d966635b384b can: j1939: transport: make sure the aborted session will be deactivated only once
First crash: 1800d, last: 1788d
Cause bisection: introduced by (bisect log) :
commit 2af6106ae949651d529c8c3f0734c3a7babd0d4b
Author: Jose Abreu <Jose.Abreu@synopsys.com>
Date: Tue Jul 9 08:03:00 2019 +0000

  net: stmmac: Introducing support for Page Pool

Crash: general protection fault in send_hsr_supervision_frame (log)
Repro: C syz .config
  
Fix bisection: failed (error log, bisect log)
  
Discussions (2)
Title Replies (including bot) Last reply
KASAN: use-after-free Read in j1939_session_get_by_addr 4 (13) 2023/12/18 14:36
[PATCH v1 0/9] can: j1939: fix multiple issues found by syzbot 16 (16) 2019/11/13 10:04
Last patch testing requests (10)
Created Duration User Patch Repo Result
2023/03/30 10:32 19m retest repro upstream OK log
2023/03/30 08:32 54m retest repro upstream OK log
2023/03/26 14:32 21m retest repro upstream OK log
2023/03/26 12:32 27m retest repro upstream report log
2023/03/26 09:32 23m retest repro upstream report log
2023/03/23 09:32 21m retest repro net-next OK log
2023/03/22 05:32 20m retest repro net OK log
2023/03/22 02:32 23m retest repro net report log
2023/03/21 22:32 22m retest repro net report log
2022/12/20 08:31 13m retest repro upstream report log

Sample crash report:
vcan0: j1939_tp_rxtimer: 0x000000001b0eb066: rx timeout, send abort
vcan0: j1939_tp_rxtimer: 0x00000000eaa1e743: rx timeout, send abort
vcan0: j1939_xtp_rx_abort_one: 0x000000001b0eb066: 0x00000: (3) A timeout occurred and this is the connection abort to close the session.
vcan0: j1939_xtp_rx_abort_one: 0x00000000eaa1e743: 0x00000: (3) A timeout occurred and this is the connection abort to close the session.
==================================================================
BUG: KASAN: use-after-free in __lock_acquire+0x3a8b/0x4a00 kernel/locking/lockdep.c:3828
Read of size 8 at addr ffff8880a4b65080 by task ksoftirqd/1/16

CPU: 1 PID: 16 Comm: ksoftirqd/1 Not tainted 5.4.0-rc6+ #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:634
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:132
 __lock_acquire+0x3a8b/0x4a00 kernel/locking/lockdep.c:3828
 lock_acquire+0x190/0x410 kernel/locking/lockdep.c:4487
 __raw_spin_lock_bh include/linux/spinlock_api_smp.h:135 [inline]
 _raw_spin_lock_bh+0x33/0x50 kernel/locking/spinlock.c:175
 spin_lock_bh include/linux/spinlock.h:343 [inline]
 j1939_session_list_lock net/can/j1939/transport.c:238 [inline]
 j1939_session_get_by_addr+0x2d/0x60 net/can/j1939/transport.c:530
 j1939_xtp_rx_abort_one+0x8d/0x100 net/can/j1939/transport.c:1242
 j1939_xtp_rx_abort net/can/j1939/transport.c:1270 [inline]
 j1939_tp_cmd_recv net/can/j1939/transport.c:1961 [inline]
 j1939_tp_recv+0x513/0x9b0 net/can/j1939/transport.c:1991
 j1939_can_recv+0x4bb/0x620 net/can/j1939/main.c:100
 deliver net/can/af_can.c:568 [inline]
 can_rcv_filter+0x292/0x8e0 net/can/af_can.c:602
 can_receive+0x2e7/0x530 net/can/af_can.c:659
 can_rcv+0x133/0x1b0 net/can/af_can.c:685
 __netif_receive_skb_one_core+0x113/0x1a0 net/core/dev.c:4929
 __netif_receive_skb+0x2c/0x1d0 net/core/dev.c:5043
 process_backlog+0x206/0x750 net/core/dev.c:5874
 napi_poll net/core/dev.c:6311 [inline]
 net_rx_action+0x508/0x1120 net/core/dev.c:6379
 __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 9670:
 save_stack+0x23/0x90 mm/kasan/common.c:69
 set_track mm/kasan/common.c:77 [inline]
 __kasan_kmalloc mm/kasan/common.c:510 [inline]
 __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:483
 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:524
 kmem_cache_alloc_trace+0x158/0x790 mm/slab.c:3550
 kmalloc include/linux/slab.h:556 [inline]
 kzalloc include/linux/slab.h:690 [inline]
 j1939_priv_create net/can/j1939/main.c:122 [inline]
 j1939_netdev_start+0xa4/0x550 net/can/j1939/main.c:251
 j1939_sk_bind+0x65a/0x8e0 net/can/j1939/socket.c:438
 __sys_bind+0x239/0x290 net/socket.c:1647
 __do_sys_bind net/socket.c:1658 [inline]
 __se_sys_bind net/socket.c:1656 [inline]
 __x64_sys_bind+0x73/0xb0 net/socket.c:1656
 do_syscall_64+0xfa/0x760 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 16:
 save_stack+0x23/0x90 mm/kasan/common.c:69
 set_track mm/kasan/common.c:77 [inline]
 kasan_set_free_info mm/kasan/common.c:332 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/common.c:471
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:480
 __cache_free mm/slab.c:3425 [inline]
 kfree+0x10a/0x2c0 mm/slab.c:3756
 __j1939_priv_release net/can/j1939/main.c:154 [inline]
 kref_put include/linux/kref.h:65 [inline]
 j1939_priv_put+0x8b/0xb0 net/can/j1939/main.c:159
 j1939_session_destroy net/can/j1939/transport.c:271 [inline]
 __j1939_session_release net/can/j1939/transport.c:280 [inline]
 kref_put include/linux/kref.h:65 [inline]
 j1939_session_put+0x12c/0x180 net/can/j1939/transport.c:285
 j1939_xtp_rx_abort_one+0xc7/0x100 net/can/j1939/transport.c:1261
 j1939_xtp_rx_abort net/can/j1939/transport.c:1269 [inline]
 j1939_tp_cmd_recv net/can/j1939/transport.c:1961 [inline]
 j1939_tp_recv+0x4fb/0x9b0 net/can/j1939/transport.c:1991
 j1939_can_recv+0x4bb/0x620 net/can/j1939/main.c:100
 deliver net/can/af_can.c:568 [inline]
 can_rcv_filter+0x292/0x8e0 net/can/af_can.c:602
 can_receive+0x2e7/0x530 net/can/af_can.c:659
 can_rcv+0x133/0x1b0 net/can/af_can.c:685
 __netif_receive_skb_one_core+0x113/0x1a0 net/core/dev.c:4929
 __netif_receive_skb+0x2c/0x1d0 net/core/dev.c:5043
 process_backlog+0x206/0x750 net/core/dev.c:5874
 napi_poll net/core/dev.c:6311 [inline]
 net_rx_action+0x508/0x1120 net/core/dev.c:6379
 __do_softirq+0x262/0x98c kernel/softirq.c:292

The buggy address belongs to the object at ffff8880a4b64000
 which belongs to the cache kmalloc-8k of size 8192
The buggy address is located 4224 bytes inside of
 8192-byte region [ffff8880a4b64000, ffff8880a4b66000)
The buggy address belongs to the page:
page:ffffea000292d900 refcount:1 mapcount:0 mapping:ffff8880aa4021c0 index:0x0 compound_mapcount: 0
flags: 0x1fffc0000010200(slab|head)
raw: 01fffc0000010200 ffffea0002217c08 ffffea00021afd08 ffff8880aa4021c0
raw: 0000000000000000 ffff8880a4b64000 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a4b64f80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880a4b65000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880a4b65080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff8880a4b65100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880a4b65180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (66):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/11/11 05:33 upstream 9805a68371ce dc438b91 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2019/11/05 20:58 upstream a99d8080aaf3 0f3ec414 .config console log report syz C ci-upstream-kasan-gce
2019/11/05 04:20 upstream a99d8080aaf3 76630fc9 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2019/11/05 14:29 net-old 3d1e5039f5f8 0f3ec414 .config console log report syz C ci-upstream-net-this-kasan-gce
2019/11/05 04:38 net-old 3d1e5039f5f8 76630fc9 .config console log report syz C ci-upstream-net-this-kasan-gce
2019/11/09 03:51 upstream 6737e7634951 dc438b91 .config console log report syz ci-upstream-kasan-gce
2019/11/05 21:23 upstream a99d8080aaf3 0f3ec414 .config console log report syz ci-upstream-kasan-gce
2019/11/10 21:43 upstream 00aff6836241 dc438b91 .config console log report syz C ci-upstream-kasan-gce-root
2019/11/07 13:50 upstream 4dd58158254c d797d201 .config console log report syz C ci-upstream-kasan-gce-root
2019/11/07 02:22 upstream 26bc67213424 da505f84 .config console log report syz C ci-upstream-kasan-gce-root
2019/11/06 10:57 upstream 26bc67213424 bc2c6e45 .config console log report syz C ci-upstream-kasan-gce
2019/11/06 10:12 upstream 26bc67213424 bc2c6e45 .config console log report syz C ci-upstream-kasan-gce-root
2019/11/10 22:35 upstream 00aff6836241 dc438b91 .config console log report syz C ci-upstream-kasan-gce-386
2019/11/10 14:55 net-next-old 14684b93019a dc438b91 .config console log report syz C ci-upstream-net-kasan-gce
2019/11/09 05:43 net-next-old a0c76345e3d3 dc438b91 .config console log report syz C ci-upstream-net-kasan-gce
2019/11/05 06:43 net-next-old 1574cf83c7a0 76630fc9 .config console log report syz C ci-upstream-net-kasan-gce
2019/11/05 03:26 net-next-old 1574cf83c7a0 76630fc9 .config console log report syz C ci-upstream-net-kasan-gce
2019/11/10 15:33 linux-next 5591cf003452 dc438b91 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2019/11/14 08:08 upstream bf9294798930 048f2d49 .config console log report syz ci-upstream-kasan-gce-selinux-root
2019/11/05 23:49 upstream a99d8080aaf3 0f3ec414 .config console log report syz ci-upstream-kasan-gce-root
2019/11/05 16:21 upstream a99d8080aaf3 0f3ec414 .config console log report syz ci-upstream-kasan-gce
2019/11/07 11:05 upstream 4dd58158254c d797d201 .config console log report syz ci-upstream-kasan-gce-386
2019/11/07 10:39 upstream 4dd58158254c d797d201 .config console log report syz ci-upstream-kasan-gce-386
2019/11/09 03:52 net-old 1b53d64435d5 dc438b91 .config console log report syz ci-upstream-net-this-kasan-gce
2019/11/05 08:35 net-old 3d1e5039f5f8 76630fc9 .config console log report syz ci-upstream-net-this-kasan-gce
2019/11/05 19:31 net-next-old 56c1291ee48b 0f3ec414 .config console log report syz ci-upstream-net-kasan-gce
2019/11/09 03:27 linux-next 5591cf003452 dc438b91 .config console log report syz ci-upstream-linux-next-kasan-gce-root
2019/11/17 04:03 upstream 6c9594bdd474 d5696d51 .config console log report ci-upstream-kasan-gce-root
2019/11/17 01:33 upstream 6c9594bdd474 d5696d51 .config console log report ci-upstream-kasan-gce-root
2019/11/15 21:37 upstream eb70e26cd79d cdac920b .config console log report ci-upstream-kasan-gce-root
2019/11/13 22:46 upstream bf9294798930 048f2d49 .config console log report ci-upstream-kasan-gce-root
2019/11/12 07:23 upstream de620fb99ef2 048f2d49 .config console log report ci-upstream-kasan-gce-selinux-root
2019/11/11 21:26 upstream 31f4f5b495a6 048f2d49 .config console log report ci-upstream-kasan-gce
2019/11/11 16:54 upstream 31f4f5b495a6 048f2d49 .config console log report ci-upstream-kasan-gce
2019/11/11 00:41 upstream 9805a68371ce dc438b91 .config console log report ci-upstream-kasan-gce-selinux-root
2019/11/10 13:53 upstream 00aff6836241 dc438b91 .config console log report ci-upstream-kasan-gce-root
2019/11/09 17:01 upstream 0058b0a506e4 dc438b91 .config console log report ci-upstream-kasan-gce-root
2019/11/08 21:23 upstream 6737e7634951 1e35461e .config console log report ci-upstream-kasan-gce-root
2019/11/08 10:15 upstream 847120f859cc 1e35461e .config console log report ci-upstream-kasan-gce-root
2019/11/08 08:52 upstream 847120f859cc 1e35461e .config console log report ci-upstream-kasan-gce-root
2019/11/08 00:05 upstream 847120f859cc f39aff9e .config console log report ci-upstream-kasan-gce-root
2019/11/07 05:32 upstream 4dd58158254c d797d201 .config console log report ci-upstream-kasan-gce-root
2019/11/06 17:18 upstream 26bc67213424 da505f84 .config console log report ci-upstream-kasan-gce-selinux-root
2019/11/06 09:14 upstream 26bc67213424 bc2c6e45 .config console log report ci-upstream-kasan-gce-root
2019/11/06 03:16 upstream 26bc67213424 bc2c6e45 .config console log report ci-upstream-kasan-gce-root
2019/11/06 01:44 upstream a99d8080aaf3 0f3ec414 .config console log report ci-upstream-kasan-gce-root
2019/11/05 18:48 upstream a99d8080aaf3 0f3ec414 .config console log report ci-upstream-kasan-gce
2019/11/05 03:00 upstream a99d8080aaf3 76630fc9 .config console log report ci-upstream-kasan-gce-selinux-root
2019/11/05 02:51 upstream a99d8080aaf3 76630fc9 .config console log report ci-upstream-kasan-gce-selinux-root
2019/11/07 22:27 upstream 847120f859cc f39aff9e .config console log report ci-upstream-kasan-gce-386
2019/11/06 04:49 upstream 26bc67213424 bc2c6e45 .config console log report ci-upstream-kasan-gce-386
2019/11/13 02:45 net-old 6d6dd528d5af 048f2d49 .config console log report ci-upstream-net-this-kasan-gce
2019/11/12 12:43 net-old 40a1dcee2d18 048f2d49 .config console log report ci-upstream-net-this-kasan-gce
2019/11/06 09:19 net-old fc564e09237f bc2c6e45 .config console log report ci-upstream-net-this-kasan-gce
2019/11/05 02:51 net-old 3d1e5039f5f8 76630fc9 .config console log report ci-upstream-net-this-kasan-gce
2019/11/07 17:04 net-next-old 426071f1f399 d797d201 .config console log report ci-upstream-net-kasan-gce
2019/11/06 09:17 net-next-old a3ead21d6eec bc2c6e45 .config console log report ci-upstream-net-kasan-gce
2019/11/05 02:53 net-next-old 1574cf83c7a0 76630fc9 .config console log report ci-upstream-net-kasan-gce
2019/11/10 00:55 linux-next 5591cf003452 dc438b91 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/11/08 09:23 linux-next 5591cf003452 1e35461e .config console log report ci-upstream-linux-next-kasan-gce-root
2019/11/06 09:18 linux-next 51309b9d73f5 bc2c6e45 .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.