Re: [PATCH] drm/amd/ras: work around write overflow attribute warning
From: Kees Cook
Date: Wed Mar 18 2026 - 13:25:36 EST
On Wed, Mar 18, 2026 at 11:50:36AM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@xxxxxxxx>
>
> clang-22 warns about possibly copying beyind the end of an array:
>
> In file included from drivers/gpu/drm/amd/amdgpu/../ras/rascore/ras_umc.c:24:
> In file included from drivers/gpu/drm/amd/amdgpu/../ras/rascore/ras.h:27:
> In file included from drivers/gpu/drm/amd/amdgpu/../ras/ras_mgr/ras_sys.h:29:
> In file included from include/linux/string.h:386:
> include/linux/fortify-string.h:569:4: error: call to '__write_overflow_field' declared with 'warning' attribute: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror,-Wattribute-warning]
> 569 | __write_overflow_field(p_size_field, size);
> | ^
>
> As far as I can tell, this is a false-postive warning, but there is
> an easy workaround, by using a direct struct assignment in place of
> the memcpy.
>
> Fixes: 7a3f9c0992c4 ("drm/amd/ras: Add umc common ras functions")
> Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
Yeah, direct assignment is much preferred anyway. :)
Reviewed-by: Kees Cook <kees@xxxxxxxxxx>
--
Kees Cook