All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tpm: Begin the process to deprecate user_read_timer
@ 2017-01-24  0:06 Jason Gunthorpe
  2017-01-24 14:32 ` Jarkko Sakkinen
  0 siblings, 1 reply; 2+ messages in thread
From: Jason Gunthorpe @ 2017-01-24  0:06 UTC (permalink / raw)
  To: Jarkko Sakkinen; +Cc: linux-security-module, tpmdd-devel, open list

For a long time the cdev read/write interface had this strange
idea that userspace had to read the result within 60 seconds otherwise
it is discarded. Perhaps this made sense under some older locking regime,
but in the modern kernel it is not required and is just dangerous.

Since something may be relying on this, double the timeout and print a
warning. We can remove the code in a few years, but this should be
enough to prevent new users.

Suggested-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
---
 drivers/char/tpm/tpm-dev.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/char/tpm/tpm-dev.c b/drivers/char/tpm/tpm-dev.c
index 826d4eaf84fcd6..06d7c8a6e7063c 100644
--- a/drivers/char/tpm/tpm-dev.c
+++ b/drivers/char/tpm/tpm-dev.c
@@ -38,6 +38,9 @@ static void user_reader_timeout(unsigned long ptr)
 {
 	struct file_priv *priv = (struct file_priv *)ptr;
 
+	pr_warn("TPM user space timeout is deprecated (pid=%d)\n",
+		task_tgid_nr(current));
+
 	schedule_work(&priv->work);
 }
 
@@ -159,7 +162,7 @@ static ssize_t tpm_write(struct file *file, const char __user *buf,
 	mutex_unlock(&priv->buffer_mutex);
 
 	/* Set a timeout by which the reader must come claim the result */
-	mod_timer(&priv->user_read_timer, jiffies + (60 * HZ));
+	mod_timer(&priv->user_read_timer, jiffies + (120 * HZ));
 
 	return in_size;
 }
-- 
2.7.4

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

* Re: [PATCH] tpm: Begin the process to deprecate user_read_timer
  2017-01-24  0:06 [PATCH] tpm: Begin the process to deprecate user_read_timer Jason Gunthorpe
@ 2017-01-24 14:32 ` Jarkko Sakkinen
  0 siblings, 0 replies; 2+ messages in thread
From: Jarkko Sakkinen @ 2017-01-24 14:32 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: linux-security-module, tpmdd-devel, open list

On Mon, Jan 23, 2017 at 05:06:08PM -0700, Jason Gunthorpe wrote:
> For a long time the cdev read/write interface had this strange
> idea that userspace had to read the result within 60 seconds otherwise
> it is discarded. Perhaps this made sense under some older locking regime,
> but in the modern kernel it is not required and is just dangerous.
> 
> Since something may be relying on this, double the timeout and print a
> warning. We can remove the code in a few years, but this should be
> enough to prevent new users.
> 
> Suggested-by: James Bottomley <James.Bottomley@HansenPartnership.com>
> Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>

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

Thanks. I'll include this to my next PR for 4.11 as it does not add
any new features.

/Jarkko

> ---
>  drivers/char/tpm/tpm-dev.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/char/tpm/tpm-dev.c b/drivers/char/tpm/tpm-dev.c
> index 826d4eaf84fcd6..06d7c8a6e7063c 100644
> --- a/drivers/char/tpm/tpm-dev.c
> +++ b/drivers/char/tpm/tpm-dev.c
> @@ -38,6 +38,9 @@ static void user_reader_timeout(unsigned long ptr)
>  {
>  	struct file_priv *priv = (struct file_priv *)ptr;
>  
> +	pr_warn("TPM user space timeout is deprecated (pid=%d)\n",
> +		task_tgid_nr(current));
> +
>  	schedule_work(&priv->work);
>  }
>  
> @@ -159,7 +162,7 @@ static ssize_t tpm_write(struct file *file, const char __user *buf,
>  	mutex_unlock(&priv->buffer_mutex);
>  
>  	/* Set a timeout by which the reader must come claim the result */
> -	mod_timer(&priv->user_read_timer, jiffies + (60 * HZ));
> +	mod_timer(&priv->user_read_timer, jiffies + (120 * HZ));
>  
>  	return in_size;
>  }
> -- 
> 2.7.4

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

end of thread, other threads:[~2017-01-24 14:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-24  0:06 [PATCH] tpm: Begin the process to deprecate user_read_timer Jason Gunthorpe
2017-01-24 14:32 ` Jarkko Sakkinen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.