Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3030700rwb; Mon, 15 Aug 2022 16:29:55 -0700 (PDT) X-Google-Smtp-Source: AA6agR4/622P3buFTOdo38zBuoR3KoOtCfJSsxAdWevKmbboJL31IKClzLLZxV0foPc4CR8QPcZS X-Received: by 2002:a05:6402:248f:b0:440:9bb3:5936 with SMTP id q15-20020a056402248f00b004409bb35936mr16761170eda.178.1660606195003; Mon, 15 Aug 2022 16:29:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660606194; cv=none; d=google.com; s=arc-20160816; b=EAWYQQJETGfwjDCcPATFVAlxT7NclNJakGg6FiYXTVh7XvKnewh1untARHerprd1+v iwbfI/L+QbJgTt9yYHJnyBe5Ik48TIvP1g2V5iIGHpE4+WJjjII/f+iH66iuxNfhn0y4 C/Z2PxqhSO+7RxzSKDF636UzXFEbBaTp3JS0NhrcdKFvciLNbtCufbOQ3Tc44RuFlah+ GLQ8A816SJaD3HUit/asZpviJ7ks8yc0VdOUDYtx815AH1BrFmLZUmkT+htJLD+inFQS F0P0LxsKEd6TzztWBLqQsPW0LakJjmWx5daiSreThUy9kfToP4lBNP0Bl74eaMP4LPcu SrQQ== 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=lFAaJf3S6r6AIG3OD5VInSS8qecaYTRE3R9/Ijdu1g9Kv24Fvt+rX2wVIUfojE7+Jg ftKR4xiH2OXDZAF/RywLHeZEHtjD6KiyubKStDC/+fw1osNWmHjzWATnRoRjHJb4TV0R aUP1WI0wHwDY7p+dRJXjnZF5yeoizqQRxWSX7L6qUCkqOsDz5vrqjFQU//YiryBNhxYn +Bg6iJzjReFDX4DbSPBjRBkPtNw2zVHyBsJat9fCFMfOyo9baEARO6xY+xNkatjyKIZN O8fjiiLDIUgwHY+rlswU+gqR1fivPxlur+K1pxnncS4/R6bS+E8RiJvFtrn7eDvWaJCJ kM9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=J1JwuGdC; 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 ww13-20020a170907084d00b007317756bc04si10507456ejb.1006.2022.08.15.16.29.13; Mon, 15 Aug 2022 16:29:54 -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=J1JwuGdC; 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 S231926AbiHOXUF (ORCPT + 99 others); Mon, 15 Aug 2022 19:20:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353125AbiHOXP5 (ORCPT ); Mon, 15 Aug 2022 19:15:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C344146CED; Mon, 15 Aug 2022 13:02:56 -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 1449F612E4; Mon, 15 Aug 2022 20:02:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0708C433C1; Mon, 15 Aug 2022 20:02:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660593775; bh=VHaLffJQoHaI+IOtGGNDfDZgg2sKNs5qPuw8gRU1Og8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J1JwuGdCa+ibvAmw02UbD58s1FCY22nDrZzh7I5wQi8wFYXc1m5JFaRz9oPXnZyEX TVKTKq1lgQpUlspYS/D73eAzzPQam7Qo2hcW0BQHJvZ3q1wAFCeHqbol0O7h+aW24/ T/Qn3S8puWLcB4x+nGA4jCW1vx+SD4jeGMUpcDkM= 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.18 1004/1095] kexec, KEYS, s390: Make use of built-in and secondary keyring for signature verification Date: Mon, 15 Aug 2022 20:06:43 +0200 Message-Id: <20220815180510.636878336@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: 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