Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1864430rwb; Fri, 19 Aug 2022 10:39:27 -0700 (PDT) X-Google-Smtp-Source: AA6agR4fLhywMXbo4P1QX2mH4PsfUmTjjnxedQTvVXqOUDnF+urWfhpBjUJizC26NUOKaWc7pXqB X-Received: by 2002:a17:902:9307:b0:170:d739:a3cf with SMTP id bc7-20020a170902930700b00170d739a3cfmr8603306plb.127.1660930766836; Fri, 19 Aug 2022 10:39:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660930766; cv=none; d=google.com; s=arc-20160816; b=pfORLNKRDKhclpD4U5uNT+opar9qVezztzAfzU11OrcUid3PbyzB4r78vbo6XW2iE4 sTjP3UfV5RaKByBJ4shikbasiBgw0oBSGPook036MPEFqMtVQhW4QJwx4G/tMvpbuYuX j6gOgaGGPR1GLCdzEwpyx0UOkmRzkFIA5SSH93GUV+7dDecDUTOlOby9D21Ii3Wk4/KP bEVpQ+oh1tWW/0Z3Hh47JKwsKJmUvj1szcJGgcZX/22OlvlzcNrhRtGOCvnNVPdybLD9 sGu85GF7haED6VRYaEGLulAIeF+dq/TcjC1N47EpZNqBIawrlS1muPd2JGUjSyuTvAPK g1tw== 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=+jYbPHB/90pW6OO0/feIp4HmXW/NGp5torq8jpxo6ZI=; b=E21Z3mrqsO6ZkItzb1yVPVZuiqfuWouMRs/AlVeelB5atf9biqr2+uMOZoOI00Jyc1 1s1uMAet0GGYFCEY7NP7pSLbS1700P4/8X7NoUkHW+ckvnO5ZNzPUbnKGDzwQINjI1Xv eRySjO3grTMWe9WtLXI5ehRy4ULZqBvJbh+vp+UrmxZa6tjzZVRPrsk+LN5Z7OXcfXqj /c+cmt1onP7i6ojF/7RpooAFjXvZByi/UzPyzZj8XtG3ZS5ZU7DRbGAacmsOBnOXi6Km hTBlt27QfHA399rW+laZXw+kGFD5IlxZP+m/91yVwx8FqwLTg9w34w90JsfQsXK7TufM Zszg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NB3OH1aT; 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 s25-20020a634519000000b00420188aa35fsi4454254pga.432.2022.08.19.10.39.15; Fri, 19 Aug 2022 10:39:26 -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=NB3OH1aT; 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 S1350132AbiHSQsM (ORCPT + 99 others); Fri, 19 Aug 2022 12:48:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354018AbiHSQpl (ORCPT ); Fri, 19 Aug 2022 12:45:41 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D1761136B4; Fri, 19 Aug 2022 09:11:33 -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 ams.source.kernel.org (Postfix) with ESMTPS id A3548B8281D; Fri, 19 Aug 2022 16:10:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6BD9C433C1; Fri, 19 Aug 2022 16:10:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660925431; bh=UbvKfmtzs32cFDTyTo+GWVhRq/t9RCRY5QIwE/sesu8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NB3OH1aThwwmcBxoO99/wyWoWFUsoQfwdLiNv3+njhuMhi64vhLSWqxkag1KWqxZ2 mXY6MIu9YnZPaBbw2aUKVfE7UE1EN5xxI8KBoWKTdGpjLq7nOkHFc/ev8UWNTMs8Um 5vrFbH1MgeSpsi6xI/XeraUKHexKYN358SkA3W84= 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.10 489/545] kexec, KEYS, s390: Make use of built-in and secondary keyring for signature verification Date: Fri, 19 Aug 2022 17:44:19 +0200 Message-Id: <20220819153851.328682509@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@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 76cd09879eaf..53da174754d9 100644 --- a/arch/s390/kernel/machine_kexec_file.c +++ b/arch/s390/kernel/machine_kexec_file.c @@ -29,6 +29,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) @@ -63,11 +64,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