tech-net archive

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

Re: m_copym() panics possibly due to pfil hook?



Scratch that prior patch, it doesn't fix the problem for IPv6.

Darren

*** ip_fil_netbsd.c.orig     26 Jan 2012 06:03:43 -0000      2.55.2.71
--- ip_fil_netbsd.c     5 Jun 2012 18:02:12 -0000
***************
*** 170,175 ****
--- 170,176 ----
  struct ifnet *ifp;
  int dir;
  {
+       struct mbuf *m;
        struct ip *ip;
        int rv, hlen;

***************
*** 220,230 ****
        NTOHS(ip->ip_off);

        rv = fr_check(ip, hlen, ifp, (dir == PFIL_OUT), mp);
!
!       if (rv == 0 && *mp != NULL) {
!               ip = mtod(*mp, struct ip *);
!               HTONS(ip->ip_len);
!               HTONS(ip->ip_off);
        }

        return (rv);
--- 221,236 ----
        NTOHS(ip->ip_off);

        rv = fr_check(ip, hlen, ifp, (dir == PFIL_OUT), mp);
!       if ((rv == 0) && ((m = *mp) != NULL)) {
!               if (m->m_len < hlen) {
!                       m = m_pullup(m, hlen);
!                       *mp = m;
!                       if (m != NULL) {
!                               ip = mtod(m, struct ip *);
!                               HTONS(ip->ip_len);
!                               HTONS(ip->ip_off);
!                       }
!               }
        }

        return (rv);
***************
*** 241,246 ****
--- 247,255 ----
  struct ifnet *ifp;
  int dir;
  {
+       struct mbuf *m;
+       int rv;
+
  #  if defined(M_CSUM_TCPv6) && (__NetBSD_Version__ > 200000000)
        /*
         * If the packet is out-bound, we can't delay checksums
***************
*** 258,265 ****
        }
  #  endif

!       return (fr_check(mtod(*mp, struct ip *), sizeof(struct ip6_hdr),
            ifp, (dir == PFIL_OUT), mp));
  }
  # endif

--- 267,279 ----
        }
  #  endif

!       rv = fr_check(mtod(*mp, struct ip *), sizeof(struct ip6_hdr),
            ifp, (dir == PFIL_OUT), mp));
+       if ((rv == 0) && ((m = *mp) != NULL)) {
+               if (m->m_len < sizeof(struct ip6_hdr))
+                       *mp = m_pullup(m, sizeof(struct ip6_hdr));
+       }
+       return rv;
  }
  # endif



Home | Main Index | Thread Index | Old Index