]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
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)
committerDavid S. Miller <davem@davemloft.net>
Mon, 18 Sep 2023 08:36:20 +0000 (09:36 +0100)
commite22c6ea025013ae447fe269269753ffec763dde5
tree8267685421254a304a45634013b3d5eccdf66664
parent74fa1a82386e0bc1095ae9d13962606612514df5
mlxsw: Use size_mul() in call to struct_size()

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>
drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_bloom_filter.c