mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] arm64: kexec: Initialize kexec_buf struct in image_load()
@ 2025-08-26 12:08 Breno Leitao
  2025-08-26 12:54 ` Pratyush Yadav
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Breno Leitao @ 2025-08-26 12:08 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, kexec
  Cc: linux-arm-kernel, linux-kernel, bhe, linux-arm-kernel, oxu,
	berrange, kernel-team, Andrew Morton, Breno Leitao

The kexec_buf structure was previously declared without initialization
in image_load(). This led to a UBSAN warning when the structure was
expanded and uninitialized fields were accessed [1].

Zero-initializing kexec_buf at declaration ensures all fields are
cleanly set, preventing future instances of uninitialized memory being
used.

Andrew Morton suggested that this function is only called 3x a week[2],
thus, the memset() cost is inexpressive.

Link: https://lore.kernel.org/all/oninomspajhxp4omtdapxnckxydbk2nzmrix7rggmpukpnzadw@c67o7njgdgm3/ [1]
Link: https://lore.kernel.org/all/20250825180531.94bfb86a26a43127c0a1296f@linux-foundation.org/ [2]
Suggested-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Breno Leitao <leitao@debian.org>
---
 arch/arm64/kernel/kexec_image.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/kexec_image.c b/arch/arm64/kernel/kexec_image.c
index 532d72ea42ee8..b70f4df15a1ae 100644
--- a/arch/arm64/kernel/kexec_image.c
+++ b/arch/arm64/kernel/kexec_image.c
@@ -41,7 +41,7 @@ static void *image_load(struct kimage *image,
 	struct arm64_image_header *h;
 	u64 flags, value;
 	bool be_image, be_kernel;
-	struct kexec_buf kbuf;
+	struct kexec_buf kbuf = {};
 	unsigned long text_offset, kernel_segment_number;
 	struct kexec_segment *kernel_segment;
 	int ret;

---
base-commit: 7a77c6b5ce68a71b9102760a988a4564ff6d4106
change-id: 20250826-akpm-18a57e3a39fd

Best regards,
--  
Breno Leitao <leitao@debian.org>


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

end of thread, other threads:[~2025-08-27  1:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-26 12:08 [PATCH] arm64: kexec: Initialize kexec_buf struct in image_load() Breno Leitao
2025-08-26 12:54 ` Pratyush Yadav
2025-08-26 14:40 ` Mark Rutland
2025-08-26 15:26   ` Breno Leitao
2025-08-27  1:07 ` Andrew Morton

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

all inboxes | Powered by JetHome®