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 6CE13C433EF for ; Thu, 14 Apr 2022 01:45:33 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=O9GBqdb6ersbhMsz7vsBNaTvA+zPO3VbAv3CeM69C1U=; b=mNPiIZFDTsFhai 6uLphCC/PMO7wp3n615oUN2+VXkMtlscnv4hUg0D+j255iR2OVxclQknLWSVntW62xWNqmpPpQwad DO1E7+pKjUmY/gZ6OckwplpM/8fSVqcojHKcGW9BvXdyYPO2a6NiD43IWqLKpzoMrhhpFbhoatgRL WJi2wnupFrfSrn9R786hj0P+WWfEjGvXapmU/UQ6wQXZPLh+gjeCYrCqCBcGxADKmhz/0xDIXJ8U+ IcWjMYHY8qHwZAwIVQP8j91xgJwL8qVa4BEWJ4/Xnv0UxLUQL4P+8d60EJPvzuG9fyFyZQUin8KXP ajDla8qAg62tffA8Wltg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1neoWp-003Iq7-Bp; Thu, 14 Apr 2022 01:44:11 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1neoWj-003IpE-JA for linux-arm-kernel@lists.infradead.org; Thu, 14 Apr 2022 01:44:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649900644; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jUo4znEOkRrWRs1sMxG9XXTvdlj/WDC4ky0CeyyLoSA=; b=Br6z+Yibw/BakuG+DPVvkib2e+usT2a5k/Iv4Pm4MBgF+5vsnpbE4YLQcYlLG4iiEPK8yc DKW6zPpnZ5I8nVyAp6H4DiJux0S+dqLT/yEy6r2UtXYYXvA1Ld1ozn0/R/QecXPW0Sf6Jk /BBmZs8ngtT1CrGBsqCw6ZmwNh4NYKs= Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-646-tUnTvj6bP22LtLH_xENrkg-1; Wed, 13 Apr 2022 21:44:03 -0400 X-MC-Unique: tUnTvj6bP22LtLH_xENrkg-1 Received: by mail-pg1-f197.google.com with SMTP id h14-20020a63530e000000b0039daafb0a84so1978611pgb.7 for ; Wed, 13 Apr 2022 18:44:03 -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=jUo4znEOkRrWRs1sMxG9XXTvdlj/WDC4ky0CeyyLoSA=; b=8HCo7oop7e5Aqm8KWx/HmoyGhtL09gF2kzjWI7jeHLhM1PcZdAAe/JzRO0z9HXKnah C7qm73OHho8S3XcLov0jr6dS+Bix8Q0gsFiZyQfWGRdtyJRPq8eoJWswumsyPnO7pImy SUFYQ9SLlJUKhit7w3Xx6LDLL938KjzzgXZwo7FyGdyDUVgi7AEg4pWhfWNI4kO9CMcl YVpIH6g5A/mZFuzuZMs43JuLo9dt3MR5fZ5yIkCVwTrogaw4dysdRreFYTzXOiIs1ky0 jzH+S094tY5wIfRvjyHoKTlHI93+iAdKr48qURl5sAG6wGFuqE1VwCKGuVIKFeiwzsyD oN3g== X-Gm-Message-State: AOAM532/dqVWIDiHmh7R6x45PsRYNbHLm3Uts2wJSHVlD8QzD0BQPvtH cZBPSqFZIiCpHmKguVDCzz8inw1BP6QX7SfU+Pq0Dz+oqgV4iFMo2HPdW3kF9b9f0XM6P5XVV/1 QA+tyDch0Sxdkz4SBN2K7dUFIP1gMnoqwVA8= X-Received: by 2002:a05:6a00:4211:b0:506:5061:3e38 with SMTP id cd17-20020a056a00421100b0050650613e38mr1591776pfb.74.1649900642600; Wed, 13 Apr 2022 18:44:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPUPsdDaV0SaXNU950qh/kHth5bPSWxu8nmDnhrsKNKGWJouIJSJ3+yN9qcKr5KVKvb/41OA== X-Received: by 2002:a05:6a00:4211:b0:506:5061:3e38 with SMTP id cd17-20020a056a00421100b0050650613e38mr1591763pfb.74.1649900642367; Wed, 13 Apr 2022 18:44:02 -0700 (PDT) Received: from localhost ([240e:3a1:31c:360:52fc:c968:cb41:efbc]) by smtp.gmail.com with ESMTPSA id ml1-20020a17090b360100b001cd40539cd9sm311141pjb.1.2022.04.13.18.44.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Apr 2022 18:44:01 -0700 (PDT) From: Coiby Xu To: kexec@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org, Michal Suchanek , Baoquan He , Dave Young , Will Deacon , "Eric W . Biederman" , Mimi Zohar , Chun-Yi Lee , stable@kernel.org, linux-kernel@vger.kernel.org (open list) Subject: [PATCH v6 1/4] kexec: clean up arch_kexec_kernel_verify_sig Date: Thu, 14 Apr 2022 09:43:41 +0800 Message-Id: <20220414014344.228523-2-coxu@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220414014344.228523-1-coxu@redhat.com> References: <20220414014344.228523-1-coxu@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=coxu@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220413_184405_943165_74F33C5F X-CRM114-Status: GOOD ( 13.88 ) 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 Currently there is 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. Suggested-by: Eric W. Biederman Cc: stable@kernel.org Reviewed-by: Michal Suchanek 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 58d1b58a971e..413235c6c797 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -202,10 +202,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