From patchwork Mon Jan 23 17:01:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Bottomley X-Patchwork-Id: 9533129 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 072926046A for ; Mon, 23 Jan 2017 17:03:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE39C28422 for ; Mon, 23 Jan 2017 17:03:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E0D8C26E82; Mon, 23 Jan 2017 17:03:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 75F5726E82 for ; Mon, 23 Jan 2017 17:03:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750821AbdAWRCh (ORCPT ); Mon, 23 Jan 2017 12:02:37 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:48157 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750714AbdAWRCg (ORCPT ); Mon, 23 Jan 2017 12:02:36 -0500 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v0NH1UWj158757 for ; Mon, 23 Jan 2017 12:01:56 -0500 Received: from e38.co.us.ibm.com (e38.co.us.ibm.com [32.97.110.159]) by mx0b-001b2d01.pphosted.com with ESMTP id 285fyeh2ba-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 23 Jan 2017 12:01:56 -0500 Received: from localhost by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 23 Jan 2017 10:01:55 -0700 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e38.co.us.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 23 Jan 2017 10:01:06 -0700 Received: from b01cxnp22034.gho.pok.ibm.com (b01cxnp22034.gho.pok.ibm.com [9.57.198.24]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id 585C61FF0025; Mon, 23 Jan 2017 10:00:44 -0700 (MST) Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v0NH0v7A35651748; Mon, 23 Jan 2017 17:01:05 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 94081124047; Mon, 23 Jan 2017 12:01:05 -0500 (EST) Received: from jarvis.ext.hansenpartnership.com (unknown [9.85.166.18]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTPS id EF0A6124037; Mon, 23 Jan 2017 12:01:04 -0500 (EST) 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> X-Mailer: Evolution 3.16.5 Mime-Version: 1.0 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: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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 --- -- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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) {