Skip to content

Commit 4d5968e

Browse files
JordyZomergregkh
authored andcommitted
ipv6: check return value of ipv6_skip_exthdr
[ Upstream commit 5f9c55c ] The offset value is used in pointer math on skb->data. Since ipv6_skip_exthdr may return -1 the pointer to uh and th may not point to the actual udp and tcp headers and potentially overwrite other stuff. This is why I think this should be checked. EDIT: added {}'s, thanks Kees Signed-off-by: Jordy Zomer <jordy@pwning.systems> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 22519ef commit 4d5968e

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎net/ipv6/esp6.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,12 @@ int esp6_input_done2(struct sk_buff *skb, int err)
808808
struct tcphdr *th;
809809

810810
offset = ipv6_skip_exthdr(skb, offset, &nexthdr, &frag_off);
811+
812+
if (offset < 0) {
813+
err = -EINVAL;
814+
goto out;
815+
}
816+
811817
uh = (void *)(skb->data + offset);
812818
th = (void *)(skb->data + offset);
813819
hdr_len += offset;

0 commit comments

Comments
 (0)