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: <36bcdab2dae7429d9c2162879d0a3f9a@AcuMS.aculab.com>
Date: Sat, 25 Nov 2023 15:23:49 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Kent Overstreet' <kent.overstreet@...ux.dev>, "netdev@...r.kernel.org"
	<netdev@...r.kernel.org>
CC: Thomas Graf <tgraf@...g.ch>, Herbert Xu <herbert@...dor.apana.org.au>
Subject: RE: [PATCH] rhashtable: Better error message on allocation failure

From: Kent Overstreet
> Sent: 24 November 2023 00:00
> 
> Memory allocation failures print backtraces by default, but when we're
> running out of a rhashtable worker the backtrace is useless - it doesn't
> tell us which hashtable the allocation failure was for.
> 
> This adds a dedicated warning that prints out functions from the
> rhashtable params, which will be a bit more useful.
> 
> Signed-off-by: Kent Overstreet <kent.overstreet@...ux.dev>
> Cc: Thomas Graf <tgraf@...g.ch>
> Cc: Herbert Xu <herbert@...dor.apana.org.au>
> Acked-by: Herbert Xu <herbert@...dor.apana.org.au>
> ---
>  lib/rhashtable.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/rhashtable.c b/lib/rhashtable.c
> index 6ae2ba8e06a2..d3fce9c8989a 100644
> --- a/lib/rhashtable.c
> +++ b/lib/rhashtable.c
> @@ -360,9 +360,14 @@ static int rhashtable_rehash_alloc(struct rhashtable *ht,
> 
>  	ASSERT_RHT_MUTEX(ht);
> 
> -	new_tbl = bucket_table_alloc(ht, size, GFP_KERNEL);
> -	if (new_tbl == NULL)
> +	new_tbl = bucket_table_alloc(ht, size, GFP_KERNEL|__GFP_NOWARN);
> +	if (new_tbl == NULL) {
> +		WARN("rhashtable bucket table allocation failure for %ps",

Won't WARN() be a panic on systems with PANICK_ON_WARN set?

> +		     (void *) ht->p.hashfn ?:
> +		     (void *) ht->p.obj_hashfn ?:
> +		     (void *) ht->p.obj_cmpfn);

That layout is horrid (and I bet checkpatch complains).
You only actually need one (void *) cast on the RH value:
			ht->p.hashfn ?: ht->p.obj_hashfn ?: (void *)ht->p.obj_cmpfn

	David


>  		return -ENOMEM;
> +	}
> 
>  	err = rhashtable_rehash_attach(ht, old_tbl, new_tbl);
>  	if (err)
> --
> 2.42.0
> 

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ