Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3118240rwb; Mon, 15 Aug 2022 18:33:48 -0700 (PDT) X-Google-Smtp-Source: AA6agR6AF+yv9765mw/d3OQUOxsClOdHlNgsmSklXqdtK7k+H9MTL/9tJn55LbMAdhTGUcZqtvGe X-Received: by 2002:a05:6a00:2352:b0:52e:a03b:76f1 with SMTP id j18-20020a056a00235200b0052ea03b76f1mr18961851pfj.34.1660613628005; Mon, 15 Aug 2022 18:33:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660613627; cv=none; d=google.com; s=arc-20160816; b=ISA/KX/Js88fs/dvV4IFoO9pMWvHb718bgQR9ycVSOmi79i7l2gTNRXFIXFfn3Db5r VjBTXsnDoSQdSbqC9LvILVm/KfdvTKepeTS/WaPYIHsSUPWOtkjmDqpBCsqSfnEUiARz aYNKzZbno61uW3YkMhBJ/hO2z7jPQjIooXNzpuTouw+vygo1ExSfdsfyYVT7m80zDpqK M/MvRCaWc1iOqIQkwFlX+wqVxaNSMyNe9jGCeuPlg0zkKJhVWTdA2uofDPB+Zv1O2AXu DiNYE+FjRxScuR40dE638oHqOZzLqu3i782G8xkL2VwZ5GPkix+bdPMsuv2E5TgRAOo4 W+/Q== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LfdwkalXQHPeQgQDFWqlBIwhnsUKhQy14xodmesKs3U=; b=gPhagaz2eoboxKwhJHzFUoY1SAn/2Hrwzu1t2XXPSM/hvgYhGep+FVoauILGckOTFv SvNUNi/YdKPstPR0M4U4mF8gwuytzlUIw1QP2qWi0WRbfWmCMcM2fk7C0Al5u+ZLqgz2 UM2DFKyoKje0OVm4Nlec0+TtqVcC8X1yijIBRt8gb7Bf7iIMf3a0J0p5PovsOgT0J4V6 978Gs31gV6j87upESw22I0EJ/zNwN9ORh0oZjqz3our8GItTFAyoU135QW7YBqeIXzq8 xevTAbiNdLCXItJFtLXvk/zJ8CywyYlqXpsI6sAQN1GanMBy6v9o6b4EYFXSO2538d3/ fUHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FOuOEN95; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 137-20020a62198f000000b005251a325ea0si7463568pfz.269.2022.08.15.18.33.36; Mon, 15 Aug 2022 18:33:47 -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=@linuxfoundation.org header.s=korg header.b=FOuOEN95; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346979AbiHPA5E (ORCPT + 99 others); Mon, 15 Aug 2022 20:57:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346693AbiHPAvN (ORCPT ); Mon, 15 Aug 2022 20:51:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37446B69FC; Mon, 15 Aug 2022 13:46:49 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8323761243; Mon, 15 Aug 2022 20:46:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D6D3C433C1; Mon, 15 Aug 2022 20:46:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660596407; bh=36XX2c9r7A8FI8w0hCoply89X3xjewEPw5zcTFeVF/g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FOuOEN950cKKE4sGWsn0Uw3HFA2/oyeyM8vqZ8uaRyvDsEzfNy2mqncY+bJADa6g7 4qXg8lR4cmjPBwvfxMNdcLyfhm7l6rt5JTMxRFHPOTYNv8ocXRy51viX1ApDfJGEuc Xa82pDpDsPxrbZnnsol6mStfzKCjJFItFNbQ1Rlk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Eric W. Biederman" , Michal Suchanek , Baoquan He , Coiby Xu , Mimi Zohar , Sasha Levin Subject: [PATCH 5.19 1070/1157] kexec: clean up arch_kexec_kernel_verify_sig Date: Mon, 15 Aug 2022 20:07:06 +0200 Message-Id: <20220815180522.915710918@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,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 From: Coiby Xu [ Upstream commit 689a71493bd2f31c024f8c0395f85a1fd4b2138e ] 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 later patches are dependent on this patch so it should be 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 [zohar@linux.ibm.com: reworded patch description "Note"] Link: https://lore.kernel.org/linux-integrity/20220714134027.394370-1-coxu@redhat.com/ Signed-off-by: Mimi Zohar Signed-off-by: Sasha Levin --- 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) { -- 2.35.1