[PATCH v2 0/2] kexec: fix probe error codes and error propagation
From: Mukesh Pilaniya
Date: Wed Aug 19 2026 - 13:47:53 EST
While debugging a misleading error on s390x where kexec -s reported
"syscall kexec_file_load not available" instead of the actual EINVAL
from a kernel command line that exceeded the architecture limit, we
found that some kexec image probe functions return -EINVAL instead of
-ENOEXEC for format mismatches, and kexec_image_probe_default() has a
bug where it returns whatever the last loader returned rather than
always returning -ENOEXEC when no loader matches.
Patch 1 fixes all probe functions to return -ENOEXEC when they do not
recognize the image format.
Patch 2 fixes kexec_image_probe_default() to distinguish format
mismatches (-ENOEXEC) from real errors (e.g. -ENOMEM), propagating
real errors immediately and only continuing to the next loader on
-ENOEXEC.
kexec-tools patch:
https://lore.kernel.org/all/20260814075329.30203-1-mpilaniy@xxxxxxxxxx/
Signed-off-by: Mukesh Pilaniya <mpilaniy@xxxxxxxxxx>
---
Changes in v2:
- Added patch 2 to fix error propagation in kexec_image_probe_default(),
as suggested by Pratyush Yadav.
- Link to v1: https://patch.msgid.link/20260813-mpilaniy-v1-1-777d4d0e30f7@xxxxxxxxxx
To: Catalin Marinas <catalin.marinas@xxxxxxx>
To: Will Deacon <will@xxxxxxxxxx>
To: Mark Rutland <mark.rutland@xxxxxxx>
To: Huacai Chen <chenhuacai@xxxxxxxxxx>
To: WANG Xuerui <kernel@xxxxxxxxxx>
To: Paul Walmsley <pjw@xxxxxxxxxx>
To: Palmer Dabbelt <palmer@xxxxxxxxxxx>
To: Albert Ou <aou@xxxxxxxxxxxxxxxxx>
To: Alexandre Ghiti <alex@xxxxxxxx>
To: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
To: Baoquan He <baoquan.he@xxxxxxxxx>
To: Mike Rapoport <rppt@xxxxxxxxxx>
To: Pasha Tatashin <pasha.tatashin@xxxxxxxxxx>
To: Pratyush Yadav <pratyush@xxxxxxxxxx>
To: Philipp Rudo <prudo@xxxxxxxxxx>
To: Tao Liu <ltao@xxxxxxxxxx>
Cc: linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
Cc: loongarch@xxxxxxxxxxxxxxx
Cc: linux-riscv@xxxxxxxxxxxxxxxxxxx
Cc: kexec@xxxxxxxxxxxxxxxxxxx
---
Mukesh Pilaniya (2):
kexec: return -ENOEXEC from image probe functions on mismatch
kexec: fix error propagation in kexec_image_probe_default()
arch/arm64/kernel/kexec_image.c | 4 ++--
arch/loongarch/kernel/kexec_efi.c | 4 ++--
arch/riscv/kernel/kexec_image.c | 4 ++--
kernel/kexec_elf.c | 4 ++--
kernel/kexec_file.c | 12 +++++++-----
5 files changed, 15 insertions(+), 13 deletions(-)
---
base-commit: dd8c49a14f169d58e7a07a2c96fb588f3456efa0
change-id: 20260813-mpilaniy-ffb0cc92c313
Best regards,
--
Mukesh Pilaniya <mpilaniy@xxxxxxxxxx>