Skip to content

Commit 4aa9340

Browse files
Baoquan Hehcahca
authored andcommitted
s390/kexec: fix memory leak of ipl report buffer
unreferenced object 0x38000195000 (size 4096): comm "kexec", pid 8548, jiffies 4294953647 (age 32443.270s) hex dump (first 32 bytes): 00 00 00 c8 20 00 00 00 00 00 00 c0 02 80 00 00 .... ........... 40 40 40 40 40 40 40 40 00 00 00 00 00 00 00 00 @@@@@@@@........ backtrace: [<0000000011a2f199>] __vmalloc_node_range+0xc0/0x140 [<0000000081fa2752>] vzalloc+0x5a/0x70 [<0000000063a4c92d>] ipl_report_finish+0x2c/0x180 [<00000000553304da>] kexec_file_add_ipl_report+0xf4/0x150 [<00000000862d033f>] kexec_file_add_components+0x124/0x160 [<000000000d2717bb>] arch_kexec_kernel_image_load+0x62/0x90 [<000000002e0373b6>] kimage_file_alloc_init+0x1aa/0x2e0 [<0000000060f2d14f>] __do_sys_kexec_file_load+0x17c/0x2c0 [<000000008c86fe5a>] __s390x_sys_kexec_file_load+0x40/0x50 [<000000001fdb9dac>] __do_syscall+0x1bc/0x1f0 [<000000003ee4258d>] system_call+0x78/0xa0 Signed-off-by: Baoquan He <[email protected]> Reviewed-by: Philipp Rudo <[email protected]> Fixes: 99feaa7 ("s390/kexec_file: Create ipl report and pass to next kernel") Cc: <[email protected]> # v5.2: 20c76e2: s390/kexec: fix return code handling Cc: <[email protected]> # v5.2 Link: https://lore.kernel.org/r/20211116033101.GD21646@MiWiFi-R3L-srv Signed-off-by: Heiko Carstens <[email protected]>
1 parent 20c76e2 commit 4aa9340

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

arch/s390/include/asm/kexec.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ void *kexec_file_add_components(struct kimage *image,
7474
int arch_kexec_do_relocs(int r_type, void *loc, unsigned long val,
7575
unsigned long addr);
7676

77+
#define ARCH_HAS_KIMAGE_ARCH
78+
79+
struct kimage_arch {
80+
void *ipl_buf;
81+
};
82+
7783
extern const struct kexec_file_ops s390_kexec_image_ops;
7884
extern const struct kexec_file_ops s390_kexec_elf_ops;
7985

arch/s390/kernel/machine_kexec_file.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/kexec.h>
1313
#include <linux/module_signature.h>
1414
#include <linux/verification.h>
15+
#include <linux/vmalloc.h>
1516
#include <asm/boot_data.h>
1617
#include <asm/ipl.h>
1718
#include <asm/setup.h>
@@ -206,6 +207,7 @@ static int kexec_file_add_ipl_report(struct kimage *image,
206207
goto out;
207208
buf.bufsz = data->report->size;
208209
buf.memsz = buf.bufsz;
210+
image->arch.ipl_buf = buf.buffer;
209211

210212
data->memsz += buf.memsz;
211213

@@ -328,3 +330,11 @@ int arch_kexec_apply_relocations_add(struct purgatory_info *pi,
328330
}
329331
return 0;
330332
}
333+
334+
int arch_kimage_file_post_load_cleanup(struct kimage *image)
335+
{
336+
vfree(image->arch.ipl_buf);
337+
image->arch.ipl_buf = NULL;
338+
339+
return kexec_image_post_load_cleanup_default(image);
340+
}

0 commit comments

Comments
 (0)