From patchwork Wed Jan 18 06:10:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Donnellan X-Patchwork-Id: 45004 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2174151wrn; Tue, 17 Jan 2023 22:31:49 -0800 (PST) X-Google-Smtp-Source: AMrXdXsDgEFihpS1q8/yw5F3knq/meJ+5WJQH4H/UwBq2sDC3G8YDnP7AVMv/qtdDH79IXOdV5RI X-Received: by 2002:a17:902:e788:b0:194:9e58:13da with SMTP id cp8-20020a170902e78800b001949e5813damr6345133plb.11.1674023509263; Tue, 17 Jan 2023 22:31:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674023509; cv=none; d=google.com; s=arc-20160816; b=YdzSs1J8SkyM7NhtVYHBkgp7cKxg0ANoh9OSBOu94rhOVkGgkt/bDR0ubViak60YqE r1+v9EJnjbxPETeDCk8lP0LLicW6kbMS65f6B3lNB7awtgCVwj1/usQaDk7lRgSBtOkS rXoDW2Uo2EexlRJtYe89Fb7h2pRbCeHYs/Jj6uLeOYt14pLF31DKI/Fn/zF0gV8srbrM jk15DKnLs1DZKNUhem90XDpXk1kqFtJJ0qxfYOUZwAKqg9LWfhQMPMtqj6mn2o8sPbfT xVlNhCEeryPBhcUvXKmDDOv2hMSxxSzw0CPN4iVGx4JggkNPPYWEzbyw6lp4t/TJIlyX jBSw== 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=/LIOovBYmShleYv8Bo+CZamu22fOrs0higkDrpFHkdw=; b=K5EtpEmKnKQiRsrRyj5bBtmfC57OQCuv0s3HorxbLpQwbh8btTr1FjEpY6ekylb4nj PNlK7P89FyN1MuIIcZEGFq9IL261znFZVAqywCD39O4Opz2bIM9VIC4BL/yVSwrMKXd7 aR1i9vfJ8j+fDiMV2/MsCqB6DPaO10WAlp9MkAkpd7TvoDipaeXbEe/L+8X45pcHZ/Ea q4VfnI8/pQZpIRJxNW+mPEPfG4laukEVvc0D7QGtX+6ZCijmS8w7N9hVb8wguGAWQU0G W3DO22zA4qPpyVQubYaZPwMIFvzIdP6HQzadBrjfWxurZgVjksGJQajNSVIvL1Z2lzYL Tpkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=r6deEbyf; 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=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q14-20020a170902f78e00b00189a6834dbesi33499214pln.103.2023.01.17.22.31.34; Tue, 17 Jan 2023 22:31:49 -0800 (PST) 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=@ibm.com header.s=pp1 header.b=r6deEbyf; 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=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229950AbjARGaS (ORCPT + 99 others); Wed, 18 Jan 2023 01:30:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbjARGWX (ORCPT ); Wed, 18 Jan 2023 01:22:23 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65DE24E501; Tue, 17 Jan 2023 22:11:28 -0800 (PST) Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30I3X8PN013916; Wed, 18 Jan 2023 06:11:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=/LIOovBYmShleYv8Bo+CZamu22fOrs0higkDrpFHkdw=; b=r6deEbyffEeIPqqn1RIlfNQY8lGTJI9QcfqGW3f95cZa4IVEB1dafKGEWOjmbIaigwp/ H46+WRjnmwWjNEmUyhDXjE8zcfN3IPuFeVg7Nb6TtSkaPUzXnNE5SH9HQasPJ8JId5QK Sw24Kvctzr2XXItX2fcCdBMKuMq3OBkO9q4R47LGrvgXBuEOmgFCCptMUdkPW3+yqI8R yRgOTrbo3KRADm845Bg/oQABYzS+KkbXAwoOA6O1QqiTXQXBxTB5a/gRoKPtQv7hU/3H g8dw4En9dM88/y7gkfzNTVQGE+L/tqndXpET+Nd84iVMMgChHTmbqanPvP/F/yk+4Pdg 6Q== Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3n68ycaq67-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 Jan 2023 06:11:19 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30I1u6wi012206; Wed, 18 Jan 2023 06:11:17 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma04fra.de.ibm.com (PPS) with ESMTPS id 3n3m16kgv3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 Jan 2023 06:11:17 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 30I6BEaf41943346 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Jan 2023 06:11:15 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BBAD72005A; Wed, 18 Jan 2023 06:11:14 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4137D2004B; Wed, 18 Jan 2023 06:11:14 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 18 Jan 2023 06:11:14 +0000 (GMT) Received: from jarvis-ozlabs-ibm-com.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id AFF08609C3; Wed, 18 Jan 2023 17:11:08 +1100 (AEDT) From: Andrew Donnellan To: linuxppc-dev@lists.ozlabs.org, linux-integrity@vger.kernel.org Cc: gregkh@linuxfoundation.org, gcwilson@linux.ibm.com, linux-kernel@vger.kernel.org, nayna@linux.ibm.com, ruscur@russell.cc, zohar@linux.ibm.com, mpe@ellerman.id.au, gjoyce@linux.ibm.com, sudhakar@linux.ibm.com, bgray@linux.ibm.com, erichte@linux.ibm.com Subject: [PATCH v3 24/24] integrity/powerpc: Support loading keys from pseries secvar Date: Wed, 18 Jan 2023 17:10:49 +1100 Message-Id: <20230118061049.1006141-25-ajd@linux.ibm.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230118061049.1006141-1-ajd@linux.ibm.com> References: <20230118061049.1006141-1-ajd@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: DTpzqE4IM2rQevC0e56YT0J8QZVUR-_Q X-Proofpoint-ORIG-GUID: DTpzqE4IM2rQevC0e56YT0J8QZVUR-_Q X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-18_01,2023-01-17_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 spamscore=0 mlxscore=0 bulkscore=0 phishscore=0 adultscore=0 mlxlogscore=999 priorityscore=1501 clxscore=1015 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301180051 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755340875125777230?= X-GMAIL-MSGID: =?utf-8?q?1755340875125777230?= From: Russell Currey The secvar object format is only in the device tree under powernv. We now have an API call to retrieve it in a generic way, so we should use that instead of having to handle the DT here. Add support for pseries secvar, with the "ibm,plpks-sb-v1" format. The object format is expected to be the same, so there shouldn't be any functional differences between objects retrieved from powernv and pseries. Signed-off-by: Russell Currey Signed-off-by: Andrew Donnellan --- v3: New patch --- .../integrity/platform_certs/load_powerpc.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/security/integrity/platform_certs/load_powerpc.c b/security/integrity/platform_certs/load_powerpc.c index dee51606d5f4..8fa899616d92 100644 --- a/security/integrity/platform_certs/load_powerpc.c +++ b/security/integrity/platform_certs/load_powerpc.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include "keyring_handler.h" @@ -59,16 +58,22 @@ static int __init load_powerpc_certs(void) void *db = NULL, *dbx = NULL; u64 dbsize = 0, dbxsize = 0; int rc = 0; - struct device_node *node; + ssize_t len; + char buf[SECVAR_MAX_FORMAT_LEN]; if (!secvar_ops) return -ENODEV; - /* The following only applies for the edk2-compat backend. */ - node = of_find_compatible_node(NULL, NULL, "ibm,edk2-compat-v1"); - if (!node) + len = secvar_ops->format(buf); + if (len <= 0) return -ENODEV; + // Check for known secure boot implementations from OPAL or PLPKS + if (strcmp("ibm,edk2-compat-v1", buf) && strcmp("ibm,plpks-sb-v1", buf)) { + pr_err("Unsupported secvar implementation \"%s\", not loading certs\n", buf); + return -ENODEV; + } + /* * Get db, and dbx. They might not exist, so it isn't an error if we * can't get them. @@ -103,8 +108,6 @@ static int __init load_powerpc_certs(void) kfree(dbx); } - of_node_put(node); - return rc; } late_initcall(load_powerpc_certs);