syzbot


KASAN: use-after-free Read in advance_sched

Status: auto-closed as invalid on 2022/03/03 15:32
Subsystems: net
[Documentation on labels]
Reported-by: syzbot+1655e83234d0f0ad1fa4@syzkaller.appspotmail.com
First crash: 913d, last: 904d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] KASAN: use-after-free Read in advance_sched 0 (1) 2021/10/29 06:31
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 KASAN: use-after-free Read in advance_sched 1 31d 31d 0/3 upstream: reported on 2024/03/25 12:01
linux-5.15 KASAN: use-after-free Read in advance_sched 1 33d 33d 0/3 upstream: reported on 2024/03/23 04:49
upstream KASAN: slab-use-after-free Read in advance_sched net C 15 1d02h 129d 0/26 upstream: reported C repro on 2023/12/19 00:19

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in advance_sched+0x967/0x9a0 net/sched/sch_taprio.c:728
Read of size 8 at addr ffff88807b240910 by task syz-executor.4/9765

CPU: 0 PID: 9765 Comm: syz-executor.4 Not tainted 5.15.0-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 <IRQ>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 print_address_description.constprop.0.cold+0x6c/0x309 mm/kasan/report.c:256
 __kasan_report mm/kasan/report.c:442 [inline]
 kasan_report.cold+0x83/0xdf mm/kasan/report.c:459
 advance_sched+0x967/0x9a0 net/sched/sch_taprio.c:728
 __run_hrtimer kernel/time/hrtimer.c:1685 [inline]
 __hrtimer_run_queues+0x609/0xe50 kernel/time/hrtimer.c:1749
 hrtimer_interrupt+0x31c/0x790 kernel/time/hrtimer.c:1811
 local_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1086 [inline]
 __sysvec_apic_timer_interrupt+0x146/0x530 arch/x86/kernel/apic/apic.c:1103
 sysvec_apic_timer_interrupt+0x8e/0xc0 arch/x86/kernel/apic/apic.c:1097
 </IRQ>
 <TASK>
 asm_sysvec_apic_timer_interrupt+0x12/0x20 arch/x86/include/asm/idtentry.h:638
RIP: 0010:check_kcov_mode kernel/kcov.c:163 [inline]
RIP: 0010:__sanitizer_cov_trace_pc+0x7/0x60 kernel/kcov.c:197
Code: fd ff ff b9 ff ff ff ff ba 08 00 00 00 4d 8b 03 48 0f bd ca 49 8b 45 00 48 63 c9 e9 64 ff ff ff 0f 1f 00 65 8b 05 69 fd 8a 7e <89> c1 48 8b 34 24 81 e1 00 01 00 00 65 48 8b 14 25 40 70 02 00 a9
RSP: 0018:ffffc9000335f770 EFLAGS: 00000286
RAX: 0000000080000001 RBX: ffffc9000335fa80 RCX: ffffffffffffffff
RDX: 0000000000000000 RSI: ffff888032545700 RDI: 0000000000000003
RBP: ffffffffffffffff R08: 0000000000000000 R09: ffffea00010f1033
R10: ffffffff81afc312 R11: 0000000000000000 R12: ffffea00010f1030
R13: 0000000000000000 R14: ffffea00010f1000 R15: 00007f9668db6000
 __tlb_remove_page_size+0x50/0x420 mm/mmu_gather.c:76
 __tlb_remove_page include/asm-generic/tlb.h:440 [inline]
 zap_pte_range mm/memory.c:1365 [inline]
 zap_pmd_range mm/memory.c:1481 [inline]
 zap_pud_range mm/memory.c:1510 [inline]
 zap_p4d_range mm/memory.c:1531 [inline]
 unmap_page_range+0xf4c/0x2a10 mm/memory.c:1552
 unmap_single_vma+0x198/0x310 mm/memory.c:1597
 unmap_vmas+0x16b/0x2f0 mm/memory.c:1629
 exit_mmap+0x1d0/0x630 mm/mmap.c:3171
 __mmput+0x122/0x4b0 kernel/fork.c:1114
 mmput+0x56/0x60 kernel/fork.c:1135
 exit_mm kernel/exit.c:502 [inline]
 do_exit+0xab8/0x2a20 kernel/exit.c:813
 do_group_exit+0x125/0x310 kernel/exit.c:923
 get_signal+0x47d/0x21d0 kernel/signal.c:2855
 arch_do_signal_or_restart+0x2a9/0x1c40 arch/x86/kernel/signal.c:868
 handle_signal_work kernel/entry/common.c:148 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:172 [inline]
 exit_to_user_mode_prepare+0x17d/0x290 kernel/entry/common.c:207
 __syscall_exit_to_user_mode_work kernel/entry/common.c:289 [inline]
 syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:300
 do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7f9669fa4ae9
Code: Unable to access opcode bytes at RIP 0x7f9669fa4abf.
RSP: 002b:00007f96674f9218 EFLAGS: 00000246 ORIG_RAX: 00000000000000ca
RAX: 0000000000000001 RBX: 00007f966a0b8028 RCX: 00007f9669fa4ae9
RDX: 00000000000f4240 RSI: 0000000000000081 RDI: 00007f966a0b802c
RBP: 00007f966a0b8020 R08: 0000000000000016 R09: 0000000000000000
R10: ffffffffffffffff R11: 0000000000000246 R12: 00007f966a0b802c
R13: 00007ffecbeafd1f R14: 00007f96674f9300 R15: 0000000000022000
 </TASK>

Allocated by task 9643:
 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:434 [inline]
 ____kasan_kmalloc mm/kasan/common.c:513 [inline]
 ____kasan_kmalloc mm/kasan/common.c:472 [inline]
 __kasan_kmalloc+0xa4/0xd0 mm/kasan/common.c:522
 kmalloc include/linux/slab.h:591 [inline]
 kzalloc include/linux/slab.h:721 [inline]
 taprio_change+0x5fb/0x4160 net/sched/sch_taprio.c:1477
 qdisc_change net/sched/sch_api.c:1329 [inline]
 tc_modify_qdisc+0xd87/0x1980 net/sched/sch_api.c:1631
 rtnetlink_rcv_msg+0x413/0xb80 net/core/rtnetlink.c:5571
 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2491
 netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
 netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1345
 netlink_sendmsg+0x86d/0xda0 net/netlink/af_netlink.c:1916
 sock_sendmsg_nosec net/socket.c:704 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:724
 sock_no_sendpage+0xf6/0x140 net/core/sock.c:3080
 kernel_sendpage.part.0+0x1a0/0x340 net/socket.c:3504
 kernel_sendpage net/socket.c:3501 [inline]
 sock_sendpage+0xe5/0x140 net/socket.c:1003
 pipe_to_sendpage+0x2ad/0x380 fs/splice.c:364
 splice_from_pipe_feed fs/splice.c:418 [inline]
 __splice_from_pipe+0x43e/0x8a0 fs/splice.c:562
 splice_from_pipe fs/splice.c:597 [inline]
 generic_splice_sendpage+0xd4/0x140 fs/splice.c:746
 do_splice_from fs/splice.c:767 [inline]
 do_splice+0xb7e/0x1960 fs/splice.c:1079
 __do_splice+0x134/0x250 fs/splice.c:1144
 __do_sys_splice fs/splice.c:1350 [inline]
 __se_sys_splice fs/splice.c:1332 [inline]
 __x64_sys_splice+0x198/0x250 fs/splice.c:1332
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Freed by task 17037:
 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:360
 ____kasan_slab_free mm/kasan/common.c:366 [inline]
 ____kasan_slab_free mm/kasan/common.c:328 [inline]
 __kasan_slab_free+0xff/0x130 mm/kasan/common.c:374
 kasan_slab_free include/linux/kasan.h:235 [inline]
 slab_free_hook mm/slub.c:1700 [inline]
 slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1726
 slab_free mm/slub.c:3492 [inline]
 kfree+0xf3/0x550 mm/slub.c:4552
 rcu_do_batch kernel/rcu/tree.c:2506 [inline]
 rcu_core+0x7ab/0x1470 kernel/rcu/tree.c:2741
 __do_softirq+0x29b/0x9c2 kernel/softirq.c:558

Last potentially related work creation:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38
 kasan_record_aux_stack+0xe9/0x110 mm/kasan/generic.c:348
 __call_rcu kernel/rcu/tree.c:2985 [inline]
 call_rcu+0xb1/0x740 kernel/rcu/tree.c:3065
 taprio_change+0x2fe5/0x4160 net/sched/sch_taprio.c:1597
 qdisc_change net/sched/sch_api.c:1329 [inline]
 tc_modify_qdisc+0xd87/0x1980 net/sched/sch_api.c:1631
 rtnetlink_rcv_msg+0x413/0xb80 net/core/rtnetlink.c:5571
 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2491
 netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
 netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1345
 netlink_sendmsg+0x86d/0xda0 net/netlink/af_netlink.c:1916
 sock_sendmsg_nosec net/socket.c:704 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:724
 sock_no_sendpage+0xf6/0x140 net/core/sock.c:3080
 kernel_sendpage.part.0+0x1a0/0x340 net/socket.c:3504
 kernel_sendpage net/socket.c:3501 [inline]
 sock_sendpage+0xe5/0x140 net/socket.c:1003
 pipe_to_sendpage+0x2ad/0x380 fs/splice.c:364
 splice_from_pipe_feed fs/splice.c:418 [inline]
 __splice_from_pipe+0x43e/0x8a0 fs/splice.c:562
 splice_from_pipe fs/splice.c:597 [inline]
 generic_splice_sendpage+0xd4/0x140 fs/splice.c:746
 do_splice_from fs/splice.c:767 [inline]
 do_splice+0xb7e/0x1960 fs/splice.c:1079
 __do_splice+0x134/0x250 fs/splice.c:1144
 __do_sys_splice fs/splice.c:1350 [inline]
 __se_sys_splice fs/splice.c:1332 [inline]
 __x64_sys_splice+0x198/0x250 fs/splice.c:1332
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Second to last potentially related work creation:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38
 kasan_record_aux_stack+0xe9/0x110 mm/kasan/generic.c:348
 kvfree_call_rcu+0x74/0x990 kernel/rcu/tree.c:3550
 cfg80211_update_known_bss+0x833/0xa60 net/wireless/scan.c:1663
 cfg80211_bss_update+0xef/0x2070 net/wireless/scan.c:1710
 cfg80211_inform_single_bss_frame_data+0x6e8/0xee0 net/wireless/scan.c:2425
 cfg80211_inform_bss_frame_data+0xa7/0xb10 net/wireless/scan.c:2458
 ieee80211_bss_info_update+0x35b/0xb30 net/mac80211/scan.c:190
 ieee80211_rx_bss_info net/mac80211/ibss.c:1119 [inline]
 ieee80211_rx_mgmt_probe_beacon net/mac80211/ibss.c:1610 [inline]
 ieee80211_ibss_rx_queued_mgmt+0x19cf/0x3130 net/mac80211/ibss.c:1639
 ieee80211_iface_process_skb net/mac80211/iface.c:1466 [inline]
 ieee80211_iface_work+0xa65/0xd00 net/mac80211/iface.c:1520
 process_one_work+0x9b2/0x1690 kernel/workqueue.c:2297
 worker_thread+0x658/0x11f0 kernel/workqueue.c:2444
 kthread+0x405/0x4f0 kernel/kthread.c:327
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

The buggy address belongs to the object at ffff88807b240900
 which belongs to the cache kmalloc-96 of size 96
The buggy address is located 16 bytes inside of
 96-byte region [ffff88807b240900, ffff88807b240960)
The buggy address belongs to the page:
page:ffffea0001ec9000 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7b240
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 ffffea0001c8b200 0000001100000011 ffff888010c41780
raw: 0000000000000000 0000000000200020 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 0x12c40(GFP_NOFS|__GFP_NOWARN|__GFP_NORETRY), pid 6803, ts 2401771800227, free_ts 2401767836615
 prep_new_page mm/page_alloc.c:2426 [inline]
 get_page_from_freelist+0xa72/0x2f80 mm/page_alloc.c:4155
 __alloc_pages+0x1b2/0x500 mm/page_alloc.c:5381
 alloc_pages+0x1a7/0x300 mm/mempolicy.c:2191
 alloc_slab_page mm/slub.c:1770 [inline]
 allocate_slab mm/slub.c:1907 [inline]
 new_slab+0x319/0x490 mm/slub.c:1970
 ___slab_alloc+0x921/0xfe0 mm/slub.c:3001
 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3088
 slab_alloc_node mm/slub.c:3179 [inline]
 slab_alloc mm/slub.c:3221 [inline]
 __kmalloc+0x303/0x320 mm/slub.c:4396
 kmalloc include/linux/slab.h:596 [inline]
 kzalloc include/linux/slab.h:721 [inline]
 tomoyo_encode2.part.0+0xe9/0x3a0 security/tomoyo/realpath.c:45
 tomoyo_encode2 security/tomoyo/realpath.c:31 [inline]
 tomoyo_encode+0x28/0x50 security/tomoyo/realpath.c:80
 tomoyo_realpath_from_path+0x186/0x620 security/tomoyo/realpath.c:288
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_path_perm+0x21b/0x400 security/tomoyo/file.c:822
 security_inode_getattr+0xcf/0x140 security/security.c:1334
 vfs_getattr fs/stat.c:157 [inline]
 vfs_statx+0x164/0x390 fs/stat.c:225
 vfs_fstatat fs/stat.c:243 [inline]
 vfs_lstat include/linux/fs.h:3356 [inline]
 __do_sys_newlstat+0x91/0x110 fs/stat.c:398
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1340 [inline]
 free_pcp_prepare+0x326/0x810 mm/page_alloc.c:1391
 free_unref_page_prepare mm/page_alloc.c:3317 [inline]
 free_unref_page+0x19/0x690 mm/page_alloc.c:3396
 __vunmap+0x781/0xb70 mm/vmalloc.c:2621
 free_work+0x58/0x70 mm/vmalloc.c:95
 process_one_work+0x9b2/0x1690 kernel/workqueue.c:2297
 worker_thread+0x658/0x11f0 kernel/workqueue.c:2444
 kthread+0x405/0x4f0 kernel/kthread.c:327
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Memory state around the buggy address:
 ffff88807b240800: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
 ffff88807b240880: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
>ffff88807b240900: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
                         ^
 ffff88807b240980: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
 ffff88807b240a00: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
==================================================================
----------------
Code disassembly (best guess), 3 bytes skipped:
   0:	b9 ff ff ff ff       	mov    $0xffffffff,%ecx
   5:	ba 08 00 00 00       	mov    $0x8,%edx
   a:	4d 8b 03             	mov    (%r11),%r8
   d:	48 0f bd ca          	bsr    %rdx,%rcx
  11:	49 8b 45 00          	mov    0x0(%r13),%rax
  15:	48 63 c9             	movslq %ecx,%rcx
  18:	e9 64 ff ff ff       	jmpq   0xffffff81
  1d:	0f 1f 00             	nopl   (%rax)
  20:	65 8b 05 69 fd 8a 7e 	mov    %gs:0x7e8afd69(%rip),%eax        # 0x7e8afd90
* 27:	89 c1                	mov    %eax,%ecx <-- trapping instruction
  29:	48 8b 34 24          	mov    (%rsp),%rsi
  2d:	81 e1 00 01 00 00    	and    $0x100,%ecx
  33:	65 48 8b 14 25 40 70 	mov    %gs:0x27040,%rdx
  3a:	02 00
  3c:	a9                   	.byte 0xa9

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/11/03 15:32 net-old db2434343b2c 4c1be0be .config console log report info ci-upstream-net-this-kasan-gce KASAN: use-after-free Read in advance_sched
2021/10/25 06:14 net-next-old 4d98bb0d7ec2 4f0000ee .config console log report info ci-upstream-net-kasan-gce KASAN: use-after-free Read in advance_sched
* Struck through repros no longer work on HEAD.