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

From: Andrew Kanner <[email-masked]>
Date: Tue, 3 Oct 2023 01:03:35 +0300

On Mon, Oct 02, 2023 at 03:52:44PM +0200, Alexander Lobakin wrote:
> From: Andrew Kanner <[email-masked]>
> 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

Thanks, Olek.
That is a reasonable optimization, I'll add it in v2.

--
pw-bot: cr

Andrew Kanner