From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1D494C61DBE for ; Tue, 25 Aug 2026 15:15:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=rLscfcmLNRd3f1PhGpx41k5USRhZyaKtVT+AsVQwKXE=; b=B7geuTYCmdf1WRjgqks+aXvnr5 WrLwGd8LZOeX7hpstQcnCsLoPTeJ+9AYZCOUfFJIUlmDPB1xftn0HfXvnBDed10yTy2QnnKmRQj4f YnEKZNqQZHCHtL87oqldYNL+KTPZEipq+c5tBrJ66J4fUb6utn2hfjyVvwTGWMolSlI/jL5nFmDbO GYElEWng68WC7ZzyrzBSc2BzMBbwRb4e6Of/6Ffuy9P75VBVQEFrdttDPcgfGtA4A7ioa9R1uJz5R NQ/Ibfmb8w+kHH1hbpqLxvr54lIB0Yisb23mqkKzVRxUKb/KZeQukNHn7iZDTAXPmfoAKqE11SFCs Edzk2vWg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wysrl-000000011ML-1xhG; Tue, 25 Aug 2026 15:15:09 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wysrj-000000011M1-2zlY; Tue, 25 Aug 2026 15:15:07 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 162E3419B0; Tue, 25 Aug 2026 15:15:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2DED1F000E9; Tue, 25 Aug 2026 15:15:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787670907; bh=rLscfcmLNRd3f1PhGpx41k5USRhZyaKtVT+AsVQwKXE=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=dKt9XnhQJ0Jv+LiWz7EZIWcKUj5pr1jQioPbRmKBddxcRnglcwR5/jrHA5iIVfgMI HzjOfACz98g59qd/tOWKog6WxXKhD/KXaPFhYLMhIv+XPz2PXkzM++hVZ+X7BI4EKZ aNUY9GhhNCFYR0CsWpf3YU61x+NPvUH26AY/MR4ivFRWyMqmS8iskw33wGv8pU2sUD KIcUtDB0UOjyqz8AR6cGUd8saiE6nhOt7YvUnUmcmwS5q4dUqZM8zRo0VF5J2ETElL aIqyGX/67NJ2/2baRrQhN5xL4WqYIhVN+uYx9vefhAK4e7Uw1k3Eb/yWzfAlOx86Z3 8vHf8+1Nvz11A== Date: Tue, 25 Aug 2026 16:14:59 +0100 From: Will Deacon To: Mukesh Pilaniya Cc: Catalin Marinas , Mark Rutland , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Andrew Morton , Baoquan He , Mike Rapoport , Pasha Tatashin , Pratyush Yadav , Tao Liu , Philipp Rudo , 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 Subject: Re: [PATCH v3 1/2] kexec: return -ENOEXEC from image probe functions on mismatch Message-ID: References: <20260821-mpilaniy-v3-0-76b355399d2e@redhat.com> <20260821-mpilaniy-v3-1-76b355399d2e@redhat.com> <06a45c67-2642-4efa-994a-ee50cd40a697@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <06a45c67-2642-4efa-994a-ee50cd40a697@redhat.com> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 > >> Reviewed-by: Philipp Rudo > >> Reviewed-by: Pratyush Yadav > >> Reviewed-by: Bradley Morgan > >> --- > >> 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