From patchwork Thu Jul 14 13:40:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Coiby Xu X-Patchwork-Id: 12917982 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 C209FC43334 for ; Thu, 14 Jul 2022 13:42:11 +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=IdOfXMMuBvwgCz4pU3OO9hNtQxi8ItKrGPyBHiWFsSQ=; b=uBCR3ENMvh9di+ qgxe64agidNsdYtfiotqqGCbF24Uz6I34JJ1hMMS5p82TWNOovbOscbfS+1rpkFrmVODpuTR34wzf Hmm6g/v5vYXY3iUGeS5Y2Lqj+goFdtDe6/4S5BHA2+dGYmaL33n2iBRYtpKarZh48CsxxdNKOgP0j XydtLaOfzfUo5Sn3S7xMQduCNK0Vr9qeCd+rC4MecVIRFTSyuBHWpWF6LrVE6+sIwl9dktx2HS6Xs Z9PZyl/QOwfCPxxJXhQYCtIPIuS3BE6cDrWWKdkiwsX0VU9VSnkWNmj41tBIeF9df7DXToa8UiKoG wGxggkitf38NCu6ZS/MA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oBz5W-00EoVC-IL; Thu, 14 Jul 2022 13:41:06 +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 1oBz5K-00EoM8-9o for linux-arm-kernel@lists.infradead.org; Thu, 14 Jul 2022 13:40:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657806053; 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=aiVvGqWued69KlQMltHUGXgLkEsQEsLtjAg7jnmKF7w=; b=BzSo71S0fWnQ6FquKZCw3IpI4dxxkiHxfTvg/3CLhN6frbAZxdofV5AW0Y7nimg+FW3LcH 1+2JLHjFhe3CUnX6mtNIOmbns3EizGT4QDE2WPTEErgOxoZlI9BUK3HYBivTlkINA3Uerm tbXu/daq/AygfD2O3gmb4KCL9uOsAm8= Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-144-Vd3vdvanOkq9CUnhkf1bKg-1; Thu, 14 Jul 2022 09:40:46 -0400 X-MC-Unique: Vd3vdvanOkq9CUnhkf1bKg-1 Received: by mail-pg1-f200.google.com with SMTP id u11-20020a654c0b000000b00415ed4acf16so1243736pgq.22 for ; Thu, 14 Jul 2022 06:40:46 -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=aiVvGqWued69KlQMltHUGXgLkEsQEsLtjAg7jnmKF7w=; b=2f1Q5redeETyB3nI8VjK4Dc7GLlNVrbo2eI5ZHSmRFcqk56WoJlW8iT2uZHgxBDrmx 9CMArkgOmc9/rqNv+vtmEUNa50FPFglV1ewEVtEi26lK/SFmaQDrtKFSOzSHCX7jkpgz sodNCuPf8CoSechb4SuKUwrFiXwBMB0/JGMUpna+oLgL+Xm4MYUMoVC5CRXxBSXqPgJY TLGibM9am19VEbH4AmwXABJiP1JFAGNLnw2IWQc656sgbXsqfGzGfdbVdQWwr/UTYa9e Zhr6tJdU15SSZvgAQX6dTQoI2w7naAUkZvCReR7YQfAtgRlOOseNPkqBLdFlYqoDrYLE t+hw== X-Gm-Message-State: AJIora+MxkryNXWyTBnCQjjt08vJDDL3b10U/J1EpObkKAk/aBTVNXNk 6uRcvwTlVQhS1DbqVswQC5j9fEtZAUHaZFSG6MZi4lFHb/LcqvnzPPfYIqDTiTTQoq8+ZrOt1mo gTzraUWuc+lZFqLsk0DjiKQTlScMJc+Cix04= X-Received: by 2002:a17:903:2310:b0:16c:1546:19ba with SMTP id d16-20020a170903231000b0016c154619bamr8463337plh.57.1657806045389; Thu, 14 Jul 2022 06:40:45 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vR6P1tHGe2AUAKkpHoPoHZ3qPv099U+d+IUX/aj3wmn46jrsJ1Kfs8MRjpFEQ0YAvbKCgu6w== X-Received: by 2002:a17:903:2310:b0:16c:1546:19ba with SMTP id d16-20020a170903231000b0016c154619bamr8463303plh.57.1657806045096; Thu, 14 Jul 2022 06:40:45 -0700 (PDT) Received: from localhost ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id o21-20020a170902779500b0016be24e3668sm1425461pll.291.2022.07.14.06.40.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Jul 2022 06:40:44 -0700 (PDT) From: Coiby Xu To: kexec@lists.infradead.org, linux-integrity@vger.kernel.org Cc: Mimi Zohar , linux-arm-kernel@lists.infradead.org, Michal Suchanek , Baoquan He , Dave Young , Will Deacon , "Eric W . Biederman" , Chun-Yi Lee , stable@vger.kernel.org, linux-kernel@vger.kernel.org (open list) Subject: [PATCH v10 1/4] kexec: clean up arch_kexec_kernel_verify_sig Date: Thu, 14 Jul 2022 21:40:24 +0800 Message-Id: <20220714134027.394370-2-coxu@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220714134027.394370-1-coxu@redhat.com> References: <20220714134027.394370-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-20220714_064054_458547_D4808D55 X-CRM114-Status: GOOD ( 15.16 ) 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 Before commit 105e10e2cf1c ("kexec_file: drop weak attribute from functions"), there was already no arch-specific implementation of arch_kexec_kernel_verify_sig. With weak attribute dropped by that commit, arch_kexec_kernel_verify_sig is completely useless. So clean it up. Note this patch is dependent by later patches so it should backported 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 | 5 ----- kernel/kexec_file.c | 33 +++++++++++++-------------------- 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/include/linux/kexec.h b/include/linux/kexec.h index 6958c6b471f4..6e7510f39368 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -212,11 +212,6 @@ static inline void *arch_kexec_kernel_image_load(struct kimage *image) } #endif -#ifdef CONFIG_KEXEC_SIG -int arch_kexec_kernel_verify_sig(struct kimage *image, void *buf, - unsigned long buf_len); -#endif - extern int kexec_add_buffer(struct kexec_buf *kbuf); int kexec_locate_mem_hole(struct kexec_buf *kbuf); diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index 0c27c81351ee..6dc1294c90fc 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -81,24 +81,6 @@ int kexec_image_post_load_cleanup_default(struct kimage *image) return image->fops->cleanup(image->image_loader_data); } -#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 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 - /* * Free up memory used by kernel, initrd, and command line. This is temporary * memory allocation which is not needed any more after these buffers have @@ -141,13 +123,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 (sig_enforce) {