Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp10129645rwr; Fri, 12 May 2023 04:22:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5OgryPRrWAA6Zd6Tc0KRUrxonqo59V9zHOHRRA2KHOh8NGWwow30iIQF25ksDjnqF9c+2F X-Received: by 2002:a05:6a21:6d9f:b0:100:b8fc:8c6c with SMTP id wl31-20020a056a216d9f00b00100b8fc8c6cmr20514746pzb.19.1683890527890; Fri, 12 May 2023 04:22:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683890527; cv=none; d=google.com; s=arc-20160816; b=RoYiEOYJwF18yP+QR2AgFNe0GSyRMxZbagJxUYxxkEhorU2qhCaRp0vBymTPQWcOsf BkyZ9O4BaNnIp5faaPJltZB+rN6H38Tls1Yc34l8chYqCuej7bsAcA4qrab64eYtAIRg AJ41wr9GnKUR6MVnrKR+GZt9gpnnjAgKqYQMoG0Wu+9EIt7nYkgg1ETnPy+GRf3Ssy4l Br6qmkxWtq29P6HP+kEkgPRibcWHUV74zHTnMs4BO0ENlDXhy84FpVjIi6ezeYVulloM 4UUovD2SAOmjXh9hMAnhgKN1sygzM200pWlbf03fPgbTt9LpSlO2BsjDJQbtGdqCQsX0 U1oA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=NX9VYeUm+ZQ0wUABlnhHacsq0t/TqdQbwYHXHwlmN8s=; b=ohvFdI0PbZM68037kmi1BbyJo7o8F2696VJ4KRed4y78mmYAEz1kZ7DaWUnxN+2+iZ 4XovrCyEWRbzRO1xEAtyFpAuMHIc9vjXdkr5gSU9ljMbMJ1s9u5EEF3k6Sv/hRA1asUw 91QE6eQczlHVGsW3qW8m5vXd7qjhU6cWY5XzAFNn78Lcd1o4qGGLkftd0NB1FWt25fgB KOqkPbyG6cu2v4joug08UkH7v/PGHVIykauzxyuaS59J+fE4azQwmvRTdUCVLLSK2aWI 0yG130dUFlfryf5QiKYHUdou3zPV/mcxYcS3U4Da0SI1dpRPwnBgjRYF9Qzi0qz3zR5X T4fw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e191-20020a6369c8000000b00530743695d1si2818065pgc.665.2023.05.12.04.21.51; Fri, 12 May 2023 04:22:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240994AbjELLJ4 (ORCPT + 99 others); Fri, 12 May 2023 07:09:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241040AbjELLJu (ORCPT ); Fri, 12 May 2023 07:09:50 -0400 Received: from cavan.codon.org.uk (irc.codon.org.uk [IPv6:2a00:1098:84:22e::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E817E4C1F; Fri, 12 May 2023 04:09:49 -0700 (PDT) Received: by cavan.codon.org.uk (Postfix, from userid 1000) id C03E142529; Fri, 12 May 2023 12:00:03 +0100 (BST) Date: Fri, 12 May 2023 12:00:03 +0100 From: Matthew Garrett To: Ross Philipson Cc: linux-kernel@vger.kernel.org, x86@kernel.org, linux-integrity@vger.kernel.org, linux-doc@vger.kernel.org, linux-crypto@vger.kernel.org, iommu@lists.linux-foundation.org, kexec@lists.infradead.org, linux-efi@vger.kernel.org, dpsmith@apertussolutions.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, ardb@kernel.org, James.Bottomley@hansenpartnership.com, luto@amacapital.net, nivedita@alum.mit.edu, kanth.ghatraju@oracle.com, trenchboot-devel@googlegroups.com Subject: Re: [PATCH v6 05/14] x86: Secure Launch main header file Message-ID: <20230512110003.GC14461@srcf.ucam.org> References: <20230504145023.835096-1-ross.philipson@oracle.com> <20230504145023.835096-6-ross.philipson@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230504145023.835096-6-ross.philipson@oracle.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,KHOP_HELO_FCRDNS,SPF_HELO_NEUTRAL, SPF_NEUTRAL,T_SCC_BODY_TEXT_LINE autolearn=no 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 On Thu, May 04, 2023 at 02:50:14PM +0000, Ross Philipson wrote: > +static inline int tpm12_log_event(void *evtlog_base, u32 evtlog_size, > + u32 event_size, void *event) > +{ > + struct tpm12_event_log_header *evtlog = > + (struct tpm12_event_log_header *)evtlog_base; > + > + if (memcmp(evtlog->signature, TPM12_EVTLOG_SIGNATURE, > + sizeof(TPM12_EVTLOG_SIGNATURE))) > + return -EINVAL; > + > + if (evtlog->container_size > evtlog_size) > + return -EINVAL; > + > + if (evtlog->next_event_offset + event_size > evtlog->container_size) > + return -E2BIG; > + > + memcpy(evtlog_base + evtlog->next_event_offset, event, event_size); > + evtlog->next_event_offset += event_size; > + > + return 0; > +} > + > +static inline int tpm20_log_event(struct txt_heap_event_log_pointer2_1_element *elem, > + void *evtlog_base, u32 evtlog_size, > + u32 event_size, void *event) > +{ > + struct tcg_pcr_event *header = > + (struct tcg_pcr_event *)evtlog_base; > + > + /* Has to be at least big enough for the signature */ > + if (header->event_size < sizeof(TCG_SPECID_SIG)) > + return -EINVAL; > + > + if (memcmp((u8 *)header + sizeof(struct tcg_pcr_event), > + TCG_SPECID_SIG, sizeof(TCG_SPECID_SIG))) > + return -EINVAL; > + > + if (elem->allocated_event_container_size > evtlog_size) > + return -EINVAL; > + > + if (elem->next_record_offset + event_size > > + elem->allocated_event_container_size) > + return -E2BIG; > + > + memcpy(evtlog_base + elem->next_record_offset, event, event_size); > + elem->next_record_offset += event_size; > + > + return 0; > +} > + These seem like they'd potentially be useful outside the context of SL, maybe put them in a more generic location? Very much a nice to have, not a blocker from my side. > +/* > + * External functions avalailable in mainline kernel. Nit: "available"