* [syzbot] [net?] [bpf?] general protection fault in bq_flush_to_queue (2)
@ 2025-12-08 8:58 syzbot
2025-12-16 3:10 ` [PATCH] bpf: Fix NULL deref in __list_del_clearprev for flush_node donglaipang
0 siblings, 1 reply; 5+ messages in thread
From: syzbot @ 2025-12-08 8:58 UTC (permalink / raw)
To: andrii, ast, bpf, daniel, davem, eddyz87, haoluo, hawk,
john.fastabend, jolsa, kpsingh, kuba, linux-kernel, martin.lau,
netdev, sdf, song, syzkaller-bugs, yonghong.song
Hello,
syzbot found the following issue on:
HEAD commit: aa833fc394ba drm/xe: Fix duplicated put due to merge resol..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=12f27cc2580000
kernel config: https://syzkaller.appspot.com/x/.config?x=bb66b4eefaf3f448
dashboard link: https://syzkaller.appspot.com/bug?extid=2b3391f44313b3983e91
compiler: Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=148d701a580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=166e7192580000
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/262740328d6d/disk-aa833fc3.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/bf629be0ab14/vmlinux-aa833fc3.xz
kernel image: https://storage.googleapis.com/syzbot-assets/b71e61abc00a/bzImage-aa833fc3.xz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+2b3391f44313b3983e91@syzkaller.appspotmail.com
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] SMP KASAN PTI
KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
CPU: 0 UID: 0 PID: 6085 Comm: syz.0.18 Not tainted syzkaller #0 PREEMPT_{RT,(full)}
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/25/2025
RIP: 0010:__list_del include/linux/list.h:204 [inline]
RIP: 0010:__list_del_clearprev include/linux/list.h:217 [inline]
RIP: 0010:bq_flush_to_queue+0x46f/0x580 kernel/bpf/cpumap.c:740
Code: 35 00 4d 8b 26 4d 8d 74 24 08 4c 89 f0 48 c1 e8 03 42 80 3c 38 00 74 08 4c 89 f7 e8 0b f2 35 00 49 89 1e 48 89 d8 48 c1 e8 03 <42> 80 3c 38 00 74 08 48 89 df e8 f2 f1 35 00 4c 89 23 48 8b 04 24
RSP: 0018:ffffc90004207650 EFLAGS: 00010246
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: 0000000000000001 RSI: 0000000000000004 RDI: 00000000ffffffff
RBP: ffff888030b0c400 R08: ffff888024b2802b R09: 1ffff11004965005
R10: dffffc0000000000 R11: ffffed1004965006 R12: ffffc90003ad79e0
R13: 0000000000000008 R14: ffffc90003ad79e8 R15: dffffc0000000000
FS: 00007f6b36bed6c0(0000) GS:ffff888126d5e000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f6b36becf98 CR3: 000000003f6c6000 CR4: 00000000003526f0
Call Trace:
<TASK>
__cpu_map_flush+0x5d/0xd0 kernel/bpf/cpumap.c:808
xdp_do_flush+0x13c/0x1d0 net/core/filter.c:4348
xdp_test_run_batch net/bpf/test_run.c:348 [inline]
bpf_test_run_xdp_live+0x154f/0x1b20 net/bpf/test_run.c:379
bpf_prog_test_run_xdp+0x7c0/0x10e0 net/bpf/test_run.c:1388
bpf_prog_test_run+0x2cd/0x340 kernel/bpf/syscall.c:4703
__sys_bpf+0x562/0x860 kernel/bpf/syscall.c:6182
__do_sys_bpf kernel/bpf/syscall.c:6274 [inline]
__se_sys_bpf kernel/bpf/syscall.c:6272 [inline]
__x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:6272
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xfa/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f6b3759f749
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 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f6b36bed038 EFLAGS: 00000246 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 00007f6b377f6090 RCX: 00007f6b3759f749
RDX: 0000000000000050 RSI: 0000200000000000 RDI: 000000000000000a
RBP: 00007f6b37623f91 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f6b377f6128 R14: 00007f6b377f6090 R15: 00007ffda92d99b8
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:__list_del include/linux/list.h:204 [inline]
RIP: 0010:__list_del_clearprev include/linux/list.h:217 [inline]
RIP: 0010:bq_flush_to_queue+0x46f/0x580 kernel/bpf/cpumap.c:740
Code: 35 00 4d 8b 26 4d 8d 74 24 08 4c 89 f0 48 c1 e8 03 42 80 3c 38 00 74 08 4c 89 f7 e8 0b f2 35 00 49 89 1e 48 89 d8 48 c1 e8 03 <42> 80 3c 38 00 74 08 48 89 df e8 f2 f1 35 00 4c 89 23 48 8b 04 24
RSP: 0018:ffffc90004207650 EFLAGS: 00010246
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: 0000000000000001 RSI: 0000000000000004 RDI: 00000000ffffffff
RBP: ffff888030b0c400 R08: ffff888024b2802b R09: 1ffff11004965005
R10: dffffc0000000000 R11: ffffed1004965006 R12: ffffc90003ad79e0
R13: 0000000000000008 R14: ffffc90003ad79e8 R15: dffffc0000000000
FS: 00007f6b36bed6c0(0000) GS:ffff888126d5e000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f6b36becf98 CR3: 000000003f6c6000 CR4: 00000000003526f0
----------------
Code disassembly (best guess):
0: 35 00 4d 8b 26 xor $0x268b4d00,%eax
5: 4d 8d 74 24 08 lea 0x8(%r12),%r14
a: 4c 89 f0 mov %r14,%rax
d: 48 c1 e8 03 shr $0x3,%rax
11: 42 80 3c 38 00 cmpb $0x0,(%rax,%r15,1)
16: 74 08 je 0x20
18: 4c 89 f7 mov %r14,%rdi
1b: e8 0b f2 35 00 call 0x35f22b
20: 49 89 1e mov %rbx,(%r14)
23: 48 89 d8 mov %rbx,%rax
26: 48 c1 e8 03 shr $0x3,%rax
* 2a: 42 80 3c 38 00 cmpb $0x0,(%rax,%r15,1) <-- trapping instruction
2f: 74 08 je 0x39
31: 48 89 df mov %rbx,%rdi
34: e8 f2 f1 35 00 call 0x35f22b
39: 4c 89 23 mov %r12,(%rbx)
3c: 48 8b 04 24 mov (%rsp),%rax
---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.
syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.
If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)
If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report
If you want to undo deduplication, reply with:
#syz undup
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] bpf: Fix NULL deref in __list_del_clearprev for flush_node
2025-12-08 8:58 [syzbot] [net?] [bpf?] general protection fault in bq_flush_to_queue (2) syzbot
@ 2025-12-16 3:10 ` donglaipang
2025-12-16 3:34 ` bot+bpf-ci
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: donglaipang @ 2025-12-16 3:10 UTC (permalink / raw)
To: syzbot+2b3391f44313b3983e91
Cc: andrii, ast, bpf, daniel, davem, eddyz87, haoluo, hawk,
john.fastabend, jolsa, kpsingh, kuba, linux-kernel, martin.lau,
netdev, sdf, song, syzkaller-bugs, yonghong.song, DLpang
From: DLpang <donglaipang@126.com>
#syz test
Hi,
This patch fixes a NULL pointer dereference in the BPF subsystem that occurs
when __list_del_clearprev() is called on an already-cleared flush_node list_head.
The fix includes two parts:
1. Properly initialize the flush_node list_head during per-CPU bulk queue allocation
using INIT_LIST_HEAD(&bq->flush_node)
2. Add defensive checks before calling __list_del_clearprev() to ensure the node
is actually in the list by checking if (bq->flush_node.prev)
According to the __list_del_clearprev documentation in include/linux/list.h,
'The code that uses this needs to check the node 'prev' pointer instead of calling list_empty()'.
This patch fixes the following syzbot-reported issue:
https://syzkaller.appspot.com/bug?extid=2b3391f44313b3983e91
Reported-by: syzbot+2b3391f44313b3983e91@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=2b3391f44313b3983e91
Signed-off-by: DLpang <donglaipang@126.com>
---
kernel/bpf/cpumap.c | 4 +++-
kernel/bpf/devmap.c | 3 ++-
net/xdp/xsk.c | 3 ++-
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c
index 703e5df1f4ef..248336df591a 100644
--- a/kernel/bpf/cpumap.c
+++ b/kernel/bpf/cpumap.c
@@ -450,6 +450,7 @@ __cpu_map_entry_alloc(struct bpf_map *map, struct bpf_cpumap_val *value,
for_each_possible_cpu(i) {
bq = per_cpu_ptr(rcpu->bulkq, i);
+ INIT_LIST_HEAD(&bq->flush_node);
bq->obj = rcpu;
}
@@ -737,7 +738,8 @@ static void bq_flush_to_queue(struct xdp_bulk_queue *bq)
bq->count = 0;
spin_unlock(&q->producer_lock);
- __list_del_clearprev(&bq->flush_node);
+ if (bq->flush_node.prev)
+ __list_del_clearprev(&bq->flush_node);
/* Feedback loop via tracepoints */
trace_xdp_cpumap_enqueue(rcpu->map_id, processed, drops, to_cpu);
diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
index 2625601de76e..7a7347e709cc 100644
--- a/kernel/bpf/devmap.c
+++ b/kernel/bpf/devmap.c
@@ -428,7 +428,8 @@ void __dev_flush(struct list_head *flush_list)
bq_xmit_all(bq, XDP_XMIT_FLUSH);
bq->dev_rx = NULL;
bq->xdp_prog = NULL;
- __list_del_clearprev(&bq->flush_node);
+ if (bq->flush_node.prev)
+ __list_del_clearprev(&bq->flush_node);
}
}
diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index f093c3453f64..052b8583542d 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -406,7 +406,8 @@ void __xsk_map_flush(struct list_head *flush_list)
list_for_each_entry_safe(xs, tmp, flush_list, flush_node) {
xsk_flush(xs);
- __list_del_clearprev(&xs->flush_node);
+ if (xs->flush_node.prev)
+ __list_del_clearprev(&xs->flush_node);
}
}
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] bpf: Fix NULL deref in __list_del_clearprev for flush_node
2025-12-16 3:10 ` [PATCH] bpf: Fix NULL deref in __list_del_clearprev for flush_node donglaipang
@ 2025-12-16 3:34 ` bot+bpf-ci
2025-12-16 3:49 ` [syzbot] [net?] [bpf?] general protection fault in bq_flush_to_queue (2) syzbot
2025-12-16 4:06 ` [PATCH] bpf: Fix NULL deref in __list_del_clearprev for flush_node Alexei Starovoitov
2 siblings, 0 replies; 5+ messages in thread
From: bot+bpf-ci @ 2025-12-16 3:34 UTC (permalink / raw)
To: donglaipang, syzbot+2b3391f44313b3983e91
Cc: andrii, ast, bpf, daniel, davem, eddyz87, haoluo, hawk,
john.fastabend, jolsa, kpsingh, kuba, linux-kernel, martin.lau,
netdev, sdf, song, syzkaller-bugs, yonghong.song, donglaipang,
ast, andrii, daniel, martin.lau, eddyz87, yonghong.song, clm,
ihor.solodrai
[-- Attachment #1: Type: text/plain, Size: 2052 bytes --]
> diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c
> index 04171fbc39cb..6ab6eae31989 100644
> --- a/kernel/bpf/cpumap.c
> +++ b/kernel/bpf/cpumap.c
> @@ -450,6 +450,7 @@ __cpu_map_entry_alloc(struct bpf_map *map, struct bpf_cpumap_val *value,
>
> for_each_possible_cpu(i) {
> bq = per_cpu_ptr(rcpu->bulkq, i);
> + INIT_LIST_HEAD(&bq->flush_node);
> bq->obj = rcpu;
> }
>
[ ... ]
> diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
> index 2625601de76e..7a7347e709cc 100644
> --- a/kernel/bpf/devmap.c
> +++ b/kernel/bpf/devmap.c
> @@ -428,7 +428,8 @@ void __dev_flush(struct list_head *flush_list)
> bq_xmit_all(bq, XDP_XMIT_FLUSH);
> bq->dev_rx = NULL;
> bq->xdp_prog = NULL;
> - __list_del_clearprev(&bq->flush_node);
> + if (bq->flush_node.prev)
> + __list_del_clearprev(&bq->flush_node);
^^^^
The devmap code adds the same defensive check but doesn't initialize
flush_node the way cpumap does. Looking at dev_map_notification(), when
NETDEV_REGISTER occurs, it calls:
alloc_percpu(struct xdp_dev_bulk_queue)
And then only initializes the dev field:
per_cpu_ptr(netdev->xdp_bulkq, cpu)->dev = netdev;
Without INIT_LIST_HEAD(&bq->flush_node), if alloc_percpu() returns
memory with non-zero bytes, bq->flush_node.prev could contain garbage.
The enqueue path in bq_enqueue() uses:
if (!bq->dev_rx)
list_add(&bq->flush_node, flush_list);
So if dev_rx contains non-zero garbage, the node never gets added to the
list. But this flush code checks bq->flush_node.prev which could also be
garbage, causing __list_del_clearprev() to be called with invalid
pointers.
Does devmap need INIT_LIST_HEAD(&bq->flush_node) similar to cpumap? The
commit message states that initialization is part of the fix, but only
cpumap gets it.
[ ... ]
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/20255377282
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [syzbot] [net?] [bpf?] general protection fault in bq_flush_to_queue (2)
2025-12-16 3:10 ` [PATCH] bpf: Fix NULL deref in __list_del_clearprev for flush_node donglaipang
2025-12-16 3:34 ` bot+bpf-ci
@ 2025-12-16 3:49 ` syzbot
2025-12-16 4:06 ` [PATCH] bpf: Fix NULL deref in __list_del_clearprev for flush_node Alexei Starovoitov
2 siblings, 0 replies; 5+ messages in thread
From: syzbot @ 2025-12-16 3:49 UTC (permalink / raw)
To: andrii, ast, bpf, daniel, davem, donglaipang, eddyz87, haoluo,
hawk, john.fastabend, jolsa, kpsingh, kuba, linux-kernel,
martin.lau, netdev, sdf, song, syzkaller-bugs, yonghong.song
Hello,
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Reported-by: syzbot+2b3391f44313b3983e91@syzkaller.appspotmail.com
Tested-by: syzbot+2b3391f44313b3983e91@syzkaller.appspotmail.com
Tested on:
commit: 8f0b4cce Linux 6.19-rc1
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=137ab91a580000
kernel config: https://syzkaller.appspot.com/x/.config?x=412fc3ec22077a03
dashboard link: https://syzkaller.appspot.com/bug?extid=2b3391f44313b3983e91
compiler: Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
patch: https://syzkaller.appspot.com/x/patch.diff?x=10be172c580000
Note: testing is done by a robot and is best-effort only.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] bpf: Fix NULL deref in __list_del_clearprev for flush_node
2025-12-16 3:10 ` [PATCH] bpf: Fix NULL deref in __list_del_clearprev for flush_node donglaipang
2025-12-16 3:34 ` bot+bpf-ci
2025-12-16 3:49 ` [syzbot] [net?] [bpf?] general protection fault in bq_flush_to_queue (2) syzbot
@ 2025-12-16 4:06 ` Alexei Starovoitov
2 siblings, 0 replies; 5+ messages in thread
From: Alexei Starovoitov @ 2025-12-16 4:06 UTC (permalink / raw)
To: donglaipang
Cc: syzbot+2b3391f44313b3983e91, Andrii Nakryiko, Alexei Starovoitov,
bpf, Daniel Borkmann, David S. Miller, Eduard, Hao Luo,
Jesper Dangaard Brouer, John Fastabend, Jiri Olsa, KP Singh,
Jakub Kicinski, LKML, Martin KaFai Lau, Network Development,
Stanislav Fomichev, Song Liu, syzkaller-bugs, Yonghong Song
On Mon, Dec 15, 2025 at 7:14 PM <donglaipang@126.com> wrote:
>
> From: DLpang <donglaipang@126.com>
>
> #syz test
>
> Hi,
>
> This patch fixes a NULL pointer dereference in the BPF subsystem that occurs
> when __list_del_clearprev() is called on an already-cleared flush_node list_head.
>
> The fix includes two parts:
> 1. Properly initialize the flush_node list_head during per-CPU bulk queue allocation
> using INIT_LIST_HEAD(&bq->flush_node)
> 2. Add defensive checks before calling __list_del_clearprev() to ensure the node
> is actually in the list by checking if (bq->flush_node.prev)
>
> According to the __list_del_clearprev documentation in include/linux/list.h,
> 'The code that uses this needs to check the node 'prev' pointer instead of calling list_empty()'.
>
> This patch fixes the following syzbot-reported issue:
> https://syzkaller.appspot.com/bug?extid=2b3391f44313b3983e91
>
> Reported-by: syzbot+2b3391f44313b3983e91@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=2b3391f44313b3983e91
> Signed-off-by: DLpang <donglaipang@126.com>
If you're going to throw AI slop at us, please do your homework
and root cause the issue.
Nothing in this AI generated commit log explains the bug.
pw-bot: cr
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-12-16 4:06 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-08 8:58 [syzbot] [net?] [bpf?] general protection fault in bq_flush_to_queue (2) syzbot
2025-12-16 3:10 ` [PATCH] bpf: Fix NULL deref in __list_del_clearprev for flush_node donglaipang
2025-12-16 3:34 ` bot+bpf-ci
2025-12-16 3:49 ` [syzbot] [net?] [bpf?] general protection fault in bq_flush_to_queue (2) syzbot
2025-12-16 4:06 ` [PATCH] bpf: Fix NULL deref in __list_del_clearprev for flush_node Alexei Starovoitov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).