Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-8]: src/sys/netinet Pull up following revision(s) (requested by c...



details:   https://anonhg.NetBSD.org/src/rev/cff4850e9e19
branches:  netbsd-8
changeset: 935640:cff4850e9e19
user:      martin <martin%NetBSD.org@localhost>
date:      Tue Jul 07 11:56:57 2020 +0000

description:
Pull up following revision(s) (requested by christos in ticket #1566):

        sys/netinet/tcp_input.c: revision 1.418 (via patch)

- always set both ip and ip6, otherwise a kernel assertion can be triggered
- move alignment early so that we do less work

diffstat:

 sys/netinet/tcp_input.c |  46 +++++++++++++++++++++-------------------------
 1 files changed, 21 insertions(+), 25 deletions(-)

diffs (97 lines):

diff -r b648d3a02fe3 -r cff4850e9e19 sys/netinet/tcp_input.c
--- a/sys/netinet/tcp_input.c   Tue Jul 07 10:44:11 2020 +0000
+++ b/sys/netinet/tcp_input.c   Tue Jul 07 11:56:57 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tcp_input.c,v 1.357.4.3 2018/03/30 11:17:19 martin Exp $       */
+/*     $NetBSD: tcp_input.c,v 1.357.4.4 2020/07/07 11:56:57 martin Exp $       */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -148,7 +148,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.357.4.3 2018/03/30 11:17:19 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.357.4.4 2020/07/07 11:56:57 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1273,16 +1273,32 @@
 #endif
 
        /*
+        * Enforce alignment requirements that are violated in
+        * some cases, see kern/50766 for details.
+        */
+       if (TCP_HDR_ALIGNED_P(th) == 0) {
+               m = m_copyup(m, toff + sizeof(struct tcphdr), 0);
+               if (m == NULL) {
+                       TCP_STATINC(TCP_STAT_RCVSHORT);
+                       return;
+               }
+               th = (struct tcphdr *)(mtod(m, char *) + toff);
+       }
+       KASSERT(TCP_HDR_ALIGNED_P(th));
+
+       /*
         * Get IP and TCP header.
         * Note: IP leaves IP header in first mbuf.
         */
+#ifdef INET6
+       ip6 = mtod(m, struct ip6_hdr *);
+#endif
+#ifdef INET
        ip = mtod(m, struct ip *);
+#endif
        switch (ip->ip_v) {
 #ifdef INET
        case 4:
-#ifdef INET6
-               ip6 = NULL;
-#endif
                af = AF_INET;
                iphlen = sizeof(struct ip);
                IP6_EXTHDR_GET(th, struct tcphdr *, m, toff,
@@ -1299,10 +1315,8 @@
 #endif
 #ifdef INET6
        case 6:
-               ip = NULL;
                iphlen = sizeof(struct ip6_hdr);
                af = AF_INET6;
-               ip6 = mtod(m, struct ip6_hdr *);
                IP6_EXTHDR_GET(th, struct tcphdr *, m, toff,
                        sizeof(struct tcphdr));
                if (th == NULL) {
@@ -1349,23 +1363,6 @@
                m_freem(m);
                return;
        }
-       /*
-         * Enforce alignment requirements that are violated in
-        * some cases, see kern/50766 for details.
-        */
-       if (TCP_HDR_ALIGNED_P(th) == 0) {
-               m = m_copyup(m, toff + sizeof(struct tcphdr), 0);
-               if (m == NULL) {
-                       TCP_STATINC(TCP_STAT_RCVSHORT);
-                       return;
-               }
-               ip = mtod(m, struct ip *);
-#ifdef INET6
-               ip6 = mtod(m, struct ip6_hdr *);
-#endif
-               th = (struct tcphdr *)(mtod(m, char *) + toff);
-       }
-       KASSERT(TCP_HDR_ALIGNED_P(th));
 
        /*
         * Check that TCP offset makes sense,
@@ -1601,7 +1598,6 @@
                        m_freem(in6p->in6p_options);
                        in6p->in6p_options = 0;
                }
-               KASSERT(ip6 != NULL);
                ip6_savecontrol(in6p, &in6p->in6p_options, ip6, m);
        }
 #endif



Home | Main Index | Thread Index | Old Index