public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH] drm/amd/ras: work around write overflow attribute warning
@ 2026-03-18 10:50 Arnd Bergmann
  2026-03-18 16:23 ` Kees Cook
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2026-03-18 10:50 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
	Nathan Chancellor, Tao Zhou, Hawking Zhang, YiPeng Chai
  Cc: Arnd Bergmann, Nick Desaulniers, Bill Wendling, Justin Stitt,
	Gangliang Xie, Kees Cook, Srinivasan Shanmugam, amd-gfx,
	dri-devel, linux-kernel, llvm

From: Arnd Bergmann <arnd@arndb.de>

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@arndb.de>
---
 drivers/gpu/drm/amd/ras/rascore/ras_umc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/ras/rascore/ras_umc.c b/drivers/gpu/drm/amd/ras/rascore/ras_umc.c
index 23118f41eb96..fb426386b384 100644
--- a/drivers/gpu/drm/amd/ras/rascore/ras_umc.c
+++ b/drivers/gpu/drm/amd/ras/rascore/ras_umc.c
@@ -290,7 +290,7 @@ static int ras_umc_get_new_records(struct ras_core_context *ras_core,
 		if (!entries[i])
 			continue;
 
-		memcpy(&records[i], entries[i], sizeof(struct eeprom_umc_record));
+		records[i] = *entries[i];
 		count++;
 		radix_tree_tag_clear(&ras_umc->root,
 				entries[i]->cur_nps_retired_row_pfn, UMC_ECC_NEW_DETECTED_TAG);
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/amd/ras: work around write overflow attribute warning
  2026-03-18 10:50 [PATCH] drm/amd/ras: work around write overflow attribute warning Arnd Bergmann
@ 2026-03-18 16:23 ` Kees Cook
  0 siblings, 0 replies; 2+ messages in thread
From: Kees Cook @ 2026-03-18 16:23 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Alex Deucher, Christian König, David Airlie, Simona Vetter,
	Nathan Chancellor, Tao Zhou, Hawking Zhang, YiPeng Chai,
	Arnd Bergmann, Nick Desaulniers, Bill Wendling, Justin Stitt,
	Gangliang Xie, Srinivasan Shanmugam, amd-gfx, dri-devel,
	linux-kernel, llvm

On Wed, Mar 18, 2026 at 11:50:36AM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> 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@arndb.de>

Yeah, direct assignment is much preferred anyway. :)

Reviewed-by: Kees Cook <kees@kernel.org>

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-18 16:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-18 10:50 [PATCH] drm/amd/ras: work around write overflow attribute warning Arnd Bergmann
2026-03-18 16:23 ` Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox