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>,
stable@kernel.org
Subject: [PATCH] ipc: initialize structure memory to zero for shmctl
Date: Wed, 6 Oct 2010 17:10:31 -0700 [thread overview]
Message-ID: <20101007001031.GX14666@outflux.net> (raw)
The old shm interface will leak a few bytes of stack contents. Explicitly
initialize the structure to zero-fill the untouched fields.
Signed-off-by: Kees Cook <kees.cook@canonical.com>
---
ipc/shm.c | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/ipc/shm.c b/ipc/shm.c
index 52ed77e..d2ee426 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -471,16 +471,17 @@ static inline unsigned long copy_shmid_to_user(void __user *buf, struct shmid64_
return copy_to_user(buf, in, sizeof(*in));
case IPC_OLD:
{
- struct shmid_ds out;
+ struct shmid_ds out = {
+ .shm_segsz = in->shm_segsz,
+ .shm_atime = in->shm_atime,
+ .shm_dtime = in->shm_dtime,
+ .shm_ctime = in->shm_ctime,
+ .shm_cpid = in->shm_cpid,
+ .shm_lpid = in->shm_lpid,
+ .shm_nattch = in->shm_nattch,
+ };
ipc64_perm_to_ipc_perm(&in->shm_perm, &out.shm_perm);
- out.shm_segsz = in->shm_segsz;
- out.shm_atime = in->shm_atime;
- out.shm_dtime = in->shm_dtime;
- out.shm_ctime = in->shm_ctime;
- out.shm_cpid = in->shm_cpid;
- out.shm_lpid = in->shm_lpid;
- out.shm_nattch = in->shm_nattch;
return copy_to_user(buf, &out, sizeof(out));
}
--
1.7.1
--
Kees Cook
Ubuntu Security Team
next reply other threads:[~2010-10-07 0:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-07 0:10 Kees Cook [this message]
2010-10-07 1:21 ` [PATCH] ipc: initialize structure memory to zero for shmctl Al Viro
2010-10-07 2:13 ` Kees Cook
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=20101007001031.GX14666@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=stable@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