Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2358320rdf; Mon, 6 Nov 2023 11:39:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IH0/j8BnGxdin+jQ7CR6J3qn32xJFpjPJKkBhk/442d3YnKNHz1kThlgH3NWBWJZzoXk+Xv X-Received: by 2002:a17:902:f9c4:b0:1cc:4ffb:26f4 with SMTP id kz4-20020a170902f9c400b001cc4ffb26f4mr14387193plb.1.1699299560137; Mon, 06 Nov 2023 11:39:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699299560; cv=none; d=google.com; s=arc-20160816; b=bbzuxE4NTmucXezYVdadbG5bGYOVELFLMz/IeNVDxrf4Cd0vqVrACilcSmmMC8nhFY f9Z4Kmx+qB45CQl4HkzvgPNNr7rJCclBC1XgvYsOXScGFiNfzj/p1pUPPczZrY37udZ8 hc9QZop+vLa6l5ldNzoKHfXae0rLN1FvBxLuaj6V/5wlljFcGpokSfmBu6caEUWcGN6f oQd5CigxSr6BEJSIkRVqh+Ufj3ulfse396VtiaT9f6hG2duDGqe3yx0BRGaPG0REAMME Hx2dHyZzprf4ooZPgJrExDhxJXRjXrOwLeNwHd/aC4damCMFq8dAO+Db4qAUoFT1HVwI rQ6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/7nXQhaGb4pY7ry3e+e6wtXTEqqn1g4LsKBGCFFbdOs=; fh=fToUerD5sH2aDksZUYomz3OetoWMi/k6Q+ZrPUfNDwc=; b=debP5WscB1yo+ff14l3yoMzdonTGvKNlFQiFST2Pq8loPh7uWDl+hRmBIA/sMDzxgu ZVxZNToquUZPVuenHQFQhIPIzalGkBdQu2FUYIhqfUN8yrM9B2kEtbBwH2QFQrDK05M4 jgqpsJ0xd6LgHdhXfOZyV6h6b38nffXM0zmQw/eq8kL85t/eChpOoFARjHMv4Bs4M7WL taGcCjJ/2hi2li0546deTlDH3CGDnY/57f3143O/DyK/ziYZlSTtYI+dYLVbVSh9gh8D vrZ/+jtbmwl659hL2Ko1Ot/fDnwi3gTmtQw0q+Z9rtuKDPjWfRvklYaPqPCozKa8BKP7 gFdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Iw6s+WGz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id p12-20020a170902eacc00b001b9ea0f0e25si8493658pld.607.2023.11.06.11.39.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 11:39:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Iw6s+WGz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id B98948063837; Mon, 6 Nov 2023 11:39:17 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233023AbjKFTjC (ORCPT + 99 others); Mon, 6 Nov 2023 14:39:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233026AbjKFTin (ORCPT ); Mon, 6 Nov 2023 14:38:43 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C628173B for ; Mon, 6 Nov 2023 11:36:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699299403; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/7nXQhaGb4pY7ry3e+e6wtXTEqqn1g4LsKBGCFFbdOs=; b=Iw6s+WGzMosFsG26Bx0pjHGxnDyXRDOcQldFAqxJOTArdf7FYoBybH/gpOSvhSmL9K082+ iGUEVr+nMAtQeJSBMFu0fXVUUpUhIFtmy6x54zzzTZN56xqYvk9OUixuwdCUqkcfs7T68t 0DuWJ5OYmme2hncuJDQa+k/pXrGxZSk= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-671-LaJe6vf1NySAAtVJC5wstA-1; Mon, 06 Nov 2023 14:36:31 -0500 X-MC-Unique: LaJe6vf1NySAAtVJC5wstA-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-77a51a90d6cso531283185a.0 for ; Mon, 06 Nov 2023 11:36:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699299391; x=1699904191; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/7nXQhaGb4pY7ry3e+e6wtXTEqqn1g4LsKBGCFFbdOs=; b=kFLhVfXgqMNoAqjWyiiUC7qT+7PJHmstUvYl3CoF4Hctt8ZH/lh9KrYOA3IfNw/KVp WYptTEq+i/UgaXvxbF/zAgqWy0OeQJzcS5JFt5OeJ7hTJHgWEuA+cBrSi//pU3Rukoy3 iKs7z4RbenpwgOWr3DmKJ2Doxpva5a5k6bWxn0UqIcXX6P9fnd0OkdU3X606Vy+zMyG4 xdyb/lnpjOjwLSLOSpUNTvwA61FiM0UxOEEraPjMuZyAtoAr46L0KjmCcPRQV82kIPHM Igv2F1riHKO3QwBhHxLUlU1fpjFbykE4kXY5xXe4K0r2OD0qfmItdRnrmgiLAneJElOm 1nxA== X-Gm-Message-State: AOJu0YwMKr1Cm52kEYvBHpGRAKciDl1UW06apfxCD1/md/Sewwbni4zh a1GKuVTovSyGndaLIrEW9sfBZdp2vy68LDX2PUjAgontqjaqanJHw4q3qhYW/y9qysp/7TG3a7+ VPRDfGCpOAwitRHKssgreM5GZ X-Received: by 2002:a05:620a:118e:b0:775:f1bd:f75e with SMTP id b14-20020a05620a118e00b00775f1bdf75emr29927580qkk.39.1699299391174; Mon, 06 Nov 2023 11:36:31 -0800 (PST) X-Received: by 2002:a05:620a:118e:b0:775:f1bd:f75e with SMTP id b14-20020a05620a118e00b00775f1bdf75emr29927560qkk.39.1699299390943; Mon, 06 Nov 2023 11:36:30 -0800 (PST) Received: from localhost (ip98-179-76-75.ph.ph.cox.net. [98.179.76.75]) by smtp.gmail.com with ESMTPSA id qs16-20020a05620a395000b00774133fb9a3sm3537442qkn.114.2023.11.06.11.36.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 11:36:30 -0800 (PST) Date: Mon, 6 Nov 2023 12:36:29 -0700 From: Jerry Snitselaar To: Jarkko Sakkinen Cc: linux-integrity@vger.kernel.org, keyrings@vger.kernel.org, James Bottomley , William Roberts , Stefan Berger , David Howells , Jason Gunthorpe , Mimi Zohar , Peter Huewe , James Bottomley , Paul Moore , James Morris , "Serge E. Hallyn" , Julien Gomes , Mario Limonciello , open list , "open list:SECURITY SUBSYSTEM" Subject: Re: [PATCH v3 2/6] tpm: Store TPM buffer length Message-ID: <4gyb46g6makecsv7mq67qdp5hilytpymvdbffz5q64tday5dva@wjg3achi5rrv> References: <20231024011531.442587-1-jarkko@kernel.org> <20231024011531.442587-3-jarkko@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231024011531.442587-3-jarkko@kernel.org> X-Spam-Status: No, score=0.6 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_PASS, 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 lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 06 Nov 2023 11:39:17 -0800 (PST) On Tue, Oct 24, 2023 at 04:15:20AM +0300, Jarkko Sakkinen wrote: > Both TPM commands and sized buffers (TPM2B) have a fixed size header, which > is followed by the body. Store TPM buffer length to a new field in the > struct tpm_buf. > > The invariant here is that the length field must always contain the total > length of the buffer, i.e. the sum header and body length. The value must > then be mapped to the length representation of the buffer type, and this > correspondence must be maintained. > > Signed-off-by: Jarkko Sakkinen > --- > drivers/char/tpm/tpm-buf.c | 36 ++++++++++++++++------- > drivers/char/tpm/tpm-interface.c | 18 +++++++++--- > include/linux/tpm.h | 10 +++---- > security/keys/trusted-keys/trusted_tpm1.c | 8 ++--- > 4 files changed, 49 insertions(+), 23 deletions(-) > > diff --git a/drivers/char/tpm/tpm-buf.c b/drivers/char/tpm/tpm-buf.c > index 88ce1a5402de..8dc6b9db006b 100644 > --- a/drivers/char/tpm/tpm-buf.c > +++ b/drivers/char/tpm/tpm-buf.c > @@ -18,6 +18,12 @@ int tpm_buf_init(struct tpm_buf *buf, u16 tag, u32 ordinal) > } > EXPORT_SYMBOL_GPL(tpm_buf_init); > > +/** > + * tpm_buf_reset() - Initialize a TPM command > + * @buf: A @tpm_buf One minor thing I meant to mention, did you intend this to be &tpm_buf like it is for tpm_buf_append? Regards, Jerry