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] [day] [month] [year] [list]
Message-ID: <23911752-3971-0230-cfd2-f8e30e8805db@gmail.com>
Date:   Tue, 12 Oct 2021 07:55:24 -0600
From:   David Ahern <dsahern@...il.com>
To:     zhang kai <zhangkaiheb@....com>, davem@...emloft.net
Cc:     yoshfuji@...ux-ipv6.org, dsahern@...nel.org, kuba@...nel.org,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] ipv4: only allow increasing fib_info_hash_size

On 10/12/21 5:06 AM, zhang kai wrote:
> and when failed to allocate memory, check fib_info_hash_size.


what problem are you trying to solve?



> 
> Signed-off-by: zhang kai <zhangkaiheb@....com>
> ---
>  net/ipv4/fib_semantics.c | 25 ++++++++++++++-----------
>  1 file changed, 14 insertions(+), 11 deletions(-)
> 
> diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
> index a632b66bc..7547708a9 100644
> --- a/net/ipv4/fib_semantics.c
> +++ b/net/ipv4/fib_semantics.c
> @@ -1403,17 +1403,20 @@ struct fib_info *fib_create_info(struct fib_config *cfg,
>  
>  		if (!new_size)
>  			new_size = 16;
> -		bytes = new_size * sizeof(struct hlist_head *);
> -		new_info_hash = fib_info_hash_alloc(bytes);
> -		new_laddrhash = fib_info_hash_alloc(bytes);
> -		if (!new_info_hash || !new_laddrhash) {
> -			fib_info_hash_free(new_info_hash, bytes);
> -			fib_info_hash_free(new_laddrhash, bytes);
> -		} else
> -			fib_info_hash_move(new_info_hash, new_laddrhash, new_size);
> -
> -		if (!fib_info_hash_size)
> -			goto failure;
> +
> +		if (new_size > fib_info_hash_size) {
> +			bytes = new_size * sizeof(struct hlist_head *);
> +			new_info_hash = fib_info_hash_alloc(bytes);
> +			new_laddrhash = fib_info_hash_alloc(bytes);
> +			if (!new_info_hash || !new_laddrhash) {
> +				fib_info_hash_free(new_info_hash, bytes);
> +				fib_info_hash_free(new_laddrhash, bytes);
> +
> +				if (!fib_info_hash_size)
> +					goto failure;
> +			} else
> +				fib_info_hash_move(new_info_hash, new_laddrhash, new_size);
> +		}
>  	}
>  
>  	fi = kzalloc(struct_size(fi, fib_nh, nhs), GFP_KERNEL);
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ