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 2A6DFC433EF for ; Mon, 21 Mar 2022 04:23:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Mo6GigkAztIgNWxAneezS/fh8hYKbhbXeBjlucTSAPk=; b=3dAwNEOj6NbwyP jl9RsmimDjEfUcQxupuBBWTfILOMYWU18DolaKoNQPc5aLfNMXtgVxWTwhk5z8oSJm9Asz0jCEt0D FLUb7Dw++QfKUgprZEbptqFbNnFuzQ8t71fq6CbMqxqwdGTEDf4GVrt9DVYX+cvll4fKQ9gtGWgya +qj6FsAxoPxzgdxIu6CNWhGzjjn9HbHFVbkMXtZDaMVj6IftjI3GYRUz3GOLelyFU+1YSbrPVwm19 bqRVQ+iUTYwb8D9ICoLCd2qCy8ResH00ZIPXxXEUlWs3CYRKSEJ9pmvpbA4GKpq/2WBGWRNR2R9U6 H4VMIffFdZC91BDghSvw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nW9YG-006SUv-65; Mon, 21 Mar 2022 04:21:52 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nW9YC-006SUI-MD for linux-arm-kernel@lists.infradead.org; Mon, 21 Mar 2022 04:21:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647836507; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=QvyzeWrMLOcevBTswhqEkb8FAM3gEDuF897VWUnNA6w=; b=Ga1Y6Tesdy32YSKGMBTr174uZbZFNlQlUQ6Tlfj67+RPE9FlugCBKdt6XUKYMtdTgnmN7J Af54tf0YHKS71tn/mKEHzBLKQNPEViT0fGArJ3ilffkBh3KH6wcL14XLjZxHFGt+lkckSu XAgzapG4O9fMKnODFezafGd/vbxJsLo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-621-6DaFMsC2NbKClrPooPyz2w-1; Mon, 21 Mar 2022 00:21:38 -0400 X-MC-Unique: 6DaFMsC2NbKClrPooPyz2w-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C2A891066566; Mon, 21 Mar 2022 04:21:37 +0000 (UTC) Received: from localhost (ovpn-12-54.pek2.redhat.com [10.72.12.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EBC06141DC29; Mon, 21 Mar 2022 04:21:36 +0000 (UTC) Date: Mon, 21 Mar 2022 12:21:33 +0800 From: Baoquan He To: Coiby Xu Cc: kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Dave Young , Will Deacon , "Eric W . Biederman" , open list Subject: Re: [PATCH v4 1/3] kexec: clean up arch_kexec_kernel_verify_sig Message-ID: References: <20220318094101.274950-1-coxu@redhat.com> <20220318094101.274950-2-coxu@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220318094101.274950-2-coxu@redhat.com> X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220320_212148_812245_7C8806A4 X-CRM114-Status: GOOD ( 21.72 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 03/18/22 at 05:40pm, Coiby Xu wrote: > Commit 9ec4ecef0af7 ("kexec_file,x86,powerpc: factor out kexec_file_ops > functions") allows implementing the arch-specific implementation of kernel > image verification in kexec_file_ops->verify_sig. Currently, there is no Looking back at the old commit 9ec4ecef0af7, it mistakenly added a generic arch_kexec_kernel_verify_sig() which is marked as __weak, and expects any architecture will add a arch specified version if needed. In fact those arch specified difference has been removed by wrapping them into each architecture's own struct kexec_file_ops methods. Means in the commit, the generic arch_kexec_kernel_verify_sig() is unnecessary at all. Now, you clean up that uncessary function with code change. I think description telling above analysis could be clearer. > arch-specific implementation of arch_kexec_kernel_verify_sig. So clean it > up. > > Suggested-by: Eric W. Biederman > Signed-off-by: Coiby Xu > --- > include/linux/kexec.h | 4 ---- > kernel/kexec_file.c | 34 +++++++++++++--------------------- > 2 files changed, 13 insertions(+), 25 deletions(-) > > diff --git a/include/linux/kexec.h b/include/linux/kexec.h > index 0c994ae37729..755fed183224 100644 > --- a/include/linux/kexec.h > +++ b/include/linux/kexec.h > @@ -196,10 +196,6 @@ int arch_kexec_apply_relocations(struct purgatory_info *pi, > const Elf_Shdr *relsec, > const Elf_Shdr *symtab); > int arch_kimage_file_post_load_cleanup(struct kimage *image); > -#ifdef CONFIG_KEXEC_SIG > -int arch_kexec_kernel_verify_sig(struct kimage *image, void *buf, > - unsigned long buf_len); > -#endif > int arch_kexec_locate_mem_hole(struct kexec_buf *kbuf); > > extern int kexec_add_buffer(struct kexec_buf *kbuf); > diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c > index 8347fc158d2b..3720435807eb 100644 > --- a/kernel/kexec_file.c > +++ b/kernel/kexec_file.c > @@ -89,25 +89,6 @@ int __weak arch_kimage_file_post_load_cleanup(struct kimage *image) > return kexec_image_post_load_cleanup_default(image); > } > > -#ifdef CONFIG_KEXEC_SIG > -static int kexec_image_verify_sig_default(struct kimage *image, void *buf, > - unsigned long buf_len) > -{ > - if (!image->fops || !image->fops->verify_sig) { > - pr_debug("kernel loader does not support signature verification.\n"); > - return -EKEYREJECTED; > - } > - > - return image->fops->verify_sig(buf, buf_len); > -} > - > -int __weak arch_kexec_kernel_verify_sig(struct kimage *image, void *buf, > - unsigned long buf_len) > -{ > - return kexec_image_verify_sig_default(image, buf, buf_len); > -} > -#endif > - > /* > * arch_kexec_apply_relocations_add - apply relocations of type RELA > * @pi: Purgatory to be relocated. > @@ -184,13 +165,24 @@ void kimage_file_post_load_cleanup(struct kimage *image) > } > > #ifdef CONFIG_KEXEC_SIG > +static int kexec_image_verify_sig(struct kimage *image, void *buf, > + unsigned long buf_len) > +{ > + if (!image->fops || !image->fops->verify_sig) { > + pr_debug("kernel loader does not support signature verification.\n"); > + return -EKEYREJECTED; > + } > + > + return image->fops->verify_sig(buf, buf_len); > +} > + > static int > kimage_validate_signature(struct kimage *image) > { > int ret; > > - ret = arch_kexec_kernel_verify_sig(image, image->kernel_buf, > - image->kernel_buf_len); > + ret = kexec_image_verify_sig(image, image->kernel_buf, > + image->kernel_buf_len); > if (ret) { > > if (IS_ENABLED(CONFIG_KEXEC_SIG_FORCE)) { > -- > 2.34.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel