mlxsw: Use size_mul() in call to struct_size()
authorGustavo A. R. Silva <gustavoars@kernel.org>
Fri, 15 Sep 2023 19:01:23 +0000 (13:01 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 20 Nov 2023 10:58:56 +0000 (11:58 +0100)
commitbe25fc451ef4ee2151c9d11fd48785396ba9ec16
tree71b49fa83424ad8ec064290ea68de2ea1ad73a47
parent3fc79c5686020fa4623a1b96f666913b14979722
mlxsw: Use size_mul() in call to struct_size()

[ Upstream commit e22c6ea025013ae447fe269269753ffec763dde5 ]

If, for any reason, the open-coded arithmetic causes a wraparound, the
protection that `struct_size()` adds against potential integer overflows
is defeated. Fix this by hardening call to `struct_size()` with `size_mul()`.

Fixes: 2285ec872d9d ("mlxsw: spectrum_acl_bloom_filter: use struct_size() in kzalloc()")
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-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/spectrum_acl_bloom_filter.c