diff mbox

[lucid/fsl-imx51,maverick,maverick/ti-omap4,CVE,1/1] TPM: Zero buffer after copying to userspace

Message ID 1323101922-9653-3-git-send-email-apw@canonical.com
State New
Headers show

Commit Message

Andy Whitcroft Dec. 5, 2011, 4:18 p.m. UTC
From: Peter Huewe <huewe.external.infineon@googlemail.com>

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>
Cc: Stable Kernel <stable@kernel.org>
Signed-off-by: James Morris <jmorris@namei.org>

(cherry picked from commit 3321c07ae5068568cd61ac9f4ba749006a7185c9)
BugLink: http://bugs.launchpad.net/bugs/899463
Signed-off-by: Andy Whitcroft <apw@canonical.com>
 drivers/char/tpm/tpm.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
diff mbox


diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index 896fc94..e0bd740 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -1025,6 +1025,7 @@  ssize_t tpm_read(struct file *file, char __user *buf,
 	struct tpm_chip *chip = file->private_data;
 	ssize_t ret_size;
+	int rc;
@@ -1035,8 +1036,11 @@  ssize_t tpm_read(struct file *file, char __user *buf,
 			ret_size = size;
-		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;