Skip to content

Commit 0c3f251

Browse files
nbd168desmondc9
authored andcommitted
kernel: backport MTK ethernet/WLAN offload fixes
Fixes issues with offloading to WED, especially with VLAN bridges involved Signed-off-by: Felix Fietkau <[email protected]>
1 parent 3be6d4a commit 0c3f251

3 files changed

+122
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
From: Tom Rix <[email protected]>
2+
Date: Sat, 16 Jul 2022 17:46:54 -0400
3+
Subject: [PATCH] net: ethernet: mtk_eth_soc: fix off by one check of
4+
ARRAY_SIZE
5+
6+
In mtk_wed_tx_ring_setup(.., int idx, ..), idx is used as an index here
7+
struct mtk_wed_ring *ring = &dev->tx_ring[idx];
8+
9+
The bounds of idx are checked here
10+
BUG_ON(idx > ARRAY_SIZE(dev->tx_ring));
11+
12+
If idx is the size of the array, it will pass this check and overflow.
13+
So change the check to >= .
14+
15+
Fixes: 804775dfc288 ("net: ethernet: mtk_eth_soc: add support for Wireless Ethernet Dispatch (WED)")
16+
Signed-off-by: Tom Rix <[email protected]>
17+
Link: https://lore.kernel.org/r/[email protected]
18+
Signed-off-by: Jakub Kicinski <[email protected]>
19+
---
20+
21+
--- a/drivers/net/ethernet/mediatek/mtk_wed.c
22+
+++ b/drivers/net/ethernet/mediatek/mtk_wed.c
23+
@@ -651,7 +651,7 @@ mtk_wed_tx_ring_setup(struct mtk_wed_dev
24+
* WDMA RX.
25+
*/
26+
27+
- BUG_ON(idx > ARRAY_SIZE(dev->tx_ring));
28+
+ BUG_ON(idx >= ARRAY_SIZE(dev->tx_ring));
29+
30+
if (mtk_wed_ring_alloc(dev, ring, MTK_WED_TX_RING_SIZE))
31+
return -ENOMEM;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
From: Lorenzo Bianconi <[email protected]>
2+
Date: Mon, 18 Jul 2022 11:51:53 +0200
3+
Subject: [PATCH] net: ethernet: mtk_ppe: fix possible NULL pointer dereference
4+
in mtk_flow_get_wdma_info
5+
6+
odev pointer can be NULL in mtk_flow_offload_replace routine according
7+
to the flower action rules. Fix possible NULL pointer dereference in
8+
mtk_flow_get_wdma_info.
9+
10+
Fixes: a333215e10cb5 ("net: ethernet: mtk_eth_soc: implement flow offloading to WED devices")
11+
Signed-off-by: Lorenzo Bianconi <[email protected]>
12+
Link: https://lore.kernel.org/r/4e1685bc4976e21e364055f6bee86261f8f9ee93.1658137753.git.lorenzo@kernel.org
13+
Signed-off-by: Jakub Kicinski <[email protected]>
14+
---
15+
16+
--- a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
17+
+++ b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
18+
@@ -93,6 +93,9 @@ mtk_flow_get_wdma_info(struct net_device
19+
};
20+
struct net_device_path path = {};
21+
22+
+ if (!ctx.dev)
23+
+ return -ENODEV;
24+
+
25+
memcpy(ctx.daddr, addr, sizeof(ctx.daddr));
26+
27+
if (!IS_ENABLED(CONFIG_NET_MEDIATEK_SOC_WED))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
From: Lorenzo Bianconi <[email protected]>
2+
Date: Fri, 22 Jul 2022 09:06:19 +0200
3+
Subject: [PATCH] net: ethernet: mtk-ppe: fix traffic offload with bridged wlan
4+
5+
A typical flow offload scenario for OpenWrt users is routed traffic
6+
received by the wan interface that is redirected to a wlan device
7+
belonging to the lan bridge. Current implementation fails to
8+
fill wdma offload info in mtk_flow_get_wdma_info() since odev device is
9+
the local bridge. Fix the issue running dev_fill_forward_path routine in
10+
mtk_flow_get_wdma_info in order to identify the wlan device.
11+
12+
Tested-by: Paolo Valerio <[email protected]>
13+
Signed-off-by: Lorenzo Bianconi <[email protected]>
14+
Signed-off-by: David S. Miller <[email protected]>
15+
---
16+
17+
--- a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
18+
+++ b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
19+
@@ -88,32 +88,28 @@ mtk_flow_offload_mangle_eth(const struct
20+
static int
21+
mtk_flow_get_wdma_info(struct net_device *dev, const u8 *addr, struct mtk_wdma_info *info)
22+
{
23+
- struct net_device_path_ctx ctx = {
24+
- .dev = dev,
25+
- };
26+
- struct net_device_path path = {};
27+
+ struct net_device_path_stack stack;
28+
+ struct net_device_path *path;
29+
+ int err;
30+
31+
- if (!ctx.dev)
32+
+ if (!dev)
33+
return -ENODEV;
34+
35+
- memcpy(ctx.daddr, addr, sizeof(ctx.daddr));
36+
-
37+
if (!IS_ENABLED(CONFIG_NET_MEDIATEK_SOC_WED))
38+
return -1;
39+
40+
- if (!dev->netdev_ops->ndo_fill_forward_path)
41+
- return -1;
42+
-
43+
- if (dev->netdev_ops->ndo_fill_forward_path(&ctx, &path))
44+
- return -1;
45+
+ err = dev_fill_forward_path(dev, addr, &stack);
46+
+ if (err)
47+
+ return err;
48+
49+
- if (path.type != DEV_PATH_MTK_WDMA)
50+
+ path = &stack.path[stack.num_paths - 1];
51+
+ if (path->type != DEV_PATH_MTK_WDMA)
52+
return -1;
53+
54+
- info->wdma_idx = path.mtk_wdma.wdma_idx;
55+
- info->queue = path.mtk_wdma.queue;
56+
- info->bss = path.mtk_wdma.bss;
57+
- info->wcid = path.mtk_wdma.wcid;
58+
+ info->wdma_idx = path->mtk_wdma.wdma_idx;
59+
+ info->queue = path->mtk_wdma.queue;
60+
+ info->bss = path->mtk_wdma.bss;
61+
+ info->wcid = path->mtk_wdma.wcid;
62+
63+
return 0;
64+
}

0 commit comments

Comments
 (0)