From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796382682; b=t1MeuUFq+FyXONS5gPejvMn1k1UTtae33MK6pWC0moQ8458rgmiFW8N8hYmNtAa8+IEu elYp22zzZUzhq0Gjg+jYXbbhpXzsXn0UwqgBG3aWyR5j3O+kGOLg9bj6DzjP2IpZqCVNv Kd+nqNKfM0h5sYnsv5F59C11715TsVfEpco52e+G6fJFoWaGeCVNnlXdU2ELwo8dRsZBb 250J3ByGjQvYZ/KgSKndk9Cger41aPxDPuZGRZUVkO85bMaYyQVsIK9P6EJYelwCvQGj+ DOXHfj08zAdGzKBKoCenZ9UtNFqk8Guz7AF8S52Q6vkoQhNUus44mLIb7n623S9Ht2w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382682; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=hsNGhOLvFffXoBhPjqvF2pTl86/8buaWUdCgE28Tivc=; b=K2htfcblAPdSgQUk8fcGVZjKCQQhrwXk7+UO130W1qAKZDb5hznu+GZm0fXtbiBDosuX HdTezYHWpkMCcYG44lb5kErm+6XzvFUlwVSWNGBM/6Vw3ZTlKrvOeLhqnzef8AyRx78vF c4O7i2/uyMdepnXIY7HSoJMa5GeCyaJ7Y5Kx0kHKA119iQ2KK3qqA8BthLztU5oNmHD/Y 7Eawgx21vSd0xZj/DyAgH8UW9GPvFTuGaq+HO5b6UVRRkOUR+n4Bc53yzqGuchuVmE7rQ 1i+sqT7hu0q4/ucC3LBUNA2YaIlhrXgX76sku8tbrq3UBC1/94xLRfR0Oi1cYTRkbeQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=AZrTePuc; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D26C7606A322; Fri, 4 Dec 2026 11:11:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=AZrTePuc Received: by smtp.kernel.org (Postfix) with ESMTPSA id 486EA1F000C2; Fri, 4 Dec 2026 11:11:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382682; bh=hsNGhOLvFffXoBhPjqvF2pTl86/8buaWUdCgE28Tivc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AZrTePucxwff73LpEz9S2AHXldASwsrLkfQDQb4kgD3sZkjfPfJyRmgbru0NQS2jb +rGwcCXiXTugqkGl4zPCPEJyI9aN5gO7XTMCXm78lQyAxWi3QE8RHL0KEdCPIv0eJ0 IFOzi2iRL3oXpy9/w8XuKdWtee6O+ilk8wdmCkXE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Joas Antonio dos Santos , Andrew Lunn , Jakub Kicinski Subject: [PATCH 6.18 559/703] net: usb: smsc75xx: reject frames without a full header and FCS Date: Fri, 4 Dec 2026 19:07:38 +0900 Message-ID: <20261204100642.648820792@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Joas Antonio dos Santos commit 1b02f90976d4bdf8c67d19dadf31b4bba05eb66f upstream. smsc75xx_rx_fixup() takes the frame length from the RX command word supplied by the device and strips the FCS by using "size - 4" for the allocation, skb_put() and memcpy() of each frame that is not the last one in the URB. The length is only checked against an upper bound and against skb->len, so a device can report a length field of 2..5, which gives a size of 0..3 after RXW_PADDING is subtracted. size is a u32, so "size - 4" then wraps to 0xfffffffc..0xffffffff. __netdev_alloc_skb() adds NET_SKB_PAD to the unsigned length, which wraps back to a small value and the allocation succeeds. skb_put() adds the length to the 32-bit skb->tail and skb->len, which also wrap, so the skb_over_panic() check does not fire. The following memcpy() then tries to copy almost 4 GiB from the URB buffer into that small allocation and writes far beyond it. A malicious or malfunctioning USB device can use this to corrupt kernel memory or crash the machine. A frame that holds an FCS but less than an Ethernet header is not valid either. usbnet drops it when it is the last frame in the URB, but the other frames go straight to usbnet_skb_return(), where eth_type_trans() reads an Ethernet header that was never copied into the new skb. Reject frames that are too short to hold an Ethernet header and an FCS, which covers both cases with one check. The driver does not set FLAG_RX_ASSEMBLE, so usbnet already counts rx_errors when smsc75xx_rx_fixup() returns 0. Also count rx_length_errors for these frames, as usbnet does for the short frames it drops itself. Found by LLM-assisted source review. Fixes: 1b3b2d9e772b ("net: usb: smsc75xx: stop lying about skb->truesize") Cc: stable@vger.kernel.org Signed-off-by: Joas Antonio dos Santos Reviewed-by: Andrew Lunn Link: https://patch.msgid.link/20261112-smsc75xx-rx-fcs-v3-1-6ad0378d0384@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/usb/smsc75xx.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/drivers/net/usb/smsc75xx.c +++ b/drivers/net/usb/smsc75xx.c @@ -2223,6 +2223,14 @@ static int smsc75xx_rx_fixup(struct usbn return 0; } + if (unlikely(size < ETH_HLEN + ETH_FCS_LEN)) { + netif_dbg(dev, rx_err, dev->net, + "size err rx_cmd_a=0x%08x\n", + rx_cmd_a); + dev->net->stats.rx_length_errors++; + return 0; + } + /* last frame in this batch */ if (skb->len == size) { smsc75xx_rx_csum_offload(dev, skb, rx_cmd_a,