Date: Thu, 21 May 2026 21:21:54 +0000 From: Colin Percival <cperciva@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Michael Tuexen <tuexen@FreeBSD.org> Subject: git: 8562c6727343 - releng/15.1 - tcp: improve validation of received TCP over UDP packets Message-ID: <6a0f7772.1c590.104fb2@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch releng/15.1 has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=8562c67273436b04ec966e9d8a5a872ea507af2d commit 8562c67273436b04ec966e9d8a5a872ea507af2d Author: Michael Tuexen <tuexen@FreeBSD.org> AuthorDate: 2026-02-20 21:21:37 +0000 Commit: Colin Percival <cperciva@FreeBSD.org> CommitDate: 2026-05-21 21:20:58 +0000 tcp: improve validation of received TCP over UDP packets Approved by: re (cperciva) Reviewed by: glebius, pouria Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D55410 (cherry picked from commit e1886559ea477add82a0a86cddf728f6778f1603) (cherry picked from commit ede0f15e03e0a172493cd20d1dd2d88b1711156f) --- sys/netinet/tcp_subr.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index 7152e8ad600c..9a227218c525 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -579,7 +579,7 @@ tcp_recv_udp_tunneled_packet(struct mbuf *m, int off, struct inpcb *inp, #endif struct udphdr *uh; struct tcphdr *th; - int thlen; + int len, thlen; uint16_t port; TCPSTAT_INC(tcps_tunneled_pkts); @@ -623,15 +623,27 @@ tcp_recv_udp_tunneled_packet(struct mbuf *m, int off, struct inpcb *inp, switch (iph->ip_v) { #ifdef INET case IPVERSION: - iph->ip_len = htons(ntohs(iph->ip_len) - sizeof(struct udphdr)); - tcp_input_with_port(&m, &off, IPPROTO_TCP, port); + len = ntohs(iph->ip_len) - sizeof(struct udphdr); + if (len != m->m_pkthdr.len) { + TCPSTAT_INC(tcps_tunneled_errs); + goto out; + } else { + iph->ip_len = htons(len); + tcp_input_with_port(&m, &off, IPPROTO_TCP, port); + } break; #endif #ifdef INET6 case IPV6_VERSION >> 4: ip6 = mtod(m, struct ip6_hdr *); - ip6->ip6_plen = htons(ntohs(ip6->ip6_plen) - sizeof(struct udphdr)); - tcp6_input_with_port(&m, &off, IPPROTO_TCP, port); + len = ntohs(ip6->ip6_plen) - sizeof(struct udphdr); + if (len + sizeof(struct ip6_hdr) != m->m_pkthdr.len) { + TCPSTAT_INC(tcps_tunneled_errs); + goto out; + } else { + ip6->ip6_plen = htons(len); + tcp6_input_with_port(&m, &off, IPPROTO_TCP, port); + } break; #endif default:home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a0f7772.1c590.104fb2>
