Re: [PATCH net-next v1] net/xdp: fix zero-size allocation warning in xskq_create()

From: Alexander Lobakin
Date: Mon Oct 02 2023 - 09:53:50 EST


From: Andrew Kanner <andrew.kanner@xxxxxxxxx>
Date: Thu, 28 Sep 2023 23:44:40 +0300

> Syzkaller reported the following issue:

[...]

> PS: the initial number of entries is 0x20000000 in syzkaller repro:
> syscall(__NR_setsockopt, (intptr_t)r[0], 0x11b, 3, 0x20000040, 0x20);
>
> Link: https://syzkaller.appspot.com/text?tag=ReproC&x=10910f18280000
>
> net/xdp/xsk_queue.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/net/xdp/xsk_queue.c b/net/xdp/xsk_queue.c
> index f8905400ee07..1bc7fb1f14ae 100644
> --- a/net/xdp/xsk_queue.c
> +++ b/net/xdp/xsk_queue.c
> @@ -34,6 +34,9 @@ struct xsk_queue *xskq_create(u32 nentries, bool umem_queue)
> q->ring_mask = nentries - 1;
>
> size = xskq_get_ring_size(q, umem_queue);
> + if (size == SIZE_MAX)

unlikely().

> + return NULL;
> +
> size = PAGE_ALIGN(size);
>
> q->ring = vmalloc_user(size);

Thanks,
Olek