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]
Date:   Thu, 23 Jul 2020 07:22:53 -0700
From:   Randy Dunlap <rdunlap@...radead.org>
To:     Huang Guobin <huangguobin4@...wei.com>, haren@...ibm.com,
        ddstreet@...e.org, herbert@...dor.apana.org.au
Cc:     linux-kernel@...r.kernel.org
Subject: Re: [PATCH] lib: Verify array index is correct before using it

On 7/23/20 6:48 AM, Huang Guobin wrote:
> This code reads from the array before verifying that "c" is a valid
> index. Move test array offset code before use to fix it.
> 
> Fixes: 2da572c959dd ("lib: add software 842 compression/decompression")
> Signed-off-by: Huang Guobin <huangguobin4@...wei.com>

Hi,
Why shouldn't these locations use array_index_nospec() from
#include <linux/nospec.h>
?


> ---
>  lib/842/842_compress.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/842/842_compress.c b/lib/842/842_compress.c
> index c02baa4168e1..10f9f8a0d05b 100644
> --- a/lib/842/842_compress.c
> +++ b/lib/842/842_compress.c
> @@ -222,12 +222,13 @@ static int add_bits(struct sw842_param *p, u64 d, u8 n)
>  static int add_template(struct sw842_param *p, u8 c)
>  {
>  	int ret, i, b = 0;
> -	u8 *t = comp_ops[c];
> +	u8 *t = NULL;
>  	bool inv = false;
>  
>  	if (c >= OPS_MAX)
>  		return -EINVAL;
>  
> +	t = comp_ops[c];
>  	pr_debug("template %x\n", t[4]);
>  
>  	ret = add_bits(p, t[4], OP_BITS);
> @@ -379,12 +380,14 @@ static int add_end_template(struct sw842_param *p)
>  
>  static bool check_template(struct sw842_param *p, u8 c)
>  {
> -	u8 *t = comp_ops[c];
> +	u8 *t = NULL;
>  	int i, match, b = 0;
>  
>  	if (c >= OPS_MAX)
>  		return false;
>  
> +	t = comp_ops[c];
> +
>  	for (i = 0; i < 4; i++) {
>  		if (t[i] & OP_ACTION_INDEX) {
>  			if (t[i] & OP_AMOUNT_2)
> 

thanks.
-- 
~Randy

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ