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 8FF4143D503; Tue, 21 Jul 2026 21:59:27 +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=1784671168; cv=none; b=cP+13gDIFQqjdRhmpR8F0hsJvbGd88jD5VYAKrE5uHg4DlJ3uqTHC/xRWPCVXQTN29lOOzBg4bqc3+EiP+40lgY+U7wTAC363nkngOq6F9CRbggXnyZKXXG4hX2ZFddEZGuUwXmcKwd1R0HrrwduZtbIdd6zzr06mfCmHf/VkgM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784671168; c=relaxed/simple; bh=nvN9F2dtKeOs3x9IJhghlbnTvS410xZ7n0ytX5naaZM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qOFhgF+ryK7vWWxRQm7hIkVJEnveYhY87w4hLxflenDACe++KWNTX7a/qNR794w25bxp6mb5U6bRrqr1llRMtRtQd/Ekpiuq24ePlPuuDdTsolJpvJRUeuGQo9QAZlp7W2CpNZpS56oodnXAoEcaJp5P6qyiAtpyqxzk9IgmkVY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=MF5qsnMS; 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="MF5qsnMS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB6761F000E9; Tue, 21 Jul 2026 21:59:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784671167; bh=wPPCppWZ6TX3ooa5bfHUDj/jfbGO7e5HLOlsb3ncWUU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=MF5qsnMSoasRog+0GmNhxQF7VnldfVVww0ihWjbwqNn8aEYmlV6axZAwbd657E6n9 QvvlzSfRGDI4HuwUW6TtNgzEe8c6tJGAHcCoxrJreD1zxZhoB9ieH5Ee/UQUtGlkU9 BnBybJbBYiqehIrrVruz4DH7zu7wLd1lAIpj1DVg= 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 5.15 127/843] net: usb: kalmia: bound RX frame length in kalmia_rx_fixup() Date: Tue, 21 Jul 2026 17:16:02 +0200 Message-ID: <20260721152408.867519514@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152405.946368001@linuxfoundation.org> References: <20260721152405.946368001@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 5.15-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]);