aboutsummaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2010-12-07 17:26:15 -0500
committerDavid S. Miller <davem@davemloft.net>2010-12-09 23:47:04 -0500
commit4bc65dd8d88671712d71592a83374cfb0b5fce7a (patch)
tree322b1618fabdc770b8a63930ab5c320a16fe5cc5 /net/core
parent60d509c823cca21e77d537bd356785f7cfe8f0d1 (diff)
filter: use size of fetched data in __load_pointer()
__load_pointer() checks data we fetch from skb is included in head portion, but assumes we fetch one byte, instead of up to four. This wont crash because we have extra bytes (struct skb_shared_info) after head, but this can read uninitialized bytes. Fix this using size of the data (1, 2, 4 bytes) in the test. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/filter.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/net/core/filter.c b/net/core/filter.c
index e193e29d4671..e8a6ac411ffb 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -88,7 +88,7 @@ enum {
88}; 88};
89 89
90/* No hurry in this branch */ 90/* No hurry in this branch */
91static void *__load_pointer(const struct sk_buff *skb, int k) 91static void *__load_pointer(const struct sk_buff *skb, int k, unsigned int size)
92{ 92{
93 u8 *ptr = NULL; 93 u8 *ptr = NULL;
94 94
@@ -97,7 +97,7 @@ static void *__load_pointer(const struct sk_buff *skb, int k)
97 else if (k >= SKF_LL_OFF) 97 else if (k >= SKF_LL_OFF)
98 ptr = skb_mac_header(skb) + k - SKF_LL_OFF; 98 ptr = skb_mac_header(skb) + k - SKF_LL_OFF;
99 99
100 if (ptr >= skb->head && ptr < skb_tail_pointer(skb)) 100 if (ptr >= skb->head && ptr + size <= skb_tail_pointer(skb))
101 return ptr; 101 return ptr;
102 return NULL; 102 return NULL;
103} 103}
@@ -110,7 +110,7 @@ static inline void *load_pointer(const struct sk_buff *skb, int k,
110 else { 110 else {
111 if (k >= SKF_AD_OFF) 111 if (k >= SKF_AD_OFF)
112 return NULL; 112 return NULL;
113 return __load_pointer(skb, k); 113 return __load_pointer(skb, k, size);
114 } 114 }
115} 115}
116 116