Re: [PATCH v3][next] skbuff: Proactively round up to kmalloc bucket size
From: Kees Cook
Date: Fri Oct 21 2022 - 12:10:37 EST
On Thu, Oct 20, 2022 at 10:42:47AM +0200, Paolo Abeni wrote:
> > size = SKB_DATA_ALIGN(size);
> > size += SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
> > - data = kmalloc_reserve(size, gfp_mask, node, &pfmemalloc);
> > - if (unlikely(!data))
> > - goto nodata;
>
> I'm sorry for not noticing the above in the previous iteration, but I
> think this revision will produce worse code than the V1, as
> kmalloc_reserve() now pollutes an additional register.
>
> Why did you prefer adding an additional parameter to kmalloc_reserve()?
> I think computing the alloc_size in the caller is even more readable.
>
> Additionally, as a matter of personal preference, I would not introduce
> an additional variable for alloc_size, just:
>
> // ...
> size = kmalloc_size_roundup(size);
> data = kmalloc_reserve(size, gfp_mask, node, &pfmemalloc);
>
> The rationale is smaller diff, and consistent style with the existing
> code where 'size' is already adjusted multiple times icrementally.
Sure, I can do that. I will respin it. :)
--
Kees Cook