Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1271613ybp; Fri, 4 Oct 2019 12:03:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqzlL2vlTceuWUiE0RTxjAB7lOxCWZvaAKEozEfLpUgcVa9FKK1N+EVDvtJDsMaNhQWGAd1q X-Received: by 2002:a05:6402:7c1:: with SMTP id u1mr17035594edy.198.1570215828463; Fri, 04 Oct 2019 12:03:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570215828; cv=none; d=google.com; s=arc-20160816; b=IEEN8t5ucTrRBOS0u5jVEMpJwkXIIppTHJI/AkxsHwjoShYarlKmNWQSkFvFyUAtoL oGiwW+PvnhECzWysI9320RBaKWF4HiwesgvaPBkh/TBESGkPssiZt1h2KAcqj+47lRZf mqM9bYNFxGyXvxiSxFIgIWb9+bXFPQT7eaTRqoZDVh2feKCM0qY14DqX4XQL0AF6nxwk s5Da1Hc7FPeZDZ3akebqYi8gZ8BZ8r8ZrvLnTS3FH+ldWV9f2xt1VqrcIu9r5HJQsvPU CBMe4XeV6P1S0cl/P8D9P/SfTMZ7Rbl9gqlwj5UynGu6bylFkLHADswY2qAEetwMuRxk 6MkQ== 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=6h/FVqXRsIjP7CfA+J/QGWRinx1+Ffd/Zr9elYoMQl0=; b=x4X7z/7B9GlViLYClbNhMro/nNC7HurT+GqayW9iZ/Krmq4uO7jb1UUfgx6p2QPS4f a1/4+A9YwUw2+98YcF75MecTMl3Up3vgDSQjbaHb36NwGfR6Z95D2g69h/bBWbWGwUZk K9JFYeJrC0VLItNSbZ43/Jb8SXqUpe7jlRQ0OTHDQ7ENAk+CRIOeQ14CDonOsrB4mwpe G3hBg/+tc/jSQ69TxWtCMXMTKibgVyj9eqkETbRlw89qglaaQDN5iQX94CaKuH3+a8lT OB8rNRMmKYe9wqJnatP6P2AYaNUuo02GdXMXco/fKYI2vmksA9DJQp4sSzcy81Nbtrzy +nSw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 e43si4055199eda.296.2019.10.04.12.03.24; Fri, 04 Oct 2019 12:03:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1728762AbfJDTBL (ORCPT + 99 others); Fri, 4 Oct 2019 15:01:11 -0400 Received: from mga02.intel.com ([134.134.136.20]:60581 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725932AbfJDTBK (ORCPT ); Fri, 4 Oct 2019 15:01:10 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Oct 2019 12:01:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,257,1566889200"; d="scan'208";a="191673088" Received: from nzaki1-mobl1.ger.corp.intel.com (HELO localhost) ([10.252.4.57]) by fmsmga008.fm.intel.com with ESMTP; 04 Oct 2019 12:01:05 -0700 Date: Fri, 4 Oct 2019 22:01:04 +0300 From: Jarkko Sakkinen To: James Bottomley Cc: linux-integrity@vger.kernel.org, Mimi Zohar , Jerry Snitselaar , Sumit Garg , Stefan Berger , Peter Huewe , Jason Gunthorpe , Arnd Bergmann , Greg Kroah-Hartman , open list Subject: Re: [PATCH v3 2/2] tpm: Detach page allocation from tpm_buf Message-ID: <20191004190104.GK6945@linux.intel.com> References: <20191003185103.26347-1-jarkko.sakkinen@linux.intel.com> <20191003185103.26347-3-jarkko.sakkinen@linux.intel.com> <1570207062.3563.17.camel@HansenPartnership.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1570207062.3563.17.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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 04, 2019 at 09:37:42AM -0700, James Bottomley wrote: > On Thu, 2019-10-03 at 21:51 +0300, Jarkko Sakkinen wrote: > > As has been seen recently, binding the buffer allocation and tpm_buf > > together is sometimes far from optimal. > > Can you elaborate on this a bit more? I must have missed the > discussion. > > > The buffer might come from the caller namely when tpm_send() is used > > by another subsystem. In addition we can stability in call sites w/o > > rollback (e.g. power events)> > > > > Take allocation out of the tpm_buf framework and make it purely a > > wrapper for the data buffer. > > What you're doing here is taking a single object with a single lifetime > and creating two separate objects with separate lifetimes and a > dependency. The problem with doing that is that it always creates > subtle and hard to debug corner cases where the dependency gets > violated, so it's usually better to simplify the object lifetimes by > reducing the dependencies and combining as many dependent objects as > possible into a single object with one lifetime. Bucking this trend > for a good reason is OK, but I think a better reason than "is sometimes > far from optimal" is needed. Right, I see your point. We can just say instead in a comment that tpm_buf_init() is optional if you need to allocate the buffer and do not provide your own. Thanks for the remark. I have to agree with this. /Jarkko