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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: Kees Cook <keescook@xxxxxxxxxxxx>
> Sent: Wednesday, August 18, 2021 11:35 AM
> To: linux-kernel@xxxxxxxxxxxxxxx
> Cc: Kees Cook <keescook@xxxxxxxxxxxx>; Ariel Elior <aelior@xxxxxxxxxxx>;
> Sudarsana Reddy Kalluru <skalluru@xxxxxxxxxxx>; GR-everest-linux-l2 <GR-
> everest-linux-l2@xxxxxxxxxxx>; David S. Miller <davem@xxxxxxxxxxxxx>; Jakub
> Kicinski <kuba@xxxxxxxxxx>; netdev@xxxxxxxxxxxxxxx; Gustavo A. R. Silva
> <gustavoars@xxxxxxxxxx>; Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>;
> Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>; linux-wireless@xxxxxxxxxxxxxxx;
> dri-devel@xxxxxxxxxxxxxxxxxxxxx; linux-staging@xxxxxxxxxxxxxxx; linux-
> block@xxxxxxxxxxxxxxx; linux-kbuild@xxxxxxxxxxxxxxx; clang-built-
> linux@xxxxxxxxxxxxxxxx; Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx>;
> linux-hardening@xxxxxxxxxxxxxxx
> 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@xxxxxxxxxxx>
> Cc: Sudarsana Kalluru <skalluru@xxxxxxxxxxx>
> Cc: GR-everest-linux-l2@xxxxxxxxxxx
> Cc: "David S. Miller" <davem@xxxxxxxxxxxxx>
> Cc: Jakub Kicinski <kuba@xxxxxxxxxx>
> Cc: netdev@xxxxxxxxxxxxxxx
> Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx>
> ---

Reviewed-by: Prabhakar Kushwaha <pkushwaha@xxxxxxxxxxx>




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux