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: 248d, last: 23d
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 338d 338d 0/24 closed as invalid on 2022/01/11 13:43

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in mini_qdisc_pair_swap+0x1b9/0x1f0 net/sched/sch_generic.c:1574
Write of size 8 at addr ffff88807a407b08 by task syz-executor.5/25338

CPU: 0 PID: 25338 Comm: syz-executor.5 Not tainted 6.0.0-rc4-syzkaller-00331-g4ed9c1e971b1 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/26/2022
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:317 [inline]
 print_report.cold+0x2ba/0x719 mm/kasan/report.c:433
 kasan_report+0xb1/0x1e0 mm/kasan/report.c:495
 mini_qdisc_pair_swap+0x1b9/0x1f0 net/sched/sch_generic.c:1574
 tcf_chain_head_change_item net/sched/cls_api.c:390 [inline]
 tcf_chain0_head_change.isra.0+0xb9/0x120 net/sched/cls_api.c:404
 tcf_chain_tp_insert net/sched/cls_api.c:1678 [inline]
 tcf_chain_tp_insert_unique net/sched/cls_api.c:1727 [inline]
 tc_new_tfilter+0x1d5b/0x2200 net/sched/cls_api.c:2108
 rtnetlink_rcv_msg+0x955/0xca0 net/core/rtnetlink.c:6081
 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2501
 netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
 netlink_unicast+0x543/0x7f0 net/netlink/af_netlink.c:1345
 netlink_sendmsg+0x917/0xe10 net/netlink/af_netlink.c:1921
 sock_sendmsg_nosec net/socket.c:714 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:734
 ____sys_sendmsg+0x334/0x810 net/socket.c:2482
 ___sys_sendmsg+0x110/0x1b0 net/socket.c:2536
 __sys_sendmmsg+0x18b/0x460 net/socket.c:2622
 __do_sys_sendmmsg net/socket.c:2651 [inline]
 __se_sys_sendmmsg net/socket.c:2648 [inline]
 __x64_sys_sendmmsg+0x99/0x100 net/socket.c:2648
 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+0x63/0xcd
RIP: 0033:0x7f385f8893c9
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 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:00007f385e7fe168 EFLAGS: 00000246 ORIG_RAX: 0000000000000133
RAX: ffffffffffffffda RBX: 00007f385f99c120 RCX: 00007f385f8893c9
RDX: 040000000000009f RSI: 00000000200002c0 RDI: 0000000000000006
RBP: 00007f385f8e433f R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f385fecfb1f R14: 00007f385e7fe300 R15: 0000000000022000
 </TASK>

Allocated by task 25325:
 kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
 kasan_set_track mm/kasan/common.c:45 [inline]
 set_alloc_info mm/kasan/common.c:437 [inline]
 ____kasan_kmalloc mm/kasan/common.c:516 [inline]
 ____kasan_kmalloc mm/kasan/common.c:475 [inline]
 __kasan_kmalloc+0xa9/0xd0 mm/kasan/common.c:525
 kmalloc_node include/linux/slab.h:623 [inline]
 kzalloc_node include/linux/slab.h:744 [inline]
 qdisc_alloc+0xb0/0xc50 net/sched/sch_generic.c:938
 qdisc_create.constprop.0+0xce/0x10f0 net/sched/sch_api.c:1211
 tc_modify_qdisc+0x4c5/0x1a00 net/sched/sch_api.c:1660
 rtnetlink_rcv_msg+0x43a/0xca0 net/core/rtnetlink.c:6090
 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2501
 netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
 netlink_unicast+0x543/0x7f0 net/netlink/af_netlink.c:1345
 netlink_sendmsg+0x917/0xe10 net/netlink/af_netlink.c:1921
 sock_sendmsg_nosec net/socket.c:714 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:734
 ____sys_sendmsg+0x334/0x810 net/socket.c:2482
 ___sys_sendmsg+0x110/0x1b0 net/socket.c:2536
 __sys_sendmmsg+0x18b/0x460 net/socket.c:2622
 __do_sys_sendmmsg net/socket.c:2651 [inline]
 __se_sys_sendmmsg net/socket.c:2648 [inline]
 __x64_sys_sendmmsg+0x99/0x100 net/socket.c:2648
 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+0x63/0xcd

Freed by task 15:
 kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
 kasan_set_track+0x21/0x30 mm/kasan/common.c:45
 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370
 ____kasan_slab_free mm/kasan/common.c:367 [inline]
 ____kasan_slab_free+0x166/0x1c0 mm/kasan/common.c:329
 kasan_slab_free include/linux/kasan.h:200 [inline]
 slab_free_hook mm/slub.c:1754 [inline]
 slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1780
 slab_free mm/slub.c:3534 [inline]
 kfree+0xe2/0x580 mm/slub.c:4562
 rcu_do_batch kernel/rcu/tree.c:2245 [inline]
 rcu_core+0x7b5/0x1890 kernel/rcu/tree.c:2505
 __do_softirq+0x1d3/0x9c6 kernel/softirq.c:571

Last potentially related work creation:
 kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
 __kasan_record_aux_stack+0xbe/0xd0 mm/kasan/generic.c:348
 call_rcu+0x99/0x790 kernel/rcu/tree.c:2793
 qdisc_put_unlocked+0x6f/0x90 net/sched/sch_generic.c:1098
 tcf_block_release+0x86/0x90 net/sched/cls_api.c:1256
 tc_new_tfilter+0xa46/0x2200 net/sched/cls_api.c:2170
 rtnetlink_rcv_msg+0x955/0xca0 net/core/rtnetlink.c:6081
 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2501
 netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
 netlink_unicast+0x543/0x7f0 net/netlink/af_netlink.c:1345
 netlink_sendmsg+0x917/0xe10 net/netlink/af_netlink.c:1921
 sock_sendmsg_nosec net/socket.c:714 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:734
 ____sys_sendmsg+0x334/0x810 net/socket.c:2482
 ___sys_sendmsg+0x110/0x1b0 net/socket.c:2536
 __sys_sendmmsg+0x18b/0x460 net/socket.c:2622
 __do_sys_sendmmsg net/socket.c:2651 [inline]
 __se_sys_sendmmsg net/socket.c:2648 [inline]
 __x64_sys_sendmmsg+0x99/0x100 net/socket.c:2648
 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+0x63/0xcd

Second to last potentially related work creation:
 kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
 __kasan_record_aux_stack+0xbe/0xd0 mm/kasan/generic.c:348
 kvfree_call_rcu+0x74/0x940 kernel/rcu/tree.c:3322
 neigh_destroy+0x431/0x630 net/core/neighbour.c:912
 neigh_release include/net/neighbour.h:454 [inline]
 neigh_cleanup_and_release+0x1f8/0x330 net/core/neighbour.c:103
 neigh_periodic_work+0x612/0x9e0 net/core/neighbour.c:994
 process_one_work+0x991/0x1610 kernel/workqueue.c:2289
 worker_thread+0x665/0x1080 kernel/workqueue.c:2436
 kthread+0x2e4/0x3a0 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306

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

The buggy address belongs to the physical page:
page:ffffea0001e90000 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7a400
head:ffffea0001e90000 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 ffffea0001e07200 dead000000000002 ffff888011841dc0
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 21, tgid 21 (ksoftirqd/1), ts 78889503141, free_ts 78889217252
 prep_new_page mm/page_alloc.c:2532 [inline]
 get_page_from_freelist+0x109b/0x2ce0 mm/page_alloc.c:4283
 __alloc_pages+0x1c7/0x510 mm/page_alloc.c:5515
 alloc_pages+0x1a6/0x270 mm/mempolicy.c:2270
 alloc_slab_page mm/slub.c:1824 [inline]
 allocate_slab+0x27e/0x3d0 mm/slub.c:1969
 new_slab mm/slub.c:2029 [inline]
 ___slab_alloc+0x7f1/0xe10 mm/slub.c:3031
 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3118
 slab_alloc_node mm/slub.c:3209 [inline]
 __kmalloc_node_track_caller+0x2f2/0x380 mm/slub.c:4955
 kmalloc_reserve net/core/skbuff.c:362 [inline]
 __alloc_skb+0xd9/0x2f0 net/core/skbuff.c:434
 alloc_skb include/linux/skbuff.h:1257 [inline]
 __tcp_send_ack.part.0+0x67/0x760 net/ipv4/tcp_output.c:3955
 __tcp_send_ack net/ipv4/tcp_output.c:3987 [inline]
 tcp_send_ack+0x7d/0xa0 net/ipv4/tcp_output.c:3987
 __tcp_ack_snd_check+0x156/0x9c0 net/ipv4/tcp_input.c:5523
 tcp_rcv_established+0x1a7c/0x20e0 net/ipv4/tcp_input.c:5967
 tcp_v4_do_rcv+0x66c/0x9b0 net/ipv4/tcp_ipv4.c:1661
 tcp_v4_rcv+0x3438/0x3930 net/ipv4/tcp_ipv4.c:2078
 ip_protocol_deliver_rcu+0x9b/0x7c0 net/ipv4/ip_input.c:205
 ip_local_deliver_finish+0x2e8/0x4c0 net/ipv4/ip_input.c:233
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1449 [inline]
 free_pcp_prepare+0x5e4/0xd20 mm/page_alloc.c:1499
 free_unref_page_prepare mm/page_alloc.c:3380 [inline]
 free_unref_page+0x19/0x4d0 mm/page_alloc.c:3476
 skb_free_frag include/linux/skbuff.h:3185 [inline]
 skb_free_head+0x96/0x110 net/core/skbuff.c:660
 skb_release_data+0x5f1/0x870 net/core/skbuff.c:691
 skb_release_all net/core/skbuff.c:756 [inline]
 __kfree_skb net/core/skbuff.c:770 [inline]
 skb_attempt_defer_free+0x31c/0x400 net/core/skbuff.c:6535
 tcp_eat_recv_skb net/ipv4/tcp.c:1638 [inline]
 tcp_recvmsg_locked+0x124e/0x22c0 net/ipv4/tcp.c:2624
 tcp_recvmsg+0x113/0x620 net/ipv4/tcp.c:2670
 inet_recvmsg+0x110/0x5d0 net/ipv4/af_inet.c:850
 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+0x344/0x470 net/socket.c:1086
 call_read_iter include/linux/fs.h:2181 [inline]
 new_sync_read fs/read_write.c:389 [inline]
 vfs_read+0x7f6/0x930 fs/read_write.c:470
 ksys_read+0x1e8/0x250 fs/read_write.c:607
 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+0x63/0xcd

Memory state around the buggy address:
 ffff88807a407a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807a407a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88807a407b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                      ^
 ffff88807a407b80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807a407c00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (20):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce 2022/09/12 09:32 upstream 4ed9c1e971b1 356d8217 .config 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 log report info KASAN: use-after-free Write in mini_qdisc_pair_swap
* Struck through repros no longer work on HEAD.