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: <YLieT3W39eSdwNZr@kroah.com>
Date:   Thu, 3 Jun 2021 11:18:07 +0200
From:   Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To:     Wan Jiabing <wanjiabing@...o.com>
Cc:     Fabio Aiuto <fabioaiuto83@...il.com>,
        Ross Schmidt <ross.schm.dev@...il.com>,
        Qiang Ma <maqianga@...ontech.com>,
        Marco Cesati <marcocesati@...il.com>,
        linux-staging@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] staging: rtl8723bs: core: fix some incorrect type
 warnings

On Thu, Jun 03, 2021 at 04:24:59PM +0800, Wan Jiabing wrote:
> Fix some "incorrect type in assignment" in rtw_security.c.
> 
> The sparse warings:
> drivers/staging//rtl8723bs/core/rtw_security.c:72:50: warning: incorrect type in assignment
> drivers/staging//rtl8723bs/core/rtw_security.c:72:50:    expected restricted __le32 [usertype]
> drivers/staging//rtl8723bs/core/rtw_security.c:72:50:    got unsigned int
> drivers/staging//rtl8723bs/core/rtw_security.c:80:50: warning: incorrect type in assignment
> drivers/staging//rtl8723bs/core/rtw_security.c:80:50:    expected restricted __le32 [usertype]
> drivers/staging//rtl8723bs/core/rtw_security.c:80:50:    got unsigned int
> drivers/staging//rtl8723bs/core/rtw_security.c:124:33: warning: cast to restricted __le32
> drivers/staging//rtl8723bs/core/rtw_security.c:509:58: warning: incorrect type in assignment
> drivers/staging//rtl8723bs/core/rtw_security.c:509:58:    expected restricted __le32 [usertype]
> drivers/staging//rtl8723bs/core/rtw_security.c:509:58:    got unsigned int
> drivers/staging//rtl8723bs/core/rtw_security.c:517:58: warning: incorrect type in assignment
> drivers/staging//rtl8723bs/core/rtw_security.c:517:58:    expected restricted __le32 [usertype]
> drivers/staging//rtl8723bs/core/rtw_security.c:517:58:    got unsigned int
> drivers/staging//rtl8723bs/core/rtw_security.c:621:41: warning: cast to restricted __le32
> 
> Signed-off-by: Wan Jiabing <wanjiabing@...o.com>
> ---
>  drivers/staging/rtl8723bs/core/rtw_security.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c
> index a99f439..4760999 100644
> --- a/drivers/staging/rtl8723bs/core/rtw_security.c
> +++ b/drivers/staging/rtl8723bs/core/rtw_security.c
> @@ -36,7 +36,7 @@ const char *security_type_str(u8 value)
>  void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe)
>  {																	/*  exclude ICV */
>  
> -	unsigned char crc[4];
> +	u8 crc[4];

Why change this?

>  
>  	signed int	curfragnum, length;
>  	u32 keylength;
> @@ -69,7 +69,7 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe)
>  
>  				length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len;
>  
> -				*((__le32 *)crc) = ~crc32_le(~0, payload, length);
> +				*((__le32 *)crc) = cpu_to_le32(~crc32_le(~0, payload, length));

Are you sure this does what you think it does?

What exactly is this doing now?

>  
>  				arc4_setkey(ctx, wepkey, 3 + keylength);
>  				arc4_crypt(ctx, payload, payload, length);
> @@ -77,7 +77,7 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe)
>  
>  			} else {
>  				length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len;
> -				*((__le32 *)crc) = ~crc32_le(~0, payload, length);
> +				*((__le32 *)crc) = cpu_to_le32(~crc32_le(~0, payload, length));
>  				arc4_setkey(ctx, wepkey, 3 + keylength);
>  				arc4_crypt(ctx, payload, payload, length);
>  				arc4_crypt(ctx, payload + length, crc, 4);
> @@ -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));
> +		*((__le32 *)crc) = cpu_to_le32(~crc32_le(~0, payload, length - 4));

This odd casting feels wrong, why is it correct now?

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ