Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3030715rwb; Mon, 15 Aug 2022 16:29:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR6aj8PBtfqbEGfZMVmng8jHu55JN4KbiTWM/L/RTzlEyMC6YHxda23u9fGN8ZylHjC05c1X X-Received: by 2002:a17:906:9bc4:b0:730:9edc:40b2 with SMTP id de4-20020a1709069bc400b007309edc40b2mr11635144ejc.155.1660606196040; Mon, 15 Aug 2022 16:29:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660606196; cv=none; d=google.com; s=arc-20160816; b=PT8NitvlzHM3cvyrnEiEFEJX6y8eQex6Ys/JMPsz/EoLUTJZ9vzzfAVKac0NFZBNZe ykG3Lzno2abbALwO6CbioniodrB9rHK8jLki+hoTKTP1/9GiZC/VhrGzcKu1kCThK08j 4ATlKNaXiyZSy6aXYGn9iRqD3NJWWkgzSq8mRPVav/+SjVLHZ1NCRWLQSsdVUntfnBwo PJ20mGADBOSJ1iWrix5lvek+uhCCYliIOtEqbtd7eOIWwpXx/48GCJ1BMdyJtWkSHRsn rkw/JArxdRAv0bvAPvQsCjj0k0Xhjy2A27pNoXlEz4AgEXGuK2RdrwR8hbvxY7Vz/mdH bYWg== 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=IYrmJvZIbHf6f9p3ovT/heKlMZWaR5xjO/AAfdm7AVI=; b=zWEBq1mTBtpIjynEkU5IHat0f3kP/u26oQuEg81/7rKnKCMBCh5Ab+A4LfBpruXu3K Pi0ION+nqQCQRvdswG2ZjCTg/jYHTFXaqoNxIJLLkgxRIsZxW36htOKniRd7d1K0MT+b A/c3VqW/O63jHJFrwNI48Fx0dFpMb0POEIXFvjbWp5Ao3ooQYnW1i6qozZVsKXXpJGAX EP05eJ5v1Vfywn8u4+cZyuSLfEusA5gNYqpxJibr8h0gsix0ebXl+ME05oMhYHn1y6oN pTwU/2kkHhGFU87XZHWUAmgqRQytzG3uVZ6L6JPYjyMde8cm5zfpnZ0ozhagPVMDw8je FMcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=T1ByAi9u; 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 nb21-20020a1709071c9500b007313013c1adsi8603806ejc.259.2022.08.15.16.29.14; Mon, 15 Aug 2022 16:29:56 -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=T1ByAi9u; 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 S238278AbiHOXTv (ORCPT + 99 others); Mon, 15 Aug 2022 19:19:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353063AbiHOXPv (ORCPT ); Mon, 15 Aug 2022 19:15:51 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDB857CB69; Mon, 15 Aug 2022 13:02:50 -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 547DD612D7; Mon, 15 Aug 2022 20:02:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 464B7C433C1; Mon, 15 Aug 2022 20:02:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660593769; bh=TbANiIQd+FPDA4iJn6Ixa9itBumf/koL+SuMqUIt8yg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T1ByAi9uw/oYAMI5X3qTyx2VstCKenTdy6G502GePe8K8rQXHSe9M2OTHk6GoOhnR bzr0VPSP4lTV7ULvmI9D1P0UC2JUTnAD5mhlN5Zh0FV4foNjOBa/eSGCmnlfdfj+70 ebR/CMWHKZcygvu/uwAn8yn0I/PWcGLHPqTpWBPk= 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.18 1003/1095] kexec: clean up arch_kexec_kernel_verify_sig Date: Mon, 15 Aug 2022 20:06:42 +0200 Message-Id: <20220815180510.604450713@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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 87c1795297b0..f3e7680befcc 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 925953dfef05..ad005cd184a4 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