Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3095694rwb; Mon, 15 Aug 2022 18:01:18 -0700 (PDT) X-Google-Smtp-Source: AA6agR7WOt01H9puI2QPhdl/MXhcLyV4/CZLsTdZVDecaUXhKdHmVAKwk9+GC8TYKhh4yRYZ8/xL X-Received: by 2002:a05:6402:50c9:b0:43e:42b0:f84a with SMTP id h9-20020a05640250c900b0043e42b0f84amr16696647edb.72.1660611677862; Mon, 15 Aug 2022 18:01:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660611677; cv=none; d=google.com; s=arc-20160816; b=SMqiB23ovBKRN2kTX3KwkRDKnYGtg3NExEvO3YjT6uvN4oEvfNEwTXYNl6xM1GV1mo 7qd4sZenSHVgT3PuIJfZggNfPfNXjxmQ1qQI0kHqW5sFxF/kCbZnLPR5PpAHejmPMyQA W/rfWsEbB6+Xk/aHp2h8/06+7hBlp+Di9cqTjyjFQv2AFllSAa1pWb0Nm7RxjnmGWg41 VO4zE+9E6zT9pYqKB/8VxpYNSfJV4Z1k4i8BAAe92O7/UoCGHbkwKIcEbjnv93he2EKT RckZNoH8Fw94M+Cf356mstsThThL1r/d2H4zqLEkLWnXXOtc4XKyOb7Cu28JccfFqAdh 86IQ== 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=wz7UOlFevJ/EGxmd6HEWMYAvZY8l0An6sO2czXtDua4=; b=WTAI9tAEvASFls7Alv4l1oLjKIo8Of0czKWlLeMweYCqJ8NL4wfOX2o97PR2bnX+DP hmRELcGlQsCFAuGIQUnSSESkB/pNFMoXOGR6GaaviRFb8xVTkUCqy/08VM9jVYinUXX7 18Uwcx6UG4Jhb6QFM+HEqRQMWbBSTcO+/mtf2kbQ0xjZc0BNQwf/bLGJo2BHWmHjA73b JqoaqQOBYvfgC7lpaqO5AoRefjLbtUDfLhGRlD+TQtkVO78yeOQiAvotJx2ONjczh7US fdzA3exN89XEx878mQYD1sU4BXEky/h3txpG5wPQNL1ffADV3XurWhDl5HIgRTx42XXU 57YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GtGLWgOW; 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 qw23-20020a1709066a1700b0073276700562si8983229ejc.282.2022.08.15.18.00.49; Mon, 15 Aug 2022 18:01:17 -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=GtGLWgOW; 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 S1346452AbiHPA4y (ORCPT + 99 others); Mon, 15 Aug 2022 20:56:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345504AbiHPAu4 (ORCPT ); Mon, 15 Aug 2022 20:50:56 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCFAA199B2A; Mon, 15 Aug 2022 13:46:54 -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 sin.source.kernel.org (Postfix) with ESMTPS id E62B9CE12C3; Mon, 15 Aug 2022 20:46:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7EB81C433C1; Mon, 15 Aug 2022 20:46:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660596411; bh=VHaLffJQoHaI+IOtGGNDfDZgg2sKNs5qPuw8gRU1Og8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GtGLWgOW9FIRgUgUPm1+jviG+EZDWvBIho5/fW/fMws1nL+zPHWP3OPdL+PfS80V3 yrQPXEvpAT0p+3XOabZcE7kgCRfk5E/9VaXIDCCnkVrOnKJ1Uq/6q8v/I3FIHQbJKr 9thRezn4ozh0N/29GqL5q7zA+afB0+a0KvI65EKM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Philipp Rudo , kexec@lists.infradead.org, keyrings@vger.kernel.org, linux-security-module@vger.kernel.org, Michal Suchanek , "Lee, Chun-Yi" , Baoquan He , Coiby Xu , Heiko Carstens , Mimi Zohar , Sasha Levin Subject: [PATCH 5.19 1071/1157] kexec, KEYS, s390: Make use of built-in and secondary keyring for signature verification Date: Mon, 15 Aug 2022 20:07:07 +0200 Message-Id: <20220815180522.963428530@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: Michal Suchanek [ Upstream commit 0828c4a39be57768b8788e8cbd0d84683ea757e5 ] commit e23a8020ce4e ("s390/kexec_file: Signature verification prototype") adds support for KEXEC_SIG verification with keys from platform keyring but the built-in keys and secondary keyring are not used. Add support for the built-in keys and secondary keyring as x86 does. Fixes: e23a8020ce4e ("s390/kexec_file: Signature verification prototype") Cc: stable@vger.kernel.org Cc: Philipp Rudo Cc: kexec@lists.infradead.org Cc: keyrings@vger.kernel.org Cc: linux-security-module@vger.kernel.org Signed-off-by: Michal Suchanek Reviewed-by: "Lee, Chun-Yi" Acked-by: Baoquan He Signed-off-by: Coiby Xu Acked-by: Heiko Carstens Signed-off-by: Mimi Zohar Signed-off-by: Sasha Levin --- arch/s390/kernel/machine_kexec_file.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/arch/s390/kernel/machine_kexec_file.c b/arch/s390/kernel/machine_kexec_file.c index 8f43575a4dd3..fc6d5f58debe 100644 --- a/arch/s390/kernel/machine_kexec_file.c +++ b/arch/s390/kernel/machine_kexec_file.c @@ -31,6 +31,7 @@ int s390_verify_sig(const char *kernel, unsigned long kernel_len) const unsigned long marker_len = sizeof(MODULE_SIG_STRING) - 1; struct module_signature *ms; unsigned long sig_len; + int ret; /* Skip signature verification when not secure IPLed. */ if (!ipl_secure_flag) @@ -65,11 +66,18 @@ int s390_verify_sig(const char *kernel, unsigned long kernel_len) return -EBADMSG; } - return verify_pkcs7_signature(kernel, kernel_len, - kernel + kernel_len, sig_len, - VERIFY_USE_PLATFORM_KEYRING, - VERIFYING_MODULE_SIGNATURE, - NULL, NULL); + ret = verify_pkcs7_signature(kernel, kernel_len, + kernel + kernel_len, sig_len, + VERIFY_USE_SECONDARY_KEYRING, + VERIFYING_MODULE_SIGNATURE, + NULL, NULL); + if (ret == -ENOKEY && IS_ENABLED(CONFIG_INTEGRITY_PLATFORM_KEYRING)) + ret = verify_pkcs7_signature(kernel, kernel_len, + kernel + kernel_len, sig_len, + VERIFY_USE_PLATFORM_KEYRING, + VERIFYING_MODULE_SIGNATURE, + NULL, NULL); + return ret; } #endif /* CONFIG_KEXEC_SIG */ -- 2.35.1