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 688F714F63; Mon, 18 Dec 2023 14:08:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="IGs5pmlT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DEE7BC433C7; Mon, 18 Dec 2023 14:08:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1702908503; bh=yiHRoC1r1lBxKJb/hoKSSfnFzbFIisABglpp7zhNDdU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IGs5pmlTlDhr82zG5k7uWi4GimepkuesHny8DmM5YwM1VeZqsJ9s/vPzOf3FYk2R2 AWFUKkQoa5HYt8TwsuWrqBgs9DBE+JktGBVA75xZLcKMtm7HLGsju95s2xpKtujqgJ 2Xhg4LsyaN7AXcO0zjCgtGqNK9yAaGZZdSEAyUuY= 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.10 33/62] usb: aqc111: check packet for fixup for true limit Date: Mon, 18 Dec 2023 14:51:57 +0100 Message-ID: <20231218135047.749876426@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231218135046.178317233@linuxfoundation.org> References: <20231218135046.178317233@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.10-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 c9c4095181744..4ea02116be182 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