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: <9e84b812-d32d-14fc-d2ae-0c8e82d6cdc5@gmail.com>
Date:   Thu, 16 Mar 2023 12:13:56 +0100
From:   Szymon Heidrich <szymon.heidrich@...il.com>
To:     Jakub Kicinski <kuba@...nel.org>
Cc:     steve.glendinning@...well.net, UNGLinuxDriver@...rochip.com,
        davem@...emloft.net, edumazet@...gle.com, pabeni@...hat.com,
        linux-usb@...r.kernel.org, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] net: usb: smsc95xx: Limit packet length to skb->len

On 16/03/2023 05:24, Jakub Kicinski wrote:
> On Mon, 13 Mar 2023 23:01:24 +0100 Szymon Heidrich wrote:
>> Packet length retrieved from skb data may be larger than
> 
> nit: s/skb data/descriptor/ may be better in terms of terminology
> 
>> the actual socket buffer length (up to 1526 bytes). In such
> 
> nit: the "up to 1526 bytes" is a bit confusing, I'd remove it.
> 
>> case the cloned skb passed up the network stack will leak
>> kernel memory contents.
> 
> 
> 
>> Fixes: 2f7ca802bdae ("net: Add SMSC LAN9500 USB2.0 10/100 ethernet adapter driver")
>> Signed-off-by: Szymon Heidrich <szymon.heidrich@...il.com>
>> ---
>>  drivers/net/usb/smsc95xx.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
>> index 32d2c60d3..ba766bdb2 100644
>> --- a/drivers/net/usb/smsc95xx.c
>> +++ b/drivers/net/usb/smsc95xx.c
>> @@ -1851,7 +1851,8 @@ static int smsc95xx_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
>>  			}
>>  		} else {
>>  			/* ETH_FRAME_LEN + 4(CRC) + 2(COE) + 4(Vlan) */
>> -			if (unlikely(size > (ETH_FRAME_LEN + 12))) {
>> +			if (unlikely(size > (ETH_FRAME_LEN + 12) ||
>> +				     size > skb->len)) {
> 
> We need this check on both sides of the big if {} statement.
> 
> In case the error bit is set and we drop the packet we still
> end up in skb_pull() which if size > skb->len will panic the
> kernel.
> 
> So let's do this check right after size and align are calculated?
> The patch for smsc75xx has sadly already been applied so you'll
> need to prepare a fix to the fix :(
> 
>>  				netif_dbg(dev, rx_err, dev->net,
>>  					  "size err header=0x%08x\n", header);
>>  				return 0;
> 

Thank you very much for you suggestions Kuba, I provided an updated patch for
smsc95xx and a new patch addressing smsc75xx. Please let me know in case additional
amendments are required.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ