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]
Date:   Mon, 1 Jul 2019 22:36:26 +0200
From:   Heiner Kallweit <hkallweit1@...il.com>
To:     Al Viro <viro@...iv.linux.org.uk>
Cc:     Realtek linux nic maintainers <nic_swsd@...ltek.com>,
        David Miller <davem@...emloft.net>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: Re: [PATCH net-next] r8169: fix ntohs/htons sparse warnings

On 01.07.2019 21:56, Al Viro wrote:
> On Mon, Jul 01, 2019 at 09:35:28PM +0200, Heiner Kallweit wrote:
>> Sparse complains about casting to/from restricted __be16. Fix this.
> 
> Fix what, exactly?  Force-cast is not a fix - it's "STFU, I know
> better, it's really correct" to sparse.  Which may or may not
> match the reality, but it definitely requires more in way of
> commit message than "sparse says it's wrong; shut it up".
> 
>>  static void rtl8169_rx_vlan_tag(struct RxDesc *desc, struct sk_buff *skb)
>> @@ -1537,7 +1537,7 @@ static void rtl8169_rx_vlan_tag(struct RxDesc *desc, struct sk_buff *skb)
>>  
>>  	if (opts2 & RxVlanTag)
>>  		__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q),
>> -				       ntohs(opts2 & 0xffff));
>> +				       ntohs((__force __be16)(opts2 & 0xffff)));
>>  }
> 
> Should that be ntohs at all?  What behaviour is correct on big-endian host?
> 
> AFAICS, in that code opts2 comes from little-endian 32bit.  It's converted to
> host-endian, lower 16 bits (i.e. the first two octets in memory) are then
> fed to ntohs.  Suppose we had in-core value stored as A0, A1, A2, A3.
> On little-endian that code will yield A0 * 256 + A1, treated as host-endian.
> On big-endian the same will yield A1 * 256 + A0.  Is that actually correct?
> 
I think you're right and the original patch should be reverted.

> The code dealing with the value passed to __vlan_hwaccel_put_tag() as the
> third argument treats it as a host-endian integer.  So... Has anyone
> tested that code on b-e host?  Should that ntohs() actually be swab16(),
> yielding (on any host) the same value we currently get for l-e hosts only?
> 
I haven't seen any b-e host with a Realtek network chip yet.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ