syzbot


KASAN: use-after-free Write in mini_qdisc_pair_swap

Status: upstream: reported syz repro on 2023/05/19 13:51
Bug presence: origin:upstream
Labels: missing-backport
[Documentation on labels]
Reported-by: syzbot+56403acf9209de69d34b@syzkaller.appspotmail.com
First crash: 581d, last: 551d
Fix bisection: the issue occurs on the latest tested release (bisect log)
Crash: INFO: rcu detected stall in corrupted (log)
Repro: syz .config
  
Bug presence (3)
Date Name Commit Repro Result
2023/07/07 linux-6.1.y (ToT) 61fd484b2cf6 C [report] INFO: rcu detected stall in corrupted
2023/05/20 upstream (ToT) 0dd2a6fb1e34 C [report] KASAN: slab-use-after-free Write in mini_qdisc_pair_swap
2023/07/07 upstream (ToT) 5133c9e51de4 C Didn't crash
Similar bugs (5)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Write in mini_qdisc_pair_swap (2) net 24 674d 1055d 22/28 fixed on 2023/02/24 13:50
upstream KASAN: use-after-free Write in mini_qdisc_pair_swap net 1 1145d 1145d 0/28 closed as invalid on 2022/01/11 13:43
upstream KASAN: slab-out-of-bounds Read in mini_qdisc_pair_swap net 2 270d 189d 0/28 auto-obsoleted due to no activity on 2024/07/04 00:16
upstream KASAN: slab-use-after-free Read in mini_qdisc_pair_swap net 1 339d 339d 0/28 closed as invalid on 2024/02/22 14:05
upstream KASAN: slab-use-after-free Write in mini_qdisc_pair_swap net C error 76 485d 638d 23/28 fixed on 2023/09/29 02:49
Fix bisection attempts (2)
Created Duration User Patch Repo Result
2023/09/18 09:40 5h46m fix candidate upstream OK (1) job log
2023/06/19 10:00 41m bisect fix linux-6.1.y OK (0) job log log

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in mini_qdisc_pair_swap+0x1ad/0x1c0 net/sched/sch_generic.c:1573
Write of size 8 at addr ffff88805cf1db08 by task syz-executor.4/8902

CPU: 0 PID: 8902 Comm: syz-executor.4 Not tainted 6.1.29-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/28/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:284 [inline]
 print_report+0x15f/0x4f0 mm/kasan/report.c:395
 kasan_report+0x136/0x160 mm/kasan/report.c:495
 mini_qdisc_pair_swap+0x1ad/0x1c0 net/sched/sch_generic.c:1573
 tcf_chain_head_change_item net/sched/cls_api.c:390 [inline]
 tcf_chain0_head_change net/sched/cls_api.c:404 [inline]
 tcf_chain_tp_insert net/sched/cls_api.c:1679 [inline]
 tcf_chain_tp_insert_unique+0xb63/0xd50 net/sched/cls_api.c:1728
 tc_new_tfilter+0x1614/0x1a80 net/sched/cls_api.c:2106
 rtnetlink_rcv_msg+0x7c3/0xf00 net/core/rtnetlink.c:6082
 netlink_rcv_skb+0x1cd/0x410 net/netlink/af_netlink.c:2524
 netlink_unicast_kernel net/netlink/af_netlink.c:1328 [inline]
 netlink_unicast+0x7bf/0x990 net/netlink/af_netlink.c:1354
 netlink_sendmsg+0xa26/0xd60 net/netlink/af_netlink.c:1902
 sock_sendmsg_nosec net/socket.c:716 [inline]
 sock_sendmsg net/socket.c:736 [inline]
 ____sys_sendmsg+0x59e/0x8f0 net/socket.c:2482
 ___sys_sendmsg net/socket.c:2536 [inline]
 __sys_sendmmsg+0x3ab/0x730 net/socket.c:2622
 __do_sys_sendmmsg net/socket.c:2651 [inline]
 __se_sys_sendmmsg net/socket.c:2648 [inline]
 __x64_sys_sendmmsg+0x9c/0xb0 net/socket.c:2648
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f2cece8c169
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f2cedb07168 EFLAGS: 00000246 ORIG_RAX: 0000000000000133
RAX: ffffffffffffffda RBX: 00007f2cecfac120 RCX: 00007f2cece8c169
RDX: 040000000000009f RSI: 00000000200002c0 RDI: 0000000000000006
RBP: 00007f2cecee7ca1 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffedafffc1f R14: 00007f2cedb07300 R15: 0000000000022000
 </TASK>

Allocated by task 8900:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 ____kasan_kmalloc mm/kasan/common.c:374 [inline]
 __kasan_kmalloc+0x97/0xb0 mm/kasan/common.c:383
 kasan_kmalloc include/linux/kasan.h:211 [inline]
 __do_kmalloc_node mm/slab_common.c:955 [inline]
 __kmalloc_node+0xb3/0x230 mm/slab_common.c:962
 kmalloc_node include/linux/slab.h:579 [inline]
 kzalloc_node include/linux/slab.h:700 [inline]
 qdisc_alloc+0x90/0x950 net/sched/sch_generic.c:938
 qdisc_create+0x176/0x1130 net/sched/sch_api.c:1235
 tc_modify_qdisc+0xa5f/0x1c00
 rtnetlink_rcv_msg+0x776/0xf00 net/core/rtnetlink.c:6091
 netlink_rcv_skb+0x1cd/0x410 net/netlink/af_netlink.c:2524
 netlink_unicast_kernel net/netlink/af_netlink.c:1328 [inline]
 netlink_unicast+0x7bf/0x990 net/netlink/af_netlink.c:1354
 netlink_sendmsg+0xa26/0xd60 net/netlink/af_netlink.c:1902
 sock_sendmsg_nosec net/socket.c:716 [inline]
 sock_sendmsg net/socket.c:736 [inline]
 ____sys_sendmsg+0x59e/0x8f0 net/socket.c:2482
 ___sys_sendmsg net/socket.c:2536 [inline]
 __sys_sendmmsg+0x3ab/0x730 net/socket.c:2622
 __do_sys_sendmmsg net/socket.c:2651 [inline]
 __se_sys_sendmmsg net/socket.c:2648 [inline]
 __x64_sys_sendmmsg+0x9c/0xb0 net/socket.c:2648
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Freed by task 21:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_free_info+0x27/0x40 mm/kasan/generic.c:516
 ____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236
 kasan_slab_free include/linux/kasan.h:177 [inline]
 slab_free_hook mm/slub.c:1724 [inline]
 slab_free_freelist_hook mm/slub.c:1750 [inline]
 slab_free mm/slub.c:3661 [inline]
 __kmem_cache_free+0x25c/0x3c0 mm/slub.c:3674
 rcu_do_batch kernel/rcu/tree.c:2251 [inline]
 rcu_core+0xa9a/0x1790 kernel/rcu/tree.c:2511
 __do_softirq+0x2e9/0xa4c kernel/softirq.c:571

Last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xb0/0xc0 mm/kasan/generic.c:486
 call_rcu+0x163/0xa10 kernel/rcu/tree.c:2799
 qdisc_put_unlocked+0x55/0x90 net/sched/sch_generic.c:1097
 tcf_block_release net/sched/cls_api.c:1256 [inline]
 tc_new_tfilter+0x14b9/0x1a80 net/sched/cls_api.c:2169
 rtnetlink_rcv_msg+0x7c3/0xf00 net/core/rtnetlink.c:6082
 netlink_rcv_skb+0x1cd/0x410 net/netlink/af_netlink.c:2524
 netlink_unicast_kernel net/netlink/af_netlink.c:1328 [inline]
 netlink_unicast+0x7bf/0x990 net/netlink/af_netlink.c:1354
 netlink_sendmsg+0xa26/0xd60 net/netlink/af_netlink.c:1902
 sock_sendmsg_nosec net/socket.c:716 [inline]
 sock_sendmsg net/socket.c:736 [inline]
 ____sys_sendmsg+0x59e/0x8f0 net/socket.c:2482
 ___sys_sendmsg net/socket.c:2536 [inline]
 __sys_sendmmsg+0x3ab/0x730 net/socket.c:2622
 __do_sys_sendmmsg net/socket.c:2651 [inline]
 __se_sys_sendmmsg net/socket.c:2648 [inline]
 __x64_sys_sendmmsg+0x9c/0xb0 net/socket.c:2648
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Second to last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xb0/0xc0 mm/kasan/generic.c:486
 call_rcu+0x163/0xa10 kernel/rcu/tree.c:2799
 notify_and_destroy net/sched/sch_api.c:1030 [inline]
 qdisc_graft+0x113b/0x1460 net/sched/sch_api.c:1107
 tc_modify_qdisc+0xe40/0x1c00 net/sched/sch_api.c:1688
 rtnetlink_rcv_msg+0x776/0xf00 net/core/rtnetlink.c:6091
 netlink_rcv_skb+0x1cd/0x410 net/netlink/af_netlink.c:2524
 netlink_unicast_kernel net/netlink/af_netlink.c:1328 [inline]
 netlink_unicast+0x7bf/0x990 net/netlink/af_netlink.c:1354
 netlink_sendmsg+0xa26/0xd60 net/netlink/af_netlink.c:1902
 sock_sendmsg_nosec net/socket.c:716 [inline]
 sock_sendmsg net/socket.c:736 [inline]
 ____sys_sendmsg+0x59e/0x8f0 net/socket.c:2482
 ___sys_sendmsg net/socket.c:2536 [inline]
 __sys_sendmmsg+0x3ab/0x730 net/socket.c:2622
 __do_sys_sendmmsg net/socket.c:2651 [inline]
 __se_sys_sendmmsg net/socket.c:2648 [inline]
 __x64_sys_sendmmsg+0x9c/0xb0 net/socket.c:2648
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

The buggy address belongs to the object at ffff88805cf1d800
 which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 776 bytes inside of
 1024-byte region [ffff88805cf1d800, ffff88805cf1dc00)

The buggy address belongs to the physical page:
page:ffffea000173c600 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x5cf18
head:ffffea000173c600 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 dead000000000100 dead000000000122 ffff888012441dc0
raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 6908, tgid 6896 (syz-executor.0), ts 274054254620, free_ts 15611928453
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x18d/0x1b0 mm/page_alloc.c:2533
 prep_new_page mm/page_alloc.c:2540 [inline]
 get_page_from_freelist+0x32ed/0x3480 mm/page_alloc.c:4292
 __alloc_pages+0x28d/0x770 mm/page_alloc.c:5559
 alloc_slab_page+0x6a/0x150 mm/slub.c:1794
 allocate_slab mm/slub.c:1939 [inline]
 new_slab+0x84/0x2d0 mm/slub.c:1992
 ___slab_alloc+0xa71/0x1080 mm/slub.c:3180
 __slab_alloc mm/slub.c:3279 [inline]
 slab_alloc_node mm/slub.c:3364 [inline]
 __kmem_cache_alloc_node+0x19f/0x260 mm/slub.c:3437
 __do_kmalloc_node mm/slab_common.c:954 [inline]
 __kmalloc_node+0xa2/0x230 mm/slab_common.c:962
 kmalloc_node include/linux/slab.h:579 [inline]
 kzalloc_node include/linux/slab.h:700 [inline]
 qdisc_alloc+0x90/0x950 net/sched/sch_generic.c:938
 qdisc_create+0x176/0x1130 net/sched/sch_api.c:1235
 tc_modify_qdisc+0xa5f/0x1c00
 rtnetlink_rcv_msg+0x776/0xf00 net/core/rtnetlink.c:6091
 netlink_rcv_skb+0x1cd/0x410 net/netlink/af_netlink.c:2524
 netlink_unicast_kernel net/netlink/af_netlink.c:1328 [inline]
 netlink_unicast+0x7bf/0x990 net/netlink/af_netlink.c:1354
 netlink_sendmsg+0xa26/0xd60 net/netlink/af_netlink.c:1902
 sock_sendmsg_nosec net/socket.c:716 [inline]
 sock_sendmsg net/socket.c:736 [inline]
 ____sys_sendmsg+0x59e/0x8f0 net/socket.c:2482
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1460 [inline]
 free_pcp_prepare mm/page_alloc.c:1510 [inline]
 free_unref_page_prepare+0xf63/0x1120 mm/page_alloc.c:3388
 free_unref_page+0x98/0x570 mm/page_alloc.c:3484
 free_contig_range+0x9a/0x150 mm/page_alloc.c:9519
 destroy_args+0xfe/0x997 mm/debug_vm_pgtable.c:1031
 debug_vm_pgtable+0x416/0x46b mm/debug_vm_pgtable.c:1354
 do_one_initcall+0x265/0x8f0 init/main.c:1303
 do_initcall_level+0x157/0x207 init/main.c:1376
 do_initcalls+0x49/0x86 init/main.c:1392
 kernel_init_freeable+0x473/0x61f init/main.c:1631
 kernel_init+0x19/0x290 init/main.c:1519
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306

Memory state around the buggy address:
 ffff88805cf1da00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88805cf1da80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88805cf1db00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                      ^
 ffff88805cf1db80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88805cf1dc00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/05/19 13:51 linux-6.1.y fa74641fb6b9 3bb7af1d .config console log report syz [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Write in mini_qdisc_pair_swap
* Struck through repros no longer work on HEAD.