Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp1611460ybj; Fri, 20 Sep 2019 13:22:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqy7rgqktRAcGa/rEI9W+adP0Q0wGGdtCwtKRUZBu+HQDlthvxJpBbZUCt++4l9rJVpic6yA X-Received: by 2002:a17:906:8287:: with SMTP id h7mr13521832ejx.61.1569010969452; Fri, 20 Sep 2019 13:22:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569010969; cv=none; d=google.com; s=arc-20160816; b=ywTThtq/ydWdxXCf8+KHBlsK+sEpzGXuYBc6uBGsToGPsjQX+0YHuZegsAzeDNTH9L 1wrVwdTzb9qZom3NtIOLDPl57L7JMhBHLah20cEb3SjMV+PdhknKCZAbIUjuMV452n1z 9VsqseE17V7FXCLdNCJMPtZS6u6I4C4guA2jlUg/4VpXphGZ6KGVdTpv5E1Pom46Z3Yg 4D9VT7ilzKodENmcrREBCjyQbfZ03K9IBe/GXGCd3MSvADP5ZtFx1jOdfjJ9IGwY1aIJ rAErQ023Qjs2nNclvFCDXlWYZzKrkD9xrICBXt9tEuWYGMF1RSXMLZqhnBYmm9+bCKf5 kZhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=333MYFZ0csT4CZEc5nFLhNNJSI6PjPmfux0TVN7Cvxg=; b=vGjnU4t0ymi2zA75bKsW+jt0ZkZ1mObCPaaXeYYNw46GZNr7fyXX2kM6Zc8twD8B2c 6XrDn/s8vEvmjcKe8CmW9SYXv9RXE1g8Wp2WMmk9aQm119WMBD5tgiLCBv6FO30ZsDR0 fN3l5eleoT9WsdlG8kfF37vdjYekBElTbYaxYdUd+LOvy33QJV1EXNXVamHITVkmstla Z3T3j8cmrU67mSCwP7wl+FAY25+Sw0XtxLPTTGViHTDUUI42xmVnklpYeKEbaIimgR2r 8jzlI/kSJY3XSNA8urBURWgrIXbd7kLn9o/Pi/zSWJJ/N3OizmM/YRkgexz61ohmK/Ac 8nQg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c54si2157933edb.230.2019.09.20.13.22.24; Fri, 20 Sep 2019 13:22:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387781AbfITOSa (ORCPT + 99 others); Fri, 20 Sep 2019 10:18:30 -0400 Received: from mga09.intel.com ([134.134.136.24]:35096 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387773AbfITOSa (ORCPT ); Fri, 20 Sep 2019 10:18:30 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Sep 2019 07:18:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,528,1559545200"; d="scan'208";a="194706214" Received: from eergin-mobl.ger.corp.intel.com (HELO localhost) ([10.252.40.12]) by FMSMGA003.fm.intel.com with ESMTP; 20 Sep 2019 07:18:27 -0700 Date: Fri, 20 Sep 2019 17:18:26 +0300 From: Jarkko Sakkinen To: James Bottomley Cc: linux-integrity@vger.kernel.org, linux-crypto@vger.kernel.org, linux-security-module@vger.kernel.org Subject: Re: [PATCH v6 02/12] tpm-buf: add handling for TPM2B types Message-ID: <20190920141826.GC9578@linux.intel.com> References: <1568031408.6613.29.camel@HansenPartnership.com> <1568031515.6613.31.camel@HansenPartnership.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1568031515.6613.31.camel@HansenPartnership.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Mon, Sep 09, 2019 at 01:18:35PM +0100, James Bottomley wrote: > Most complex TPM commands require appending TPM2B buffers to the > command body. Since TPM2B types are essentially variable size arrays, > it makes it impossible to represent these complex command arguments as > structures and we simply have to build them up using append primitives > like these. > > Signed-off-by: James Bottomley I think a better idea would be to have headerless TPM buffers and also it makes sense to have a separate length field in the struct to keep the code sane given that sometimes the buffer does not store the length. E.g. enum tpm_buf_flags { TPM_BUF_OVERFLOW = BIT(0), TPM_BUF_HEADERLESS = BIT(1), }; struct tpm_buf { unsigned int length; struct page *data_page; unsigned int flags; u8 *data; }; /Jarkko