Skip to content

Commit df16b89

Browse files
tangyoulingchenhuacai
authored andcommitted
LoongArch: kexec: Initialize the kexec_buf structure
The kexec_buf structure was previously declared without initialization. commit bf454ec ("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 is 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: bf454ec ("kexec_file: allow to place kexec_buf randomly") Link: https://lore.kernel.org/r/20250827-kbuf_all-v1-2-1df9882bb01a@debian.org Signed-off-by: Youling Tang <tangyouling@kylinos.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
1 parent eeeeaaf commit df16b89

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

arch/loongarch/kernel/kexec_efi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static void *efi_kexec_load(struct kimage *image,
4242
{
4343
int ret;
4444
unsigned long text_offset, kernel_segment_number;
45-
struct kexec_buf kbuf;
45+
struct kexec_buf kbuf = {};
4646
struct kexec_segment *kernel_segment;
4747
struct loongarch_image_header *h;
4848

arch/loongarch/kernel/kexec_elf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static void *elf_kexec_load(struct kimage *image,
5959
int ret;
6060
unsigned long text_offset, kernel_segment_number;
6161
struct elfhdr ehdr;
62-
struct kexec_buf kbuf;
62+
struct kexec_buf kbuf = {};
6363
struct kexec_elf_info elf_info;
6464
struct kexec_segment *kernel_segment;
6565

arch/loongarch/kernel/machine_kexec_file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ int load_other_segments(struct kimage *image,
143143
unsigned long initrd_load_addr = 0;
144144
unsigned long orig_segments = image->nr_segments;
145145
char *modified_cmdline = NULL;
146-
struct kexec_buf kbuf;
146+
struct kexec_buf kbuf = {};
147147

148148
kbuf.image = image;
149149
/* Don't allocate anything below the kernel */

0 commit comments

Comments
 (0)