Re: [PATCH] IB/hfi1: Replace 1-element array with singleton

From: Jason Gunthorpe
Date: Fri Nov 18 2022 - 19:59:54 EST


On Fri, Nov 18, 2022 at 01:58:51PM -0800, Kees Cook wrote:
> Zero-length arrays are deprecated[1] and are being replaced with
> flexible array members in support of the ongoing efforts to tighten the
> FORTIFY_SOURCE routines on memcpy(), correctly instrument array indexing
> with UBSAN_BOUNDS, and to globally enable -fstrict-flex-arrays=3.
>
> Replace zero-length array with flexible-array member "lvs" in struct
> opa_port_data_counters_msg and struct opa_port_error_counters64_msg.
>
> Additionally, the "port" member of several structs is defined as a
> single-element, but is only ever accessed at index 0. Replace it with a
> singleton so that flexible array usage is sane.
>
> This results in no differences in binary output.
>
> [1] https://github.com/KSPP/linux/issues/78
>
> Cc: Dennis Dalessandro <dennis.dalessandro@xxxxxxxxxxxxxxxxxxxx>
> Cc: Jason Gunthorpe <jgg@xxxxxxxx>
> Cc: Leon Romanovsky <leon@xxxxxxxxxx>
> Cc: cgel.zte@xxxxxxxxx
> Cc: "Gustavo A. R. Silva" <gustavoars@xxxxxxxxxx>
> Cc: linux-rdma@xxxxxxxxxxxxxxx
> Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx>
> ---
> drivers/infiniband/hw/hfi1/mad.c | 22 +++++++++++-----------
> 1 file changed, 11 insertions(+), 11 deletions(-)

Applied to for-next, thanks

Jason