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 575B6C433F5 for ; Thu, 12 May 2022 02:37:54 +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=zPWk3avBXvxN2bHeY/8RGL+YbTMBQAMk56SUtOGTE4o=; b=CBk9fxH+osr682 wnmexwcc7r1TYF1P1SNTLbWaa90jvpIsktqt77GsL/bslqp6tkX4ujzYfsl1kN8sj0ccdYZnS58px BlON8yul2wig8SIyF7xlZm0UdgrzDTPCIm++jxkpGe/K2xbi90SovXbg+hlhmaIuZjwrJKN2UTjut ldI0/stGs79R+wU7bTC50ww0r2Ydr+6zTGd2bp4jBqeas2X8xJK3p8vYpVEW/g4IJLI1t5eDa0zIK fNv5UaAqms4XvR/IaIc8Ub4zbA80CklYSmbop2qFqjaWWd75AG3ySaQIkjS32bC9ktntDnVY3zF12 Ga5h/dYIuigudDXiJzVg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1noygd-009Wbe-28; Thu, 12 May 2022 02:36:19 +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 1noyea-009VYw-UR for linux-arm-kernel@lists.infradead.org; Thu, 12 May 2022 02:34:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652322851; 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=p1RM6J3uuTVxgrBSDhjonzu3khLVyy7UfT2z18Xr7/8=; b=Pb98WOapdqK3vWEUWidlwfcGB2Vd31EqDD563DrFuc6mdiJWXpHwJs21HU+YKxqkdv6k8O YEUo4kBCDZU/ZWAnVdV5W2qoTVlxi08eE1ABVJpDEEY4/K08PEZko3BkXxyL5c7LpoK0ve /T2+kmnJsmncSqjAOfXH4JDTmp0r44g= Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-648-TpSsy-zDNVieDvmS5HsG-w-1; Wed, 11 May 2022 22:34:10 -0400 X-MC-Unique: TpSsy-zDNVieDvmS5HsG-w-1 Received: by mail-pl1-f200.google.com with SMTP id m11-20020a170902f64b00b0015820f8038fso1980455plg.23 for ; Wed, 11 May 2022 19:34:10 -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=p1RM6J3uuTVxgrBSDhjonzu3khLVyy7UfT2z18Xr7/8=; b=xeIUXPr/rIlSdYDyPWysCrp5frS0+dg/j3a9nOx24AgtZzAQP410yKPcIvSQHTiT+K ZXq8LpnQsTBJWXzO6nt3SYeNnv+OH3abnvWjc9Ogbs4h85jX9xlvj/4lvrWV9kbZqLD0 xM5qlhl1yjH9s/Kgoy1bRr39hPa22nfoSXYmJrQPF6dXaZf5ddJbBog1Q+k7YwcCIQmP N2BlumkVhCXJrHC513VVBeBl5c2oivsevyG4z0F13yJ5NObvywXwHc2dnxkiGvmO3sWz 465Q1N+R8erC2klfheUUhkay9582kiRgD3FRzX1Anhtfk+Eks0F+RB3vfMNuGS5DxBkj WTsA== X-Gm-Message-State: AOAM53384iUfPzENv4ofBbqL4fmOT/zXpYSb8wBMSP8rOcsoxYjLhjnT fGXeVCjfYOHlIyLohW/tv9a07rz7ApByAS8+EcJ21thS9qlOzaMgODdXEQxSNxXkq8zm2tvlqmm H4UfsjeyfkPRAnGAWac+0zPGMW7XI+LkZRiA= X-Received: by 2002:a17:903:230b:b0:15e:bc9c:18c7 with SMTP id d11-20020a170903230b00b0015ebc9c18c7mr28317282plh.29.1652322849330; Wed, 11 May 2022 19:34:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBLwmAnT3YjOM0+q7aOBCPUuYBD9cDVb22vSPfF5bLWDIiVaY+O2ApMQ8Fxd/8OpkQUf8EAA== X-Received: by 2002:a17:903:230b:b0:15e:bc9c:18c7 with SMTP id d11-20020a170903230b00b0015ebc9c18c7mr28317266plh.29.1652322849104; Wed, 11 May 2022 19:34:09 -0700 (PDT) Received: from localhost ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id 7-20020a621507000000b0050dc762812asm2475053pfv.4.2022.05.11.19.34.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 May 2022 19:34:08 -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@vger.kernel.org, linux-kernel@vger.kernel.org (open list) Subject: [PATCH v7 1/4] kexec: clean up arch_kexec_kernel_verify_sig Date: Thu, 12 May 2022 10:33:59 +0800 Message-Id: <20220512023402.9913-2-coxu@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220512023402.9913-1-coxu@redhat.com> References: <20220512023402.9913-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-20220511_193413_186548_0D60DC60 X-CRM114-Status: GOOD ( 15.54 ) 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. Note this patch is needed by later patches so Cc it to the stable tree as well. Cc: stable@vger.kernel.org Suggested-by: Eric W. Biederman Reviewed-by: Michal Suchanek Acked-by: Baoquan He 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.35.3 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel