linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Steffen <Alexander.Steffen@infineon.com>
To: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>,
	Tadeusz Struk <tadeusz.struk@intel.com>
Cc: <jgg@ziepe.ca>, <linux-integrity@vger.kernel.org>,
	<linux-security-module@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	Alexander Steffen <Alexander.Steffen@infineon.com>
Subject: [PATCH] tpm-dev: Require response to be read only if there actually is a response
Date: Thu, 6 Dec 2018 18:58:01 +0100	[thread overview]
Message-ID: <20181206175801.23048-1-Alexander.Steffen@infineon.com> (raw)

If the tpm_transmit call in tpm_common_write fails for any reason, there is
no response that could be read. Therefore, do not require the application
to issue a read call before sending further commands. This restores the
behavior from before support for partial reads was introduced.

Signed-off-by: Alexander Steffen <Alexander.Steffen@infineon.com>
---
Feel free to merge this into Tadeusz' original commit.

 drivers/char/tpm/tpm-dev-common.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/char/tpm/tpm-dev-common.c b/drivers/char/tpm/tpm-dev-common.c
index 344739223451..5eecad233ea1 100644
--- a/drivers/char/tpm/tpm-dev-common.c
+++ b/drivers/char/tpm/tpm-dev-common.c
@@ -140,7 +140,8 @@ ssize_t tpm_common_write(struct file *file, const char __user *buf,
 	 * tpm_read or a user_read_timer timeout. This also prevents split
 	 * buffered writes from blocking here.
 	 */
-	if (!priv->response_read || priv->command_enqueued) {
+	if ((!priv->response_read && priv->response_length) ||
+	    priv->command_enqueued) {
 		ret = -EBUSY;
 		goto out;
 	}
-- 
2.17.1


             reply	other threads:[~2018-12-06 18:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-06 17:58 Alexander Steffen [this message]
2018-12-12 17:53 ` [PATCH] tpm-dev: Require response to be read only if there actually is a response Jarkko Sakkinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181206175801.23048-1-Alexander.Steffen@infineon.com \
    --to=alexander.steffen@infineon.com \
    --cc=jarkko.sakkinen@linux.intel.com \
    --cc=jgg@ziepe.ca \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=tadeusz.struk@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).