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 68FC73BCD11; Thu, 16 Jul 2026 14:12:52 +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=1784211173; cv=none; b=IXDEL6yRiFceGvHHRuorsm8d+PNdPNgOtnv7kHAgfovG8BgNwWuuDRIoJt9315Ue64nF9aupo8c1ZZvrsJ+pW0kbJsR2YIvyubFpnKJ/misLes2ukSJqQErOP8frvZKADR41vQNS8Yohxkk6ys/gN96U1JRvxBp4R7m/9zOBACI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784211173; c=relaxed/simple; bh=C9XrTow29+/Z50OytExCMYI22kxVYraceN+2YcC2EGA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JWqONCPfsBWI3qo6SLgpJvgxOwLGxAmLEIy9DGfUl8AYPlPhmWMW0XKahHApPgunkr2yS6ZnzQxEh8M1OcDDGHwsiC2+Y8Xr9QPeF/Gce0VGzyAVumuF8QVM+ly4JZogb3g/zEanCrVt/L57x6sx9VyZ3xyqzzVyxulO9jKtUcQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=i6GcBZCV; 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="i6GcBZCV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD9441F000E9; Thu, 16 Jul 2026 14:12:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784211172; bh=OaXTEJgqFM0Jctlb9QWth9IPmmr7AqogdU7orzclOqA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=i6GcBZCV6AuKkkhuoKuOpaVMI3awD1mqcav3UKY1ZsAql4prdzen1v6VTjDqM7uIl J+3e86ohZjRhG7zk9p+lnySphcYEgbYjuXDJfdNRY5EwzqjLwRB2/Cdr8UuZ+ri0H9 kohwWsQ6ArLwQeY6Wrv0xTHHHWy+quPQDjjLjSHo= 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.18 283/480] net: usb: kalmia: bound RX frame length in kalmia_rx_fixup() Date: Thu, 16 Jul 2026 15:30:30 +0200 Message-ID: <20260716133050.949851263@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260716133044.672218725@linuxfoundation.org> References: <20260716133044.672218725@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.18-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]);