From: Will Deacon <will@kernel.org>
To: Mukesh Pilaniya <mpilaniy@redhat.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
Mark Rutland <mark.rutland@arm.com>,
Huacai Chen <chenhuacai@kernel.org>,
WANG Xuerui <kernel@xen0n.name>, Paul Walmsley <pjw@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Alexandre Ghiti <alex@ghiti.fr>,
Andrew Morton <akpm@linux-foundation.org>,
Baoquan He <baoquan.he@linux.dev>,
Mike Rapoport <rppt@kernel.org>,
Pasha Tatashin <pasha.tatashin@soleen.com>,
Pratyush Yadav <pratyush@kernel.org>, Tao Liu <ltao@redhat.com>,
Philipp Rudo <prudo@redhat.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, loongarch@lists.linux.dev,
linux-riscv@lists.infradead.org, kexec@lists.infradead.org,
Bradley Morgan <include@grrlz.net>
Subject: Re: [PATCH v3 1/2] kexec: return -ENOEXEC from image probe functions on mismatch
Date: Tue, 25 Aug 2026 16:14:59 +0100 [thread overview]
Message-ID: <ao2xc027TNYTwBA1@willie-the-truck> (raw)
In-Reply-To: <06a45c67-2642-4efa-994a-ee50cd40a697@redhat.com>
On Tue, Aug 25, 2026 at 10:43:48AM +0530, Mukesh Pilaniya wrote:
> On 24/08/26 7:37 pm, Will Deacon wrote:
> > On Fri, Aug 21, 2026 at 07:19:57PM +0530, Mukesh Pilaniya wrote:
> >> Several kexec_file_load() image probe functions return -EINVAL when
> >> they do not recognize the image format. A probe function that rejects
> >> an image should return -ENOEXEC to indicate that the image is not a
> >> recognized executable format. -EINVAL implies a problem with the
> >> syscall parameters, not with image recognition.
> >>
> >> kexec_image_probe_default() iterates through registered loaders and
> >> returns the last probe's error code to the caller. That error
> >> propagates as the kexec_file_load() return value to userspace.
> >> Returning -EINVAL from a probe when no loader matches is semantically
> >> incorrect and misleads userspace about the nature of the failure.
> >>
> >> Return -ENOEXEC from all probe functions and their helpers when the
> >> image format is not recognized.
> >>
> >> Signed-off-by: Mukesh Pilaniya <mpilaniy@redhat.com>
> >> Reviewed-by: Philipp Rudo <prudo@redhat.com>
> >> Reviewed-by: Pratyush Yadav <pratyush@kernel.org>
> >> Reviewed-by: Bradley Morgan <include@grrlz.net>
> >> ---
> >> 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 ++--
> >> 4 files changed, 8 insertions(+), 8 deletions(-)
> >
> > Hmm, so after this patch, are there actually any implementations of .probe()
> > that return anything other than 0 or -ENOEXEC? I couldn't spot any after
> > a quick look.
> >
> > Willkexec_elf_probe() can return -ENOMEM if memory allocation (kzalloc())
> fails inside elf_read_phdrs(). This behavior was previously discussed in
> the first patch of this series [1].
Fair enough, but I'd have thought it would be easier to special-case the
one -ENOMEM path instead of changing all the backends to return
-ENOEXEC all over the place (and hoping people don't start returning
-EINVAL again in future).
Will
next prev parent reply other threads:[~2026-08-25 15:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-21 13:49 [PATCH v3 0/2] kexec: fix probe error codes and error propagation Mukesh Pilaniya
2026-08-21 13:49 ` [PATCH v3 1/2] kexec: return -ENOEXEC from image probe functions on mismatch Mukesh Pilaniya
2026-08-24 14:07 ` Will Deacon
2026-08-25 5:13 ` Mukesh Pilaniya
2026-08-25 15:14 ` Will Deacon [this message]
2026-08-21 13:49 ` [PATCH v3 2/2] kexec: fix error propagation in kexec_image_probe_default() Mukesh Pilaniya
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ao2xc027TNYTwBA1@willie-the-truck \
--to=will@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=baoquan.he@linux.dev \
--cc=catalin.marinas@arm.com \
--cc=chenhuacai@kernel.org \
--cc=include@grrlz.net \
--cc=kernel@xen0n.name \
--cc=kexec@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=loongarch@lists.linux.dev \
--cc=ltao@redhat.com \
--cc=mark.rutland@arm.com \
--cc=mpilaniy@redhat.com \
--cc=palmer@dabbelt.com \
--cc=pasha.tatashin@soleen.com \
--cc=pjw@kernel.org \
--cc=pratyush@kernel.org \
--cc=prudo@redhat.com \
--cc=rppt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox