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:51:52 +0000 (11:51 +0100)
commit65e65a8b2de4b617b908c89538179aa92c94203a
treedc2f8013e34e9ef0e2b39111a03beeef61a155c5
parenta764c22bbc859cff185b1d33eaec09878f638e12
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