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 28EF8479876; Sat, 12 Sep 2026 15:59:29 +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=1789228771; cv=none; b=F72+/qKbE92KKlkuF1PBxLlJXKpNdXPOCgj3X8LPUwlDrSyJ2icUebynjI28OqVaVeWo0g8QOmDLVLfEEnnuIGWW01rW0pDkOh2lfvS0zZnhoPMppcofsfl9mi2W+CN0TEJjfZt88Frw/6olzVdLyUFoYJ0mpT0OyPOBBELfyhw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789228771; c=relaxed/simple; bh=E/fOICqEnhVn79Ee8DCwlNkyGQJCprcBMtKbOKEHwjE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jFjJDsotwR4FjtuM7rwZRDiLRV/QlotC39xT+ux2B9UbdyCYtIvvh3oeZUVG/XyHMXIj+rtqPi7fxvo14ylwJpiDLv1JZK8S7hz8ffsONajUjiQ/eE2Nevg1f0P12gszeWmCiA4cRJg6ozE9EtRVFWktvFxGtDDKPso0UvUypoc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=qhYTUqwZ; 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="qhYTUqwZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 948501F000FF; Sat, 12 Sep 2026 15:59:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789228769; bh=nS4BNCivA4QugIi4Ctvqbn8bg4keZD8wYkPSlE+Hs9g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=qhYTUqwZ4LREPTBNHP7c+FerGC2QypmfG3U7pBvRyHFTBsQeUba6UG5gL9LRznuSe +am6epyKRMkEGftR1/BAyiIrG2QU8jRIYec6WW/QYrqrm+RFxdm3HRpuMTLg4jwklw g8IMVreiAm0yD4SFf+UNyUfTTU2SBf1HJo+QRJlY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Tobi Gaertner , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.1 0452/1191] net: usb: cdc_ncm: add ndpoffset to NDP32 nframes bounds check Date: Sat, 12 Sep 2026 08:53:00 +0200 Message-ID: <20260912065558.387813660@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065548.086904252@linuxfoundation.org> References: <20260912065548.086904252@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.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tobi Gaertner [ Upstream commit 77914255155e68a20aa41175edeecf8121dac391 ] The same bounds-check bug fixed for NDP16 in the previous patch also exists in cdc_ncm_rx_verify_ndp32(). The DPE array size is validated against the total skb length without accounting for ndpoffset, allowing out-of-bounds reads when the NDP32 is placed near the end of the NTB. Add ndpoffset to the nframes bounds check and use struct_size_t() to express the NDP-plus-DPE-array size more clearly. Compile-tested only. Fixes: 0fa81b304a79 ("cdc_ncm: Implement the 32-bit version of NCM Transfer Block") Signed-off-by: Tobi Gaertner Link: https://patch.msgid.link/20260314054640.2895026-3-tob.gaertner@me.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/usb/cdc_ncm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c index 72f97a6d04bcc..a73ad0cd20fc3 100644 --- a/drivers/net/usb/cdc_ncm.c +++ b/drivers/net/usb/cdc_ncm.c @@ -1692,6 +1692,7 @@ int cdc_ncm_rx_verify_ndp32(struct sk_buff *skb_in, int ndpoffset) struct usbnet *dev = netdev_priv(skb_in->dev); struct usb_cdc_ncm_ndp32 *ndp32; int ret = -EINVAL; + size_t ndp_len; if ((ndpoffset + sizeof(struct usb_cdc_ncm_ndp32)) > skb_in->len) { netif_dbg(dev, rx_err, dev->net, "invalid NDP offset <%u>\n", @@ -1711,8 +1712,8 @@ int cdc_ncm_rx_verify_ndp32(struct sk_buff *skb_in, int ndpoffset) sizeof(struct usb_cdc_ncm_dpe32)); ret--; /* we process NDP entries except for the last one */ - if ((sizeof(struct usb_cdc_ncm_ndp32) + - ret * (sizeof(struct usb_cdc_ncm_dpe32))) > skb_in->len) { + ndp_len = struct_size_t(struct usb_cdc_ncm_ndp32, dpe32, ret); + if (ndpoffset + ndp_len > skb_in->len) { netif_dbg(dev, rx_err, dev->net, "Invalid nframes = %d\n", ret); ret = -EINVAL; } -- 2.53.0