lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6cc54680-3093-4d75-b688-91688023c41b@suse.cz>
Date: Wed, 19 Feb 2025 11:32:25 +0100
From: Vlastimil Babka <vbabka@...e.cz>
To: Kohei Enju <enjuk@...zon.com>, netdev@...r.kernel.org,
 linux-kernel@...r.kernel.org
Cc: "David S . Miller" <davem@...emloft.net>,
 Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
 Paolo Abeni <pabeni@...hat.com>, Simon Horman <horms@...nel.org>,
 Kuniyuki Iwashima <kuniyu@...zon.com>, Gilad Naaman <gnaaman@...venets.com>,
 Joel Granados <joel.granados@...nel.org>, Li Zetao <lizetao1@...wei.com>,
 Christoph Lameter <cl@...ux.com>, Pekka Enberg <penberg@...nel.org>,
 David Rientjes <rientjes@...gle.com>, Joonsoo Kim <iamjoonsoo.kim@....com>,
 Andrew Morton <akpm@...ux-foundation.org>,
 Roman Gushchin <roman.gushchin@...ux.dev>,
 Hyeonggon Yoo <42.hyeyoo@...il.com>, Kohei Enju <kohei.enju@...il.com>
Subject: Re: [PATCH net-next v2] neighbour: Replace kvzalloc() with kzalloc()
 when GFP_ATOMIC is specified

On 2/19/25 11:22, Kohei Enju wrote:
> kzalloc() uses page allocator when size is larger than
> KMALLOC_MAX_CACHE_SIZE, so the intention of commit ab101c553bc1
> ("neighbour: use kvzalloc()/kvfree()") can be achieved by using kzalloc().
> 
> When using GFP_ATOMIC, kvzalloc() only tries the kmalloc path,
> since the vmalloc path does not support the flag.
> In this case, kvzalloc() is equivalent to kzalloc() in that neither try
> the vmalloc path, so this replacement brings no functional change.
> This is primarily a cleanup change, as the original code functions
> correctly.
> 
> This patch replaces kvzalloc() introduced by commit 41b3caa7c076
> ("neighbour: Add hlist_node to struct neighbour"), which is called in
> the same context and with the same gfp flag as the aforementioned commit
> ab101c553bc1 ("neighbour: use kvzalloc()/kvfree()").
> 
> Signed-off-by: Kohei Enju <enjuk@...zon.com>

Acked-by: Vlastimil Babka <vbabka@...e.cz>

> ---
> Notes:
>     One of the SLAB maintainers (Vlastimil Babka) looked at v1 patch and
>     double-checked kzalloc() is clearer in this context:
>     https://lore.kernel.org/netdev/b4a2bf18-c1ec-4ccd-bed9-671a2fd543a9@suse.cz/
> 
> Changes:
>     v1: https://lore.kernel.org/netdev/20250216163016.57444-1-enjuk@amazon.com/
>     v1->v2:
>         - Change commit message
>         - Remove the Fixes tag since there is no real bug now
> ---
>  net/core/neighbour.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/net/core/neighbour.c b/net/core/neighbour.c
> index d8dd686b5287..344c9cd168ec 100644
> --- a/net/core/neighbour.c
> +++ b/net/core/neighbour.c
> @@ -518,7 +518,7 @@ static struct neigh_hash_table *neigh_hash_alloc(unsigned int shift)
>  	if (!ret)
>  		return NULL;
>  
> -	hash_heads = kvzalloc(size, GFP_ATOMIC);
> +	hash_heads = kzalloc(size, GFP_ATOMIC);
>  	if (!hash_heads) {
>  		kfree(ret);
>  		return NULL;
> @@ -536,7 +536,7 @@ static void neigh_hash_free_rcu(struct rcu_head *head)
>  						    struct neigh_hash_table,
>  						    rcu);
>  
> -	kvfree(nht->hash_heads);
> +	kfree(nht->hash_heads);
>  	kfree(nht);
>  }
>  


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ