]> git.baikalelectronics.ru Git - kernel.git/commit
filter: make sure filters dont read uninitialized memory
authorDavid S. Miller <davem@davemloft.net>
Wed, 10 Nov 2010 18:38:24 +0000 (10:38 -0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 10 Nov 2010 18:38:24 +0000 (10:38 -0800)
commit09e8e0b1738980504695c8d07a80d8cbccaa8558
tree12648abf4c941275e5a12a8416e8fa6a92276753
parent8633de00a719c8d7e88e737569be744f9877fd94
filter: make sure filters dont read uninitialized memory

There is a possibility malicious users can get limited information about
uninitialized stack mem array. Even if sk_run_filter() result is bound
to packet length (0 .. 65535), we could imagine this can be used by
hostile user.

Initializing mem[] array, like Dan Rosenberg suggested in his patch is
expensive since most filters dont even use this array.

Its hard to make the filter validation in sk_chk_filter(), because of
the jumps. This might be done later.

In this patch, I use a bitmap (a single long var) so that only filters
using mem[] loads/stores pay the price of added security checks.

For other filters, additional cost is a single instruction.

[ Since we access fentry->k a lot now, cache it in a local variable
  and mark filter entry pointer as const. -DaveM ]

Reported-by: Dan Rosenberg <drosenberg@vsecurity.com>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/filter.c