Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mlxsw: core_acl_flex_actions: Split memcpy() of struct flow_action_cookie flexible array

To work around a misbehavior of the compiler's ability to see into
composite flexible array structs (as detailed in the coming memcpy()
hardening series[1]), split the memcpy() of the header and the payload
so no false positive run-time overflow warning will be generated.

[1] https://lore.kernel.org/linux-hardening/20220901065914.1417829-2-keescook@chromium.org

Cc: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Link: https://lore.kernel.org/r/20220927004033.1942992-1-keescook@chromium.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Kees Cook and committed by
Jakub Kicinski
d89318bb e1d07700

+3 -2
+3 -2
drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c
··· 737 737 if (!cookie) 738 738 return ERR_PTR(-ENOMEM); 739 739 refcount_set(&cookie->ref_count, 1); 740 - memcpy(&cookie->fa_cookie, fa_cookie, 741 - sizeof(*fa_cookie) + fa_cookie->cookie_len); 740 + cookie->fa_cookie = *fa_cookie; 741 + memcpy(cookie->fa_cookie.cookie, fa_cookie->cookie, 742 + fa_cookie->cookie_len); 742 743 743 744 err = rhashtable_insert_fast(&mlxsw_afa->cookie_ht, &cookie->ht_node, 744 745 mlxsw_afa_cookie_ht_params);