Re: [syzbot] Re: [syzbot] [bpf?] [net?] general protection fault in __xsk_map_flush

From: syzbot
Date: Mon Jul 22 2024 - 12:12:55 EST


For archival purposes, forwarding an incoming command email to
linux-kernel@xxxxxxxxxxxxxxx.

***

Subject: Re: [syzbot] [bpf?] [net?] general protection fault in __xsk_map_flush
Author: aha310510@xxxxxxxxx

#syz test git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

---
kernel/bpf/cpumap.c | 2 +-
kernel/bpf/devmap.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c
index fbdf5a1aabfe..8fccc311397c 100644
--- a/kernel/bpf/cpumap.c
+++ b/kernel/bpf/cpumap.c
@@ -676,7 +676,7 @@ static void bq_flush_to_queue(struct xdp_bulk_queue *bq)
struct ptr_ring *q;
int i;

- if (unlikely(!bq->count))
+ if (unlikely(!bq->count) || unlikely(bq->count) > CPU_MAP_BULK_SIZE)
return;

q = rcpu->queue;
diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
index 9e0e3b0a18e4..4b9203deb711 100644
--- a/kernel/bpf/devmap.c
+++ b/kernel/bpf/devmap.c
@@ -378,7 +378,7 @@ static void bq_xmit_all(struct xdp_dev_bulk_queue *bq, u32 flags)
int to_send = cnt;
int i;

- if (unlikely(!cnt))
+ if (unlikely(!cnt) || unlikely(cnt) > DEV_MAP_BULK_SIZE)
return;

for (i = 0; i < cnt; i++) {
--