[PATCH net 3/4] net: ethernet: cortina: Protect against oversized frames
Linus Walleij
linus.walleij at linaro.org
Sat Nov 4 05:43:50 PDT 2023
The max size of a transfer no matter the MTU is 64KB-1 so immediately
bail out if the skb exceeds that.
Fixes: 4d5ae32f5e1e ("net: ethernet: Add a driver for Gemini gigabit ethernet")
Signed-off-by: Linus Walleij <linus.walleij at linaro.org>
---
drivers/net/ethernet/cortina/gemini.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
index fd08f098850b..23723c9c0f93 100644
--- a/drivers/net/ethernet/cortina/gemini.c
+++ b/drivers/net/ethernet/cortina/gemini.c
@@ -1156,6 +1156,12 @@ static int gmac_map_tx_bufs(struct net_device *netdev, struct sk_buff *skb,
mtu = MTU_SIZE_BIT_MASK;
}
+ if (skb->len > 65535) {
+ /* The field for length is only 16 bits */
+ netdev_err(netdev, "%s: frame too big, max size 65535 bytes\n", __func__);
+ return -EINVAL;
+ }
+
word1 = skb->len;
word3 = SOF_BIT;
--
2.34.1
More information about the linux-arm-kernel
mailing list