Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2567460pxp; Fri, 18 Mar 2022 13:26:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5I41eP7cbo8lyN6wzRCHZnhv4ZG1GLbvVgvxVetgUmemEaOXeMLvy5Nzkqeu3pVlKV8+4 X-Received: by 2002:a17:90a:ba07:b0:1bc:a0fd:faf with SMTP id s7-20020a17090aba0700b001bca0fd0fafmr13208739pjr.194.1647635177952; Fri, 18 Mar 2022 13:26:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647635177; cv=none; d=google.com; s=arc-20160816; b=RRGNvNuntqpqkoKQ5IO2nE39RiwkLcFjPOrRqMbV+iW8ISSPQSWt9aE/e2VFJ6nmOw 519Ll//VZ3onxv24LOY4CfXrDwYrOSP3SFXtWfA/Y1whKUzn4VVze/l0W73wFqNECPlV qtALmQmqcTqwtDAVl735w3zsvFCQwStz4vBSIyj/RQo7hecsMLVSz5DijChgNGCqjqXO AYEJXisj7COAQXW2kjgyKtjtwYFj+ja6oOBSipaowkP5Y9V7mzYMU6EmFKjrxQlIpBdt VRpNT8FNyXomzwLOFTnqFqI3nAh2C3PdK159sTKuoaX4nVOWx8SiLztnmVSyOc64ENSa HRvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gwB9ZURkcH7/Y+etuUEb9xxXjVVCmMsQlrMh7LXVjOY=; b=qW/9LLCctuX03yXHPlpRZ3A6eS6RW9h9xE0Rk15+Q3B8sx3Q2bwxNFhYxAHQcklxQB KEdbB37k7zqLBs396+5r14aXsAMiFzb9tu4YSJ7xeYrR68HF3ebdleT05jCke+jscMgQ FXa/l2z5gCwJK/0ho/jjsbdXeSCvcf+mo7Dhv0wG8PjsFNja6DlXTi4yUOdC+jrmUsBr Cug0BrFwjpQ85NHuM5J5LKRLvLBK8EHq2Kf9ezjMWfeVm+R7wZpZX3JGfUTmvVFE1wD/ ljUPukLBw2pqrw8Wh7ndiPiRHxBCGl7sal6oru+BB4NT2E0j+vlwrz3boPKFPRhYHXVU slPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KfuZMq7n; 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 p17-20020a634f51000000b003816043f10asi5796249pgl.767.2022.03.18.13.26.03; Fri, 18 Mar 2022 13:26:17 -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=KfuZMq7n; 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 S233997AbiCRJma (ORCPT + 99 others); Fri, 18 Mar 2022 05:42:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233747AbiCRJm3 (ORCPT ); Fri, 18 Mar 2022 05:42:29 -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 958BB2C3DEE for ; Fri, 18 Mar 2022 02:41:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647596470; 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=gwB9ZURkcH7/Y+etuUEb9xxXjVVCmMsQlrMh7LXVjOY=; b=KfuZMq7nv0Ng0/omNkftCpxUyKI85aarzqlSlZt5hbULj/y+QCZ4Q5vikegE+0/gsbL7Cy IM2bkGB+OSKpi8o5EX7epZpXh8ewqMVhlNw/LHr3FqBHA3nwuB+8FUQLQX/gxHfmRWY/IS UGyc9ebmbjxOem/rRC1Fwk7xR2igUJw= Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-151-s2x06zI1OG2rYxjG7CRyEQ-1; Fri, 18 Mar 2022 05:41:09 -0400 X-MC-Unique: s2x06zI1OG2rYxjG7CRyEQ-1 Received: by mail-pf1-f197.google.com with SMTP id y27-20020aa79afb000000b004fa7883f756so26408pfp.18 for ; Fri, 18 Mar 2022 02:41:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gwB9ZURkcH7/Y+etuUEb9xxXjVVCmMsQlrMh7LXVjOY=; b=dNRG7Qjkp76Txgt2e/Bbvky+Otf12lbsoc1dHHXUZZSxdpl2VW5diflQY2eqDeOmc1 biSv0D5lDsYAtjYGK2n34gEAlfQe96jSascp90mnKO5xSM7sdQZBrmFIyTGe0Hka2771 kW71w8V+QqImSxq3DmpGQDOBCctC0xo+oNuhIV9BTFwCsvj8s7Ao1MVvcghRa26oHSAW 14UUxogtwI9eRh/DtNOoSZEUGTgdEl0yv5gRkYTbRwUSuF7jPnl9PPB6afldXGA2okrH iuDEfyrn4HjZ5DjtneQhNtdutO3JpAuZ6LfzFxONn4FLMzk1qjoIzj5JCZ/6Z/8k5U/I rgfw== X-Gm-Message-State: AOAM532EJHOrsmrK6zEyeLbm83SW7z9BzaDiI4df6LYFzwE7mrR1ZBts 8wLbhrWPHRXYKo36tVQeUF4Pb+heAoCA2tevzRBME6fDKJCmEv1fG76NXIuDmIMI3tuZfwIluqi oNaJ/fLYtNusVza+/hDEWc/po X-Received: by 2002:a17:90a:ca96:b0:1c6:b478:788e with SMTP id y22-20020a17090aca9600b001c6b478788emr1699047pjt.162.1647596468357; Fri, 18 Mar 2022 02:41:08 -0700 (PDT) X-Received: by 2002:a17:90a:ca96:b0:1c6:b478:788e with SMTP id y22-20020a17090aca9600b001c6b478788emr1699023pjt.162.1647596468092; Fri, 18 Mar 2022 02:41:08 -0700 (PDT) Received: from localhost ([240e:3a1:2e5:800:f995:6136:f760:a3d0]) by smtp.gmail.com with ESMTPSA id m18-20020a639412000000b003820bd9f2f2sm3599952pge.53.2022.03.18.02.41.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Mar 2022 02:41:07 -0700 (PDT) From: Coiby Xu To: kexec@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org, Baoquan He , Dave Young , Will Deacon , "Eric W . Biederman" , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 1/3] kexec: clean up arch_kexec_kernel_verify_sig Date: Fri, 18 Mar 2022 17:40:59 +0800 Message-Id: <20220318094101.274950-2-coxu@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220318094101.274950-1-coxu@redhat.com> References: <20220318094101.274950-1-coxu@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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 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