Linux-Security-Module Archive on lore.kernel.org
 help / Atom feed
* [PATCH] tpm-dev: Require response to be read only if there actually is a response
@ 2018-12-06 17:58 Alexander Steffen
  2018-12-12 17:53 ` Jarkko Sakkinen
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Steffen @ 2018-12-06 17:58 UTC (permalink / raw)
  To: Jarkko Sakkinen, Tadeusz Struk
  Cc: jgg, linux-integrity, linux-security-module, linux-kernel,
	Alexander Steffen

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] tpm-dev: Require response to be read only if there actually is a response
  2018-12-06 17:58 [PATCH] tpm-dev: Require response to be read only if there actually is a response Alexander Steffen
@ 2018-12-12 17:53 ` Jarkko Sakkinen
  0 siblings, 0 replies; 2+ messages in thread
From: Jarkko Sakkinen @ 2018-12-12 17:53 UTC (permalink / raw)
  To: Alexander Steffen
  Cc: Tadeusz Struk, jgg, linux-integrity, linux-security-module, linux-kernel

On Thu, Dec 06, 2018 at 06:58:01PM +0100, Alexander Steffen wrote:
> 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.

Thank you, good catch.

My PR is a bit late becuse just came from Oregon back to Finland so
I'll follow your advice and squash this. Thanks again.

/Jarkko

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-06 17:58 [PATCH] tpm-dev: Require response to be read only if there actually is a response Alexander Steffen
2018-12-12 17:53 ` Jarkko Sakkinen

Linux-Security-Module Archive on lore.kernel.org

Archives are clonable: git clone --mirror https://lore.kernel.org/linux-security-module/0 linux-security-module/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-security-module linux-security-module/ https://lore.kernel.org/linux-security-module \
		linux-security-module@vger.kernel.org linux-security-module@archiver.kernel.org
	public-inbox-index linux-security-module


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-security-module


AGPL code for this site: git clone https://public-inbox.org/ public-inbox