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 6B399C433F5 for ; Tue, 22 Mar 2022 03:14:50 +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=Kl9SvWL2uTFLSLY6k05+X4hnACCEPAc6ctJ2M0r8kVc=; b=lzYG8m8957uYpY Dz2dk2qW+gL04zLNTeYQyHyLsORpRHV51Tz2Qz4F2zShSYrYl3eJdVhTH22ZL9y01AC71iTEetW5t L5zL3suU4gSUIMiS8zyBG9hdBaberJZWqJlcximIKQ/co+Ud/TjxbVRvvQIg8ig4bpExYO/WCZkTw Y3zvsVslADhPYMmCWaw2YxOdJNdIxND1U7XD9ipxMw/M4pDH63nUREUEgL+DRgfh3cyG/FyUXoGNT ZYxh11YilWWjSE67XE9pBSGQ3vUe2Elom1FuoO2yZ0uE6DJZos0NSrZLHzrty2WeaKPInJrGfmYic /MwzPf69FpUdqZbRKdSw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nWUxl-009qvZ-Fj; Tue, 22 Mar 2022 03:13:37 +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 1nWUxf-009qu6-Sy for linux-arm-kernel@lists.infradead.org; Tue, 22 Mar 2022 03:13:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647918811; 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=vKHt9i7mfT3YgAWaqrPaWVsW7oiZVUiyVt+3RKfn+jc=; b=VWi3Rc4gGiDMTHU7ayu2Q+GpqkDit4uaN+S03385GEUDltC+Yjba0Rc1rb4ycLu5GuNPz3 HQ2zfLatrQasJC2TeQkfEQnw7c/fbY7Wu9G4aI+nVmCzwQDr2Qk+urrjQaWLGxAyikiSA1 Xs1cDoTc4S1LHXKvX7kVHl8z/pmNwBQ= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-119-MnYR_Qr5OY6_s-dsCS-qjA-1; Mon, 21 Mar 2022 23:13:29 -0400 X-MC-Unique: MnYR_Qr5OY6_s-dsCS-qjA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A812E1C04B46; Tue, 22 Mar 2022 03:13:28 +0000 (UTC) Received: from localhost (ovpn-13-156.pek2.redhat.com [10.72.13.156]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8419B2166B44; Tue, 22 Mar 2022 03:13:23 +0000 (UTC) Date: Tue, 22 Mar 2022 11:13:20 +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> <20220322025912.r2ahc2ztx3npt7av@Rk> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220322025912.r2ahc2ztx3npt7av@Rk> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220321_201332_021863_5D82E368 X-CRM114-Status: GOOD ( 38.67 ) 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/22/22 at 10:59am, Coiby Xu wrote: > On Mon, Mar 21, 2022 at 12:21:33PM +0800, Baoquan He wrote: > > 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. > > Thanks for looking at commit 9ec4ecef0af7 for me! > > Although commit 9ec4ecef0af7 added some code in arch_kexec_kernel_verify_sig > so kexec_file_ops->verify_sig can be called, this commit doesn't add __weak > arch_kexec_kernel_verify_sig itself. And kexec_file_ops isn't supposed > to replace arch-specific implementation using __weak considering s390 and x86 > still make use of __weak to implement its own version of > arch_kexec_apply_relocations_add. How about the commit message as > follows? Yes, arch_kexec_apply_relocations_add has its different version on arches. But arch_kexec_kernel_verify_sig() is different. There's a specific method for that, ->verify_sig(). struct kexec_file_ops { kexec_probe_t *probe; kexec_load_t *load; kexec_cleanup_t *cleanup; #ifdef CONFIG_KEXEC_SIG kexec_verify_sig_t *verify_sig; #endif }; > > Currently this no arch-specific implementation of > arch_kexec_kernel_verify_sig. Even if we want to add an implementation > for an architecture in the future, we can simply use "(struct > kexec_file_ops*)->verify_sig". So clean it up. That is also fine. I think it's better to put the above in if we have checked the old commit. Anyway, please take the sentences which comforts you more. And there's grammer mistake, please use 'Currently there is not' to replace. > > > > 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 > > > > > > > -- > Best regards, > Coiby > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel