syzbot


KASAN: slab-use-after-free Read in page_pool_put_defragged_page

Status: auto-obsoleted due to no activity on 2023/09/23 20:09
Subsystems: net
[Documentation on labels]
Reported-by: syzbot+273d3aeed4bcce3c35c9@syzkaller.appspotmail.com
First crash: 608d, last: 583d

Sample crash report:
==================================================================
BUG: KASAN: slab-use-after-free in page_pool_recycle_in_ring net/core/page_pool.c:546 [inline]
BUG: KASAN: slab-use-after-free in page_pool_put_defragged_page+0x85e/0x880 net/core/page_pool.c:630
Read of size 8 at addr ffff88803bab3700 by task syz-executor.3/5959

CPU: 0 PID: 5959 Comm: syz-executor.3 Not tainted 6.4.0-rc7-syzkaller-00234-g547cc9be86f4 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/27/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xd9/0x150 lib/dump_stack.c:106
 print_address_description.constprop.0+0x2c/0x3c0 mm/kasan/report.c:351
 print_report mm/kasan/report.c:462 [inline]
 kasan_report+0x11c/0x130 mm/kasan/report.c:572
 page_pool_recycle_in_ring net/core/page_pool.c:546 [inline]
 page_pool_put_defragged_page+0x85e/0x880 net/core/page_pool.c:630
 page_pool_put_page include/net/page_pool.h:342 [inline]
 page_pool_put_full_page include/net/page_pool.h:350 [inline]
 page_pool_return_skb_page+0x1c8/0x3d0 net/core/page_pool.c:952
 skb_pp_recycle net/core/skbuff.c:896 [inline]
 skb_free_head+0x14b/0x1b0 net/core/skbuff.c:914
 skb_release_data+0x598/0x820 net/core/skbuff.c:948
 skb_release_all net/core/skbuff.c:1014 [inline]
 __kfree_skb net/core/skbuff.c:1028 [inline]
 consume_skb net/core/skbuff.c:1244 [inline]
 consume_skb+0xd2/0x170 net/core/skbuff.c:1238
 packet_recvmsg+0x9b9/0x12b0 net/packet/af_packet.c:3557
 sock_recvmsg_nosec net/socket.c:1019 [inline]
 sock_recvmsg+0xe2/0x160 net/socket.c:1040
 ____sys_recvmsg+0x210/0x5a0 net/socket.c:2722
 ___sys_recvmsg+0xf2/0x180 net/socket.c:2764
 __sys_recvmsg+0xf4/0x1c0 net/socket.c:2794
 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:0x7fc8ba28c389
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:00007fc8baf27168 EFLAGS: 00000246 ORIG_RAX: 000000000000002f
RAX: ffffffffffffffda RBX: 00007fc8ba3ac050 RCX: 00007fc8ba28c389
RDX: 0000000000000000 RSI: 00000000200012c0 RDI: 0000000000000003
RBP: 00007fc8ba2d7493 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffccf3b221f R14: 00007fc8baf27300 R15: 0000000000022000
 </TASK>

Allocated by task 5949:
 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:374 [inline]
 ____kasan_kmalloc mm/kasan/common.c:333 [inline]
 __kasan_kmalloc+0xa3/0xb0 mm/kasan/common.c:383
 kmalloc_node include/linux/slab.h:575 [inline]
 kzalloc_node include/linux/slab.h:691 [inline]
 page_pool_create+0x7c/0x6d0 net/core/page_pool.c:232
 xdp_test_run_setup net/bpf/test_run.c:179 [inline]
 bpf_test_run_xdp_live+0x1be/0x18c0 net/bpf/test_run.c:374
 bpf_prog_test_run_xdp+0xa05/0x14e0 net/bpf/test_run.c:1439
 bpf_prog_test_run kernel/bpf/syscall.c:3690 [inline]
 __sys_bpf+0x1615/0x5400 kernel/bpf/syscall.c:5090
 __do_sys_bpf kernel/bpf/syscall.c:5176 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:5174 [inline]
 __x64_sys_bpf+0x79/0xc0 kernel/bpf/syscall.c:5174
 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 32550:
 kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
 kasan_set_track+0x25/0x30 mm/kasan/common.c:52
 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:521
 ____kasan_slab_free mm/kasan/common.c:236 [inline]
 ____kasan_slab_free+0x13b/0x1a0 mm/kasan/common.c:200
 kasan_slab_free include/linux/kasan.h:162 [inline]
 __cache_free mm/slab.c:3389 [inline]
 __do_kmem_cache_free mm/slab.c:3576 [inline]
 __kmem_cache_free+0xcd/0x2c0 mm/slab.c:3583
 page_pool_free net/core/page_pool.c:792 [inline]
 page_pool_release+0xb31/0xd90 net/core/page_pool.c:830
 page_pool_release_retry+0x22/0x1f0 net/core/page_pool.c:841
 process_one_work+0x99a/0x15e0 kernel/workqueue.c:2408
 worker_thread+0x67d/0x10c0 kernel/workqueue.c:2555
 kthread+0x344/0x440 kernel/kthread.c:379
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308

Last potentially related work creation:
 kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
 __kasan_record_aux_stack+0x7b/0x90 mm/kasan/generic.c:491
 insert_work+0x48/0x360 kernel/workqueue.c:1368
 __queue_work+0x625/0x1120 kernel/workqueue.c:1529
 call_timer_fn+0x1a0/0x580 kernel/time/timer.c:1700
 expire_timers+0xbc/0x4b0 kernel/time/timer.c:1746
 __run_timers kernel/time/timer.c:2022 [inline]
 __run_timers kernel/time/timer.c:1995 [inline]
 run_timer_softirq+0x326/0x910 kernel/time/timer.c:2035
 __do_softirq+0x1d4/0x905 kernel/softirq.c:571

Second to last potentially related work creation:
 kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
 __kasan_record_aux_stack+0x7b/0x90 mm/kasan/generic.c:491
 insert_work+0x48/0x360 kernel/workqueue.c:1368
 __queue_work+0x625/0x1120 kernel/workqueue.c:1529
 call_timer_fn+0x1a0/0x580 kernel/time/timer.c:1700
 expire_timers+0xbc/0x4b0 kernel/time/timer.c:1746
 __run_timers kernel/time/timer.c:2022 [inline]
 __run_timers kernel/time/timer.c:1995 [inline]
 run_timer_softirq+0x326/0x910 kernel/time/timer.c:2035
 __do_softirq+0x1d4/0x905 kernel/softirq.c:571

The buggy address belongs to the object at ffff88803bab3000
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 1792 bytes inside of
 freed 2048-byte region [ffff88803bab3000, ffff88803bab3800)

The buggy address belongs to the physical page:
page:ffffea0000eeacc0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x3bab3
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0x1()
raw: 00fff00000000200 ffff888012440800 ffffea0000877750 ffffea0001443fd0
raw: 0000000000000000 ffff88803bab3000 0000000100000001 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 0x3420c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_COMP|__GFP_HARDWALL|__GFP_THISNODE), pid 4430, tgid 4419 (syz-executor.3), ts 3436711564967, free_ts 3431568489354
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x2db/0x350 mm/page_alloc.c:1731
 prep_new_page mm/page_alloc.c:1738 [inline]
 get_page_from_freelist+0xf41/0x2c00 mm/page_alloc.c:3502
 __alloc_pages+0x1cb/0x4a0 mm/page_alloc.c:4768
 __alloc_pages_node include/linux/gfp.h:237 [inline]
 kmem_getpages mm/slab.c:1360 [inline]
 cache_grow_begin+0x9b/0x3b0 mm/slab.c:2569
 cache_alloc_refill+0x27f/0x380 mm/slab.c:2942
 ____cache_alloc mm/slab.c:3018 [inline]
 ____cache_alloc mm/slab.c:3001 [inline]
 __do_cache_alloc mm/slab.c:3201 [inline]
 slab_alloc_node mm/slab.c:3249 [inline]
 __kmem_cache_alloc_node+0x360/0x3f0 mm/slab.c:3540
 __do_kmalloc_node mm/slab_common.c:965 [inline]
 __kmalloc+0x4e/0x190 mm/slab_common.c:979
 kmalloc include/linux/slab.h:563 [inline]
 kzalloc include/linux/slab.h:680 [inline]
 ops_init+0x16b/0x6b0 net/core/net_namespace.c:126
 setup_net+0x5d1/0xc50 net/core/net_namespace.c:339
 copy_net_ns+0x4ee/0x8e0 net/core/net_namespace.c:491
 create_new_namespaces+0x3f6/0xb20 kernel/nsproxy.c:110
 unshare_nsproxy_namespaces+0xc1/0x1f0 kernel/nsproxy.c:228
 ksys_unshare+0x449/0x920 kernel/fork.c:3441
 __do_sys_unshare kernel/fork.c:3512 [inline]
 __se_sys_unshare kernel/fork.c:3510 [inline]
 __x64_sys_unshare+0x31/0x40 kernel/fork.c:3510
 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
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1302 [inline]
 free_unref_page_prepare+0x62e/0xcb0 mm/page_alloc.c:2564
 free_unref_page+0x33/0x370 mm/page_alloc.c:2659
 slab_destroy mm/slab.c:1612 [inline]
 slabs_destroy+0x85/0xc0 mm/slab.c:1632
 cache_flusharray mm/slab.c:3360 [inline]
 ___cache_free+0x2ae/0x3d0 mm/slab.c:3423
 qlink_free mm/kasan/quarantine.c:166 [inline]
 qlist_free_all+0x4f/0x1a0 mm/kasan/quarantine.c:185
 kasan_quarantine_reduce+0x195/0x220 mm/kasan/quarantine.c:292
 __kasan_slab_alloc+0x63/0x90 mm/kasan/common.c:305
 kasan_slab_alloc include/linux/kasan.h:186 [inline]
 slab_post_alloc_hook mm/slab.h:711 [inline]
 slab_alloc_node mm/slab.c:3256 [inline]
 slab_alloc mm/slab.c:3265 [inline]
 __kmem_cache_alloc_lru mm/slab.c:3442 [inline]
 kmem_cache_alloc+0x1bd/0x3f0 mm/slab.c:3451
 getname_flags.part.0+0x50/0x4f0 fs/namei.c:140
 getname_flags include/linux/audit.h:321 [inline]
 getname+0x92/0xd0 fs/namei.c:219
 do_sys_openat2+0xf5/0x4c0 fs/open.c:1350
 do_sys_open fs/open.c:1372 [inline]
 __do_sys_openat fs/open.c:1388 [inline]
 __se_sys_openat fs/open.c:1383 [inline]
 __x64_sys_openat+0x143/0x1f0 fs/open.c:1383
 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

Memory state around the buggy address:
 ffff88803bab3600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88803bab3680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88803bab3700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff88803bab3780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88803bab3800: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/06/25 20:08 upstream 547cc9be86f4 09ffe269 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: slab-use-after-free Read in page_pool_put_defragged_page
2023/05/31 14:30 linux-next 715abedee4cd e2a77acd .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: slab-use-after-free Read in page_pool_put_defragged_page
* Struck through repros no longer work on HEAD.