Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp402508iob; Fri, 13 May 2022 04:23:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyoEL+xn8ka1M9ZPMu31BDSv6Ixrt0yVv2IMXZBTRYBm9t5fQedGl7fFTcfe2t9pKXjksbG X-Received: by 2002:a05:6402:280a:b0:427:df14:d6a9 with SMTP id h10-20020a056402280a00b00427df14d6a9mr39863286ede.139.1652440995478; Fri, 13 May 2022 04:23:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652440995; cv=none; d=google.com; s=arc-20160816; b=X9HRN/9a5WCwAZHoag+MAuDc1MEAPNdEcWO26cvr+qWjYML2QjCOQgYPg0/Rsxfe9Z zNveIeB/KCeoLABC0Y41AXxUW4msrLVy8E4ipTEqB6esnNB6K7QnVwUEppLrURHq1H77 mOr2d+13jcBVcl18Wv+unMy9xqUNsVyl0j//iD4vOsuGN+9nz+8qUFhzz0oXfIjs/rye UmulbgLVXE0glo0tWJ+f5ITCr/JvVCBSP0CXGMpt3poDzXjhfcNrU2/p1UpfrAGgraFz eihWCxRxwK12AW7+OgA5ImvpLcCCfedGm3MJ+3zyBM78CUj34otC3cUrzJNaiSWg712W Rxmw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Sd8cjBSOdeaVjyH4f3lxl+0xYw15nzSjwpJw6bzSgLk=; b=xeoFX+1/stEn5vnMVcFFpk5F8ZmOWRKWYEsPXa8odDYlly9fMM0mzVN0JvBTKzHe4h mzREMFhRw5CieKcpqVFuYYi0D3hcmzyBdb00wXgu4UD1ytPA1Q3zb7zZTPDPWbMHBb3W IYubjvJwDO4qOO6crHoh5aCPihKO1wJaEYVmzJR5dVdDfh2ljv8ePc3/F2sMxHUZJNjD Rx3kywtQbvGAIn6pn/RWBTyxTxcHgWUl0Kg40WgXl6CpxhERYcq2QkDVUmQfPKElnP2S yQob0Hcom7AUFcZoZ239ZdpMWIiUohYI1gaUlq3KxfU/eiIlEt5R0dfpHUXmQhtbHzq0 swjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BhkDdrWh; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m19-20020a056402431300b0041d79f5da31si1880111edc.534.2022.05.13.04.22.47; Fri, 13 May 2022 04:23:15 -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=@redhat.com header.s=mimecast20190719 header.b=BhkDdrWh; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350675AbiELHCQ (ORCPT + 99 others); Thu, 12 May 2022 03:02:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350669AbiELHBv (ORCPT ); Thu, 12 May 2022 03:01:51 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AB7AA4C42E for ; Thu, 12 May 2022 00:01:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652338901; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Sd8cjBSOdeaVjyH4f3lxl+0xYw15nzSjwpJw6bzSgLk=; b=BhkDdrWhqqTMWA0vmLl88Ygt39C3XagThZzO3obx3OSTyM3tMvKcngNvRlNNGoRe1spyrv dgeHXtriVpiaIPew1LB+hQebekKOm4oc9i3ladtRZQDhu8nR/UDrHQRCope8CtDmKQ8eKw qSUCvrjYfFgeYGXD9rOWEdKguXPdSW8= Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-187-ub-0L7jXMB6VLkuuWG4dgQ-1; Thu, 12 May 2022 03:01:39 -0400 X-MC-Unique: ub-0L7jXMB6VLkuuWG4dgQ-1 Received: by mail-pg1-f200.google.com with SMTP id f7-20020a6547c7000000b003c600995546so2194756pgs.5 for ; Thu, 12 May 2022 00:01:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Sd8cjBSOdeaVjyH4f3lxl+0xYw15nzSjwpJw6bzSgLk=; b=lSuhJQD3/o+3+nqcm/QL5agWgRPaKf0YY2USazGvJzrMwXnrV7oc3QTQYipTA9Md6w MWyVKK7OMYcJ78uLgAOkt+yqpgPZHRX94bRChPSk/7qoH1vO3Jo7oXbCnj70jXTt8d2W 2Zb2Y9LnvXX1n32+o9sbEyUe6kfT/IbW24aUMfheemrKIvxyM9TmpZkq0Z9OUOx9amCi ASf5vxYuxqjWkkS0FQ/acjXtotbpcTR9cDNrk6KQU7U6Aveja2+FtzvsavFIvzRpcZ1+ MKl5A5/ifYsJfWpFxV2ZDROMcA+d9ZdZcmYR6HWVeSAdUugmWCBQcK9W7YSD1SDPj/p7 NXaA== X-Gm-Message-State: AOAM531e/6lvwAdWXxL3WWXxogwCCC5ugg2f4GzPGT7IdmCLq8M38HB9 qTkQDneUK3LFEVsaAvgepsLnklfZYAASeymCCGb8NgpQDyMepH2kJR6vpCZTkeyaSDKsXVUEGFa +XVbyIxsoBhWV7C/nMfRUlZWD X-Received: by 2002:a63:db17:0:b0:3c1:dc15:7a6e with SMTP id e23-20020a63db17000000b003c1dc157a6emr24702552pgg.107.1652338898844; Thu, 12 May 2022 00:01:38 -0700 (PDT) X-Received: by 2002:a63:db17:0:b0:3c1:dc15:7a6e with SMTP id e23-20020a63db17000000b003c1dc157a6emr24702527pgg.107.1652338898566; Thu, 12 May 2022 00:01:38 -0700 (PDT) Received: from localhost ([240e:3a1:2e9:efa0:e73c:e550:ac9e:58fd]) by smtp.gmail.com with ESMTPSA id q9-20020a170902a3c900b0015e8d4eb22fsm3060866plb.121.2022.05.12.00.01.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 00:01:38 -0700 (PDT) From: Coiby Xu To: kexec@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org, Michal Suchanek , Baoquan He , Dave Young , Will Deacon , "Eric W . Biederman" , Mimi Zohar , Chun-Yi Lee , stable@vger.kernel.org, Philipp Rudo , keyrings@vger.kernel.org, linux-security-module@vger.kernel.org, Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Martin Schwidefsky , linux-s390@vger.kernel.org (open list:S390), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v8 4/4] kexec, KEYS, s390: Make use of built-in and secondary keyring for signature verification Date: Thu, 12 May 2022 15:01:23 +0800 Message-Id: <20220512070123.29486-5-coxu@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220512070123.29486-1-coxu@redhat.com> References: <20220512070123.29486-1-coxu@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 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 --- 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.3