Re: [syzbot] [bpf?] [net?] KASAN: slab-use-after-free Read in bq_xmit_all

From: syzbot
Date: Sun Jul 21 2024 - 09:41:12 EST


Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
general protection fault in __dev_flush

bq->count = 0
Oops: general protection fault, probably for non-canonical address 0xdffffc0003fffe01: 0000 [#1] PREEMPT SMP KASAN PTI
KASAN: probably user-memory-access in range [0x000000001ffff008-0x000000001ffff00f]
CPU: 1 PID: 6644 Comm: syz.0.358 Not tainted 6.10.0-syzkaller-11185-g2c9b3512402e-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/27/2024
RIP: 0010:__list_del include/linux/list.h:195 [inline]
RIP: 0010:__list_del_clearprev include/linux/list.h:209 [inline]
RIP: 0010:__dev_flush+0xe4/0x160 kernel/bpf/devmap.c:430
Code: b8 00 00 00 00 00 fc ff df 41 80 7c 05 00 00 49 89 c5 74 08 48 89 df e8 0a 80 3a 00 48 8b 2b 48 8d 5d 08 48 89 d8 48 c1 e8 03 <42> 80 3c 28 00 74 08 48 89 df e8 dd 80 3a 00 4c 89 23 4c 89 e0 48
RSP: 0018:ffffc90000a18af0 EFLAGS: 00010202
RAX: 0000000003fffe01 RBX: 000000001ffff008 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff88802e31a120
RBP: 000000001ffff000 R08: ffff88802e31a11f R09: 0000000000000000
R10: ffff88802e31a110 R11: ffffed1005c63424 R12: 0000000020000000
R13: dffffc0000000000 R14: ffff88802e31a100 R15: 1ffff11005c63420
FS: 0000000000000000(0000) GS:ffff8880b9500000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007efc38d06030 CR3: 000000002d8c8000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<IRQ>
xdp_do_check_flushed+0x129/0x240 net/core/filter.c:4300
__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
</IRQ>
<TASK>
asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:702
RIP: 0010:page_ext_get+0x5/0x2a0 mm/page_ext.c:518
Code: f1 49 91 ff 90 0f 0b 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 66 0f 1f 00 55 <41> 57 41 56 41 54 53 48 89 fb e8 bc 49 91 ff e8 57 40 78 ff 4c 8d
RSP: 0018:ffffc90003d6f378 EFLAGS: 00000283
RAX: 0000001e5a5649e6 RBX: ffffea00019ecd00 RCX: 0000001f7035090d
RDX: 0000000000000001 RSI: 0000000000000004 RDI: ffffea00019ecd00
RBP: 0000000000000000 R08: ffffea00019ecd37 R09: 1ffffd400033d9a6
R10: dffffc0000000000 R11: fffff9400033d9a7 R12: 0000000000000005
R13: ffffea00019ecd00 R14: 0000000000000000 R15: 0000000000000000
__reset_page_owner+0x2f/0x3f0 mm/page_owner.c:290
reset_page_owner include/linux/page_owner.h:25 [inline]
free_pages_prepare mm/page_alloc.c:1093 [inline]
free_unref_folios+0xf12/0x19c0 mm/page_alloc.c:2637
folios_put_refs+0x93a/0xa60 mm/swap.c:1024
folios_put include/linux/mm.h:1572 [inline]
folio_batch_move_lru+0x5d7/0x690 mm/swap.c:227
lru_add_drain_cpu+0x10e/0x8c0 mm/swap.c:657
lru_add_drain+0x123/0x3e0 mm/swap.c:757
exit_mmap+0x22b/0xc80 mm/mmap.c:3336
__mmput+0x115/0x380 kernel/fork.c:1343
exit_mm+0x220/0x310 kernel/exit.c:566
do_exit+0x9b2/0x27f0 kernel/exit.c:864
do_group_exit+0x207/0x2c0 kernel/exit.c:1026
get_signal+0x16a1/0x1740 kernel/signal.c:2917
arch_do_signal_or_restart+0x96/0x860 arch/x86/kernel/signal.c:310
exit_to_user_mode_loop kernel/entry/common.c:111 [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+0xc9/0x370 kernel/entry/common.c:218
do_syscall_64+0x100/0x230 arch/x86/entry/common.c:89
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7efc38b75b59
Code: Unable to access opcode bytes at 0x7efc38b75b2f.
RSP: 002b:00007efc385ff0f8 EFLAGS: 00000246 ORIG_RAX: 00000000000000ca
RAX: fffffffffffffe00 RBX: 00007efc38d05f68 RCX: 00007efc38b75b59
RDX: 0000000000000000 RSI: 0000000000000080 RDI: 00007efc38d05f68
RBP: 00007efc38d05f60 R08: 00007efc385ff6c0 R09: 00007efc385ff6c0
R10: 0000000000000000 R11: 0000000000000246 R12: 00007efc38d05f6c
R13: 000000000000000b R14: 00007fff8a519330 R15: 00007fff8a519418
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:__list_del include/linux/list.h:195 [inline]
RIP: 0010:__list_del_clearprev include/linux/list.h:209 [inline]
RIP: 0010:__dev_flush+0xe4/0x160 kernel/bpf/devmap.c:430
Code: b8 00 00 00 00 00 fc ff df 41 80 7c 05 00 00 49 89 c5 74 08 48 89 df e8 0a 80 3a 00 48 8b 2b 48 8d 5d 08 48 89 d8 48 c1 e8 03 <42> 80 3c 28 00 74 08 48 89 df e8 dd 80 3a 00 4c 89 23 4c 89 e0 48
RSP: 0018:ffffc90000a18af0 EFLAGS: 00010202
RAX: 0000000003fffe01 RBX: 000000001ffff008 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff88802e31a120
RBP: 000000001ffff000 R08: ffff88802e31a11f R09: 0000000000000000
R10: ffff88802e31a110 R11: ffffed1005c63424 R12: 0000000020000000
R13: dffffc0000000000 R14: ffff88802e31a100 R15: 1ffff11005c63420
FS: 0000000000000000(0000) GS:ffff8880b9500000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007efc38d06030 CR3: 000000002d8c8000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
0: b8 00 00 00 00 mov $0x0,%eax
5: 00 fc add %bh,%ah
7: ff (bad)
8: df 41 80 filds -0x80(%rcx)
b: 7c 05 jl 0x12
d: 00 00 add %al,(%rax)
f: 49 89 c5 mov %rax,%r13
12: 74 08 je 0x1c
14: 48 89 df mov %rbx,%rdi
17: e8 0a 80 3a 00 call 0x3a8026
1c: 48 8b 2b mov (%rbx),%rbp
1f: 48 8d 5d 08 lea 0x8(%rbp),%rbx
23: 48 89 d8 mov %rbx,%rax
26: 48 c1 e8 03 shr $0x3,%rax
* 2a: 42 80 3c 28 00 cmpb $0x0,(%rax,%r13,1) <-- trapping instruction
2f: 74 08 je 0x39
31: 48 89 df mov %rbx,%rdi
34: e8 dd 80 3a 00 call 0x3a8116
39: 4c 89 23 mov %r12,(%rbx)
3c: 4c 89 e0 mov %r12,%rax
3f: 48 rex.W


Tested on:

commit: 2c9b3512 Merge tag 'for-linus' of git://git.kernel.org..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=103033fd980000
kernel config: https://syzkaller.appspot.com/x/.config?x=f4925140c45a2a50
dashboard link: https://syzkaller.appspot.com/bug?extid=707d98c8649695eaf329
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=13eae521980000