[PATCH v2 17/63] bnx2x: Use struct_group() for memcpy() region

Prabhakar Kushwaha pkushwaha at marvell.com
Tue Aug 24 13:51:44 UTC 2021


> -----Original Message-----
> From: Kees Cook <keescook at chromium.org>
> Sent: Wednesday, August 18, 2021 11:35 AM
> To: linux-kernel at vger.kernel.org
> Cc: Kees Cook <keescook at chromium.org>; Ariel Elior <aelior at marvell.com>;
> Sudarsana Reddy Kalluru <skalluru at marvell.com>; GR-everest-linux-l2 <GR-
> everest-linux-l2 at marvell.com>; David S. Miller <davem at davemloft.net>; Jakub
> Kicinski <kuba at kernel.org>; netdev at vger.kernel.org; Gustavo A. R. Silva
> <gustavoars at kernel.org>; Greg Kroah-Hartman <gregkh at linuxfoundation.org>;
> Andrew Morton <akpm at linux-foundation.org>; linux-wireless at vger.kernel.org;
> dri-devel at lists.freedesktop.org; linux-staging at lists.linux.dev; linux-
> block at vger.kernel.org; linux-kbuild at vger.kernel.org; clang-built-
> linux at googlegroups.com; Rasmus Villemoes <linux at rasmusvillemoes.dk>;
> linux-hardening at vger.kernel.org
> Subject: [PATCH v2 17/63] bnx2x: Use struct_group() for memcpy() region
> 
> In preparation for FORTIFY_SOURCE performing compile-time and run-time
> field bounds checking for memcpy(), memmove(), and memset(), avoid
> intentionally writing across neighboring fields.
> 
> Use struct_group() in struct nig_stats around members egress_mac_pkt0_lo,
> egress_mac_pkt0_hi, egress_mac_pkt1_lo, and egress_mac_pkt1_hi (and the
> respective members in struct bnx2x_eth_stats), so they can be referenced
> together. This will allow memcpy() and sizeof() to more easily reason
> about sizes, improve readability, and avoid future warnings about writing
> beyond the end of struct bnx2x_eth_stats's rx_stat_ifhcinbadoctets_hi.
> 
> "pahole" shows no size nor member offset changes to either struct.
> "objdump -d" shows no meaningful object code changes (i.e. only source
> line number induced differences and optimizations).
> 
> Additionally adds BUILD_BUG_ON() to compare the separate struct group
> sizes.
> 
> Cc: Ariel Elior <aelior at marvell.com>
> Cc: Sudarsana Kalluru <skalluru at marvell.com>
> Cc: GR-everest-linux-l2 at marvell.com
> Cc: "David S. Miller" <davem at davemloft.net>
> Cc: Jakub Kicinski <kuba at kernel.org>
> Cc: netdev at vger.kernel.org
> Signed-off-by: Kees Cook <keescook at chromium.org>
> ---

Reviewed-by: Prabhakar Kushwaha <pkushwaha at marvell.com>


More information about the dri-devel mailing list