Message ID | 20230210080401.345462-6-ajd@linux.ibm.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp820920wrn; Fri, 10 Feb 2023 00:06:48 -0800 (PST) X-Google-Smtp-Source: AK7set+uf/aKJlYDNdaZpwt+geefMm3Bbwkvj3g1GcJxBknj8ljTNBgFnrK1/c5vDPlQC5YpfCpB X-Received: by 2002:a17:907:8b94:b0:87b:d402:95ac with SMTP id tb20-20020a1709078b9400b0087bd40295acmr11488733ejc.27.1676016408130; Fri, 10 Feb 2023 00:06:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676016408; cv=none; d=google.com; s=arc-20160816; b=lN9YOvU3ejmrZMb/4h8hvsDyKmS8mwFdzIjP81rpDMRSPuMXWL0/rlx9z3sVX6ZBw5 MoaPdnLXTYuUo2vLbA3EzmkqYsqvOs1l3TBWTZZ0K3+NVqNqYX+FvdHZ6yu5eMNoJq71 0bz8nBzeQMQQJhEw2MkI2F6qCRIvIO4sUckBE3+k3LEhyoB0Lm9fCLK3zlFslAno4JlJ CjiTDqTGZ0ex7xVcsIwrzYihQm+7ldUlpBw0ggyaPzVkzg8M7ra2DxvSSVIpbRIIfpxk VeKQbJvnKBm2BSEm/lEQ6zx2Fb/0uaKSlcE5bHGG16W71nBoPmn4kL0nKVhuj2OmOI/4 TNQQ== 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=ztcs7hjvlb+xQDMWzJNeJQfiFEBDyVtgrMDBAAXoIfo=; b=APELopStFWpso4ChrozydE31l78kXyEzMyNmExTfageN1pa8hYrc+TRb90QuCSuzO0 BKUxndUL6ghPESVR8gcqxyaEvt/4dQ/wUsIRI/8q0B3rT5zTxrKApQlguLQnv2T1Olys utGKGKDBPv8PCuUED+Bztz4ORXb4Sc2v3msuKtBpBQaE+zE7mswuYv8BLBLqajCNpNVg c6uVW8CC94u4Swf5r7bkhwISBTG6W8SPsJPG4EkmzbA0A2aPEZDqvhbqUx4dy2vN23Pb FX6vb00/C/Hyt8R8oZVAd2o6/Ws8ZDTK0u+f6ad0QK2+yQtK/307XD3747JiJXiClbkI NhHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=AL0tast1; 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 w6-20020aa7dcc6000000b004aab20ef6desi4622703edu.502.2023.02.10.00.06.25; Fri, 10 Feb 2023 00:06:48 -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=AL0tast1; 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 S231531AbjBJIE7 (ORCPT <rfc822;ybw1215001957@gmail.com> + 99 others); Fri, 10 Feb 2023 03:04:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231539AbjBJIEo (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 10 Feb 2023 03:04:44 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B29180752; Fri, 10 Feb 2023 00:04:35 -0800 (PST) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31A7sd3O025516; Fri, 10 Feb 2023 08:04:27 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=ztcs7hjvlb+xQDMWzJNeJQfiFEBDyVtgrMDBAAXoIfo=; b=AL0tast18NAWUUO18Zx8e4tQFExppwe0CRFhocu7IBO5uOFWsZzPKKTH3WFV3fNaZ9UW /1EEbdw9BVXuRIiz104m3hLwwg4/ZEROCJiVYh3VUEW4xBfstpUBLTJMYXWzfbjmqWLY Y+quik/FjNRFktsJtSwdgJLG77u6XJkea+6bTr5NiJeMXb41RLjuC/LsWV/So8i4Rcto Qevmn08inSB5NsMYBx2x+HEntrY9/HMf6h5yHiq/hPoPGFZVEDLL38iD4JvSelN4unpO RYcqaa+kyubLgOty7XyRxv2pRTY5xQ+1666issT6jmwIfaynMGPJ2r2BYtCPbmOXGOE0 ZQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nnhxxg9c7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Feb 2023 08:04:26 +0000 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 31A7snsp025911; Fri, 10 Feb 2023 08:04:26 GMT Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nnhxxg9ad-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Feb 2023 08:04:26 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 319IQcNG004425; Fri, 10 Feb 2023 08:04:23 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma03fra.de.ibm.com (PPS) with ESMTPS id 3nhf06n3ur-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Feb 2023 08:04:23 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 31A84KQk24183382 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Feb 2023 08:04:20 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ABF4A20040; Fri, 10 Feb 2023 08:04:20 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2714C2004B; Fri, 10 Feb 2023 08:04:20 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 10 Feb 2023 08:04:20 +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 C9BF5606E6; Fri, 10 Feb 2023 19:04:14 +1100 (AEDT) From: Andrew Donnellan <ajd@linux.ibm.com> To: linuxppc-dev@lists.ozlabs.org, linux-integrity@vger.kernel.org Cc: ruscur@russell.cc, bgray@linux.ibm.com, nayna@linux.ibm.com, gcwilson@linux.ibm.com, gjoyce@linux.ibm.com, brking@linux.ibm.com, stefanb@linux.ibm.com, sudhakar@linux.ibm.com, erichte@linux.ibm.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, zohar@linux.ibm.com, joel@jms.id.au, npiggin@gmail.com Subject: [PATCH v6 05/26] powerpc/secvar: Warn and error if multiple secvar ops are set Date: Fri, 10 Feb 2023 19:03:40 +1100 Message-Id: <20230210080401.345462-6-ajd@linux.ibm.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210080401.345462-1-ajd@linux.ibm.com> References: <20230210080401.345462-1-ajd@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: Ir0nQ3hgifueK7CNeCr0v7sQ_Lq7286S X-Proofpoint-GUID: F7gaYkEvg46cbt5VqEtueV0oBtfqxC2_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-10_03,2023-02-09_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 spamscore=0 suspectscore=0 clxscore=1015 mlxscore=0 bulkscore=0 impostorscore=0 mlxlogscore=999 phishscore=0 adultscore=0 malwarescore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302100070 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757430581187451715?= X-GMAIL-MSGID: =?utf-8?q?1757430581187451715?= |
Series |
pSeries dynamic secure boot secvar interface + platform keyring loading
|
|
Commit Message
Andrew Donnellan
Feb. 10, 2023, 8:03 a.m. UTC
From: Russell Currey <ruscur@russell.cc> The secvar code only supports one consumer at a time. Multiple consumers aren't possible at this point in time, but we'd want it to be obvious if it ever could happen. Signed-off-by: Russell Currey <ruscur@russell.cc> Co-developed-by: Andrew Donnellan <ajd@linux.ibm.com> Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com> --- v4: Return an error and don't actually try to set secvar_operations if the warning is triggered (npiggin) v5: Drop "extern" to fix a checkpatch check (snowpatch) v6: Return -EBUSY rather than -1 (stefanb) --- arch/powerpc/include/asm/secvar.h | 4 ++-- arch/powerpc/kernel/secvar-ops.c | 10 ++++++++-- arch/powerpc/platforms/powernv/opal-secvar.c | 4 +--- 3 files changed, 11 insertions(+), 7 deletions(-)
Comments
On 2/10/23 03:03, Andrew Donnellan wrote: > From: Russell Currey <ruscur@russell.cc> > > The secvar code only supports one consumer at a time. > > Multiple consumers aren't possible at this point in time, but we'd want > it to be obvious if it ever could happen. > > Signed-off-by: Russell Currey <ruscur@russell.cc> > Co-developed-by: Andrew Donnellan <ajd@linux.ibm.com> > Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com> > > --- > > v4: Return an error and don't actually try to set secvar_operations if the > warning is triggered (npiggin) > > v5: Drop "extern" to fix a checkpatch check (snowpatch) > > v6: Return -EBUSY rather than -1 (stefanb) > --- > arch/powerpc/include/asm/secvar.h | 4 ++-- > arch/powerpc/kernel/secvar-ops.c | 10 ++++++++-- > arch/powerpc/platforms/powernv/opal-secvar.c | 4 +--- > 3 files changed, 11 insertions(+), 7 deletions(-) > > diff --git a/arch/powerpc/include/asm/secvar.h b/arch/powerpc/include/asm/secvar.h > index 07ba36f868a7..a2b5f2203dc5 100644 > --- a/arch/powerpc/include/asm/secvar.h > +++ b/arch/powerpc/include/asm/secvar.h > @@ -21,11 +21,11 @@ struct secvar_operations { > > #ifdef CONFIG_PPC_SECURE_BOOT > > -extern void set_secvar_ops(const struct secvar_operations *ops); > +int set_secvar_ops(const struct secvar_operations *ops); > > #else > > -static inline void set_secvar_ops(const struct secvar_operations *ops) { } > +static inline int set_secvar_ops(const struct secvar_operations *ops) { return 0; } > > #endif > > diff --git a/arch/powerpc/kernel/secvar-ops.c b/arch/powerpc/kernel/secvar-ops.c > index 6a29777d6a2d..19172a2804f0 100644 > --- a/arch/powerpc/kernel/secvar-ops.c > +++ b/arch/powerpc/kernel/secvar-ops.c > @@ -8,10 +8,16 @@ > > #include <linux/cache.h> > #include <asm/secvar.h> > +#include <asm/bug.h> > > -const struct secvar_operations *secvar_ops __ro_after_init; > +const struct secvar_operations *secvar_ops __ro_after_init = NULL; > > -void set_secvar_ops(const struct secvar_operations *ops) > +int set_secvar_ops(const struct secvar_operations *ops) > { > + if (WARN_ON_ONCE(secvar_ops)) > + return -EBUSY; > + > secvar_ops = ops; > + > + return 0; > } > diff --git a/arch/powerpc/platforms/powernv/opal-secvar.c b/arch/powerpc/platforms/powernv/opal-secvar.c > index ef89861569e0..4c0a3b030fe0 100644 > --- a/arch/powerpc/platforms/powernv/opal-secvar.c > +++ b/arch/powerpc/platforms/powernv/opal-secvar.c > @@ -113,9 +113,7 @@ static int opal_secvar_probe(struct platform_device *pdev) > return -ENODEV; > } > > - set_secvar_ops(&opal_secvar_ops); > - > - return 0; > + return set_secvar_ops(&opal_secvar_ops); > } > > static const struct of_device_id opal_secvar_match[] = { Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
diff --git a/arch/powerpc/include/asm/secvar.h b/arch/powerpc/include/asm/secvar.h index 07ba36f868a7..a2b5f2203dc5 100644 --- a/arch/powerpc/include/asm/secvar.h +++ b/arch/powerpc/include/asm/secvar.h @@ -21,11 +21,11 @@ struct secvar_operations { #ifdef CONFIG_PPC_SECURE_BOOT -extern void set_secvar_ops(const struct secvar_operations *ops); +int set_secvar_ops(const struct secvar_operations *ops); #else -static inline void set_secvar_ops(const struct secvar_operations *ops) { } +static inline int set_secvar_ops(const struct secvar_operations *ops) { return 0; } #endif diff --git a/arch/powerpc/kernel/secvar-ops.c b/arch/powerpc/kernel/secvar-ops.c index 6a29777d6a2d..19172a2804f0 100644 --- a/arch/powerpc/kernel/secvar-ops.c +++ b/arch/powerpc/kernel/secvar-ops.c @@ -8,10 +8,16 @@ #include <linux/cache.h> #include <asm/secvar.h> +#include <asm/bug.h> -const struct secvar_operations *secvar_ops __ro_after_init; +const struct secvar_operations *secvar_ops __ro_after_init = NULL; -void set_secvar_ops(const struct secvar_operations *ops) +int set_secvar_ops(const struct secvar_operations *ops) { + if (WARN_ON_ONCE(secvar_ops)) + return -EBUSY; + secvar_ops = ops; + + return 0; } diff --git a/arch/powerpc/platforms/powernv/opal-secvar.c b/arch/powerpc/platforms/powernv/opal-secvar.c index ef89861569e0..4c0a3b030fe0 100644 --- a/arch/powerpc/platforms/powernv/opal-secvar.c +++ b/arch/powerpc/platforms/powernv/opal-secvar.c @@ -113,9 +113,7 @@ static int opal_secvar_probe(struct platform_device *pdev) return -ENODEV; } - set_secvar_ops(&opal_secvar_ops); - - return 0; + return set_secvar_ops(&opal_secvar_ops); } static const struct of_device_id opal_secvar_match[] = {