The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH net 1/2] virtio_net: check AF_XDP queue index before use
@ 2026-08-04  8:53 Xiong Weimin
  2026-08-04  8:53 ` [PATCH net 2/2] virtio_net: unmap AF_XDP header with tx virtqueue Xiong Weimin
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Xiong Weimin @ 2026-08-04  8:53 UTC (permalink / raw)
  To: Michael S. Tsirkin, Jason Wang
  Cc: Xuan Zhuo, Eugenio Pérez, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, virtualization,
	linux-kernel, Xiong Weimin

Validate the AF_XDP queue index before dereferencing the receive or
send queue arrays in virtnet_xsk_pool_enable().  This keeps an out of
range queue id from reaching vi->rq[qid] while checking page_pool.

Signed-off-by: Xiong Weimin <xiongweimin@kylinos.cn>
---
 drivers/net/virtio_net.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 3e2a5876c..6160aa8ba 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -5896,15 +5896,15 @@ static int virtnet_xsk_pool_enable(struct net_device *dev,
 	if (vi->hdr_len > xsk_pool_get_headroom(pool))
 		return -EINVAL;
 
+	if (qid >= vi->curr_queue_pairs)
+		return -EINVAL;
+
 	/* In big_packets mode, xdp cannot work, so there is no need to
 	 * initialize xsk of rq.
 	 */
 	if (!vi->rq[qid].page_pool)
 		return -ENOENT;
 
-	if (qid >= vi->curr_queue_pairs)
-		return -EINVAL;
-
 	sq = &vi->sq[qid];
 	rq = &vi->rq[qid];
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-08-07  5:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-04  8:53 [PATCH net 1/2] virtio_net: check AF_XDP queue index before use Xiong Weimin
2026-08-04  8:53 ` [PATCH net 2/2] virtio_net: unmap AF_XDP header with tx virtqueue Xiong Weimin
2026-08-04 11:53   ` Jason Xing
2026-08-06 16:04   ` Jakub Kicinski
2026-08-07  1:32     ` Xiong Weimin
2026-08-04 11:46 ` [PATCH net 1/2] virtio_net: check AF_XDP queue index before use Jason Xing
2026-08-06 16:04 ` Jakub Kicinski
2026-08-07  1:32   ` Xiong Weimin
2026-08-07  5:23   ` Jason Xing

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox