aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/raw.c
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2013-08-02 09:51:34 -0400
committerDavid S. Miller <davem@davemloft.net>2013-08-02 18:15:50 -0400
commitd1c53c8e870cdedb6fc9550f41c558bab45b5219 (patch)
treeb740b4b81c96ec056aec738cb59ed5c003d329a2 /net/ipv6/raw.c
parent9cc08af3a1d9d1687cb2ad6063ac1552ec2f695a (diff)
icmpv6_filter: allow ICMPv6 messages with bodies < 4 bytes
By using sizeof(_hdr), net/ipv6/raw.c:icmpv6_filter implicitly assumes that any valid ICMPv6 message is at least eight bytes long, i.e., that the message body is at least four bytes. The DIS message of RPL (RFC 6550 section 6.2, from the 6LoWPAN world), has a minimum length of only six bytes, and is thus blocked by icmpv6_filter. RFC 4443 seems to allow even a zero-sized body, making the minimum allowable message size four bytes. Signed-off-by: Werner Almesberger <werner@almesberger.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/raw.c')
-rw-r--r--net/ipv6/raw.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index 164fb5f58641..c1e533498203 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -63,6 +63,8 @@
63#include <linux/seq_file.h> 63#include <linux/seq_file.h>
64#include <linux/export.h> 64#include <linux/export.h>
65 65
66#define ICMPV6_HDRLEN 4 /* ICMPv6 header, RFC 4443 Section 2.1 */
67
66static struct raw_hashinfo raw_v6_hashinfo = { 68static struct raw_hashinfo raw_v6_hashinfo = {
67 .lock = __RW_LOCK_UNLOCKED(raw_v6_hashinfo.lock), 69 .lock = __RW_LOCK_UNLOCKED(raw_v6_hashinfo.lock),
68}; 70};
@@ -111,8 +113,11 @@ static int icmpv6_filter(const struct sock *sk, const struct sk_buff *skb)
111 struct icmp6hdr _hdr; 113 struct icmp6hdr _hdr;
112 const struct icmp6hdr *hdr; 114 const struct icmp6hdr *hdr;
113 115
116 /* We require only the four bytes of the ICMPv6 header, not any
117 * additional bytes of message body in "struct icmp6hdr".
118 */
114 hdr = skb_header_pointer(skb, skb_transport_offset(skb), 119 hdr = skb_header_pointer(skb, skb_transport_offset(skb),
115 sizeof(_hdr), &_hdr); 120 ICMPV6_HDRLEN, &_hdr);
116 if (hdr) { 121 if (hdr) {
117 const __u32 *data = &raw6_sk(sk)->filter.data[0]; 122 const __u32 *data = &raw6_sk(sk)->filter.data[0];
118 unsigned int type = hdr->icmp6_type; 123 unsigned int type = hdr->icmp6_type;