From nobody Mon Feb 9 15:09:01 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B613A1F03D7 for ; Mon, 19 Jan 2026 03:25:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768793149; cv=none; b=cqGIBkNWDGiULt/W+ppa1T2P4AG0wR434igTlilEZ6XgwZEqb4Vo2+rpeQ7SdtDTyqNYf7e9AeRVIbBpKsDfoggDkr4rGYrhThYDX+YVVAh3Ecmq2fpij2qE64itth88MfqPZom9hIQ63dw7ASRIDSroL51DO8cspZ6F/4/hQzk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768793149; c=relaxed/simple; bh=xZIJ/PR6dsy+v+Zq7zr3kiP1+mSLugxSEkpHG58PHlM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZrRQvdFoe0TwonngM9vZAI9kIU9ziuy0rZGiK/ouTeRxX13ltzZJiLIo6n7aEyb1hl/LUNSPoipSe3DsNP14N5lLFVqzxw3zWz6+q8ueB/XQrU40njJedyP0Egq7bzTRp5c/LLbpSqX23EQaFFyP7/LgVuvERVMD29SaE9g9Z/Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=i33r6dhu; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="i33r6dhu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768793146; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uUfcEW/wlh3C/HM93w8YTTa2lylF3eZQ+D1pvi16zc0=; b=i33r6dhuWEQ/hsfY+2teZ4uXdifa1xkF9ditdK4nqZmByLdiCq7xdCA9MSf+rcKgvxRvjQ XZpd7Q1p2WCwsj6pJMskZoDokCPxGTnHPBTkAcDepZoCnwFw1ZkxfK5uQ/QTciwOW5Ly83 5wdxyK3SF8mop9mrIPmV8/X4WerFpv0= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-582-WBnPK6nxPgym9yRbPGjS6w-1; Sun, 18 Jan 2026 22:25:41 -0500 X-MC-Unique: WBnPK6nxPgym9yRbPGjS6w-1 X-Mimecast-MFC-AGG-ID: WBnPK6nxPgym9yRbPGjS6w_1768793139 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D70F01800447; Mon, 19 Jan 2026 03:25:38 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.72.112.74]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EBD0C195419F; Mon, 19 Jan 2026 03:25:26 +0000 (UTC) From: Pingfan Liu To: kexec@lists.infradead.org Cc: Pingfan Liu , "David S. Miller" , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , Jeremy Linton , Catalin Marinas , Will Deacon , Ard Biesheuvel , Simon Horman , Gerd Hoffmann , Vitaly Kuznetsov , Philipp Rudo , Viktor Malik , Jan Hendrik Farr , Baoquan He , Dave Young , Andrew Morton , bpf@vger.kernel.org, systemd-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCHv6 02/13] kexec_file: Move signature validation ahead Date: Mon, 19 Jan 2026 11:24:13 +0800 Message-ID: <20260119032424.10781-3-piliu@redhat.com> In-Reply-To: <20260119032424.10781-1-piliu@redhat.com> References: <20260119032424.10781-1-piliu@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" Move the signature validation at the head of the function, so the image can be unfold and handled later. Signed-off-by: Pingfan Liu Cc: Baoquan He Cc: Dave Young Cc: Andrew Morton Cc: Philipp Rudo To: kexec@lists.infradead.org --- kernel/kexec_file.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index eb62a97942428..0222d17072d40 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -231,18 +231,19 @@ kimage_file_prepare_segments(struct kimage *image, in= t kernel_fd, int initrd_fd, kexec_dprintk("kernel: %p kernel_size: %#lx\n", image->kernel_buf, image->kernel_buf_len); =20 - /* Call arch image probe handlers */ - ret =3D arch_kexec_kernel_image_probe(image, image->kernel_buf, - image->kernel_buf_len); - if (ret) - goto out; - #ifdef CONFIG_KEXEC_SIG ret =3D kimage_validate_signature(image); =20 if (ret) goto out; #endif + + /* Call arch image probe handlers */ + ret =3D arch_kexec_kernel_image_probe(image, image->kernel_buf, + image->kernel_buf_len); + if (ret) + goto out; + /* It is possible that there no initramfs is being loaded */ if (!(flags & KEXEC_FILE_NO_INITRAMFS)) { ret =3D kernel_read_file_from_fd(initrd_fd, 0, &image->initrd_buf, --=20 2.49.0