]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
TPM: Zero buffer after copying to userspace
authorPeter Huewe <huewe.external.infineon@googlemail.com>
Thu, 15 Sep 2011 17:47:42 +0000 (14:47 -0300)
committerWilly Tarreau <w@1wt.eu>
Sat, 11 Feb 2012 14:37:43 +0000 (15:37 +0100)
commit 3321c07ae5068568cd61ac9f4ba749006a7185c9 upstream.

Since the buffer might contain security related data it might be a good idea to
zero the buffer after we have copied it to userspace.

This got assigned CVE-2011-1162.

Signed-off-by: Rajiv Andrade <srajiv@linux.vnet.ibm.com>
Signed-off-by: James Morris <jmorris@namei.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Willy Tarreau <w@1wt.eu>
drivers/char/tpm/tpm.c

index 4569d24e76c0bf313700bb3d7c461670ef5f4979..d97bffd80d5fea0222aa26e6b32db1fe6359b652 100644 (file)
@@ -1069,6 +1069,7 @@ ssize_t tpm_read(struct file *file, char __user *buf,
 {
        struct tpm_chip *chip = file->private_data;
        ssize_t ret_size;
+       int rc;
 
        del_singleshot_timer_sync(&chip->user_read_timer);
        flush_scheduled_work();
@@ -1079,8 +1080,11 @@ ssize_t tpm_read(struct file *file, char __user *buf,
                        ret_size = size;
 
                mutex_lock(&chip->buffer_mutex);
-               if (copy_to_user(buf, chip->data_buffer, ret_size))
+               rc = copy_to_user(buf, chip->data_buffer, ret_size);
+               memset(chip->data_buffer, 0, ret_size);
+               if (rc)
                        ret_size = -EFAULT;
+
                mutex_unlock(&chip->buffer_mutex);
        }