Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2309301pxp; Mon, 21 Mar 2022 16:33:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJza57cOnF7q28Ys6O1jU9e1TMtR2X9oK7wDxyZgubl0idr+szU+eVI+I4t0TFGbIbLBt9gS X-Received: by 2002:a17:902:d4c8:b0:154:2416:218b with SMTP id o8-20020a170902d4c800b001542416218bmr15402204plg.139.1647905585616; Mon, 21 Mar 2022 16:33:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647905585; cv=none; d=google.com; s=arc-20160816; b=TkyWSDDDBlHrd0ovkNY86m4cPsps5xklKkixuJh8EN44ux8Itmquh8a7iVq9hKYI0w TwjoLNW+mlqrydXsIhFQ0tdWS5lK2E3Cpuht3M3R4j0H3IfmH/lXRslVba/aaS0GsZsT Esaklk6FF+8FndGjEke5E491CrS8ohBxonoTGhhb2x33NNo4HkdBtx74ee0n8Cc8Etkt DVgS4gueFN+zM2dbT3KFBua1j8taziZFmrHSZj9/VWRerJ037vRHYDzyi1zwS5yXMPGx f0YXSmzzlKnz5faxaefV6BYLFllfIvsVfL9Za6BjdDuq8Uz30d4FZ7vsl9ixgZMvpWZQ c3VQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=QvyzeWrMLOcevBTswhqEkb8FAM3gEDuF897VWUnNA6w=; b=wqCjg6YRmIG0n0VtppvwkUvcj8FCtWrc4+dAGMZjdidolSZKBXnchDOitBoEqNPtT+ oszySiOx1Ng6hdoVA3OZ8Wi+GNlmaT/u5x1i7O7CR8/eCHiKTNKmY06wVch5zCRcN+S6 PuOJw4E1JNTAwAcht14KIrUpyhQcLeHpyMLXeJYuiQgAyqBDrQjD5/E7EjFi1bI578R7 Etk3w8fXF/t/N89QY19DD2i5rhjahaDNMPBhvYdyZEncvBA5kgYNRy25SPPKHEObwHvw XcMQ6nD4xXjzH8fsKTGly8Y3xnpGlCf3+6xiTIznQZCu8eEU4TOxpd4wSb4vaNzFx+s1 jIwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iQbPOfZ+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id e16-20020a656bd0000000b00382a7c1893asi2269174pgw.52.2022.03.21.16.33.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 16:33:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iQbPOfZ+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6F64F479880; Mon, 21 Mar 2022 15:23:46 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244925AbiCUEXL (ORCPT + 99 others); Mon, 21 Mar 2022 00:23:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239857AbiCUEXK (ORCPT ); Mon, 21 Mar 2022 00:23:10 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8E01713D52 for ; Sun, 20 Mar 2022 21:21:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647836504; 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=iQbPOfZ+VVEQG4wJZ9eFQ0puQCP3ucX8D3VzUk7Q3B6fAD/i1lW62aw3PRgrtyH0OTFhK7 brXkbQqe4qNnNiV4ndOPDSKl2g/LjgJM5ZP7qha1gJUeTn0iI/k5MTTOq+hnLA15CNNyvp xqcdRX+49MOfaZN4xfzslILrGHueCFE= 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220318094101.274950-2-coxu@redhat.com> X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 >