public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <kees.cook@canonical.com>
To: linux-kernel@vger.kernel.org
Cc: Al Viro <viro@zeniv.linux.org.uk>,
	Andrew Morton <akpm@linux-foundation.org>,
	Jiri Slaby <jslaby@suse.cz>,
	"David S. Miller" <davem@davemloft.net>
Subject: [PATCH] ipc: explicitly clear stack memory in user structs
Date: Mon, 25 Oct 2010 16:58:04 -0700	[thread overview]
Message-ID: <20101025235804.GA11760@outflux.net> (raw)

CVE-2010-4072

The old shm interface will leak a few bytes of stack contents. Explicitly
clear structure using memset instead of C99-style initialization in case
there are ever holes in the packing.

Cc: stable <stable@kernel.org>
Signed-off-by: Kees Cook <kees.cook@canonical.com>
---

This was originally sent as http://lkml.org/lkml/2010/10/6/486 but was
never taken into any tree.

---
 ipc/shm.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/ipc/shm.c b/ipc/shm.c
index 52ed77e..f943b1e 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -473,6 +473,7 @@ static inline unsigned long copy_shmid_to_user(void __user *buf, struct shmid64_
 	    {
 		struct shmid_ds out;
 
+		memset(&out, 0, sizeof(out));
 		ipc64_perm_to_ipc_perm(&in->shm_perm, &out.shm_perm);
 		out.shm_segsz	= in->shm_segsz;
 		out.shm_atime	= in->shm_atime;
@@ -524,6 +525,7 @@ static inline unsigned long copy_shminfo_to_user(void __user *buf, struct shminf
 	    {
 		struct shminfo out;
 
+		memset(&out, 0, sizeof(out));
 		if(in->shmmax > INT_MAX)
 			out.shmmax = INT_MAX;
 		else
-- 
1.7.1

-- 
Kees Cook
Ubuntu Security Team

             reply	other threads:[~2010-10-25 23:58 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-25 23:58 Kees Cook [this message]
2010-11-09 20:43 ` [PATCH] ipc: explicitly clear stack memory in user structs Pekka Enberg
2010-11-09 20:50   ` Kees Cook
2010-11-09 20:51     ` Pekka Enberg
2010-11-09 21:34       ` Pekka Enberg
2010-11-09 21:49         ` Kees Cook
2010-11-09 22:46     ` Linus Torvalds
2010-11-09 23:09       ` Andrew Morton
2010-11-09 23:48       ` Kees Cook
2010-11-10  0:54         ` Linus Torvalds
2010-11-10  1:03           ` Joe Perches
2010-11-10  2:00             ` Kees Cook
2010-11-11  7:37               ` Pekka Enberg

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=20101025235804.GA11760@outflux.net \
    --to=kees.cook@canonical.com \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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