Source-Changes-HG archive

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

[src/trunk]: src/sys/netipsec Don't assume M_PKTHDR is set only on the first ...



details:   https://anonhg.NetBSD.org/src/rev/cdbf1fecd111
branches:  trunk
changeset: 322083:cdbf1fecd111
user:      maxv <maxv%NetBSD.org@localhost>
date:      Tue Apr 17 06:23:30 2018 +0000

description:
Don't assume M_PKTHDR is set only on the first mbuf of the chain. It
should, but it looks like there are several places that can put M_PKTHDR
on secondary mbufs (PR/53189), so drop this assumption right now to
prevent further bugs.

The check is replaced by (m1 != m), which is equivalent to the previous
code: we want to modify m->m_pkthdr.len only when 'm' was not passed in
m_adj().

diffstat:

 sys/netipsec/ipsec_mbuf.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (36 lines):

diff -r fcafbea5e8b6 -r cdbf1fecd111 sys/netipsec/ipsec_mbuf.c
--- a/sys/netipsec/ipsec_mbuf.c Tue Apr 17 05:23:58 2018 +0000
+++ b/sys/netipsec/ipsec_mbuf.c Tue Apr 17 06:23:30 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ipsec_mbuf.c,v 1.22 2018/03/10 17:52:50 maxv Exp $     */
+/*     $NetBSD: ipsec_mbuf.c,v 1.23 2018/04/17 06:23:30 maxv Exp $     */
 
 /*
  * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ipsec_mbuf.c,v 1.22 2018/03/10 17:52:50 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec_mbuf.c,v 1.23 2018/04/17 06:23:30 maxv Exp $");
 
 /*
  * IPsec-specific mbuf routines.
@@ -400,7 +400,7 @@
                /* The header was at the beginning of the mbuf */
                IPSEC_STATINC(IPSEC_STAT_INPUT_FRONT);
                m_adj(m1, hlen);
-               if ((m1->m_flags & M_PKTHDR) == 0)
+               if (m1 != m)
                        m->m_pkthdr.len -= hlen;
        } else if (roff + hlen >= m1->m_len) {
                struct mbuf *mo;
@@ -425,7 +425,7 @@
 
                /* ...and trim the end of the first part of the chain...sick */
                m_adj(m1, -(m1->m_len - roff));
-               if ((m1->m_flags & M_PKTHDR) == 0)
+               if (m1 != m)
                        m->m_pkthdr.len -= (m1->m_len - roff);
 
                /* Finally, let's relink */



Home | Main Index | Thread Index | Old Index