================================================================== BUG: KASAN: stack-out-of-bounds in bpf_net_ctx_get_all_used_flush_lists include/linux/filter.h:837 [inline] BUG: KASAN: stack-out-of-bounds in xdp_do_check_flushed+0x231/0x240 net/core/filter.c:4298 Read of size 4 at addr ffffc9000445f7f8 by task syz.4.832/9295 CPU: 1 UID: 0 PID: 9295 Comm: syz.4.832 Not tainted 6.10.0-next-20240724-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/27/2024 Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:377 [inline] print_report+0x169/0x550 mm/kasan/report.c:488 kasan_report+0x143/0x180 mm/kasan/report.c:601 bpf_net_ctx_get_all_used_flush_lists include/linux/filter.h:837 [inline] xdp_do_check_flushed+0x231/0x240 net/core/filter.c:4298 __napi_poll+0xe4/0x490 net/core/dev.c:6774 napi_poll net/core/dev.c:6840 [inline] net_rx_action+0x89b/0x1240 net/core/dev.c:6962 handle_softirqs+0x2c4/0x970 kernel/softirq.c:554 __do_softirq kernel/softirq.c:588 [inline] invoke_softirq kernel/softirq.c:428 [inline] __irq_exit_rcu+0xf4/0x1c0 kernel/softirq.c:637 irq_exit_rcu+0x9/0x30 kernel/softirq.c:649 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1043 [inline] sysvec_apic_timer_interrupt+0xa6/0xc0 arch/x86/kernel/apic/apic.c:1043 asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:702 RIP: 0010:finish_task_switch+0x1ea/0x870 kernel/sched/core.c:5113 Code: c9 50 e8 39 b8 0b 00 48 83 c4 08 4c 89 f7 e8 dd 38 00 00 cc de 04 00 00 4c 89 f7 e8 60 80 3a 0a e8 fb 85 37 00 fb 48 8b 5d c0 <48> 8d bb f8 15 00 00 48 89 f8 48 c1 e8 03 49 be 00 00 00 00 00 fc RSP: 0018:ffffc9000445f668 EFLAGS: 00000286 RAX: d263a0c279a24200 RBX: ffff888028f43c00 RCX: ffffffff94803903 RDX: dffffc0000000000 RSI: ffffffff8bcad540 RDI: ffffffff8c2078c0 RBP: ffffc9000445f6b0 R08: ffffffff8faf9baf R09: 1ffffffff1f5f375 R10: dffffc0000000000 R11: fffffbfff1f5f376 R12: 1ffff110172a7ef3 R13: dffffc0000000000 R14: ffff8880b943ea00 R15: ffff8880b953f798 context_switch kernel/sched/core.c:5242 [inline] __schedule+0x1808/0x4a60 kernel/sched/core.c:6603 __schedule_loop kernel/sched/core.c:6680 [inline] schedule+0x14b/0x320 kernel/sched/core.c:6695 schedule_timeout+0xb0/0x310 kernel/time/timer.c:2557 do_wait_for_common kernel/sched/completion.c:95 [inline] __wait_for_common kernel/sched/completion.c:116 [inline] wait_for_common kernel/sched/completion.c:127 [inline] wait_for_completion_interruptible+0x3a8/0x6a0 kernel/sched/completion.c:216 raw_process_ep0_io+0x3cb/0x8f0 drivers/usb/gadget/legacy/raw_gadget.c:735 raw_ioctl_ep0_write drivers/usb/gadget/legacy/raw_gadget.c:766 [inline] raw_ioctl+0x223f/0x3cd0 drivers/usb/gadget/legacy/raw_gadget.c:1312 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:907 [inline] __se_sys_ioctl+0xfc/0x170 fs/ioctl.c:893 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f958db75b1b Code: 00 48 89 44 24 18 31 c0 48 8d 44 24 60 c7 04 24 10 00 00 00 48 89 44 24 08 48 8d 44 24 20 48 89 44 24 10 b8 10 00 00 00 0f 05 <89> c2 3d 00 f0 ff ff 77 1c 48 8b 44 24 18 64 48 2b 04 25 28 00 00 RSP: 002b:00007f958e8e0f20 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 0000000000000008 RCX: 00007f958db75b1b RDX: 00007f958e8e0fe0 RSI: 0000000040085503 RDI: 0000000000000008 RBP: 00007f958e8e1ff0 R08: 0000000000000080 R09: 00007f958e8e0fe8 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000080085502 R13: 0000000800000000 R14: 0000000000000012 R15: 00007f958dbecafa The buggy address belongs to stack of task syz.4.832/9295 and is located at offset 88 in frame: __schedule+0x0/0x4a60 This frame has 4 objects: [32, 56) 'ac.i' [96, 100) 'cid.i.i.i' [112, 120) 'flags.i.i.i' [144, 160) 'rf' The buggy address belongs to the virtual mapping at [ffffc90004458000, ffffc90004461000) created by: copy_process+0x5d1/0x3d90 kernel/fork.c:2206 The buggy address belongs to the physical page: page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x3f pfn:0x5fbff memcg:ffff88802dbe1202 flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000000000 0000000000000000 dead000000000122 0000000000000000 raw: 000000000000003f 0000000000000000 00000001ffffffff ffff88802dbe1202 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 0, migratetype Unmovable, gfp_mask 0x102dc2(GFP_HIGHUSER|__GFP_NOWARN|__GFP_ZERO), pid 9279, tgid 9279 (syz.4.828), ts 466420482703, free_ts 465614445012 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x1f3/0x230 mm/page_alloc.c:1493 prep_new_page mm/page_alloc.c:1501 [inline] get_page_from_freelist+0x2e4c/0x2f10 mm/page_alloc.c:3438 __alloc_pages_noprof+0x256/0x6c0 mm/page_alloc.c:4696 alloc_pages_mpol_noprof+0x3e8/0x680 mm/mempolicy.c:2263 vm_area_alloc_pages mm/vmalloc.c:3584 [inline] __vmalloc_area_node mm/vmalloc.c:3660 [inline] __vmalloc_node_range_noprof+0x971/0x1460 mm/vmalloc.c:3841 alloc_thread_stack_node kernel/fork.c:314 [inline] dup_task_struct+0x444/0x8c0 kernel/fork.c:1115 copy_process+0x5d1/0x3d90 kernel/fork.c:2206 kernel_clone+0x226/0x8f0 kernel/fork.c:2788 __do_sys_clone3 kernel/fork.c:3092 [inline] __se_sys_clone3+0x2cb/0x350 kernel/fork.c:3071 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f page last free pid 8601 tgid 8601 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1094 [inline] free_unref_folios+0x103a/0x1b00 mm/page_alloc.c:2656 folios_put_refs+0x76e/0x860 mm/swap.c:1039 folio_batch_release include/linux/pagevec.h:101 [inline] truncate_inode_pages_range+0x47b/0xfc0 mm/truncate.c:346 kill_bdev block/bdev.c:90 [inline] blkdev_flush_mapping+0x108/0x250 block/bdev.c:664 blkdev_put_whole block/bdev.c:671 [inline] bdev_release+0x466/0x700 block/bdev.c:1096 blkdev_release+0x15/0x20 block/fops.c:638 __fput+0x24a/0x8a0 fs/file_table.c:422 task_work_run+0x24f/0x310 kernel/task_work.c:222 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline] exit_to_user_mode_loop kernel/entry/common.c:114 [inline] exit_to_user_mode_prepare include/linux/entry-common.h:328 [inline] __syscall_exit_to_user_mode_work kernel/entry/common.c:207 [inline] syscall_exit_to_user_mode+0x168/0x370 kernel/entry/common.c:218 do_syscall_64+0x100/0x230 arch/x86/entry/common.c:89 entry_SYSCALL_64_after_hwframe+0x77/0x7f Memory state around the buggy address: ffffc9000445f680: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffffc9000445f700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffffc9000445f780: 00 00 00 00 f1 f1 f1 f1 00 00 00 f2 f2 f2 f2 f2 ^ ffffc9000445f800: 04 f2 00 f2 f2 f2 00 00 f3 f3 f3 f3 00 00 00 00 ffffc9000445f880: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ================================================================== ---------------- Code disassembly (best guess): 0: c9 leave 1: 50 push %rax 2: e8 39 b8 0b 00 call 0xbb840 7: 48 83 c4 08 add $0x8,%rsp b: 4c 89 f7 mov %r14,%rdi e: e8 dd 38 00 00 call 0x38f0 13: cc int3 14: de 04 00 fiadds (%rax,%rax,1) 17: 00 4c 89 f7 add %cl,-0x9(%rcx,%rcx,4) 1b: e8 60 80 3a 0a call 0xa3a8080 20: e8 fb 85 37 00 call 0x378620 25: fb sti 26: 48 8b 5d c0 mov -0x40(%rbp),%rbx * 2a: 48 8d bb f8 15 00 00 lea 0x15f8(%rbx),%rdi <-- trapping instruction 31: 48 89 f8 mov %rdi,%rax 34: 48 c1 e8 03 shr $0x3,%rax 38: 49 rex.WB 39: be 00 00 00 00 mov $0x0,%esi 3e: 00 fc add %bh,%ah