Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1450228pxp; Thu, 17 Mar 2022 09:25:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQwyBfAh7mv1lycn5Ii3Oktr7/xzCeQwaRegqrbOw8SESeMlIBAdTvj6I7rV4IvfrcSFBq X-Received: by 2002:a4a:9809:0:b0:324:65dd:16ff with SMTP id y9-20020a4a9809000000b0032465dd16ffmr70553ooi.6.1647534346741; Thu, 17 Mar 2022 09:25:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647534346; cv=none; d=google.com; s=arc-20160816; b=wZxIGVLOoGhcxE4vqd5z51LCIhANjbHI8o0kk+m5Dn9x/x1BfwGupWiY9H/AK77B83 lUsgmpbZRXxWTXKDDiqs/3On+QOiI/jm4GokeU9T+Z0DQEhV8AmGoIj7ldeSulwuxpFp mQCEAEIZDv3hBxaBgCykO4GR11DCc88pRI4HTZfirHUYRH+YRnQrLvP7miA6rdlOmj8w Ao4VPgBAMuPQ9oYPm7VuwKa0sLJygbJ4EWueqTOvEbVxDJXpS+HAJUwPc637c4kd81FV 82L4OaACZ5UwSlN3kGgkNpdvPLL/OydDQ7ohuehSkr3wt97K0+jCXZy+7Y+7VIanYFuW pnrg== 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=VBBuRe1MzVMSa5tl85JWrPgpG0AsZAv8LA7ACqhOxW8=; b=ST7XqYAyf63vkm450xJcgnWXgnX44c3zN0ZF6oeJrP6IXALcg4FSV8vzB76tboA3z5 TUCU98TOC2xKLArJpwQFCnhdmv/6CpUzPTKa/QB6Xmm/VO+7xZF9b8wjLkCWAo0ir7we v8suD/u0OHToxuelHVtitcD0H7UIdbbqCsSN6I7AXW3dKHRQd36OR1DHV33vx0CmeXVi MYWHgMUNr3q4AMk1pFgj7mgZBsgrzK3jO3OsTvEl2K7Q9W59lEgDSNjN6hL9QN2uf91d sL5DiNN+2HayvrTA1c3R/A19UrAbdJSWyEVjPhz9nQErgI3o+kCPcs84s4eo3rb7edax YKqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=B+pNlGsP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u6-20020a056808114600b002ecb7d01a47si2846132oiu.77.2022.03.17.09.25.32; Thu, 17 Mar 2022 09:25:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=B+pNlGsP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233664AbiCQMrA (ORCPT + 99 others); Thu, 17 Mar 2022 08:47:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233606AbiCQMq7 (ORCPT ); Thu, 17 Mar 2022 08:46:59 -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 A6DEF111DD8 for ; Thu, 17 Mar 2022 05:45:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647521141; 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=VBBuRe1MzVMSa5tl85JWrPgpG0AsZAv8LA7ACqhOxW8=; b=B+pNlGsP7v0mhHNFSFf/RREGIVItS2orlAbxgwC/BqLW0Nb12oK3Xi/cM6WR09HFAHx8Ea EijWoEQ95KxhbBb+KDotOlWalAzBM4IxOdp1SxSAqgfpY8Lu2XdPZmzv4eIauBXqJPf/U0 x3Eij+6bf0d+VOz1gj6N5/T5R0LL8yI= 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-563-LSns4lGNMQquxhPprBInwg-1; Thu, 17 Mar 2022 08:45:40 -0400 X-MC-Unique: LSns4lGNMQquxhPprBInwg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 11AD81C0150E; Thu, 17 Mar 2022 12:45:40 +0000 (UTC) Received: from localhost (ovpn-13-216.pek2.redhat.com [10.72.13.216]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4AB72C15D57; Thu, 17 Mar 2022 12:45:38 +0000 (UTC) Date: Thu, 17 Mar 2022 20:45:35 +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" , Coiby Xu , open list Subject: Re: [RESEND PATCH v3 1/3] kexec: clean up arch_kexec_kernel_verify_sig Message-ID: References: <20220304020341.85583-1-coiby.xu@gmail.com> <20220304020341.85583-2-coiby.xu@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220304020341.85583-2-coiby.xu@gmail.com> X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham 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/04/22 at 10:03am, Coiby Xu wrote: > From: Coiby Xu > > commit 9ec4ecef0af7790551109283ca039a7c52de343c ("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 arch-specific > implementation of arch_kexec_kernel_verify_sig. So clean it up. This is a nice cleanup, while the log may need to be improved. You should run ./scripts/checkpatch.pl on your patch before sending out. When we refer to a commit in log, please refer to Documentation/process/submitting-patches.rst. > > 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 >