netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] Prevent reading uninitialized memory with socketfilters
@ 2010-11-10 18:18 Dan Rosenberg
  2010-11-10 18:21 ` David Miller
  0 siblings, 1 reply; 27+ messages in thread
From: Dan Rosenberg @ 2010-11-10 18:18 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, stable, security

The code sample I linked to clearly demonstrates exactly how to accomplish this, if you had bothered to read it.  I install a socket filter that loads the desired uninitialized int into the accumulator, performs some bit shifting to get the desired byte, and returns the accumulator.  Since the packet size is greater than 256, the packet will be truncated based on the value of that byte, allowing me to determine its value.

There are no restrictions - I can access any byte in the array regardless of its value.

-Dan


------Original Message------
From: David Miller
To: drosenberg@vsecurity.com
Cc: netdev@vger.kernel.org
Cc: stable@kernel.org
Cc: security@kernel.org
Subject: Re: [PATCH] Prevent reading uninitialized memory with socketfilters
Sent: Nov 10, 2010 1:07 PM

From: Dan Rosenberg <drosenberg@vsecurity.com>
Date: Wed, 10 Nov 2010 06:12:47 -0500

> 
>> 
>> Prove it.
> 
> I hope this was a joke.

It absolutely is not.

You are very much not the first person ever to try and add an
expensive memset() here.

So the onus is really on you to prove this assertion and show the
exact code path by which the user can actually see any uninitialized
kernel stack memory (he can't, he can peek at certain values in a
certain extremely contrived range, making the leak useless), rather
than point us at some web external site archive of a list posting
which we cannot easily quote and reply to here.

I think you cannot do it, really.  Except in the AF_PACKET case, the
sockets can only see "0" or a negative error code, not the actual
sk_run_filter() return value.

In the one exception, AF_PACKET, the range of values the user can
see are in the range of MTU of the device being accessed, which
realistically is 1500 bytes.  This means the user cannot see any
kernel stack value outside of the range 0 to 1500, which isn't
worth using this expensive memset to guard against at all.

I don't even think it's worth adding all of the extra cpu cycles
incurred by Eric Dumazet's scheme of using a bitmap test on every
single memory buffer access.

^ permalink raw reply	[flat|nested] 27+ messages in thread
* Re: [PATCH] Prevent reading uninitialized memory with socketfilters
@ 2010-11-10 18:25 Dan Rosenberg
  0 siblings, 0 replies; 27+ messages in thread
From: Dan Rosenberg @ 2010-11-10 18:25 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, stable, security

Apologies for the terseness, I'm not looking for a fight.

I agree the memset is too expensive, and that Eric's fix is far better.

-Dan

------Original Message------
From: David Miller
To: drosenberg@vsecurity.com
Cc: netdev@vger.kernel.org
Cc: stable@kernel.org
Cc: security@kernel.org
Subject: Re: [PATCH] Prevent reading uninitialized memory with socketfilters
Sent: Nov 10, 2010 1:21 PM

From: "Dan Rosenberg" <drosenberg@vsecurity.com>
Date: Wed, 10 Nov 2010 18:18:08 +0000

> The code sample I linked to clearly demonstrates exactly how to
> accomplish this, if you had bothered to read it.

I told you why I didn't read it, if you had bothered to read my
reply properly :-)

Anyways, I realize we have to do something, but memset() is going
to completely kill performance.  I consider Eric's suggestion the
closest to acceptable cost at this point but even that is hard
to digest for me.


^ permalink raw reply	[flat|nested] 27+ messages in thread
* [PATCH] Prevent reading uninitialized memory with socket filters
@ 2010-11-09 22:28 Dan Rosenberg
  2010-11-10  5:28 ` David Miller
  0 siblings, 1 reply; 27+ messages in thread
From: Dan Rosenberg @ 2010-11-09 22:28 UTC (permalink / raw)
  To: netdev; +Cc: stable, security

The "mem" array used as scratch space for socket filters is not
initialized, allowing unprivileged users to leak kernel stack bytes.

Signed-off-by: Dan Rosenberg <drosenberg@vsecurity.com>

---
 net/core/filter.c               |    2 ++
 1 file changed, 2 insertions(+), 0 deletions(-)

diff --git a/net/core/filter.c b/net/core/filter.c
index 7beaec3..2749ba0 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -121,6 +121,8 @@ unsigned int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int
 	int k;
 	int pc;
 
+	memset(mem, 0, sizeof(mem));
+
 	/*
 	 * Process array of filter instructions.
 	 */



^ permalink raw reply related	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2010-11-18 18:58 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-10 18:18 [PATCH] Prevent reading uninitialized memory with socketfilters Dan Rosenberg
2010-11-10 18:21 ` David Miller
2010-11-10 18:33   ` Eric Dumazet
2010-11-10 18:38     ` David Miller
2010-11-16 13:08       ` [PATCH] filter: Optimize instruction revalidation code Tetsuo Handa
2010-11-16 13:11         ` Michael Tokarev
2010-11-16 13:44         ` Eric Dumazet
2010-11-16 14:31           ` [PATCH v2] " Tetsuo Handa
2010-11-16 16:30             ` Eric Dumazet
2010-11-17  1:19               ` [PATCH v3] " Tetsuo Handa
2010-11-17  7:48                 ` Eric Dumazet
2010-11-17  7:54                   ` Changli Gao
2010-11-17  8:18                     ` Eric Dumazet
2010-11-17  8:06                   ` Tetsuo Handa
2010-11-17  9:01                     ` Hagen Paul Pfeifer
2010-11-18 18:58                 ` David Miller
2010-11-16 22:13         ` [PATCH] " Hagen Paul Pfeifer
2010-11-16 23:31           ` Changli Gao
2010-11-16 23:45             ` Hagen Paul Pfeifer
2010-11-16 23:24         ` Changli Gao
  -- strict thread matches above, loose matches on Subject: below --
2010-11-10 18:25 [PATCH] Prevent reading uninitialized memory with socketfilters Dan Rosenberg
2010-11-09 22:28 [PATCH] Prevent reading uninitialized memory with socket filters Dan Rosenberg
2010-11-10  5:28 ` David Miller
2010-11-10  5:53   ` Eric Dumazet
2010-11-10  7:22     ` Eric Dumazet
2010-11-10 14:25       ` [PATCH] Prevent reading uninitialized memory with socketfilters Tetsuo Handa
2010-11-10 18:32         ` David Miller
2010-11-10 18:39         ` David Miller
2010-11-10 20:57           ` Ben Hutchings
2010-11-10 20:59             ` David Miller
2010-11-10 21:25               ` Ben Hutchings

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).