Skip to content

Commit ed5f07e

Browse files
lategoodbyejfvogel
authored andcommitted
net: vertexcom: mse102x: Add range check for CMD_RTS
[ Upstream commit d4dda902dac194e3231a1ed0f76c6c3b6340ba8a ] Since there is no protection in the SPI protocol against electrical interferences, the driver shouldn't blindly trust the length payload of CMD_RTS. So introduce a bounds check for incoming frames. Fixes: 2f207cb ("net: vertexcom: Add MSE102x SPI support") Signed-off-by: Stefan Wahren <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit 2e5b8eb6b42e7108f14cf3c65fd079832a498b63) Signed-off-by: Jack Vogel <[email protected]>
1 parent 8b6cb62 commit ed5f07e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/net/ethernet/vertexcom/mse102x.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
88

9+
#include <linux/if_vlan.h>
910
#include <linux/interrupt.h>
1011
#include <linux/module.h>
1112
#include <linux/kernel.h>
@@ -337,8 +338,9 @@ static void mse102x_rx_pkt_spi(struct mse102x_net *mse)
337338
}
338339

339340
rxlen = cmd_resp & LEN_MASK;
340-
if (!rxlen) {
341-
net_dbg_ratelimited("%s: No frame length defined\n", __func__);
341+
if (rxlen < ETH_ZLEN || rxlen > VLAN_ETH_FRAME_LEN) {
342+
net_dbg_ratelimited("%s: Invalid frame length: %d\n", __func__,
343+
rxlen);
342344
mse->stats.invalid_len++;
343345
return;
344346
}

0 commit comments

Comments
 (0)