aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/net/ethernet/freescale/fman/mac.c
diff options
context:
space:
mode:
authorAleksandr Mishin <amishin@t-argos.ru>2024-10-28 09:58:24 +0300
committerJakub Kicinski <kuba@kernel.org>2024-10-31 19:05:09 -0700
commitbd50c4125c98bd1a86f8e514872159700a9c678c (patch)
tree0c1246d87cf596cfb8785ae0c7eefa711613e4c5 /drivers/net/ethernet/freescale/fman/mac.c
parentnetlabel: document doi_remove field of struct netlbl_calipso_ops (diff)
downloadwireguard-linux-bd50c4125c98bd1a86f8e514872159700a9c678c.tar.xz
wireguard-linux-bd50c4125c98bd1a86f8e514872159700a9c678c.zip
fsl/fman: Validate cell-index value obtained from Device Tree
Cell-index value is obtained from Device Tree and then used to calculate the index for accessing arrays port_mfl[], mac_mfl[] and intr_mng[]. In case of broken DT due to any error cell-index can contain any value and it is possible to go beyond the array boundaries which can lead at least to memory corruption. Validate cell-index value obtained from Device Tree. Found by Linux Verification Center (linuxtesting.org) with SVACE. Reviewed-by: Sean Anderson <sean.anderson@seco.com> Signed-off-by: Aleksandr Mishin <amishin@t-argos.ru> Link: https://patch.msgid.link/20241028065824.15452-1-amishin@t-argos.ru Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to '')
-rw-r--r--drivers/net/ethernet/freescale/fman/mac.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/net/ethernet/freescale/fman/mac.c b/drivers/net/ethernet/freescale/fman/mac.c
index c7bff9490ce0..a39fcea6a77a 100644
--- a/drivers/net/ethernet/freescale/fman/mac.c
+++ b/drivers/net/ethernet/freescale/fman/mac.c
@@ -217,6 +217,11 @@ static int mac_probe(struct platform_device *_of_dev)
err = -EINVAL;
goto _return_dev_put;
}
+ if (val >= MAX_NUM_OF_MACS) {
+ dev_err(dev, "cell-index value is too big for %pOF\n", mac_node);
+ err = -EINVAL;
+ goto _return_dev_put;
+ }
priv->cell_index = (u8)val;
/* Get the MAC address */