From: tobgaertner <tob.gaertner@me.com>
To: netdev@vger.kernel.org
Cc: linux-usb@vger.kernel.org, gregkh@linuxfoundation.org,
oneukum@suse.com, bjorn@mork.no,
tobgaertner <tob.gaertner@me.com>
Subject: [PATCH v2 2/2] net: usb: cdc_ncm: add ndpoffset to NDP32 nframes bounds check
Date: Mon, 9 Mar 2026 13:34:49 -0700 [thread overview]
Message-ID: <20260309203449.2594858-3-tob.gaertner@me.com> (raw)
In-Reply-To: <20260309203449.2594858-1-tob.gaertner@me.com>
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.
Fixes: 0fa81b304a79 ("cdc_ncm: Implement the 32-bit version of NCM Transfer Block")
Signed-off-by: Tobi Gaertner <tob.gaertner@me.com>compile-tested only.
---
drivers/net/usb/cdc_ncm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 846f8b997..0689169d3 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -1711,8 +1711,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) {
+ if (ndpoffset + struct_size_t(struct usb_cdc_ncm_ndp32,
+ dpe32, ret) > skb_in->len) {
netif_dbg(dev, rx_err, dev->net, "Invalid nframes = %d\n", ret);
ret = -EINVAL;
}
--
2.43.0
next prev parent reply other threads:[~2026-03-09 20:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-09 20:34 [PATCH v2 0/2] net: usb: cdc_ncm: fix NDP nframes bounds check tobgaertner
2026-03-09 20:34 ` [PATCH v2 1/2] net: usb: cdc_ncm: add ndpoffset to NDP16 " tobgaertner
2026-03-12 1:53 ` Jakub Kicinski
2026-03-09 20:34 ` tobgaertner [this message]
2026-03-12 1:53 ` [PATCH v2 2/2] net: usb: cdc_ncm: add ndpoffset to NDP32 " Jakub Kicinski
2026-03-11 17:17 ` [PATCH v2 0/2] net: usb: cdc_ncm: fix NDP " Simon Horman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260309203449.2594858-3-tob.gaertner@me.com \
--to=tob.gaertner@me.com \
--cc=bjorn@mork.no \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=oneukum@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox