From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964847AbdBQWhP (ORCPT ); Fri, 17 Feb 2017 17:37:15 -0500 Received: from wind.enjellic.com ([76.10.64.91]:44322 "EHLO wind.enjellic.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935007AbdBQWhN (ORCPT ); Fri, 17 Feb 2017 17:37:13 -0500 Date: Fri, 17 Feb 2017 16:37:01 -0600 From: "Dr. Greg Wettstein" To: Jarkko Sakkinen Cc: "Dr. Greg Wettstein" , Ken Goldman , linux-kernel@vger.kernel.org, tpmdd-devel@lists.sourceforge.net Subject: Re: [tpmdd-devel] [RFC] tpm2-space: add handling for global session exhaustion Message-ID: <20170217223701.GA31840@wind.enjellic.com> Reply-To: "Dr. Greg Wettstein" References: <201702101003.v1AA3plF029882@wind.enjellic.com> <1486745163.2502.26.camel@HansenPartnership.com> <20170214143829.GA28175@wind.enjellic.com> <71dc0e80-6678-a124-9184-1f93c8532d09@linux.vnet.ibm.com> <20170216200642.GA20942@wind.enjellic.com> <20170216203304.wrbpfd4mrmyh6vct@intel.com> <20170217095626.GA26064@wind.enjellic.com> <20170217123712.n7gcj62bob35i7ll@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170217123712.n7gcj62bob35i7ll@intel.com> User-Agent: Mutt/1.4i X-Operating-System: uname -s -r X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.2.3 (wind.enjellic.com [0.0.0.0]); Fri, 17 Feb 2017 16:37:01 -0600 (CST) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 17, 2017 at 02:37:12PM +0200, Jarkko Sakkinen wrote: Hi, I hope the week is ending well for everyone. > On Fri, Feb 17, 2017 at 03:56:26AM -0600, Dr. Greg Wettstein wrote: > > On Thu, Feb 16, 2017 at 10:33:04PM +0200, Jarkko Sakkinen wrote: > > > > Good morning to everyone. > > > > > On Thu, Feb 16, 2017 at 02:06:42PM -0600, Dr. Greg Wettstein wrote: > > > > Just as an aside, has anyone given any thought about TPM2 resource > > > > management in things like TXT/tboot environments? The current tboot > > > > code makes a rather naive assumption that it can take a handle slot to > > > > protect its platform verification secret. Doing resource management > > > > correctly will require addressing extra-OS environments such as this > > > > which may have TPM2 state requirement issues. > > > > > The current implementation handles stuff created from regular > > > /dev/tpm0 so I do not think this would be an issue. You can only > > > access objects from a TPM space that are created within that space. > > > > Unless I misunderstand the number of transient objects which can be > > managed is a characteristic of the hardware and is a limited resource, > > hence our discussion on the notion of a resource manager to shuttle > > context in and out of these limited slots. > > > > On a Kabylake system, running the following command: > > > > getcapability -cap 6 | grep trans > > > > After booting into a TXT mediated measured launch environment (MLE) yields > > the following: > > > > TPM_PT 0000010e value 00000003 TPM_PT_HR_TRANSIENT_MIN - the minimum number of transient objects that can be held in TPM RAM > > > > TPM_PT 00000207 value 00000002 TPM_PT_HR_TRANSIENT_AVAIL - estimate of the number of additional transient objects that could be loaded into TPM RAM > > > > Booting without TXT results in the getcapability call indicating that > > three slots are available. Based on that and reading the tboot code, > > we are assuming the occupied slot is the ephemeral primary key > > generated by tboot which seals the verification secret. > > > > In an MLE it is possible to create and then flush a new ephemeral > > primary key which results in the following getcapability output: > > > > TPM_PT 00000207 value 00000003 TPM_PT_HR_TRANSIENT_AVAIL - estimate of > > the number of additional transient objects that could be loaded into TPM RAM > > > > Which is probably going to be pretty surprising to tboot in the event > > that it tries to re-verify the system state after a suspend event. > > > > So based on that it would seem there would need to be some semblance > > of cooperation between the resource manager and an extra-OS > > utilization of TPM2 resources such as tboot. > > > > Thoughts? > The driver swaps in and out all the objects for one send-receive > cycle. So unless the driver is sending a command to a TPM the > resource manager occupies zero slots. I do not see reason for > forseeable future to change this pattern. > > I discussed about some "lazier" schemes for swapping with James an > Ken in the early Fall but came into conclusion that it would make > the RM really complicated. There would have to be something show > stopper work load to even to start consider it. > > With the capacity of current TPMs and amount of traffic and > workloads it is really not a worth of the trouble. > > I guess the way we do swapping kind of indirectly sorts out the > issue you described, doesn't it? I'm not sure, we've pulled down your resource manager branch so we can figure out the exact mechanics of how it works. Based on a cursory read of the code it appears as if it loops through all three transient handle slots and attempts to context save each transient object it finds. So if it does that for each send/receive cycle it should theoretically inter-operate with TXT/tboot. As noted previously, with the current kernel driver, we can see that tboot has allocated a slot for the ephemeral key which is used to seal the memory verification secrets. This key gets allocated to handle 80000000 as one would anticipate. However when we attempt to issue a context save against that handle we get an error. Interestingly, when we attempt to flush that handle manually we receive an error as well, but the number of available transient handles increases by one which suggests the context flush cleared the slot. It seems that we should be able to manually replicate what the resource manager is doing with the standard kernel driver or is this an incorrect assumption? We will have to spin up a kernel with your patches and see how it reacts to the presence of the extra-OS handle allocation. > /Jarkko Greg As always, Dr. G.W. Wettstein, Ph.D. Enjellic Systems Development, LLC. 4206 N. 19th Ave. Specializing in information infra-structure Fargo, ND 58102 development. PH: 701-281-1686 FAX: 701-281-3949 EMAIL: greg@enjellic.com ------------------------------------------------------------------------------ "We know that communication is a problem, but the company is not going to discuss it with the employees." -- Switching supervisor AT&T Long Lines Division