All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] net: wwan: mhi_wwan_mbim: guard against a cyclic NDP chain
@ 2026-09-10  3:33 Guanglei Zhu
  2026-09-10  3:33 ` [PATCH 2/3] net: wwan: mhi_wwan_mbim: check skb_copy_bits() return value Guanglei Zhu
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Guanglei Zhu @ 2026-09-10  3:33 UTC (permalink / raw)
  To: Loic Poulain, Sergey Ryazanov
  Cc: Chandrashekar Devegowda, Liu Haijun, Ricardo Martinez,
	Johannes Berg, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, netdev, linux-kernel, stable

The NDP traversal in mhi_mbim_rx() only stops when wNextNdpIndex is
zero.  Nothing requires the offsets to advance, so a modem that
points an NDP at itself, or at an earlier NDP, keeps the loop
spinning forever on one CPU.

Break out when the next NDP offset is not larger than the current
one.

Fixes: aa730a9905b7 ("net: wwan: Add MHI MBIM network driver")
Cc: stable@vger.kernel.org
Signed-off-by: Guanglei Zhu <zhugl3@xiaopeng.com>
---

Verified in a QEMU guest with a fault injector feeding the driver's
receive callback an NTB whose single NDP points at itself: the
unpatched driver spins in mhi_mbim_rx() with one CPU pinned at 100%
and the thread never returns.  With this check the loop terminates
within one iteration.
 drivers/net/wwan/mhi_wwan_mbim.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/wwan/mhi_wwan_mbim.c b/drivers/net/wwan/mhi_wwan_mbim.c
index a94998712..ef158edeb 100644
--- a/drivers/net/wwan/mhi_wwan_mbim.c
+++ b/drivers/net/wwan/mhi_wwan_mbim.c
@@ -254,6 +254,7 @@ static int mbim_rx_verify_ndp16(struct sk_buff *skb, struct usb_cdc_ncm_ndp16 *n
 static void mhi_mbim_rx(struct mhi_mbim_context *mbim, struct sk_buff *skb)
 {
 	int ndpoffset;
+	int last_ndpoffset = 0;
 
 	/* Check NTB header and retrieve first NDP offset */
 	ndpoffset = mbim_rx_verify_nth16(mbim, skb);
@@ -265,6 +266,13 @@ static void mhi_mbim_rx(struct mhi_mbim_context *mbim, struct sk_buff *skb)
 	/* Process each NDP */
 	while (1) {
 		struct usb_cdc_ncm_ndp16 ndp16;
+
+		if (ndpoffset <= last_ndpoffset) {
+			net_err_ratelimited("mbim: non-increasing NDP offset (%u)\n",
+					    ndpoffset);
+			break;
+		}
+		last_ndpoffset = ndpoffset;
 		struct usb_cdc_ncm_dpe16 dpe16;
 		struct mhi_mbim_link *link;
 		int nframes, n, dpeoffset;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-09-11  2:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-10  3:33 [PATCH 1/3] net: wwan: mhi_wwan_mbim: guard against a cyclic NDP chain Guanglei Zhu
2026-09-10  3:33 ` [PATCH 2/3] net: wwan: mhi_wwan_mbim: check skb_copy_bits() return value Guanglei Zhu
2026-09-10  8:09   ` Loic Poulain
2026-09-10  3:33 ` [PATCH 3/3] net: wwan: t7xx: validate the netif index in t7xx_ccmni_recv_skb() Guanglei Zhu
2026-09-10  8:20 ` [PATCH 1/3] net: wwan: mhi_wwan_mbim: guard against a cyclic NDP chain Loic Poulain
2026-09-11  2:17 ` [PATCH v2 " Guanglei Zhu
2026-09-11  2:17   ` [PATCH v2 2/3] net: wwan: mhi_wwan_mbim: check skb_copy_bits() return value Guanglei Zhu
2026-09-11  2:17   ` [PATCH v2 3/3] net: wwan: t7xx: validate the netif index in t7xx_ccmni_recv_skb() Guanglei Zhu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.