syzbot


KASAN: use-after-free Write in mini_qdisc_pair_swap (2)

Status: internal: reported on 2022/01/31 05:52
Reported-by: syzbot+@syzkaller.appspotmail.com
Fix commit: 04c2a47ffb13 net: sched: fix use-after-free in tc_new_tfilter()
Patched on: [ci-qemu-upstream ci-qemu-upstream-386 ci-qemu2-arm32 ci-qemu2-arm64 ci-qemu2-arm64-compat ci-qemu2-arm64-mte ci-upstream-bpf-kasan-gce ci-upstream-bpf-next-kasan-gce ci-upstream-gce-arm64 ci-upstream-gce-leak ci-upstream-kasan-gce ci-upstream-kasan-gce-386 ci-upstream-kasan-gce-root ci-upstream-kasan-gce-selinux-root ci-upstream-kasan-gce-smack-root ci-upstream-kmsan-gce ci-upstream-kmsan-gce-386 ci-upstream-linux-next-kasan-gce-root ci-upstream-net-kasan-gce ci-upstream-net-this-kasan-gce ci2-upstream-fs ci2-upstream-kcsan-gce ci2-upstream-usb], missing on: [ci-qemu2-riscv64]
First crash: 370d, last: 37d
similar bugs (1):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Write in mini_qdisc_pair_swap 1 461d 461d 0/24 closed as invalid on 2022/01/11 13:43

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in mini_qdisc_pair_swap+0x1bd/0x1f0 net/sched/sch_generic.c:1573
Write of size 8 at addr ffff888021019b08 by task syz-executor.3/26681

CPU: 1 PID: 26681 Comm: syz-executor.3 Not tainted 6.2.0-rc1-syzkaller-00043-g2258c2dc850b #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xd1/0x138 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:306 [inline]
 print_report+0x15e/0x45d mm/kasan/report.c:417
 kasan_report+0xbf/0x1f0 mm/kasan/report.c:517
 mini_qdisc_pair_swap+0x1bd/0x1f0 net/sched/sch_generic.c:1573
 tcf_chain_head_change_item net/sched/cls_api.c:391 [inline]
 tcf_chain0_head_change.isra.0+0xb9/0x120 net/sched/cls_api.c:405
 tcf_chain_tp_insert net/sched/cls_api.c:1679 [inline]
 tcf_chain_tp_insert_unique net/sched/cls_api.c:1728 [inline]
 tc_new_tfilter+0x1d7b/0x2220 net/sched/cls_api.c:2111
 rtnetlink_rcv_msg+0x959/0xca0 net/core/rtnetlink.c:6132
 netlink_rcv_skb+0x165/0x440 net/netlink/af_netlink.c:2564
 netlink_unicast_kernel net/netlink/af_netlink.c:1330 [inline]
 netlink_unicast+0x547/0x7f0 net/netlink/af_netlink.c:1356
 netlink_sendmsg+0x91b/0xe10 net/netlink/af_netlink.c:1932
 sock_sendmsg_nosec net/socket.c:714 [inline]
 sock_sendmsg+0xd3/0x120 net/socket.c:734
 ____sys_sendmsg+0x334/0x8c0 net/socket.c:2476
 ___sys_sendmsg+0x110/0x1b0 net/socket.c:2530
 __sys_sendmmsg+0x18f/0x460 net/socket.c:2616
 __do_sys_sendmmsg net/socket.c:2645 [inline]
 __se_sys_sendmmsg net/socket.c:2642 [inline]
 __x64_sys_sendmmsg+0x9d/0x100 net/socket.c:2642
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7fdc0c08c0a9
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:00007fdc0ce95168 EFLAGS: 00000246 ORIG_RAX: 0000000000000133
RAX: ffffffffffffffda RBX: 00007fdc0c1ac050 RCX: 00007fdc0c08c0a9
RDX: 040000000000009f RSI: 00000000200002c0 RDI: 000000000000000d
RBP: 00007fdc0c0e7ae9 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007fdc0c2cfb1f R14: 00007fdc0ce95300 R15: 0000000000022000
 </TASK>

Allocated by task 26670:
 kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
 kasan_set_track+0x25/0x30 mm/kasan/common.c:52
 ____kasan_kmalloc mm/kasan/common.c:371 [inline]
 ____kasan_kmalloc mm/kasan/common.c:330 [inline]
 __kasan_kmalloc+0xa5/0xb0 mm/kasan/common.c:380
 kasan_kmalloc include/linux/kasan.h:211 [inline]
 __do_kmalloc_node mm/slab_common.c:968 [inline]
 __kmalloc_node+0x5d/0xd0 mm/slab_common.c:975
 kmalloc_node include/linux/slab.h:610 [inline]
 kzalloc_node include/linux/slab.h:731 [inline]
 qdisc_alloc+0xb0/0xb00 net/sched/sch_generic.c:938
 qdisc_create+0xce/0x1170 net/sched/sch_api.c:1231
 tc_modify_qdisc+0x479/0x19a0 net/sched/sch_api.c:1673
 rtnetlink_rcv_msg+0x43e/0xca0 net/core/rtnetlink.c:6141
 netlink_rcv_skb+0x165/0x440 net/netlink/af_netlink.c:2564
 netlink_unicast_kernel net/netlink/af_netlink.c:1330 [inline]
 netlink_unicast+0x547/0x7f0 net/netlink/af_netlink.c:1356
 netlink_sendmsg+0x91b/0xe10 net/netlink/af_netlink.c:1932
 sock_sendmsg_nosec net/socket.c:714 [inline]
 sock_sendmsg+0xd3/0x120 net/socket.c:734
 ____sys_sendmsg+0x334/0x8c0 net/socket.c:2476
 ___sys_sendmsg+0x110/0x1b0 net/socket.c:2530
 __sys_sendmmsg+0x18f/0x460 net/socket.c:2616
 __do_sys_sendmmsg net/socket.c:2645 [inline]
 __se_sys_sendmmsg net/socket.c:2642 [inline]
 __x64_sys_sendmmsg+0x9d/0x100 net/socket.c:2642
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Freed by task 8962:
 kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
 kasan_set_track+0x25/0x30 mm/kasan/common.c:52
 kasan_save_free_info+0x2e/0x40 mm/kasan/generic.c:518
 ____kasan_slab_free mm/kasan/common.c:236 [inline]
 ____kasan_slab_free+0x160/0x1c0 mm/kasan/common.c:200
 kasan_slab_free include/linux/kasan.h:177 [inline]
 slab_free_hook mm/slub.c:1781 [inline]
 slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1807
 slab_free mm/slub.c:3787 [inline]
 __kmem_cache_free+0xaf/0x3b0 mm/slub.c:3800
 rcu_do_batch kernel/rcu/tree.c:2246 [inline]
 rcu_core+0x81f/0x1980 kernel/rcu/tree.c:2506
 __do_softirq+0x1fb/0xadc kernel/softirq.c:571

Last potentially related work creation:
 kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:488
 __call_rcu_common.constprop.0+0x99/0x820 kernel/rcu/tree.c:2755
 qdisc_put_unlocked+0x73/0x90 net/sched/sch_generic.c:1097
 tcf_block_release+0x86/0x90 net/sched/cls_api.c:1257
 tc_new_tfilter+0xa27/0x2220 net/sched/cls_api.c:2176
 rtnetlink_rcv_msg+0x959/0xca0 net/core/rtnetlink.c:6132
 netlink_rcv_skb+0x165/0x440 net/netlink/af_netlink.c:2564
 netlink_unicast_kernel net/netlink/af_netlink.c:1330 [inline]
 netlink_unicast+0x547/0x7f0 net/netlink/af_netlink.c:1356
 netlink_sendmsg+0x91b/0xe10 net/netlink/af_netlink.c:1932
 sock_sendmsg_nosec net/socket.c:714 [inline]
 sock_sendmsg+0xd3/0x120 net/socket.c:734
 ____sys_sendmsg+0x334/0x8c0 net/socket.c:2476
 ___sys_sendmsg+0x110/0x1b0 net/socket.c:2530
 __sys_sendmmsg+0x18f/0x460 net/socket.c:2616
 __do_sys_sendmmsg net/socket.c:2645 [inline]
 __se_sys_sendmmsg net/socket.c:2642 [inline]
 __x64_sys_sendmmsg+0x9d/0x100 net/socket.c:2642
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Second to last potentially related work creation:
 kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:488
 kvfree_call_rcu+0x78/0x8f0 kernel/rcu/tree.c:3376
 put_css_set_locked kernel/cgroup/cgroup.c:995 [inline]
 put_css_set_locked+0xaa0/0x1000 kernel/cgroup/cgroup.c:961
 cgroup_migrate_finish+0x189/0x650 kernel/cgroup/cgroup.c:2713
 cgroup_attach_task+0x42d/0x880 kernel/cgroup/cgroup.c:2912
 cgroup_attach_task_all+0xe0/0x140 kernel/cgroup/cgroup-v1.c:70
 kvm_vm_worker_thread+0xe1/0x5a0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:6081
 kthread+0x2e8/0x3a0 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308

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

The buggy address belongs to the physical page:
page:ffffea0000840600 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x21018
head:ffffea0000840600 order:3 compound_mapcount:0 subpages_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 ffff888012441dc0 ffffea0000600400 dead000000000002
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 0xd2a20(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 5063, tgid 5063 (syz-fuzzer), ts 142848741643, free_ts 142565722150
 prep_new_page mm/page_alloc.c:2531 [inline]
 get_page_from_freelist+0x119c/0x2ce0 mm/page_alloc.c:4283
 __alloc_pages+0x1cb/0x5b0 mm/page_alloc.c:5549
 alloc_pages+0x1aa/0x270 mm/mempolicy.c:2286
 alloc_slab_page mm/slub.c:1851 [inline]
 allocate_slab+0x25f/0x350 mm/slub.c:1998
 new_slab mm/slub.c:2051 [inline]
 ___slab_alloc+0xa91/0x1400 mm/slub.c:3193
 __slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3292
 __slab_alloc_node mm/slub.c:3345 [inline]
 slab_alloc_node mm/slub.c:3442 [inline]
 __kmem_cache_alloc_node+0x1a4/0x430 mm/slub.c:3491
 __do_kmalloc_node mm/slab_common.c:967 [inline]
 __kmalloc_node_track_caller+0x4b/0xc0 mm/slab_common.c:988
 kmalloc_reserve net/core/skbuff.c:492 [inline]
 __alloc_skb+0xe9/0x310 net/core/skbuff.c:565
 alloc_skb include/linux/skbuff.h:1270 [inline]
 __tcp_send_ack.part.0+0x67/0x760 net/ipv4/tcp_output.c:3957
 __tcp_send_ack net/ipv4/tcp_output.c:3989 [inline]
 tcp_send_ack+0x81/0xa0 net/ipv4/tcp_output.c:3989
 __tcp_cleanup_rbuf+0x356/0x470 net/ipv4/tcp.c:1617
 tcp_recvmsg_locked+0x72c/0x22b0 net/ipv4/tcp.c:2649
 tcp_recvmsg+0x117/0x620 net/ipv4/tcp.c:2679
 inet_recvmsg+0x114/0x5e0 net/ipv4/af_inet.c:861
 sock_recvmsg_nosec net/socket.c:995 [inline]
 sock_recvmsg net/socket.c:1013 [inline]
 sock_recvmsg net/socket.c:1009 [inline]
 sock_read_iter+0x348/0x480 net/socket.c:1086
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1446 [inline]
 free_pcp_prepare+0x65c/0xc00 mm/page_alloc.c:1496
 free_unref_page_prepare mm/page_alloc.c:3369 [inline]
 free_unref_page+0x1d/0x490 mm/page_alloc.c:3464
 __unfreeze_partials+0x17c/0x1a0 mm/slub.c:2637
 qlink_free mm/kasan/quarantine.c:168 [inline]
 qlist_free_all+0x6a/0x170 mm/kasan/quarantine.c:187
 kasan_quarantine_reduce+0x192/0x220 mm/kasan/quarantine.c:294
 __kasan_slab_alloc+0x66/0x90 mm/kasan/common.c:302
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook mm/slab.h:761 [inline]
 slab_alloc_node mm/slub.c:3452 [inline]
 kmem_cache_alloc_node+0x1f1/0x460 mm/slub.c:3497
 __alloc_skb+0x216/0x310 net/core/skbuff.c:552
 alloc_skb_fclone include/linux/skbuff.h:1320 [inline]
 tcp_stream_alloc_skb+0x3c/0x580 net/ipv4/tcp.c:862
 tcp_sendmsg_locked+0xc47/0x2950 net/ipv4/tcp.c:1325
 tcp_sendmsg+0x2f/0x50 net/ipv4/tcp.c:1483
 inet_sendmsg+0x9d/0xe0 net/ipv4/af_inet.c:827
 sock_sendmsg_nosec net/socket.c:714 [inline]
 sock_sendmsg+0xd3/0x120 net/socket.c:734
 sock_write_iter+0x295/0x3d0 net/socket.c:1108
 call_write_iter include/linux/fs.h:2186 [inline]
 new_sync_write fs/read_write.c:491 [inline]
 vfs_write+0x9ed/0xdd0 fs/read_write.c:584
 ksys_write+0x1ec/0x250 fs/read_write.c:637

Memory state around the buggy address:
 ffff888021019a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888021019a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888021019b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                      ^
 ffff888021019b80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888021019c00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (22):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets Title
ci-upstream-kasan-gce 2022/12/30 09:32 upstream 2258c2dc850b 44712fbc .config console log report info [disk image] [vmlinux] [kernel image] KASAN: use-after-free Write in mini_qdisc_pair_swap
ci-upstream-kasan-gce 2022/11/12 18:20 upstream 8f2975c2bb4c 3ead01ad .config console log report info [disk image] [vmlinux] [kernel image] KASAN: use-after-free Write in mini_qdisc_pair_swap
ci-upstream-kasan-gce 2022/09/12 09:32 upstream 4ed9c1e971b1 356d8217 .config console log report info KASAN: use-after-free Write in mini_qdisc_pair_swap
ci-upstream-kasan-gce 2022/08/10 01:44 upstream 200e340f2196 c2a623d6 .config console log report info KASAN: use-after-free Write in mini_qdisc_pair_swap
ci-upstream-kasan-gce 2022/07/26 18:23 upstream 5de64d44968e 279b89c2 .config console log report info KASAN: use-after-free Write in mini_qdisc_pair_swap
ci-upstream-kasan-gce 2022/06/03 03:12 upstream 50fd82b3a9a9 5783034f .config console log report info KASAN: use-after-free Write in mini_qdisc_pair_swap
ci-upstream-kasan-gce 2022/05/29 03:11 upstream 9d004b2f4fea a46af346 .config console log report info KASAN: use-after-free Write in mini_qdisc_pair_swap
ci-upstream-kasan-gce 2022/05/20 02:16 upstream b015dcd62b86 cb1ac2e7 .config console log report info KASAN: use-after-free Write in mini_qdisc_pair_swap
ci-upstream-kasan-gce 2022/05/14 02:32 upstream ec7f49619d8e 107f6434 .config console log report info KASAN: use-after-free Write in mini_qdisc_pair_swap
ci-upstream-net-this-kasan-gce 2022/02/03 00:13 net 3aa430d33b8d 4ebb2798 .config console log report info KASAN: use-after-free Write in mini_qdisc_pair_swap
ci-upstream-net-kasan-gce 2022/06/19 14:10 net-next 9776fe0f424b 8f633d84 .config console log report info KASAN: use-after-free Write in mini_qdisc_pair_swap
ci-upstream-net-kasan-gce 2022/06/18 02:53 net-next 4875d94c69d5 cb58b3b2 .config console log report info KASAN: use-after-free Write in mini_qdisc_pair_swap
ci-upstream-net-kasan-gce 2022/06/11 15:38 net-next e10b02ee5b6c 0d5abf15 .config console log report info KASAN: use-after-free Write in mini_qdisc_pair_swap
ci-upstream-net-kasan-gce 2022/06/01 00:31 net-next 7e062cda7d90 3666edfe .config console log report info KASAN: use-after-free Write in mini_qdisc_pair_swap
ci-upstream-net-kasan-gce 2022/05/06 07:01 net-next 949dfdcf343c efeff0a5 .config console log report info KASAN: use-after-free Write in mini_qdisc_pair_swap
ci-upstream-net-kasan-gce 2022/05/05 09:39 net-next fa728505f3e7 02ba4ad6 .config console log report info KASAN: use-after-free Write in mini_qdisc_pair_swap
ci-upstream-net-kasan-gce 2022/05/04 04:42 net-next 2201124dbbad dc9e5259 .config console log report info KASAN: use-after-free Write in mini_qdisc_pair_swap
ci-upstream-net-kasan-gce 2022/05/03 21:22 net-next 2b68abf93365 dc9e5259 .config console log report info KASAN: use-after-free Write in mini_qdisc_pair_swap
ci-upstream-net-kasan-gce 2022/04/28 09:29 net-next 03fa8fc93e44 8a1f1f07 .config console log report info KASAN: use-after-free Write in mini_qdisc_pair_swap
ci-upstream-net-kasan-gce 2022/04/27 22:09 net-next 03fa8fc93e44 8a1f1f07 .config console log report info KASAN: use-after-free Write in mini_qdisc_pair_swap
ci-upstream-net-kasan-gce 2022/04/06 12:11 net-next 0b5c21bbc01e 86b4b7f8 .config console log report info KASAN: use-after-free Write in mini_qdisc_pair_swap
ci-upstream-net-kasan-gce 2022/01/31 05:51 net-next ff58831fa02d 495e00c5 .config console log report info KASAN: use-after-free Write in mini_qdisc_pair_swap
* Struck through repros no longer work on HEAD.