From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751160AbdAWRCi (ORCPT ); Mon, 23 Jan 2017 12:02:38 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:48160 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750738AbdAWRCg (ORCPT ); Mon, 23 Jan 2017 12:02:36 -0500 Subject: Re: [tpmdd-devel] [PATCH RFC v4 0/5] RFC: in-kernel resource manager From: James Bottomley To: Jarkko Sakkinen , tpmdd-devel@lists.sourceforge.net Cc: linux-security-module@vger.kernel.org, open list Date: Mon, 23 Jan 2017 09:01:03 -0800 In-Reply-To: <20170122234438.12102-1-jarkko.sakkinen@linux.intel.com> References: <20170122234438.12102-1-jarkko.sakkinen@linux.intel.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.16.5 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17012317-0028-0000-0000-000006DB0044 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006484; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000200; SDB=6.00811606; UDB=6.00395718; IPR=6.00589023; BA=6.00005084; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00014015; XFM=3.00000011; UTC=2017-01-23 17:01:53 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17012317-0029-0000-0000-000032F30A80 Message-Id: <1485190863.2534.10.camel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-01-23_15:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1701230228 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2017-01-23 at 01:44 +0200, Jarkko Sakkinen wrote: > This patch set adds support for TPM spaces that provide a context > for isolating and swapping transient objects. The content does > not yet include support for policy and HMAC sessions. > > There's a test script for trying out TPM spaces in > > git://git.infradead.org/users/jjs/tpm2-scripts.git > > A simple smoke test can be run by > > sudo python -m unittest -v tpm2_smoke.SpaceTest > > v2: > Changed to James' proposal of API. I did not make any other changes > except split core TPM space code its own patch because I want to find > consensus on the API before polishing the corners. Thus, this version > also carries the RFC tag. I have not yet locked in my standpoint > whether > ioctl or a device file is a better deal. > > v3: > - Check TPM return code in tpm_map_response. > - Reference tracking for /dev/tpms0. > - clear_bit(is_open) was removed from tpm-dev.c. Added it back. > - Use response length as the buffer size limit in tpm2_commit_space. > - This version now passes again my smoke tests. > > v4: > - Lots of small bug fixes and clean ups. > - Quirk for TPM2_CC_FlushHandle It's still failing my flush test. This time the problem is the return code on context save failure: it's TPM_RC_REFERENCE_H0 not TPM_RC_HANDLE. This is the fix. The manual implies TPM_RC_HANDLE could also be the return, so I kept both. James --- diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index 62e8421..cc1db77 100644 --- a/drivers/char/tpm/tpm.h +++ b/drivers/char/tpm/tpm.h @@ -106,6 +106,7 @@ enum tpm2_algorithms { TPM2_ALG_SHA512 = 0x000D, TPM2_ALG_NULL = 0x0010, TPM2_ALG_SM3_256 = 0x0012, + TPM2_RC_REFERENCE_H0 = 0x0910, }; enum tpm2_command_codes { diff --git a/drivers/char/tpm/tpm2-space.c b/drivers/char/tpm/tpm2-space.c index 83e9708..b36337a 100644 --- a/drivers/char/tpm/tpm2-space.c +++ b/drivers/char/tpm/tpm2-space.c @@ -104,7 +104,8 @@ static int tpm2_save_context(struct tpm_chip *chip, u32 handle, u8 *buf, __func__, rc); tpm_buf_destroy(&tbuf); return -EFAULT; - } else if ((rc & TPM2_RC_HANDLE) == TPM2_RC_HANDLE) { + } else if ((rc & TPM2_RC_HANDLE) == TPM2_RC_HANDLE || + rc == TPM2_RC_REFERENCE_H0) { tpm_buf_destroy(&tbuf); return -ENOENT; } else if (rc) {