stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tpm: handle negative priv->response_len in tpm_common_read
       [not found] <b85fa669-d3aa-f6c9-9631-988ae47e392c@redhat.com>
@ 2020-01-07 22:04 ` Tadeusz Struk
  2020-01-08 15:58   ` Jarkko Sakkinen
  0 siblings, 1 reply; 5+ messages in thread
From: Tadeusz Struk @ 2020-01-07 22:04 UTC (permalink / raw)
  To: jarkko.sakkinen
  Cc: keescook, tadeusz.struk, linux-kernel, stable, linux-integrity, labbott

The priv->responce_length can hold the size of an response or
an negative error code, and the tpm_common_read() needs to handle
both cases correctly. Changed the type of responce_length to
signed and accounted for negative value in tpm_common_read()

Cc: stable@vger.kernel.org
Fixes: d23d12484307 ("tpm: fix invalid locking in NONBLOCKING mode")
Reported-by: Laura Abbott <labbott@redhat.com>
Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
---
 drivers/char/tpm/tpm-dev-common.c |    2 +-
 drivers/char/tpm/tpm-dev.h        |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/char/tpm/tpm-dev-common.c b/drivers/char/tpm/tpm-dev-common.c
index b23b0b999232..87f449340202 100644
--- a/drivers/char/tpm/tpm-dev-common.c
+++ b/drivers/char/tpm/tpm-dev-common.c
@@ -130,7 +130,7 @@ ssize_t tpm_common_read(struct file *file, char __user *buf,
 		priv->response_read = true;
 
 		ret_size = min_t(ssize_t, size, priv->response_length);
-		if (!ret_size) {
+		if (ret_size <= 0) {
 			priv->response_length = 0;
 			goto out;
 		}
diff --git a/drivers/char/tpm/tpm-dev.h b/drivers/char/tpm/tpm-dev.h
index 1089fc0bb290..f3742bcc73e3 100644
--- a/drivers/char/tpm/tpm-dev.h
+++ b/drivers/char/tpm/tpm-dev.h
@@ -14,7 +14,7 @@ struct file_priv {
 	struct work_struct timeout_work;
 	struct work_struct async_work;
 	wait_queue_head_t async_wait;
-	size_t response_length;
+	ssize_t response_length;
 	bool response_read;
 	bool command_enqueued;
 


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

* Re: [PATCH] tpm: handle negative priv->response_len in tpm_common_read
  2020-01-07 22:04 ` [PATCH] tpm: handle negative priv->response_len in tpm_common_read Tadeusz Struk
@ 2020-01-08 15:58   ` Jarkko Sakkinen
  2020-01-08 16:04     ` Jarkko Sakkinen
  0 siblings, 1 reply; 5+ messages in thread
From: Jarkko Sakkinen @ 2020-01-08 15:58 UTC (permalink / raw)
  To: Tadeusz Struk; +Cc: keescook, linux-kernel, stable, linux-integrity, labbott

On Tue, 2020-01-07 at 14:04 -0800, Tadeusz Struk wrote:
> The priv->responce_length can hold the size of an response or
> an negative error code, and the tpm_common_read() needs to handle
> both cases correctly. Changed the type of responce_length to
> signed and accounted for negative value in tpm_common_read()
> 
> Cc: stable@vger.kernel.org
> Fixes: d23d12484307 ("tpm: fix invalid locking in NONBLOCKING mode")
> Reported-by: Laura Abbott <labbott@redhat.com>
> Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>

Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>

Adding to the next PR.

/Jarkko


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

* Re: [PATCH] tpm: handle negative priv->response_len in tpm_common_read
  2020-01-08 15:58   ` Jarkko Sakkinen
@ 2020-01-08 16:04     ` Jarkko Sakkinen
  2020-01-08 17:47       ` Tadeusz Struk
  0 siblings, 1 reply; 5+ messages in thread
From: Jarkko Sakkinen @ 2020-01-08 16:04 UTC (permalink / raw)
  To: Tadeusz Struk; +Cc: keescook, linux-kernel, stable, linux-integrity, labbott

On Wed, 2020-01-08 at 17:58 +0200, Jarkko Sakkinen wrote:
> On Tue, 2020-01-07 at 14:04 -0800, Tadeusz Struk wrote:
> > The priv->responce_length can hold the size of an response or
> > an negative error code, and the tpm_common_read() needs to handle
> > both cases correctly. Changed the type of responce_length to
> > signed and accounted for negative value in tpm_common_read()
> > 
> > Cc: stable@vger.kernel.org
> > Fixes: d23d12484307 ("tpm: fix invalid locking in NONBLOCKING mode")
> > Reported-by: Laura Abbott <labbott@redhat.com>
> > Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
> 
> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> 
> Adding to the next PR.

Applied but had to fix bunch of typos, missing punctaction and
missing parentheses in the commit message. Even checkpatch.pl
was complaining :-/

Thanks.

/Jarkko


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

* Re: [PATCH] tpm: handle negative priv->response_len in tpm_common_read
  2020-01-08 16:04     ` Jarkko Sakkinen
@ 2020-01-08 17:47       ` Tadeusz Struk
  2020-01-13  0:07         ` Jarkko Sakkinen
  0 siblings, 1 reply; 5+ messages in thread
From: Tadeusz Struk @ 2020-01-08 17:47 UTC (permalink / raw)
  To: Jarkko Sakkinen; +Cc: keescook, linux-kernel, stable, linux-integrity, labbott

On 1/8/20 8:04 AM, Jarkko Sakkinen wrote:
> Applied but had to fix bunch of typos, missing punctaction and
> missing parentheses in the commit message. Even checkpatch.pl
> was complaining :-/

Forgot about the checkpatch.pl thing. Sorry.

-- 
Tadeusz

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

* Re: [PATCH] tpm: handle negative priv->response_len in tpm_common_read
  2020-01-08 17:47       ` Tadeusz Struk
@ 2020-01-13  0:07         ` Jarkko Sakkinen
  0 siblings, 0 replies; 5+ messages in thread
From: Jarkko Sakkinen @ 2020-01-13  0:07 UTC (permalink / raw)
  To: Tadeusz Struk; +Cc: keescook, linux-kernel, stable, linux-integrity, labbott

On Wed, Jan 08, 2020 at 09:47:31AM -0800, Tadeusz Struk wrote:
> On 1/8/20 8:04 AM, Jarkko Sakkinen wrote:
> > Applied but had to fix bunch of typos, missing punctaction and
> > missing parentheses in the commit message. Even checkpatch.pl
> > was complaining :-/
> 
> Forgot about the checkpatch.pl thing. Sorry.

NP, just mentioning this for the future patches.

/Jarkko

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

end of thread, other threads:[~2020-01-13  0:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <b85fa669-d3aa-f6c9-9631-988ae47e392c@redhat.com>
2020-01-07 22:04 ` [PATCH] tpm: handle negative priv->response_len in tpm_common_read Tadeusz Struk
2020-01-08 15:58   ` Jarkko Sakkinen
2020-01-08 16:04     ` Jarkko Sakkinen
2020-01-08 17:47       ` Tadeusz Struk
2020-01-13  0:07         ` Jarkko Sakkinen

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).