From patchwork Thu Jan 12 19:46:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Bottomley X-Patchwork-Id: 9514107 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 A7F5E601E7 for ; Thu, 12 Jan 2017 19:56:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 95484286A5 for ; Thu, 12 Jan 2017 19:56:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 886BF286C9; Thu, 12 Jan 2017 19:56:26 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham 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 F25DE286A5 for ; Thu, 12 Jan 2017 19:56:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750880AbdALT4Y (ORCPT ); Thu, 12 Jan 2017 14:56:24 -0500 Received: from bedivere.hansenpartnership.com ([66.63.167.143]:37244 "EHLO bedivere.hansenpartnership.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750819AbdALT4Y (ORCPT ); Thu, 12 Jan 2017 14:56:24 -0500 Received: from localhost (localhost [127.0.0.1]) by bedivere.hansenpartnership.com (Postfix) with ESMTP id 1E4F18EE218; Thu, 12 Jan 2017 11:46:11 -0800 (PST) Received: from bedivere.hansenpartnership.com ([127.0.0.1]) by localhost (bedivere.hansenpartnership.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id h-_bFRPdIehv; Thu, 12 Jan 2017 11:46:11 -0800 (PST) Received: from [153.66.254.194] (unknown [50.46.144.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by bedivere.hansenpartnership.com (Postfix) with ESMTPSA id A77C38EE07D; Thu, 12 Jan 2017 11:46:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=hansenpartnership.com; s=20151216; t=1484250370; bh=THpFgf1KCSQPYbAIU92gQeH1AcUIeLlMvNkYXvQuYf8=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=M4kcVFWvVkfHi+QGVBlhwiMTbOYqAS0u/GZmc8GbrGNV4+3mKg+i2CCOO9jKW0Tmo D2nKDufcGK98TQwpZ+1wxS0SXe9IgGUvRKMHMN07POARpL1VKBesvSn62BeI/8AwA3 WX+hgUWyKlwq+7ayFLU4YfTuwJ31zcv4x8D6KlII= Message-ID: <1484250369.5807.11.camel@HansenPartnership.com> Subject: Re: [tpmdd-devel] [PATCH RFC v2 5/5] tpm2: expose resource manager via a device link /dev/tpms From: James Bottomley To: Jarkko Sakkinen , tpmdd-devel@lists.sourceforge.net Cc: open list , linux-security-module@vger.kernel.org Date: Thu, 12 Jan 2017 11:46:09 -0800 In-Reply-To: <20170112174612.9314-6-jarkko.sakkinen@linux.intel.com> References: <20170112174612.9314-1-jarkko.sakkinen@linux.intel.com> <20170112174612.9314-6-jarkko.sakkinen@linux.intel.com> X-Mailer: Evolution 3.16.5 Mime-Version: 1.0 Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP On Thu, 2017-01-12 at 19:46 +0200, Jarkko Sakkinen wrote: > From: James Bottomley > > Currently the Resource Manager (RM) is not exposed to userspace. > Make > this exposure via a separate device, which can now be opened multiple > times because each read/write transaction goes separately via the RM. > > Concurrency is protected by the chip->tpm_mutex for each read/write > transaction separately. The TPM is cleared of all transient objects > by the time the mutex is dropped, so there should be no interference > between the kernel and userspace. There's a bug in this code that will crash on first command. This is the incremental fix. It must have got lost when I did the split. 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/tpms-dev.c b/drivers/char/tpm/tpms-dev.c index f4cb7a3..3eb5955 100644 --- a/drivers/char/tpm/tpms-dev.c +++ b/drivers/char/tpm/tpms-dev.c @@ -20,6 +20,11 @@ static int tpms_open(struct inode *inode, struct file *file) priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (priv == NULL) return -ENOMEM; + priv->space.context_buf = kzalloc(PAGE_SIZE, GFP_KERNEL); + if (priv->space.context_buf == NULL) { + kfree(priv); + return -ENOMEM; + } tpm_common_open(file, chip, &priv->priv);