public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ipv6: check return value of ipv6_skip_exthdr
@ 2021-11-17 18:16 Jordy Zomer
  2021-11-17 18:44 ` Kees Cook
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Jordy Zomer @ 2021-11-17 18:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-hardening, Jordy Zomer, Steffen Klassert, Herbert Xu,
	David S. Miller, Hideaki YOSHIFUJI, David Ahern, Jakub Kicinski,
	netdev

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.

Signed-off-by: Jordy Zomer <jordy@pwning.systems>
---
 net/ipv6/esp6.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index ed2f061b8768..dc4251655df9 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -808,6 +808,11 @@ int esp6_input_done2(struct sk_buff *skb, int err)
 		struct tcphdr *th;
 
 		offset = ipv6_skip_exthdr(skb, offset, &nexthdr, &frag_off);
+
+		if (offset < 0)
+			err = -EINVAL;
+			goto out;
+
 		uh = (void *)(skb->data + offset);
 		th = (void *)(skb->data + offset);
 		hdr_len += offset;
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-11-18 11:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-17 18:16 [PATCH] ipv6: check return value of ipv6_skip_exthdr Jordy Zomer
2021-11-17 18:44 ` Kees Cook
2021-11-17 18:46 ` Kees Cook
2021-11-17 19:06 ` [PATCH v2] " Jordy Zomer
2021-11-18 11:50   ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox