From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 6ED8441735B; Tue, 21 Jul 2026 20:20:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784665232; cv=none; b=btz64kSG3JRobh/psUVPzhQJHoUge+OZOw1eBQi6NRKxOeisQtC3iu3oGTni+lqdGNhOiH2BAy/tcKaewoc3aaHddDGnnNWkZyhYzThgiReoUxYwTP2CgyWyuv8PoeKH6H4gwmEKwXf06zjH69Ca0D2OucE1LlCtK6ryHFH4H6c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784665232; c=relaxed/simple; bh=hiMzSh4qhnhFJ3tTm8+qK1pmGsPvzwhWBw8zZ/qVo3w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K4LJjmw/3c1zfai8jLghFdOx/IDShnaVnvqRDQ+go8Uq2axQLztJNwYpQxmCNDGPMvxCvhAXKoTOg7Zr66phIubsKdYxkW+zxFMWhi87riErtVHefHKag3la/iU2ndvWpgfnn/OraugepYYGVyu1SP6fCZRgg3AJuKMA66UB3/I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=b9lS+O3F; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="b9lS+O3F" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8AA1E1F000E9; Tue, 21 Jul 2026 20:20:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784665231; bh=pcClcet34O/RM7QJQ8FoNtXEdeKZm2adVgQvVhlGZeg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=b9lS+O3FHwsAwrmuwNieoZL5w7QbH0m/72IhNaKDqAZ+4E4Js5rWLlsiMZvwB2I3K 4BkK5M9tkwXKQUqdkuMd51KLJmnyAw8VLCDWkY9hxzjiczRRtwV0nhhKX5xO1rbrRe FmtNzDLeO91vVflgnF9ubZ+5/0Klvf5BJl8whKS8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Maoyi Xie , Andrew Lunn , Jakub Kicinski Subject: [PATCH 6.6 0224/1266] net: usb: kalmia: bound RX frame length in kalmia_rx_fixup() Date: Tue, 21 Jul 2026 17:11:01 +0200 Message-ID: <20260721152446.830786916@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152441.786066624@linuxfoundation.org> References: <20260721152441.786066624@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Maoyi Xie commit 47b6bcef6e679593d2e86e04ee72c46a4e2f7139 upstream. kalmia_rx_fixup() computes usb_packet_length = skb->len - (2 * KALMIA_HEADER_LENGTH) as a u16, guarded only by a pre-loop check that skb->len is at least KALMIA_HEADER_LENGTH, which is 6. A device can deliver a short bulk-IN frame with skb->len in the 6 to 11 range, or leave a short trailing remainder on a later loop iteration. Either case underflows usb_packet_length to about 65530. That bypasses the usb_packet_length < ether_packet_length truncation path. The device-supplied ether_packet_length, a le16 up to 65535 read from header_start[2], then drives a memcmp() and the following skb_trim() and skb_pull() past the end of the rx buffer. The rx buffer is hard_mtu * 10, which is 14000 bytes. That is an out of bounds read. Require both the start and end framing headers to be present before subtracting them, on every loop iteration. Fixes: d40261236e8e ("net/usb: Add Samsung Kalmia driver for Samsung GT-B3730") Cc: stable@vger.kernel.org Signed-off-by: Maoyi Xie Reviewed-by: Andrew Lunn Link: https://patch.msgid.link/178211531778.2216480.12637613349790980750@maoyixie.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/usb/kalmia.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/drivers/net/usb/kalmia.c +++ b/drivers/net/usb/kalmia.c @@ -276,6 +276,14 @@ kalmia_rx_fixup(struct usbnet *dev, stru "Received header: %6phC. Package length: %i\n", header_start, skb->len - KALMIA_HEADER_LENGTH); + /* both framing headers must be present before we subtract + * them, otherwise usb_packet_length underflows and the + * device-supplied ether_packet_length drives an out of bounds + * access below + */ + if (skb->len < 2 * KALMIA_HEADER_LENGTH) + return 0; + /* subtract start header and end header */ usb_packet_length = skb->len - (2 * KALMIA_HEADER_LENGTH); ether_packet_length = get_unaligned_le16(&header_start[2]);