Skip to contentSkip to conversation

ipc: explicitly clear stack memory in user structs

PATCH In review Kees Cook 5 participants 13 messages Oct 25, 2010 – Nov 11, 2010

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 ipc: explicitly clear stack memory in user structs

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.

---

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(-)
ipc/shm.c +2 -0
index 52ed77e..f943b1e 100644
@@ -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
Signature · 5 lines
1.7.1

-- 
Kees Cook
Ubuntu Security Team
#1 lore raw
Quoted 8 lines · Kees Cook

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.

This looks like a genuine bug fix but I don't see this patch in mainline. Why is that?

Quoted 41 lines

---

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(-)
ipc/shm.c +2 -0
index 52ed77e..f943b1e 100644
@@ -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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

author
#2 lore raw

Hi Pekka,

Quoted 7 lines · Pekka Enberg
Quoted 6 lines · Kees Cook

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.

Quoted 5 lines
Quoted 2 lines

This looks like a genuine bug fix but I don't see this patch in mainline. Why is that?

No one has committed it. I don't know why; I've sent it a few times now.

-Kees

Signature · 2 lines
Kees Cook
Ubuntu Security Team
Acked-by
#3 lore raw
Quoted 10 lines · Kees Cook

Hi Pekka,

Quoted 7 lines · Pekka Enberg
Quoted 6 lines · Kees Cook

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.

Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

This looks like a genuine bug fix but I don't see this patch in mainline. Why is that?

No one has committed it. I don't know why; I've sent it a few times now.

Andrew, would you mind picking this up and route it to the appropriate person if necessary?

Pekka

#4 lore raw
Quoted 22 lines · Pekka Enberg
Quoted 21 lines · Kees Cook

Hi Pekka,

Quoted 16 lines · Pekka Enberg
Quoted 10 lines · Kees Cook

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.

This looks like a genuine bug fix but I don't see this patch in mainline. Why is that?

Quoted 6 lines
Quoted 1 line

No one has committed it. I don't know why; I've sent it a few times now.

Andrew, would you mind picking this up and route it to the appropriate person if necessary?

Oh, there seems to be a partial fix in mainline:

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=3af54c9bd9e6f14f896aac1bb0e8405ae0bc7a44

Hmmh?

author
#5 lore raw

Hi Pekka,

Quoted 1 line · Pekka Enberg

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=3af54c9bd9e6f14f896aac1bb0e8405ae0bc7a44

Yes, it looks like Vasiliy Kulikov's version[0] from Oct 30th went in instead of my second[1] or third[2] posting of the patches earlier in the month.

-Kees

[0] http://lkml.org/lkml/2010/10/30/30
[1] http://lkml.org/lkml/2010/10/6/486
[2] http://lkml.org/lkml/2010/10/25/447

Signature · 2 lines
Kees Cook
Ubuntu Security Team
#6 lore raw
In reply to Kees Cook
Quoted 2 lines · Kees Cook

No one has committed it. I don't know why; I've sent it a few times now.

You seem to have sent it just to lkml. At least in this case the patch itself was not sent to me (only the subsequent replies were), and the choice of recipients was fairly odd apart from Andrew (who probably _is_ the right person).

I don't quite see where you got the particular collection of people from.

Linus

#7 lore raw
Quoted 8 lines · On Tue, 9 Nov 2010 14:46:30 -0800 Linus Torvalds…
Quoted 2 lines · Kees Cook

No one has committed it. I don't know why; I've sent it a few times now.

You seem to have sent it just to lkml. At least in this case the patch itself was not sent to me (only the subsequent replies were), and the choice of recipients was fairly odd apart from Andrew (who probably _is_ the right person).

It's in my backlog queue. Waaaay back.

The -rc1 merging and kermel summit put me way behind (again) and when I'm way behind, I start to work in reverse order (mainly to avoid looking at older versions of patches). And when I'm working in time-reverse order, things which were sent a long time ago get delayed even more.

The good news is that the longer I take to merge something, the less likely it is that I'll actually merge it ;) Either it got shot down or a new version came out or someone else merged it.

author
#8 lore raw
In reply to Linus Torvalds

Hi Linus,

Quoted 7 lines · Linus Torvalds
Quoted 1 line · Kees Cook

No one has committed it. I don't know why; I've sent it a few times now.

You seem to have sent it just to lkml. At least in this case the patch itself was not sent to me (only the subsequent replies were), and the choice of recipients was fairly odd apart from Andrew (who probably _is_ the right person).

I've been avoiding sending minor security issues like this directly to you or [email protected] since that probably should be a high-priority channel.

Quoted 2 lines

I don't quite see where you got the particular collection of people from.

I used scripts/get_maintainer.pl

-Kees

Signature · 2 lines
Kees Cook
Ubuntu Security Team
#9 lore raw
Quoted 4 lines · Kees Cook
Quoted 2 lines

I don't quite see where you got the particular collection of people from.

I used scripts/get_maintainer.pl

Hmm. I get totally different results. You had

[email protected]
Al Viro <[email protected]>,
Andrew Morton <[email protected]>,
Jiri Slaby <[email protected]>,
"David S. Miller" <[email protected]>

and I get

Al Viro <[email protected]>
Andrew Morton <[email protected]>
Helge Deller <[email protected]>
David Howells <[email protected]>
Hugh Dickins <[email protected]>
[email protected]

so there is something odd going on there.

Linus

#10 lore raw
Quoted 17 lines · Linus Torvalds
Quoted 2 lines · Kees Cook
Quoted 1 line

I don't quite see where you got the particular collection of people from.

I used scripts/get_maintainer.pl

Hmm. I get totally different results. You had
[email protected]
Al Viro <[email protected]>,
Andrew Morton <[email protected]>,
Jiri Slaby <[email protected]>,
"David S. Miller" <[email protected]>
and I get
Al Viro <[email protected]>
Andrew Morton <[email protected]>
Helge Deller <[email protected]>
David Howells <[email protected]>
Hugh Dickins <[email protected]>
[email protected]
so there is something odd going on there.

I'd like to know as well.

author
#11 lore raw
Quoted 19 lines · Joe Perches
Quoted 17 lines · Linus Torvalds
Quoted 2 lines · Kees Cook
Quoted 1 line

I don't quite see where you got the particular collection of people from.

I used scripts/get_maintainer.pl

Hmm. I get totally different results. You had
[email protected]
Al Viro <[email protected]>,
Andrew Morton <[email protected]>,
Jiri Slaby <[email protected]>,
"David S. Miller" <[email protected]>
and I get
Al Viro <[email protected]>
Andrew Morton <[email protected]>
Helge Deller <[email protected]>
David Howells <[email protected]>
Hugh Dickins <[email protected]>
[email protected]
so there is something odd going on there.

Quoted 1 line

I'd like to know as well.

Well, let's see what happens. If I rewind the tree to roughly 542181d3769d001c59cd17573dd4381e87d215f2 taking a wild guess at where my tree was when I send the patch, and run it, here's what I get:

$ ./scripts/get_maintainer.pl 0001-ipc-initialize-structure-memory-to-zero-in-shm.patch
Al Viro <[email protected]>
Andrew Morton <[email protected]>
Jiri Slaby <[email protected]>
"Serge E. Hallyn" <[email protected]>
"David S. Miller" <[email protected]>
[email protected]

And since I know Serge's address isn't at ibm any more, I dropped it from Cc, assuming he didn't care about ipc structure fixups.

If I fast-forward to today and run it, I get the same output you do.

-Kees

Signature · 2 lines
Kees Cook
Ubuntu Security Team
#12 lore raw
Quoted 1 line · Kees Cook

If I fast-forward to today and run it, I get the same output you do.

Your patch had two parts and I only see one of them in mainline. Care to resubmit?