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: <8974a58823d74d118595d4f8db5ac870@AcuMS.aculab.com>
Date:   Mon, 14 Jun 2021 20:48:45 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Jhih-Ming Huang' <fbihjmeric@...il.com>,
        "gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
        "fabioaiuto83@...il.com" <fabioaiuto83@...il.com>,
        "ross.schm.dev@...il.com" <ross.schm.dev@...il.com>,
        "maqianga@...ontech.com" <maqianga@...ontech.com>,
        "marcocesati@...il.com" <marcocesati@...il.com>,
        "linux-staging@...ts.linux.dev" <linux-staging@...ts.linux.dev>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] rtw_security: fix cast to restricted __le32

From: Jhih-Ming Huang
> Sent: 13 June 2021 11:22
> 
> This patch fixes the sparse warning of fix cast to restricted __le32.
> 
> Signed-off-by: Jhih-Ming Huang <fbihjmeric@...il.com>
> ---
>  drivers/staging/rtl8723bs/core/rtw_security.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c
> b/drivers/staging/rtl8723bs/core/rtw_security.c
> index a99f439328f1..2f4da67e31c6 100644
> --- a/drivers/staging/rtl8723bs/core/rtw_security.c
> +++ b/drivers/staging/rtl8723bs/core/rtw_security.c
> @@ -121,7 +121,7 @@ void rtw_wep_decrypt(struct adapter  *padapter, u8 *precvframe)
>  		arc4_crypt(ctx, payload, payload,  length);
> 
>  		/* calculate icv and compare the icv */
> -		*((u32 *)crc) = le32_to_cpu(~crc32_le(~0, payload, length - 4));
> +		*((u32 *)crc) = le32_to_cpu((__force __le32)~crc32_le(~0, payload, length - 4));
> 
>  	}
>  }
> @@ -618,7 +618,8 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe)
>  			arc4_setkey(ctx, rc4key, 16);
>  			arc4_crypt(ctx, payload, payload, length);

Is someone using 'rc4' and 'security' in the same file?

> 
> -			*((u32 *)crc) = le32_to_cpu(~crc32_le(~0, payload, length - 4));
> +			*((u32 *)crc) = le32_to_cpu((__force __le32)~crc32_le(~0, payload,
> +						length - 4));
> 
>  			if (crc[3] != payload[length - 1] || crc[2] != payload[length - 2] ||
>  			    crc[1] != payload[length - 3] || crc[0] != payload[length - 4])

In both cases the *((u32 *)crc) is also very dubious.
Casts of pointers to integer types are almost always broken.
Given the code that follows the second hunk I'm guessing you
have 'u8 crc[4];' (or equivalent).
That can be misaligned and then access will panic on some systems.

There is a get_unaligned_be32() (or something similar) that can be used
to read the crc from (payload + length - 4).

	David

-
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