riscv: kexec: Initialize kexec_buf struct
authorBreno Leitao <leitao@debian.org>
Wed, 27 Aug 2025 10:42:22 +0000 (03:42 -0700)
committerPaul Walmsley <pjw@kernel.org>
Fri, 5 Sep 2025 21:31:28 +0000 (15:31 -0600)
commit95c54cd9c769a198118772e196adfaa1f002e365
treede38370d4934604157859a8a10123a1ec452fa6e
parentf4ea67a722e8c9e1fb8109adebb9fb881ff0793a
riscv: kexec: Initialize kexec_buf struct

The kexec_buf structure was previously declared without initialization.
commit bf454ec31add ("kexec_file: allow to place kexec_buf randomly")
added a field that is always read but not consistently populated by all
architectures. This un-initialized field will contain garbage.

This is also triggering a UBSAN warning when the uninitialized data was
accessed:

------------[ cut here ]------------
UBSAN: invalid-load in ./include/linux/kexec.h:210:10
load of value 252 is not a valid value for type '_Bool'

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

Fixes: bf454ec31add ("kexec_file: allow to place kexec_buf randomly")
Signed-off-by: Breno Leitao <leitao@debian.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20250827-kbuf_all-v1-2-1df9882bb01a@debian.org
Signed-off-by: Paul Walmsley <pjw@kernel.org>
arch/riscv/kernel/kexec_elf.c
arch/riscv/kernel/kexec_image.c
arch/riscv/kernel/machine_kexec_file.c