Skip to content

Commit 6624ff3

Browse files
naya451Michael Tokarev
authored andcommitted
net: fix buffer overflow in af_xdp_umem_create()
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: cb039ef ("net: add initial support for AF_XDP network backend") Cc: [email protected] Reviewed-by: Ilya Maximets <[email protected]> Signed-off-by: Anastasia Belova <[email protected]> Signed-off-by: Jason Wang <[email protected]> (cherry picked from commit 110d0fa2d4d1f754242f6775baec43776a9adb35) Signed-off-by: Michael Tokarev <[email protected]>
1 parent a655b65 commit 6624ff3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/af-xdp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ static int af_xdp_umem_create(AFXDPState *s, int sock_fd, Error **errp)
323323

324324
s->pool = g_new(uint64_t, n_descs);
325325
/* Fill the pool in the opposite order, because it's a LIFO queue. */
326-
for (i = n_descs; i >= 0; i--) {
326+
for (i = n_descs - 1; i >= 0; i--) {
327327
s->pool[i] = i * XSK_UMEM__DEFAULT_FRAME_SIZE;
328328
}
329329
s->n_pool = n_descs;

0 commit comments

Comments
 (0)