]> www.infradead.org Git - users/hch/misc.git/commitdiff
xsk: fix an integer overflow in xp_create_and_assign_umem()
authorGavrilov Ilia <Ilia.Gavrilov@infotecs.ru>
Thu, 13 Mar 2025 08:50:08 +0000 (08:50 +0000)
committerPaolo Abeni <pabeni@redhat.com>
Wed, 19 Mar 2025 21:57:04 +0000 (22:57 +0100)
Since the i and pool->chunk_size variables are of type 'u32',
their product can wrap around and then be cast to 'u64'.
This can lead to two different XDP buffers pointing to the same
memory area.

Found by InfoTeCS on behalf of Linux Verification Center
(linuxtesting.org) with SVACE.

Fixes: 94033cd8e73b ("xsk: Optimize for aligned case")
Cc: stable@vger.kernel.org
Signed-off-by: Ilia Gavrilov <Ilia.Gavrilov@infotecs.ru>
Link: https://patch.msgid.link/20250313085007.3116044-1-Ilia.Gavrilov@infotecs.ru
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
net/xdp/xsk_buff_pool.c

index 1f7975b4965794f5de345cacccbecec0b03c5634..d158cb6dd39193586f5392cbcfe3080830664000 100644 (file)
@@ -105,7 +105,7 @@ struct xsk_buff_pool *xp_create_and_assign_umem(struct xdp_sock *xs,
                if (pool->unaligned)
                        pool->free_heads[i] = xskb;
                else
-                       xp_init_xskb_addr(xskb, pool, i * pool->chunk_size);
+                       xp_init_xskb_addr(xskb, pool, (u64)i * pool->chunk_size);
        }
 
        return pool;