qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: qemu-devel@nongnu.org
Cc: Anastasia Belova <nabelova31@gmail.com>,
	qemu-stable@nongnu.org, Ilya Maximets <i.maximets@ovn.org>,
	Jason Wang <jasowang@redhat.com>
Subject: [PULL 01/13] net: fix buffer overflow in af_xdp_umem_create()
Date: Mon, 14 Jul 2025 13:34:11 +0800	[thread overview]
Message-ID: <20250714053423.10415-2-jasowang@redhat.com> (raw)
In-Reply-To: <20250714053423.10415-1-jasowang@redhat.com>

From: Anastasia Belova <nabelova31@gmail.com>

s->pool has n_descs elements so maximum i should be
n_descs - 1. Fix the upper bound.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: cb039ef3d9 ("net: add initial support for AF_XDP network backend")
Cc: qemu-stable@nongnu.org
Reviewed-by: Ilya Maximets <i.maximets@ovn.org>
Signed-off-by: Anastasia Belova <nabelova31@gmail.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 net/af-xdp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/af-xdp.c b/net/af-xdp.c
index 01c5fb914e..d022534d76 100644
--- a/net/af-xdp.c
+++ b/net/af-xdp.c
@@ -323,7 +323,7 @@ static int af_xdp_umem_create(AFXDPState *s, int sock_fd, Error **errp)
 
     s->pool = g_new(uint64_t, n_descs);
     /* Fill the pool in the opposite order, because it's a LIFO queue. */
-    for (i = n_descs; i >= 0; i--) {
+    for (i = n_descs - 1; i >= 0; i--) {
         s->pool[i] = i * XSK_UMEM__DEFAULT_FRAME_SIZE;
     }
     s->n_pool = n_descs;
-- 
2.42.0



  reply	other threads:[~2025-07-14  5:35 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-14  5:34 [PULL 00/13] Net patches Jason Wang
2025-07-14  5:34 ` Jason Wang [this message]
2025-07-14  5:34 ` [PULL 02/13] virtio-net: Add queues for RSS during migration Jason Wang
2025-07-14  5:34 ` [PULL 03/13] net: Refactor stream logic for reuse in '-net passt' Jason Wang
2025-07-14  5:34 ` [PULL 04/13] net: Define net_client_set_link() Jason Wang
2025-07-14  5:34 ` [PULL 05/13] vhost_net: Rename vhost_set_vring_enable() for clarity Jason Wang
2025-07-14  5:34 ` [PULL 06/13] net: Add get_vhost_net callback to NetClientInfo Jason Wang
2025-07-14  5:34 ` [PULL 07/13] net: Consolidate vhost feature bits into vhost_net structure Jason Wang
2025-07-14  5:34 ` [PULL 08/13] net: Add get_acked_features callback to VhostNetOptions Jason Wang
2025-07-14  5:34 ` [PULL 09/13] net: Add save_acked_features callback to vhost_net Jason Wang
2025-07-14  5:34 ` [PULL 10/13] net: Allow network backends to advertise max TX queue size Jason Wang
2025-07-14  5:34 ` [PULL 11/13] net: Add is_vhost_user flag to vhost_net struct Jason Wang
2025-07-14  5:34 ` [PULL 12/13] net: Add passt network backend Jason Wang
2025-07-14  5:34 ` [PULL 13/13] net/passt: Implement vhost-user backend support Jason Wang
2025-07-15  4:13 ` [PULL 00/13] Net patches Jason Wang
2025-07-15 19:50 ` Stefan Hajnoczi
2025-07-16  2:21   ` Jason Wang
2025-07-16  4:40     ` Philippe Mathieu-Daudé
2025-07-16 10:26     ` Stefan Hajnoczi
2025-07-16 10:30       ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250714053423.10415-2-jasowang@redhat.com \
    --to=jasowang@redhat.com \
    --cc=i.maximets@ovn.org \
    --cc=nabelova31@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).