]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
tpm: Begin the process to deprecate user_read_timer
authorJason Gunthorpe <jgunthorpe@obsidianresearch.com>
Tue, 24 Jan 2017 00:06:08 +0000 (17:06 -0700)
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Fri, 3 Feb 2017 20:03:14 +0000 (22:03 +0200)
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>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
drivers/char/tpm/tpm-dev.c

index 912ad30be5852f8a2145d0c1e56c03257bbbb211..02a8850d3a69022dcf58346c7e69413e9f34ea27 100644 (file)
@@ -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);
 }
 
@@ -157,7 +160,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;
 }