lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250214125402.90709-1-sourabhjain@linux.ibm.com>
Date: Fri, 14 Feb 2025 18:24:02 +0530
From: Sourabh Jain <sourabhjain@...ux.ibm.com>
To: akpm@...ux-foundation.org
Cc: Sourabh Jain <sourabhjain@...ux.ibm.com>,
        Venkat Rao Bagalkote <venkat88@...ux.vnet.ibm.com>,
        Alexander Graf <graf@...zon.com>, Baoquan he <bhe@...hat.com>,
        Hari Bathini <hbathini@...ux.ibm.com>,
        Madhavan Srinivasan <maddy@...ux.ibm.com>,
        "Mike Rapoport (Microsoft)" <rppt@...nel.org>,
        kexec@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: [PATCH] kexec: Fix kexec_locate_mem_hole() for missing CONFIG_KEXEC_HANDOVER

While adding KHO support, commit 7d128945e003 ("kexec: add KHO support
to kexec file loads") returns early from kexec_locate_mem_hole() if
CONFIG_KEXEC_HANDOVER is not defined.

Due to this, kexec_locate_mem_hole() does not locate a hole for the
kexec segment, and kbuf.mem holds 0x0. This leads to a kexec_file_load
syscall failure in sanity_check_segment_list(). This impacts both
kexec and kdump kernels.

Without this patch included:
----------------------------
kexec --initrd=initrd.img ./vmlinuz --append="`cat /proc/cmdline`" -lsd
Try gzip decompression.
Try LZMA decompression.
[   59.745154] kexec_file: kernel: 000000003473b9a0 kernel_size: 0x2cdacf0
[   59.753713] ima: kexec measurement buffer for the loaded kernel at 0x0.
[   59.753759] kexec_elf: Loaded the kernel at 0x0
[   59.753777] kexec_elf: Loaded purgatory at 0x0
[   59.753783] kexec_elf: Loaded initrd at 0x0
[   59.758657] kexec_elf: Loaded device tree at 0x0
syscall kexec_file_load not available.

With this patch included:
-------------------------
kexec --initrd=initrd.img ./vmlinuz --append="`cat /proc/cmdline`" -lsd
Try gzip decompression.
Try LZMA decompression.
[  112.091308] kexec_file: kernel: 000000009eb0432d kernel_size: 0x2cdacf0
[  112.099881] ima: kexec measurement buffer for the loaded kernel at 0x3fd9c0000.
[  112.099935] kexec_elf: Loaded the kernel at 0x2f60000
[  112.099953] kexec_elf: Loaded purgatory at 0x3fd9b0000
[  112.099969] kexec_elf: Loaded initrd at 0x5eb0000
[  112.104993] kexec_elf: Loaded device tree at 0x3fd650000
[  113.484422] kexec_file: nr_segments = 5
[  113.484452] kexec_file: segment[0]: buf=0x00000000b6970fc9 bufsz=0x82 mem=0x3fd9c0000 memsz=0x10000
[  113.484473] kexec_file: segment[1]: buf=0x00000000cabe3fe7 bufsz=0x2cc9ca4 mem=0x2f60000 memsz=0x2f50000
[  113.489144] kexec_file: segment[2]: buf=0x00000000deec4aaf bufsz=0x310 mem=0x3fd9b0000 memsz=0x10000
[  113.489195] kexec_file: segment[3]: buf=0x0000000081960708 bufsz=0x581a9c6 mem=0x5eb0000 memsz=0x5820000
[  113.498768] kexec_file: segment[4]: buf=0x00000000c1be9ac7 bufsz=0x6632 mem=0x3fd650000 memsz=0x10000
[  113.498819] kexec_file: kexec_file_load: type:0, start:0x3fd9b0000 head:0x5f1c0002 flags:0x8

To fix this, return 1 from kexec_locate_mem_hole() in kexec_internal.h.
This ensures that kexec_locate_mem_hole() locates a memory hole if
CONFIG_KEXEC_HANDOVER is not defined.

Note: The kexec tool printing "kexec_file_load not available" does not
necessarily mean that the kernel lacks support for the kexec_file_load
syscall. Instead, it occurs because multiple errors are handled under
the same condition.

Reported-by: Venkat Rao Bagalkote <venkat88@...ux.vnet.ibm.com>
Closes: https://lore.kernel.org/all/8e73069b-5987-4a08-b13d-13fe691092ad@linux.vnet.ibm.com/
Signed-off-by: Sourabh Jain <sourabhjain@...ux.ibm.com>
Cc: Alexander Graf <graf@...zon.com>
Cc: Baoquan he <bhe@...hat.com>
Cc: Hari Bathini <hbathini@...ux.ibm.com>
Cc: Madhavan Srinivasan <maddy@...ux.ibm.com>
Cc: Mike Rapoport (Microsoft) <rppt@...nel.org>
Cc: kexec@...ts.infradead.org
Cc: linux-kernel@...r.kernel.org
---

Rebased on top of next-20250213

---
 kernel/kexec_internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/kexec_internal.h b/kernel/kexec_internal.h
index c535dbd3b5bd..66ce6872fda1 100644
--- a/kernel/kexec_internal.h
+++ b/kernel/kexec_internal.h
@@ -50,7 +50,7 @@ int kho_fill_kimage(struct kimage *image);
 static inline int kho_locate_mem_hole(struct kexec_buf *kbuf,
 				      int (*func)(struct resource *, void *))
 {
-	return 0;
+	return 1;
 }
 
 static inline int kho_fill_kimage(struct kimage *image) { return 0; }
-- 
2.48.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ