Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2021780rdb; Tue, 3 Oct 2023 08:05:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF+GVcCJDNpkW7RQ55+PmWuBqeO17j39zFbXh2J2HNaVo6SPRmnGCXGWdaqHvPBzWl7cPag X-Received: by 2002:a17:902:c412:b0:1be:f37f:a8d5 with SMTP id k18-20020a170902c41200b001bef37fa8d5mr4971164plk.10.1696345522167; Tue, 03 Oct 2023 08:05:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696345522; cv=none; d=google.com; s=arc-20160816; b=jBXDyCDqagAPFjbBda6GyJydzjTT244SCCpbPlK5/ueTZ9bxa4HooMcu1S/MHYR3Xw H/EvXQjddT4X6Kmq1ycIewkUqB1brHiEdVakgi+58D05HvUZZbhB0CXZ+oEsUznOxPsd 4R9To5j7EaJXqhD4sJDWLMFMugVRMqkkfCFIAd5VfFbsR8TLwcAIm6GuLP5omgV1Zn5j Y8nY3+l5yFwpIAAQazjbt0AvwOPmo/MXrStnQ6t/w+R+kVbCVoGYHLP5ndhpn2XG5rzx r4m/dFGyGy4Ndel5T0jFUbcD1DpTeLGYYC8bs1hqxky/X/AnBNhAMKQ8xgwa2ecvY6FA yIwA== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=lhjC6SKFJXcRkzep76AdYPpzm9EJD8oOnf6hU0/9Emo=; fh=VytaWnrtIe6rQzSTidyaXKVP21CYVB05Erb1vcNmZ/4=; b=g0zEmM9ZJWb+ufofYpGkRL2M//Jpvs4LCaodhlamoDrCdQWgEcCcW/tZh+08M4LRKr T5aXd85ZkkDvSyTDiu+CdELtlffSHi1yiNWmI7kQXvGcEiCbQ/4fg5Vtfacd8ngxygYQ XB8ISHIloUnLRmD0DFPD63SwrXWAU8zHPMwDQlRdbkWnZQmDJ3TYHWZjH0H8s9dSEDcD MKt+wyedV37/Nyu4sSA3wG4Yupat/YQ2UEyQzX5TLSW7ePnw9ty6NQVju5nh3CvE5cGw 58ORIP43mzo96aLu7tE50vrK799D8jxXuqNjpdT3f7LzISjThSv/p/kl2tjVt+YEUqd+ iWYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id h9-20020a170902f54900b001bc8a9f5e52si1709487plf.135.2023.10.03.08.05.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 08:05:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 09A2A82B2E98; Tue, 3 Oct 2023 08:05:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231417AbjJCPFF (ORCPT + 99 others); Tue, 3 Oct 2023 11:05:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230270AbjJCPFE (ORCPT ); Tue, 3 Oct 2023 11:05:04 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15A15A7; Tue, 3 Oct 2023 08:05:01 -0700 (PDT) Received: from lhrpeml500005.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4S0Ldj6N6Bz6HJcm; Tue, 3 Oct 2023 23:02:17 +0800 (CST) Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Tue, 3 Oct 2023 16:04:56 +0100 Date: Tue, 3 Oct 2023 16:04:55 +0100 From: Jonathan Cameron To: Lukas Wunner CC: Bjorn Helgaas , David Howells , David Woodhouse , Herbert Xu , "David S. Miller" , Alex Williamson , , , , , , , , David Box , Dan Williams , Dave Jiang , "Li, Ming" , Zhi Wang , Alistair Francis , Wilfred Mallawa , Alexey Kardashevskiy , Tom Lendacky , Sean Christopherson , Alexander Graf Subject: Re: [PATCH 09/12] PCI/CMA: Validate Subject Alternative Name in certificates Message-ID: <20231003160455.00001a4f@Huawei.com> In-Reply-To: References: Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.227.76] X-ClientProxiedBy: lhrpeml100001.china.huawei.com (7.191.160.183) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, 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-crypto@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 08:05:05 -0700 (PDT) On Thu, 28 Sep 2023 19:32:39 +0200 Lukas Wunner wrote: > PCIe r6.1 sec 6.31.3 stipulates requirements for X.509 Leaf Certificates > presented by devices, in particular the presence of a Subject Alternative > Name extension with a name that encodes the Vendor ID, Device ID, Device > Serial Number, etc. Lets you do any of * What you have here * Reference Integrity Manifest, e.g. see Trusted Computing Group * A pointer to a location where such a Reference Integrity Manifest can be obtained. So this text feels a little strong though I'm fine with only support the Subject Alternative Name bit for now. Whoever has one of the other options can add that support :) > > This prevents a mismatch between the device identity in Config Space and > the certificate. A device cannot misappropriate a certificate from a > different device without also spoofing Config Space. As a corollary, > it cannot dupe an arbitrary driver into binding to it. (Only those > which bind to the device identity in the Subject Alternative Name work.) > > Parse the Subject Alternative Name using a small ASN.1 module and > validate its contents. The theory of operation is explained in a code > comment at the top of the newly added cma-x509.c. > > This functionality is introduced in a separate commit on top of basic > CMA-SPDM support to split the code into digestible, reviewable chunks. > > The CMA OID added here is taken from the official OID Repository > (it's not documented in the PCIe Base Spec): > https://oid-rep.orange-labs.fr/get/2.23.147 > > Signed-off-by: Lukas Wunner I haven't looked asn.1 recently enough to have any confidence on a review of that bit... So, for everything except the asn.1 Reviewed-by: Jonathan Cameron