FAILED: patch "[PATCH] net: wwan: t7xx: validate the netif index in" failed to apply to 6.1-stable tree
[email protected]
maintainerThe patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x c7ead9704249d57d4693a04697e3bbd285138fa9
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026092215-sincere-shack-66e6@gregkh' --subject-prefix 'PATCH 6.1.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From c7ead9704249d57d4693a04697e3bbd285138fa9 Mon Sep 17 00:00:00 2001
From: Guanglei Zhu <[email protected]>
Date: Fri, 11 Sep 2026 10:17:34 +0800
Subject: [PATCH] net: wwan: t7xx: validate the netif index in
t7xx_ccmni_recv_skb()
The netif index carried in the DPMAIF PIT header is five bits wide, but ccmni_inst[] only has room for NIC_DEV_MAX (21) entries. t7xx_ccmni_recv_skb() indexes the array without a bounds check, so indexes 21 to 31 read past it. The out-of-bounds value lands in the callback table that follows the array, which is never NULL, so the existing !ccmni check does not catch it and the driver dereferences whatever sits there as a struct t7xx_ccmni.
Drop the skb when the index is out of range.
Verified in a QEMU guest with a fault injector setting the netif index to 25: the unpatched driver reads a value past ccmni_inst[], which lands in the callback table, and dereferences it far enough to queue the skb. With this check the packet is dropped. Well-formed traffic on index 0 is unaffected.
Changes in v2: none.
drivers/net/wwan/t7xx/t7xx_netdev.c +4 -0
@@ -420,6 +420,10 @@ static void t7xx_ccmni_recv_skb(struct t7xx_ccmni_ctrl *ccmni_ctlb, struct sk_bu skb_cb =T7XX_SKB_CB (skb); netif_id = skb_cb->netif_idx; +if (netif_id >=NIC_DEV_MAX ) { +dev_kfree_skb (skb); +return ; + } ccmni =READ_ONCE (ccmni_ctlb->ccmni_inst[netif_id]);if (!ccmni) {dev_kfree_skb (skb);
Sasha Levin
maintainerPATCH 1/2 net: wwan: t7xx: Fix napi rx poll issue
From: Jinjian Song <[email protected]>
[ Upstream commit 905fe0845bb27e4eed2ca27ea06e6c4847f1b2b1 ]
When driver handles the napi rx polling requests, the netdev might have been released by the dellink logic triggered by the disconnect operation on user plane. However, in the logic of processing skb in polling, an invalid netdev is still being used, which causes a panic.
BUG: kernel NULL pointer dereference, address: 00000000000000f1 Oops: 0000 [#1] PREEMPT SMP NOPTI RIP: 0010:dev_gro_receive+0x3a/0x620 [...] Call Trace: <IRQ> ? __die_body+0x68/0xb0 ? page_fault_oops+0x379/0x3e0 ? exc_page_fault+0x4f/0xa0 ? asm_exc_page_fault+0x22/0x30 ? __pfx_t7xx_ccmni_recv_skb+0x10/0x10 [mtk_t7xx (HASH:1400 7)] ? dev_gro_receive+0x3a/0x620 napi_gro_receive+0xad/0x170 t7xx_ccmni_recv_skb+0x48/0x70 [mtk_t7xx (HASH:1400 7)] t7xx_dpmaif_napi_rx_poll+0x590/0x800 [mtk_t7xx (HASH:1400 7)] net_rx_action+0x103/0x470 irq_exit_rcu+0x13a/0x310 sysvec_apic_timer_interrupt+0x56/0x90 </IRQ>
Backport to 6.1: the receive callback still takes struct t7xx_pci_dev and delivers packets through netif_rx(), without the upstream NAPI conversion. Keep that callback interface and add a local ccmni_ctlb pointer so the READ_ONCE() lookup uses the upstream expression. Retain the other pointer publication, removal, and notification changes.
This also preserves the receive-side context needed to apply c7ead9704249 ("net: wwan: t7xx: validate the netif index in t7xx_ccmni_recv_skb()") unchanged. No new functions are introduced.
Stable-dep-of: c7ead9704249 ("net: wwan: t7xx: validate the netif index in t7xx_ccmni_recv_skb()")
--- drivers/net/wwan/t7xx/t7xx_netdev.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/net/wwan/t7xx/t7xx_netdev.c +7 -5
@@ -205,7 +205,7 @@ static int t7xx_ccmni_wwan_newlink(void *ctxt, struct net_device *dev, u32 if_id ccmni->ctlb = ctlb; ccmni->dev = dev;atomic_set (&ccmni->usage,0 ); - ctlb->ccmni_inst[if_id] = ccmni; +WRITE_ONCE (ctlb->ccmni_inst[if_id], ccmni); ret =register_netdevice (dev);if (ret)
@@ -227,6 +227,7 @@ static void t7xx_ccmni_wwan_dellink(void *ctxt, struct net_device *dev, struct lif (WARN_ON (ctlb->ccmni_inst[if_id] != ccmni))return ; +WRITE_ONCE (ctlb->ccmni_inst[if_id],NULL );unregister_netdevice (dev); }
@@ -313,6 +314,7 @@ static void init_md_status_notifier(struct t7xx_pci_dev *t7xx_dev)static void t7xx_ccmni_recv_skb (struct t7xx_pci_dev *t7xx_dev,struct sk_buff *skb) { +struct t7xx_ccmni_ctrl *ccmni_ctlb = t7xx_dev->ccmni_ctlb;struct t7xx_skb_cb *skb_cb;struct net_device *net_dev;struct t7xx_ccmni *ccmni;
@@ -321,7 +323,7 @@ static void t7xx_ccmni_recv_skb(struct t7xx_pci_dev *t7xx_dev, struct sk_buff *s skb_cb =T7XX_SKB_CB (skb); netif_id = skb_cb->netif_idx; - ccmni = t7xx_dev->ccmni_ctlb->ccmni_inst[netif_id]; + ccmni =READ_ONCE (ccmni_ctlb->ccmni_inst[netif_id]);if (!ccmni) {dev_kfree_skb (skb);return ;
@@ -344,7 +346,7 @@ static void t7xx_ccmni_recv_skb(struct t7xx_pci_dev *t7xx_dev, struct sk_buff *sstatic void t7xx_ccmni_queue_tx_irq_notify (struct t7xx_ccmni_ctrl *ctlb,int qno) { -struct t7xx_ccmni *ccmni = ctlb->ccmni_inst[0 ]; +struct t7xx_ccmni *ccmni =READ_ONCE (ctlb->ccmni_inst[0 ]);struct netdev_queue *net_queue;if (netif_running (ccmni->dev) &&atomic_read (&ccmni->usage) >0 ) {
@@ -356,7 +358,7 @@ static void t7xx_ccmni_queue_tx_irq_notify(struct t7xx_ccmni_ctrl *ctlb, int qnostatic void t7xx_ccmni_queue_tx_full_notify (struct t7xx_ccmni_ctrl *ctlb,int qno) { -struct t7xx_ccmni *ccmni = ctlb->ccmni_inst[0 ]; +struct t7xx_ccmni *ccmni =READ_ONCE (ctlb->ccmni_inst[0 ]);struct netdev_queue *net_queue;if (atomic_read (&ccmni->usage) >0 ) {
@@ -374,7 +376,7 @@ static void t7xx_ccmni_queue_state_notify(struct t7xx_pci_dev *t7xx_dev,if (ctlb->md_sta !=MD_STATE_READY )return ; -if (!ctlb->ccmni_inst[0 ]) { +if (!READ_ONCE (ctlb->ccmni_inst[0 ])) {dev_warn (&t7xx_dev->pdev->dev,"No netdev registered yet\n" );return ; }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/2 net: wwan: t7xx: validate the netif index in t7xx_ccmni_recv_skb()
From: Guanglei Zhu <[email protected]>
[ Upstream commit c7ead9704249d57d4693a04697e3bbd285138fa9 ]
The netif index carried in the DPMAIF PIT header is five bits wide, but ccmni_inst[] only has room for NIC_DEV_MAX (21) entries. t7xx_ccmni_recv_skb() indexes the array without a bounds check, so indexes 21 to 31 read past it. The out-of-bounds value lands in the callback table that follows the array, which is never NULL, so the existing !ccmni check does not catch it and the driver dereferences whatever sits there as a struct t7xx_ccmni.
Drop the skb when the index is out of range.
Verified in a QEMU guest with a fault injector setting the netif index to 25: the unpatched driver reads a value past ccmni_inst[], which lands in the callback table, and dereferences it far enough to queue the skb. With this check the packet is dropped. Well-formed traffic on index 0 is unaffected.
Changes in v2: none.
--- drivers/net/wwan/t7xx/t7xx_netdev.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wwan/t7xx/t7xx_netdev.c +4 -0
@@ -323,6 +323,10 @@ static void t7xx_ccmni_recv_skb(struct t7xx_pci_dev *t7xx_dev, struct sk_buff *s skb_cb =T7XX_SKB_CB (skb); netif_id = skb_cb->netif_idx; +if (netif_id >=NIC_DEV_MAX ) { +dev_kfree_skb (skb); +return ; + } ccmni =READ_ONCE (ccmni_ctlb->ccmni_inst[netif_id]);if (!ccmni) {dev_kfree_skb (skb);
Signature · 1 line
2.53.0
PATCH 1/1 net: wwan: t7xx: validate the netif index in t7xx_ccmni_recv_skb()
In reply to [email protected]commit c7ead9704249d57d4693a04697e3bbd285138fa9 upstream.
The netif index carried in the DPMAIF PIT header is five bits wide, but ccmni_inst[] only has room for NIC_DEV_MAX (21) entries. t7xx_ccmni_recv_skb() indexes the array without a bounds check, so indexes 21 to 31 read past it. The out-of-bounds value lands in the callback table that follows the array, which is never NULL, so the existing !ccmni check does not catch it and the driver dereferences whatever sits there as a struct t7xx_ccmni.
Drop the skb when the index is out of range.
--- drivers/net/wwan/t7xx/t7xx_netdev.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wwan/t7xx/t7xx_netdev.c +4 -0
@@ -321,6 +321,10 @@ static void t7xx_ccmni_recv_skb(struct t7xx_pci_dev *t7xx_dev, struct sk_buff *s skb_cb =T7XX_SKB_CB (skb); netif_id = skb_cb->netif_idx; +if (netif_id >=NIC_DEV_MAX ) { +dev_kfree_skb (skb); +return ; + } ccmni = t7xx_dev->ccmni_ctlb->ccmni_inst[netif_id];if (!ccmni) {dev_kfree_skb (skb);
Signature · 1 line
2.43.0
Sasha Levin
maintainerRe: [PATCH 6.1.y] net: wwan: t7xx: validate the netif index in t7xx_ccmni_recv_skb()
Quoted 3 lines
Fixes 05d19bf500f8 ("net: wwan: t7xx: Add WWAN network interface")Signed-off-by Guanglei Zhu <[email protected]>
This is missing the last two trailers of the upstream commit:
Could you resend with the full upstream trailer block?
Signature · 2 lines
Thanks, Sasha
PATCH v2 1/1 net: wwan: t7xx: validate the netif index in t7xx_ccmni_recv_skb()
In reply to Guanglei Zhucommit c7ead9704249d57d4693a04697e3bbd285138fa9 upstream.
The netif index carried in the DPMAIF PIT header is five bits wide, but ccmni_inst[] only has room for NIC_DEV_MAX (21) entries. t7xx_ccmni_recv_skb() indexes the array without a bounds check, so indexes 21 to 31 read past it. The out-of-bounds value lands in the callback table that follows the array, which is never NULL, so the existing !ccmni check does not catch it and the driver dereferences whatever sits there as a struct t7xx_ccmni.
Drop the skb when the index is out of range.
---
v2: add the Link: and Signed-off-by: Jakub Kicinski trailers from the upstream commit, as requested by Sasha Levin. No change to the code or the rest of the commit message.
drivers/net/wwan/t7xx/t7xx_netdev.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wwan/t7xx/t7xx_netdev.c +4 -0
@@ -321,6 +321,10 @@ static void t7xx_ccmni_recv_skb(struct t7xx_pci_dev *t7xx_dev, struct sk_buff *s skb_cb =T7XX_SKB_CB (skb); netif_id = skb_cb->netif_idx; +if (netif_id >=NIC_DEV_MAX ) { +dev_kfree_skb (skb); +return ; + } ccmni = t7xx_dev->ccmni_ctlb->ccmni_inst[netif_id];if (!ccmni) {dev_kfree_skb (skb);
Signature · 1 line
2.43.0
Re: [PATCH 6.1.y v2] net: wwan: t7xx: validate the netif index in t7xx_ccmni_recv_skb()
Quoted 3 lines
v2: add the Link: and Signed-off-by: Jakub Kicinski trailers from the upstream commit, as requested by Sasha Levin. No change to the code or the rest of the commit message.
Queued for 6.1, thanks. This replaces my own 6.1.y series for this fix from September 22, which I'm withdrawing.
Signature · 2 lines
Thanks, Sasha