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: <eb9e61a8-dee1-ec86-d477-5df7955209e8@lwfinger.net>
Date:   Mon, 13 Feb 2017 09:54:00 -0600
From:   Larry Finger <Larry.Finger@...inger.net>
To:     David Laight <David.Laight@...LAB.COM>,
        "gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>
Cc:     "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "devel@...verdev.osuosl.org" <devel@...verdev.osuosl.org>
Subject: Re: [PATCH 6/7] staging: r8712u: Fix Sparse warnings in
 rtl871x_ioctl_linux.c

On 02/13/2017 05:27 AM, David Laight wrote:
> From: Larry Finger
>> Sent: 11 February 2017 03:30
>> Sparse reports the following:
>>   CHECK   drivers/staging/rtl8712/rtl871x_ioctl_linux.c
>> drivers/staging/rtl8712/rtl871x_ioctl_linux.c:1422:46: warning: restricted __le16 degrades to integer
>> drivers/staging/rtl8712/rtl871x_ioctl_linux.c:1424:46: warning: restricted __le16 degrades to integer
>>
>> Signed-off-by: Larry Finger <Larry.Finger@...inger.net>
>> ---
>>  drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
>> b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
>> index 0dc18d6..f4167f1 100644
>> --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
>> +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
>> @@ -1419,9 +1419,9 @@ static int r8711_wx_get_rate(struct net_device *dev,
>>  			ht_cap = true;
>>  			pht_capie = (struct ieee80211_ht_cap *)(p + 2);
>>  			memcpy(&mcs_rate, pht_capie->supp_mcs_set, 2);
>> -			bw_40MHz = (pht_capie->cap_info &
>> +			bw_40MHz = (le16_to_cpu(pht_capie->cap_info) &
>>  				    IEEE80211_HT_CAP_SUP_WIDTH) ? 1 : 0;
>> -			short_GI = (pht_capie->cap_info &
>> +			short_GI = (le16_to_cpu(pht_capie->cap_info) &
>>  				    (IEEE80211_HT_CAP_SGI_20 |
>>  				    IEEE80211_HT_CAP_SGI_40)) ? 1 : 0;
>
> You've added a byteswap on le systems - so the title is wrong.
> You need to sort out whether the byteswap is needed or not.
>
> Also it is best to byteswap the constant.

Yes, I could byteswap the constant rather than the variable, but I prefer to 
have both be in cpu order. That way there will be no confusion when that 
quantity is used later. In this case, both results are boolean and it would not 
make a difference.

I do not understand the comment about the title being wrong. All multi-byte 
quantities in struct ieee80211_ht_cap are little endian. For the code to work on 
BE hardware, a byteswap is necessary. On LE hardware, le16_to_cpu() is defined 
as ((__force __u16)(__le16)(x)), which does not result in a byteswap.

Larry


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ