Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F145517210
D55410.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D55410.diff
View Options
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -575,7 +575,7 @@
#endif
struct udphdr *uh;
struct tcphdr *th;
- int thlen;
+ int len, thlen;
uint16_t port;
TCPSTAT_INC(tcps_tunneled_pkts);
@@ -619,15 +619,27 @@
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:
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Feb 21, 9:17 PM (4 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28927524
Default Alt Text
D55410.diff (1 KB)
Attached To
Mode
D55410: tcp: improve validation of received TCP over UDP packets
Attached
Detach File
Event Timeline
Log In to Comment