mlxsw: Verify the accessed index doesn't exceed the array length
authorDanielle Ratson <danieller@nvidia.com>
Mon, 17 May 2021 17:03:57 +0000 (20:03 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 Dec 2021 08:19:05 +0000 (09:19 +0100)
commit33d89128a9602c34d2875dbf7153d9bdbccd7511
tree265fc4a86364da03cf28b072db3d7d8a7d489c67
parent29e1b57347957a2be71af782ba5aeaadf544be29
mlxsw: Verify the accessed index doesn't exceed the array length

[ Upstream commit 837ec05cfea08284c575e8e834777b107da5ff9d ]

There are few cases in which an array index queried from a fw register,
is accessed without any validation that it doesn't exceed the array
length.

Add a proper length validation, so accessing memory past the end of an
array will be forbidden.

Signed-off-by: Danielle Ratson <danieller@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/mellanox/mlxsw/minimal.c
drivers/net/ethernet/mellanox/mlxsw/spectrum.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c