Skip to content

Commit e67f0bd

Browse files
leitaoakpm00
authored andcommitted
s390: kexec: initialize kexec_buf struct
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 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. Link: https://lkml.kernel.org/r/20250827-kbuf_all-v1-3-1df9882bb01a@debian.org Fixes: bf454ec ("kexec_file: allow to place kexec_buf randomly") Signed-off-by: Breno Leitao <leitao@debian.org> Cc: Albert Ou <aou@eecs.berkeley.edu> Cc: Alexander Gordeev <agordeev@linux.ibm.com> Cc: Alexandre Ghiti <alex@ghiti.fr> Cc: Baoquan He <bhe@redhat.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Christian Borntraeger <borntraeger@linux.ibm.com> Cc: Coiby Xu <coxu@redhat.com> Cc: Heiko Carstens <hca@linux.ibm.com> Cc: Palmer Dabbelt <palmer@dabbelt.com> Cc: Paul Walmsley <paul.walmsley@sifive.com> Cc: Sven Schnelle <svens@linux.ibm.com> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Will Deacon <will@kernel.org> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 8afbd00 commit e67f0bd

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

arch/s390/kernel/kexec_elf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
static int kexec_file_add_kernel_elf(struct kimage *image,
1717
struct s390_load_data *data)
1818
{
19-
struct kexec_buf buf;
19+
struct kexec_buf buf = {};
2020
const Elf_Ehdr *ehdr;
2121
const Elf_Phdr *phdr;
2222
Elf_Addr entry;

arch/s390/kernel/kexec_image.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
static int kexec_file_add_kernel_image(struct kimage *image,
1717
struct s390_load_data *data)
1818
{
19-
struct kexec_buf buf;
19+
struct kexec_buf buf = {};
2020

2121
buf.image = image;
2222

arch/s390/kernel/machine_kexec_file.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ static int kexec_file_update_purgatory(struct kimage *image,
129129
static int kexec_file_add_purgatory(struct kimage *image,
130130
struct s390_load_data *data)
131131
{
132-
struct kexec_buf buf;
132+
struct kexec_buf buf = {};
133133
int ret;
134134

135135
buf.image = image;
@@ -152,7 +152,7 @@ static int kexec_file_add_purgatory(struct kimage *image,
152152
static int kexec_file_add_initrd(struct kimage *image,
153153
struct s390_load_data *data)
154154
{
155-
struct kexec_buf buf;
155+
struct kexec_buf buf = {};
156156
int ret;
157157

158158
buf.image = image;
@@ -184,7 +184,7 @@ static int kexec_file_add_ipl_report(struct kimage *image,
184184
{
185185
__u32 *lc_ipl_parmblock_ptr;
186186
unsigned int len, ncerts;
187-
struct kexec_buf buf;
187+
struct kexec_buf buf = {};
188188
unsigned long addr;
189189
void *ptr, *end;
190190
int ret;

0 commit comments

Comments
 (0)