mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-28 12:53:14 +01:00
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.
Fixes: 05d19bf500 ("net: wwan: t7xx: Add WWAN network interface")
Cc: [email protected]
Signed-off-by: Guanglei Zhu <[email protected]>
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.
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
This commit is contained in:
1 parent
31550d5855
commit
c7ead97042
1 file changed
+4
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user