Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1e98a0f0 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller
Browse files

flow_dissector: fix ipv6 dst, hop-by-hop and routing ext hdrs



__skb_header_pointer() returns a pointer that must be checked.

Fixes infinite loop reported by Alexei, and add __must_check to
catch these errors earlier.

Fixes: 6a74fcf4 ("flow_dissector: add support for dst, hop-by-hop and routing ext hdrs")
Reported-by: default avatarAlexei Starovoitov <alexei.starovoitov@gmail.com>
Tested-by: default avatarAlexei Starovoitov <alexei.starovoitov@gmail.com>
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Acked-by: default avatarTom Herbert <tom@herbertland.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5b173cf9
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -2743,7 +2743,8 @@ __wsum __skb_checksum(const struct sk_buff *skb, int offset, int len,
__wsum skb_checksum(const struct sk_buff *skb, int offset, int len,
		    __wsum csum);

static inline void *__skb_header_pointer(const struct sk_buff *skb, int offset,
static inline void * __must_check
__skb_header_pointer(const struct sk_buff *skb, int offset,
		     int len, void *data, int hlen, void *buffer)
{
	if (hlen - offset >= len)
@@ -2756,8 +2757,8 @@ static inline void *__skb_header_pointer(const struct sk_buff *skb, int offset,
	return buffer;
}

static inline void *skb_header_pointer(const struct sk_buff *skb, int offset,
				       int len, void *buffer)
static inline void * __must_check
skb_header_pointer(const struct sk_buff *skb, int offset, int len, void *buffer)
{
	return __skb_header_pointer(skb, offset, len, skb->data,
				    skb_headlen(skb), buffer);
+4 −2
Original line number Diff line number Diff line
@@ -394,9 +394,11 @@ bool __skb_flow_dissect(const struct sk_buff *skb,

		opthdr = __skb_header_pointer(skb, nhoff, sizeof(_opthdr),
					      data, hlen, &_opthdr);
		if (!opthdr)
			return false;

		ip_proto = _opthdr[0];
		nhoff += (_opthdr[1] + 1) << 3;
		ip_proto = opthdr[0];
		nhoff += (opthdr[1] + 1) << 3;

		goto ip_proto_again;
	}