diff options
Diffstat (limited to 'net/ipv4/raw.c')
-rw-r--r-- | net/ipv4/raw.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c index f2425785d40a..a80740ba4248 100644 --- a/net/ipv4/raw.c +++ b/net/ipv4/raw.c | |||
@@ -131,18 +131,23 @@ found: | |||
131 | * 0 - deliver | 131 | * 0 - deliver |
132 | * 1 - block | 132 | * 1 - block |
133 | */ | 133 | */ |
134 | static __inline__ int icmp_filter(struct sock *sk, struct sk_buff *skb) | 134 | static int icmp_filter(const struct sock *sk, const struct sk_buff *skb) |
135 | { | 135 | { |
136 | int type; | 136 | struct icmphdr _hdr; |
137 | 137 | const struct icmphdr *hdr; | |
138 | if (!pskb_may_pull(skb, sizeof(struct icmphdr))) | 138 | |
139 | pr_err("icmp_filter skb_transport_offset %d data-head %ld len %d/%d\n", | ||
140 | skb_transport_offset(skb), skb->data - skb->head, skb->len, skb->data_len); | ||
141 | hdr = skb_header_pointer(skb, skb_transport_offset(skb), | ||
142 | sizeof(_hdr), &_hdr); | ||
143 | pr_err("head %p data %p hdr %p type %d\n", skb->head, skb->data, hdr, hdr ? hdr->type : -1); | ||
144 | if (!hdr) | ||
139 | return 1; | 145 | return 1; |
140 | 146 | ||
141 | type = icmp_hdr(skb)->type; | 147 | if (hdr->type < 32) { |
142 | if (type < 32) { | ||
143 | __u32 data = raw_sk(sk)->filter.data; | 148 | __u32 data = raw_sk(sk)->filter.data; |
144 | 149 | ||
145 | return ((1 << type) & data) != 0; | 150 | return ((1U << hdr->type) & data) != 0; |
146 | } | 151 | } |
147 | 152 | ||
148 | /* Do not block unknown ICMP types */ | 153 | /* Do not block unknown ICMP types */ |