From: Tim Gardner <tim.gardner@canonical.com>
To: linux-kernel@vger.kernel.org
Cc: Seth Forshee <seth.forshee@canonical.com>,
Tim Gardner <tim.gardner@canonical.com>,
Debora Velarde <debora@linux.vnet.ibm.com>,
Rajiv Andrade <srajiv@linux.vnet.ibm.com>,
Marcel Selhorst <m.selhorst@sirrix.com>,
tpmdd-devel@lists.sourceforge.net, stable@vger.kernel.org
Subject: [PATCH 1/3] TPM: Zero buffer whole after copying to userspace
Date: Tue, 6 Dec 2011 11:29:20 -0700 [thread overview]
Message-ID: <1323196162-2717-2-git-send-email-tim.gardner@canonical.com> (raw)
In-Reply-To: <1323196162-2717-1-git-send-email-tim.gardner@canonical.com>
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>
---
drivers/char/tpm/tpm.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index 361a1df..b366b34 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -1115,12 +1115,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;
--
1.7.0.4
next prev parent reply other threads:[~2011-12-06 18:49 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-06 18:29 [PATCH 0/3] TPM: CVE patch, close a race, atomic cleanup Tim Gardner
2011-12-06 18:29 ` Tim Gardner [this message]
2012-02-03 17:39 ` [PATCH 1/3] TPM: Zero buffer whole after copying to userspace Rajiv Andrade
2011-12-06 18:29 ` [PATCH 2/3] TPM: Close data_pending and data_buffer races Tim Gardner
2011-12-20 16:38 ` Rajiv Andrade
2011-12-20 19:39 ` Tim Gardner
2011-12-22 17:42 ` Rajiv Andrade
2011-12-22 18:44 ` Tim Gardner
2011-12-22 20:02 ` Rajiv Andrade
2011-12-23 14:25 ` Tim Gardner
2011-12-27 20:02 ` [tpmdd-devel] " Mimi Zohar
2012-01-11 19:43 ` Rajiv Andrade
2012-07-25 17:36 ` Kent Yoder
2011-12-06 18:29 ` [PATCH 3/3] TPM: data_pending is no longer atomic Tim Gardner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1323196162-2717-2-git-send-email-tim.gardner@canonical.com \
--to=tim.gardner@canonical.com \
--cc=debora@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=m.selhorst@sirrix.com \
--cc=seth.forshee@canonical.com \
--cc=srajiv@linux.vnet.ibm.com \
--cc=stable@vger.kernel.org \
--cc=tpmdd-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®