kernel_samsung_a53x/drivers/net/ethernet/marvell
Gustavo A. R. Silva 946d0edf40 octeontx2-pf: Fix out-of-bounds read in otx2_get_fecparam()
commit 93efb0c656837f4a31d7cc6117a7c8cecc8fadac upstream.

Code at line 967 implies that rsp->fwdata.supported_fec may be up to 4:

 967: if (rsp->fwdata.supported_fec <= FEC_MAX_INDEX)

If rsp->fwdata.supported_fec evaluates to 4, then there is an
out-of-bounds read at line 971 because fec is an array with
a maximum of 4 elements:

 954         const int fec[] = {
 955                 ETHTOOL_FEC_OFF,
 956                 ETHTOOL_FEC_BASER,
 957                 ETHTOOL_FEC_RS,
 958                 ETHTOOL_FEC_BASER | ETHTOOL_FEC_RS};
 959 #define FEC_MAX_INDEX 4

 971: fecparam->fec = fec[rsp->fwdata.supported_fec];

Fix this by properly indexing fec[] with rsp->fwdata.supported_fec - 1.
In this case the proper indexes 0 to 3 are used when
rsp->fwdata.supported_fec evaluates to a range of 1 to 4, correspondingly.

Fixes: d0cf9503e908 ("octeontx2-pf: ethtool fec mode support")
Addresses-Coverity-ID: 1501722 ("Out-of-bounds read")
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-12-17 13:24:23 +01:00
..
mvpp2 Revert "net: mvpp2: Increase size of queue_name buffer" 2024-11-24 00:23:08 +01:00
octeontx2 octeontx2-pf: Fix out-of-bounds read in otx2_get_fecparam() 2024-12-17 13:24:23 +01:00
prestera
Kconfig
Makefile
mv643xx_eth.c
mvmdio.c
mvneta.c
mvneta_bm.c
mvneta_bm.h
pxa168_eth.c marvell: pxa168_eth: fix call balance of pep->clk handling routines 2024-12-17 13:24:15 +01:00
skge.c
skge.h
sky2.c
sky2.h