From patchwork Mon Oct 18 08:31:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Coiby Xu X-Patchwork-Id: 12565335 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D292EC433F5 for ; Mon, 18 Oct 2021 08:33:26 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id A07EA60F21 for ; Mon, 18 Oct 2021 08:33:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A07EA60F21 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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=Jze6tgCysBPUMmRspdh04Clwt6Gt4E4UDfhsFx3eBJU=; b=fLiCT4zugkJlr6 ZWFFzVAMDNzBurfAQYgx3frgUblmP9B95XK7pCv2vht9NcYWGdulrq2g9/Ykif2Erv4lPw+nev5OT QlWJUwZs/PKmx8ikWKpvW1hf6XnCXrU3TGJDhOCFLYIaUZJ+xVVnZkDkofe3oi+bCXz4ty8pVXER7 QbnA/4Yq69uhWwV5SNrAjRvZ888TKReGl8gCyYME3aUwkdT3ulWPcIuASw6DwGmOF1cFEpfyPDtfo hpowgQW8J0C5AWBP7V9Jzxfvjlpp4giZnMzGJcxJZ53XPNqsQOYgPUj8BW31r0UljTB2AyB3376db eYzb6HcVpVchbYoOG4/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mcO3t-00EdjR-VA; Mon, 18 Oct 2021 08:32:02 +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 1mcO3f-00EddX-LQ for linux-arm-kernel@lists.infradead.org; Mon, 18 Oct 2021 08:31:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634545906; 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=csQLUtgBqx/5daSsrbY1xfwwRnYytpMxFZ1u3egdn8A=; b=c30tdYq7OHUkSoqrw3F4AYwIdyf6osNkwBYTNe1LmU6gOExOR+az5nT3JGgXpMUMA6VdcP Nyo8bavqALm4zOH3p9oPTBKRzyZUj076fGjblff/c24z/J9JkwurZGOl5l1U51VTBqUD9I Yjqv1RXCKT021mEliTon8437LeLogLM= Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-502-h69CC0X1NtGpOUC5QuJpzw-1; Mon, 18 Oct 2021 04:31:45 -0400 X-MC-Unique: h69CC0X1NtGpOUC5QuJpzw-1 Received: by mail-pj1-f70.google.com with SMTP id 41-20020a17090a0fac00b00195a5a61ab8so7434307pjz.3 for ; Mon, 18 Oct 2021 01:31:45 -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=csQLUtgBqx/5daSsrbY1xfwwRnYytpMxFZ1u3egdn8A=; b=BDxMhWx5i+nX81r48Y+kCVZOQktWzUmP5+Vncp4Q7WAK5qZuUza+78s4DflCKJLi8l nYjIsflnk5rFqY7SLuKS+tGe8mM9UZwBHF+fJTxJVnzS+lU5Riuo9YBMHGpErQ9y2Epr 6SKWvVvOCeqRLBPUPKrzdAXUhBPRjqqSuuAZJo2LoFYjdzdZZnyd5UlcBJPlVIxEfS+1 9teQtXAKtajSlJhph5rCmOHiPUn/n2eWtTWOn6JczGXzrYDkzvYE9hcvcdU38gUQmnCM IMoUmPrzem+wOaWDI47Mtb9Lhs7LlnxEWGuWTZLv0mWPWtJqMsOZEuWNOAPRTEi9FgkO T5Qg== X-Gm-Message-State: AOAM530Y1GIEF+mg7EdNakbZDsnQP3epummCec8USpXNGxsi9TqrnVwl Nw9KAzAvmZ1LxKzpnCDWJYjMUikK2oHeEn1mw5X2751mPundTirHUDnpEKC6Qgx29s8JTW5EFa8 uvI9rO+2hODvSyqqpmCPRdtVoBd7Ljtj9Gf4= X-Received: by 2002:a62:6d86:0:b0:448:152d:83a4 with SMTP id i128-20020a626d86000000b00448152d83a4mr27718011pfc.38.1634545904236; Mon, 18 Oct 2021 01:31:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyn4FXgnyzb3d0WSsDjD/Mru61iAEyKojJxN31Ju5AUtYVebTdKCkuc0TjOokerxjuu5Gk15A== X-Received: by 2002:a62:6d86:0:b0:448:152d:83a4 with SMTP id i128-20020a626d86000000b00448152d83a4mr27717993pfc.38.1634545903998; Mon, 18 Oct 2021 01:31:43 -0700 (PDT) Received: from localhost ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id u4sm2402404pjg.54.2021.10.18.01.31.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 01:31:43 -0700 (PDT) From: Coiby Xu To: kexec@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org, Dave Young , Will Deacon , "Eric W . Biederman" , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 1/3] kexec: clean up arch_kexec_kernel_verify_sig Date: Mon, 18 Oct 2021 16:31:35 +0800 Message-Id: <20211018083137.338757-2-coxu@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211018083137.338757-1-coxu@redhat.com> References: <20211018083137.338757-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-20211018_013147_809109_233E9FD0 X-CRM114-Status: GOOD ( 13.70 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. 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 33400ff051a8..42b3ac34e4ee 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)) {