]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/meta-ti-glsdk.git/blob - recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.14/0053-TPM-Zero-buffer-whole-after-copying-to-userspace.patch
linux-ti335x-psp 3.2: update to 3.2.14
[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-ti33x-psp-3.2 / 3.2.14 / 0053-TPM-Zero-buffer-whole-after-copying-to-userspace.patch
1 From 6afa33c872ff109ed854c7dcec52130732f9e62e Mon Sep 17 00:00:00 2001
2 From: Tim Gardner <tim.gardner@canonical.com>
3 Date: Tue, 6 Dec 2011 11:29:20 -0700
4 Subject: [PATCH 053/147] TPM: Zero buffer whole after copying to userspace
6 commit 3ab1aff89477dafb1aaeafe8c8669114a02b7226 upstream.
8 Commit 3321c07ae5068568cd61ac9f4ba749006a7185c9 correctly clears the TPM
9 buffer if the user specified read length is >= the TPM buffer length. However,
10 if the user specified read length is < the TPM buffer length, then part of the
11 TPM buffer is left uncleared.
13 Reported-by: Seth Forshee <seth.forshee@canonical.com>
14 Cc: Debora Velarde <debora@linux.vnet.ibm.com>
15 Cc: Rajiv Andrade <srajiv@linux.vnet.ibm.com>
16 Cc: Marcel Selhorst <m.selhorst@sirrix.com>
17 Cc: tpmdd-devel@lists.sourceforge.net
18 Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
19 Signed-off-by: Rajiv Andrade <srajiv@linux.vnet.ibm.com>
20 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
21 ---
22  drivers/char/tpm/tpm.c |    3 ++-
23  1 file changed, 2 insertions(+), 1 deletion(-)
25 diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
26 index 361a1df..b366b34 100644
27 --- a/drivers/char/tpm/tpm.c
28 +++ b/drivers/char/tpm/tpm.c
29 @@ -1115,12 +1115,13 @@ ssize_t tpm_read(struct file *file, char __user *buf,
30         ret_size = atomic_read(&chip->data_pending);
31         atomic_set(&chip->data_pending, 0);
32         if (ret_size > 0) {     /* relay data */
33 +               ssize_t orig_ret_size = ret_size;
34                 if (size < ret_size)
35                         ret_size = size;
36  
37                 mutex_lock(&chip->buffer_mutex);
38                 rc = copy_to_user(buf, chip->data_buffer, ret_size);
39 -               memset(chip->data_buffer, 0, ret_size);
40 +               memset(chip->data_buffer, 0, orig_ret_size);
41                 if (rc)
42                         ret_size = -EFAULT;
43  
44 -- 
45 1.7.9.4