Skip to content

Commit

Permalink
filter: use size of fetched data in __load_pointer()
Browse files Browse the repository at this point in the history
__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>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Dec 10, 2010
1 parent 60d509c commit 4bc65dd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions net/core/filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ enum {
};

/* No hurry in this branch */
static void *__load_pointer(const struct sk_buff *skb, int k)
static void *__load_pointer(const struct sk_buff *skb, int k, unsigned int size)
{
u8 *ptr = NULL;

Expand All @@ -97,7 +97,7 @@ static void *__load_pointer(const struct sk_buff *skb, int k)
else if (k >= SKF_LL_OFF)
ptr = skb_mac_header(skb) + k - SKF_LL_OFF;

if (ptr >= skb->head && ptr < skb_tail_pointer(skb))
if (ptr >= skb->head && ptr + size <= skb_tail_pointer(skb))
return ptr;
return NULL;
}
Expand All @@ -110,7 +110,7 @@ static inline void *load_pointer(const struct sk_buff *skb, int k,
else {
if (k >= SKF_AD_OFF)
return NULL;
return __load_pointer(skb, k);
return __load_pointer(skb, k, size);
}
}

Expand Down

0 comments on commit 4bc65dd

Please sign in to comment.