syzbot


KASAN: use-after-free Read in ax25_heartbeat_expiry

Status: upstream: reported on 2025/02/21 07:36
Reported-by: syzbot+56f5db4969f4609f5fea@syzkaller.appspotmail.com
First crash: 144d, last: 6d12h

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in ax25_heartbeat_expiry+0x10c/0x130 net/ax25/ax25_timer.c:125
Read of size 4 at addr ffff888019dcf050 by task kworker/u5:0/146

CPU: 0 PID: 146 Comm: kworker/u5:0 Not tainted 5.15.186-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025
Workqueue: hci5 hci_rx_work
Call Trace:
 <IRQ>
 dump_stack_lvl+0x168/0x230 lib/dump_stack.c:106
 print_address_description+0x60/0x2d0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:434 [inline]
 kasan_report+0xdf/0x130 mm/kasan/report.c:451
 ax25_heartbeat_expiry+0x10c/0x130 net/ax25/ax25_timer.c:125
 call_timer_fn+0x16c/0x530 kernel/time/timer.c:1451
 expire_timers kernel/time/timer.c:1496 [inline]
 __run_timers+0x525/0x7c0 kernel/time/timer.c:1767
 run_timer_softirq+0x63/0xf0 kernel/time/timer.c:1780
 handle_softirqs+0x328/0x820 kernel/softirq.c:576
 __do_softirq kernel/softirq.c:610 [inline]
 invoke_softirq kernel/softirq.c:450 [inline]
 __irq_exit_rcu+0x12f/0x220 kernel/softirq.c:659
 irq_exit_rcu+0x5/0x20 kernel/softirq.c:671
 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1108 [inline]
 sysvec_apic_timer_interrupt+0xa0/0xc0 arch/x86/kernel/apic/apic.c:1108
 </IRQ>
 <TASK>
 asm_sysvec_apic_timer_interrupt+0x16/0x20 arch/x86/include/asm/idtentry.h:676
RIP: 0010:dump_stack_lvl+0x1d0/0x230 lib/dump_stack.c:108
Code: e8 35 18 d6 f7 49 21 de 75 61 e8 4b 14 d6 f7 4d 85 ed 75 07 e8 41 14 d6 f7 eb 06 e8 3a 14 d6 f7 fb 48 c7 44 24 20 0e 36 e0 45 <4b> c7 04 27 00 00 00 00 43 c7 44 27 09 00 00 00 00 66 43 c7 44 27
RSP: 0018:ffffc900016cf2e0 EFLAGS: 00000293
RAX: ffffffff89a1aed6 RBX: 0000000000000082 RCX: ffff888017bfd940
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: ffffc900016cf3d0 R08: dffffc0000000000 R09: fffffbfff1ff7436
R10: fffffbfff1ff7436 R11: 1ffffffff1ff7435 R12: dffffc0000000000
R13: 0000000000000200 R14: 0000000000000000 R15: 1ffff920002d9e60
 sysfs_warn_dup fs/sysfs/dir.c:30 [inline]
 sysfs_create_dir_ns+0x252/0x280 fs/sysfs/dir.c:64
 create_dir lib/kobject.c:89 [inline]
 kobject_add_internal+0x662/0xd00 lib/kobject.c:263
 kobject_add_varg lib/kobject.c:398 [inline]
 kobject_add+0x152/0x210 lib/kobject.c:450
 device_add+0x483/0xfb0 drivers/base/core.c:3347
 hci_conn_add_sysfs+0xd1/0x1e0 net/bluetooth/hci_sysfs.c:46
 le_conn_complete_evt+0xcbc/0x1590 net/bluetooth/hci_event.c:5406
 hci_le_conn_complete_evt net/bluetooth/hci_event.c:5454 [inline]
 hci_le_meta_evt+0x289/0x3b80 net/bluetooth/hci_event.c:6176
 hci_event_packet+0xe05/0x12f0 net/bluetooth/hci_event.c:6525
 hci_rx_work+0x255/0xa10 net/bluetooth/hci_core.c:5160
 process_one_work+0x863/0x1000 kernel/workqueue.c:2310
 worker_thread+0xaa8/0x12a0 kernel/workqueue.c:2457
 kthread+0x436/0x520 kernel/kthread.c:334
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287
 </TASK>

Allocated by task 5231:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:434 [inline]
 ____kasan_kmalloc mm/kasan/common.c:513 [inline]
 __kasan_kmalloc+0xb5/0xf0 mm/kasan/common.c:522
 kmalloc include/linux/slab.h:604 [inline]
 kzalloc include/linux/slab.h:735 [inline]
 ax25_dev_device_up+0x50/0x580 net/ax25/ax25_dev.c:55
 ax25_device_event+0x483/0x4f0 net/ax25/af_ax25.c:139
 notifier_call_chain kernel/notifier.c:83 [inline]
 raw_notifier_call_chain+0xcb/0x160 kernel/notifier.c:391
 call_netdevice_notifiers_extack net/core/dev.c:2061 [inline]
 call_netdevice_notifiers net/core/dev.c:2075 [inline]
 __dev_notify_flags+0x178/0x2d0 net/core/dev.c:-1
 dev_change_flags+0xe3/0x1a0 net/core/dev.c:8929
 dev_ifsioc+0x147/0xe70 net/core/dev_ioctl.c:324
 dev_ioctl+0x55f/0xe50 net/core/dev_ioctl.c:587
 sock_do_ioctl+0x222/0x2f0 net/socket.c:1154
 sock_ioctl+0x4ed/0x6e0 net/socket.c:1257
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:874 [inline]
 __se_sys_ioctl+0xfa/0x170 fs/ioctl.c:860
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0

Freed by task 7721:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:46
 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:360
 ____kasan_slab_free+0xd5/0x110 mm/kasan/common.c:366
 kasan_slab_free include/linux/kasan.h:230 [inline]
 slab_free_hook mm/slub.c:1705 [inline]
 slab_free_freelist_hook+0xea/0x170 mm/slub.c:1731
 slab_free mm/slub.c:3499 [inline]
 kfree+0xef/0x2a0 mm/slub.c:4559
 ax25_dev_put include/net/ax25.h:302 [inline]
 ax25_release+0x661/0x870 net/ax25/af_ax25.c:1062
 __sock_release net/socket.c:649 [inline]
 sock_close+0xd5/0x240 net/socket.c:1336
 __fput+0x234/0x930 fs/file_table.c:311
 task_work_run+0x125/0x1a0 kernel/task_work.c:188
 tracehook_notify_resume include/linux/tracehook.h:189 [inline]
 exit_to_user_mode_loop+0x10f/0x130 kernel/entry/common.c:181
 exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:214
 __syscall_exit_to_user_mode_work kernel/entry/common.c:296 [inline]
 syscall_exit_to_user_mode+0x16/0x40 kernel/entry/common.c:307
 do_syscall_64+0x58/0xa0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x66/0xd0

Last potentially related work creation:
 kasan_save_stack+0x35/0x60 mm/kasan/common.c:38
 kasan_record_aux_stack+0xb8/0x100 mm/kasan/generic.c:348
 insert_work+0x54/0x3d0 kernel/workqueue.c:1366
 __queue_work+0x9c5/0xd50 kernel/workqueue.c:1532
 queue_work_on+0x11d/0x1d0 kernel/workqueue.c:1559
 inet6addr_event+0x9c/0xc0 drivers/infiniband/core/roce_gid_mgmt.c:883
 notifier_call_chain kernel/notifier.c:83 [inline]
 atomic_notifier_call_chain+0x15d/0x280 kernel/notifier.c:198
 addrconf_ifdown+0xdf4/0x1970 net/ipv6/addrconf.c:3906
 addrconf_notify+0x445/0xf00 net/ipv6/addrconf.c:-1
 notifier_call_chain kernel/notifier.c:83 [inline]
 raw_notifier_call_chain+0xcb/0x160 kernel/notifier.c:391
 call_netdevice_notifiers_extack net/core/dev.c:2061 [inline]
 call_netdevice_notifiers net/core/dev.c:2075 [inline]
 dev_close_many+0x28d/0x400 net/core/dev.c:1650
 unregister_netdevice_many+0x472/0x18f0 net/core/dev.c:11110
 default_device_exit_batch+0x336/0x390 net/core/dev.c:11667
 ops_exit_list net/core/net_namespace.c:177 [inline]
 cleanup_net+0x77b/0xb80 net/core/net_namespace.c:635
 process_one_work+0x863/0x1000 kernel/workqueue.c:2310
 worker_thread+0xaa8/0x12a0 kernel/workqueue.c:2457
 kthread+0x436/0x520 kernel/kthread.c:334
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287

Second to last potentially related work creation:
 kasan_save_stack+0x35/0x60 mm/kasan/common.c:38
 kasan_record_aux_stack+0xb8/0x100 mm/kasan/generic.c:348
 insert_work+0x54/0x3d0 kernel/workqueue.c:1366
 __queue_work+0x9c5/0xd50 kernel/workqueue.c:1532
 queue_work_on+0x11d/0x1d0 kernel/workqueue.c:1559
 queue_work include/linux/workqueue.h:512 [inline]
 netdevice_queue_work drivers/infiniband/core/roce_gid_mgmt.c:659 [inline]
 netdevice_event+0x803/0x900 drivers/infiniband/core/roce_gid_mgmt.c:802
 notifier_call_chain kernel/notifier.c:83 [inline]
 raw_notifier_call_chain+0xcb/0x160 kernel/notifier.c:391
 call_netdevice_notifiers_extack net/core/dev.c:2061 [inline]
 call_netdevice_notifiers net/core/dev.c:2075 [inline]
 register_netdevice+0x1275/0x16b0 net/core/dev.c:10428
 ip6gre_newlink_common+0x39a/0x530 net/ipv6/ip6_gre.c:2005
 ip6gre_newlink+0x1d4/0x530 net/ipv6/ip6_gre.c:2036
 __rtnl_newlink net/core/rtnetlink.c:3524 [inline]
 rtnl_newlink+0x114c/0x17d0 net/core/rtnetlink.c:3572
 rtnetlink_rcv_msg+0x9b9/0xe60 net/core/rtnetlink.c:5650
 netlink_rcv_skb+0x1e0/0x430 net/netlink/af_netlink.c:2489
 netlink_unicast_kernel net/netlink/af_netlink.c:1311 [inline]
 netlink_unicast+0x77c/0x920 net/netlink/af_netlink.c:1337
 netlink_sendmsg+0x8ab/0xbc0 net/netlink/af_netlink.c:1905
 sock_sendmsg_nosec net/socket.c:704 [inline]
 __sock_sendmsg net/socket.c:716 [inline]
 __sys_sendto+0x423/0x580 net/socket.c:2063
 __do_sys_sendto net/socket.c:2075 [inline]
 __se_sys_sendto net/socket.c:2071 [inline]
 __x64_sys_sendto+0xda/0xf0 net/socket.c:2071
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0

The buggy address belongs to the object at ffff888019dcf000
 which belongs to the cache kmalloc-192 of size 192
The buggy address is located 80 bytes inside of
 192-byte region [ffff888019dcf000, ffff888019dcf0c0)
The buggy address belongs to the page:
page:ffffea00006773c0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x19dcf
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 ffffea0000902ec0 0000000200000002 ffff888016841a00
raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY), pid 1, ts 2719394485, free_ts 0
 prep_new_page mm/page_alloc.c:2426 [inline]
 get_page_from_freelist+0x1b77/0x1c60 mm/page_alloc.c:4192
 __alloc_pages+0x1e1/0x470 mm/page_alloc.c:5474
 alloc_page_interleave+0x24/0x1e0 mm/mempolicy.c:2031
 alloc_slab_page mm/slub.c:1775 [inline]
 allocate_slab mm/slub.c:1912 [inline]
 new_slab+0xc0/0x4b0 mm/slub.c:1975
 ___slab_alloc+0x81e/0xdf0 mm/slub.c:3008
 __slab_alloc mm/slub.c:3095 [inline]
 slab_alloc_node mm/slub.c:3186 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 kmem_cache_alloc_trace+0x1a5/0x2a0 mm/slub.c:3245
 kmalloc include/linux/slab.h:604 [inline]
 kzalloc include/linux/slab.h:735 [inline]
 call_usermodehelper_setup+0x8a/0x260 kernel/umh.c:365
 kobject_uevent_env+0x65e/0x890 lib/kobject_uevent.c:629
 kernel_add_sysfs_param+0xfb/0x120 kernel/params.c:816
 param_sysfs_builtin+0x164/0x1e0 kernel/params.c:851
 param_sysfs_init+0x66/0x70 kernel/params.c:972
 do_one_initcall+0x1ee/0x680 init/main.c:1302
 do_initcall_level+0x137/0x1f0 init/main.c:1375
 do_initcalls+0x4b/0x90 init/main.c:1391
 kernel_init_freeable+0x3ce/0x560 init/main.c:1615
 kernel_init+0x19/0x1b0 init/main.c:1506
page_owner free stack trace missing

Memory state around the buggy address:
 ffff888019dcef00: 06 fc fc fc fc 05 fc fc fc fc 05 fc fc fc fc 06
 ffff888019dcef80: fc fc fc fc 04 fc fc fc fc 04 fc fc fc fc fc fc
>ffff888019dcf000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                 ^
 ffff888019dcf080: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff888019dcf100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================
----------------
Code disassembly (best guess):
   0:	e8 35 18 d6 f7       	call   0xf7d6183a
   5:	49 21 de             	and    %rbx,%r14
   8:	75 61                	jne    0x6b
   a:	e8 4b 14 d6 f7       	call   0xf7d6145a
   f:	4d 85 ed             	test   %r13,%r13
  12:	75 07                	jne    0x1b
  14:	e8 41 14 d6 f7       	call   0xf7d6145a
  19:	eb 06                	jmp    0x21
  1b:	e8 3a 14 d6 f7       	call   0xf7d6145a
  20:	fb                   	sti
  21:	48 c7 44 24 20 0e 36 	movq   $0x45e0360e,0x20(%rsp)
  28:	e0 45
* 2a:	4b c7 04 27 00 00 00 	movq   $0x0,(%r15,%r12,1) <-- trapping instruction
  31:	00
  32:	43 c7 44 27 09 00 00 	movl   $0x0,0x9(%r15,%r12,1)
  39:	00 00
  3b:	66                   	data16
  3c:	43                   	rex.XB
  3d:	c7                   	.byte 0xc7
  3e:	44 27                	rex.R (bad)

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/07/09 12:29 linux-5.15.y 3dea0e7f549e f4e5e155 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in ax25_heartbeat_expiry
2025/06/26 18:19 linux-5.15.y 1c700860e8bc 803ce19b .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in ax25_heartbeat_expiry
2025/05/12 22:47 linux-5.15.y 3b8db0e4f263 f6671af7 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in ax25_heartbeat_expiry
2025/02/21 07:36 linux-5.15.y c16c81c81336 0808a665 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in ax25_heartbeat_expiry
* Struck through repros no longer work on HEAD.