From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE5901D14F; Mon, 18 Dec 2023 14:13:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="x+Ij7nqT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 077F5C433C7; Mon, 18 Dec 2023 14:13:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1702908820; bh=1Q1RfpzNouIx+mfyP+xg9W+WfHNyXrTHy0N4jP1EzBE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x+Ij7nqTSu1EtP1C44UbY4FJcg4D5do5xdB0oR9EZDqTSCFmzmwVQl5s0aTYkFLUq zzMOE3UwRMC2D+qRSMgN/8ayh/gkl2XYQCzvL4Y9kw7oN8H68BMn0gyQ+jmDaXzkJr YDWHGIixIrq233BC0hG6N/6M4hBfDmkC+0h4LOZE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Oliver Neukum , "David S. Miller" , Sasha Levin Subject: [PATCH 5.15 46/83] usb: aqc111: check packet for fixup for true limit Date: Mon, 18 Dec 2023 14:52:07 +0100 Message-ID: <20231218135051.780819334@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231218135049.738602288@linuxfoundation.org> References: <20231218135049.738602288@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Oliver Neukum [ Upstream commit ccab434e674ca95d483788b1895a70c21b7f016a ] If a device sends a packet that is inbetween 0 and sizeof(u64) the value passed to skb_trim() as length will wrap around ending up as some very large value. The driver will then proceed to parse the header located at that position, which will either oops or process some random value. The fix is to check against sizeof(u64) rather than 0, which the driver currently does. The issue exists since the introduction of the driver. Signed-off-by: Oliver Neukum Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/usb/aqc111.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c index e8d49886d6953..bc5e3f45c499e 100644 --- a/drivers/net/usb/aqc111.c +++ b/drivers/net/usb/aqc111.c @@ -1079,17 +1079,17 @@ static int aqc111_rx_fixup(struct usbnet *dev, struct sk_buff *skb) u16 pkt_count = 0; u64 desc_hdr = 0; u16 vlan_tag = 0; - u32 skb_len = 0; + u32 skb_len; if (!skb) goto err; - if (skb->len == 0) + skb_len = skb->len; + if (skb_len < sizeof(desc_hdr)) goto err; - skb_len = skb->len; /* RX Descriptor Header */ - skb_trim(skb, skb->len - sizeof(desc_hdr)); + skb_trim(skb, skb_len - sizeof(desc_hdr)); desc_hdr = le64_to_cpup((u64 *)skb_tail_pointer(skb)); /* Check these packets */ -- 2.43.0