Re: [PATCH 1/3] [RESEND] RDMA/hfi1: use a struct group to avoid warning

From: Kees Cook

Date: Fri Mar 20 2026 - 14:05:58 EST


On Fri, Mar 20, 2026 at 04:12:37PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@xxxxxxxx>
>
> On gcc-11 and earlier, the driver sometimes produces a warning
> for memset:
>
> In file included from include/linux/string.h:392,
> from drivers/infiniband/hw/hfi1/mad.c:6:
> In function 'fortify_memset_chk',
> inlined from '__subn_get_opa_hfi1_cong_log' at drivers/infiniband/hw/hfi1/mad.c:3873:2,
> inlined from 'subn_get_opa_sma' at drivers/infiniband/hw/hfi1/mad.c:4114:9:
> include/linux/fortify-string.h:480:4: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror]
> __write_overflow_field(p_size_field, size);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> This seems to be a false positive, and I found no nice way to rewrite
> the code to avoid the warning, but adding a a struct group works.
>
> Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>

Reviewed-by: Kees Cook <kees@xxxxxxxxxx>

--
Kees Cook