TPM: Zero buffer whole after copying to userspace
authorTim Gardner <tim.gardner@canonical.com>
Tue, 6 Dec 2011 18:29:20 +0000 (11:29 -0700)
committerRajiv Andrade <srajiv@linux.vnet.ibm.com>
Tue, 14 Feb 2012 18:43:38 +0000 (16:43 -0200)
Commit 3321c07ae5068568cd61ac9f4ba749006a7185c9 correctly clears the TPM
buffer if the user specified read length is >= the TPM buffer length. However,
if the user specified read length is < the TPM buffer length, then part of the
TPM buffer is left uncleared.

Reported-by: Seth Forshee <seth.forshee@canonical.com>
Cc: Debora Velarde <debora@linux.vnet.ibm.com>
Cc: Rajiv Andrade <srajiv@linux.vnet.ibm.com>
Cc: Marcel Selhorst <m.selhorst@sirrix.com>
Cc: tpmdd-devel@lists.sourceforge.net
Cc: stable@vger.kernel.org
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Signed-off-by: Rajiv Andrade <srajiv@linux.vnet.ibm.com>
drivers/char/tpm/tpm.c

index 32362cf35b8d1a42c4b1f3e4f67881687ecad0cc..ad7c7320dd1ba13f6ef55cf8f06ff88203904d49 100644 (file)
@@ -1221,12 +1221,13 @@ ssize_t tpm_read(struct file *file, char __user *buf,
        ret_size = atomic_read(&chip->data_pending);
        atomic_set(&chip->data_pending, 0);
        if (ret_size > 0) {     /* relay data */
+               ssize_t orig_ret_size = ret_size;
                if (size < ret_size)
                        ret_size = size;
 
                mutex_lock(&chip->buffer_mutex);
                rc = copy_to_user(buf, chip->data_buffer, ret_size);
-               memset(chip->data_buffer, 0, ret_size);
+               memset(chip->data_buffer, 0, orig_ret_size);
                if (rc)
                        ret_size = -EFAULT;
 
This page took 0.421625 seconds and 5 git commands to generate.