Fix mbuf leak when an interface is destroyed while forwarding IPv6
authormpi <mpi@openbsd.org>
Tue, 28 Nov 2017 15:32:51 +0000 (15:32 +0000)
committermpi <mpi@openbsd.org>
Tue, 28 Nov 2017 15:32:51 +0000 (15:32 +0000)
packets.

Found by Hrvoje Popovski.

ok visa@, bluhm@

sys/netinet6/ip6_forward.c

index b2b6e46..b254756 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ip6_forward.c,v 1.96 2017/11/21 12:05:09 mpi Exp $    */
+/*     $OpenBSD: ip6_forward.c,v 1.97 2017/11/28 15:32:51 mpi Exp $    */
 /*     $KAME: ip6_forward.c,v 1.75 2001/06/29 12:42:13 jinmei Exp $    */
 
 /*
@@ -240,8 +240,10 @@ reroute:
         * modified by a redirect.
         */
        ifp = if_get(rt->rt_ifidx);
-       if (ifp == NULL)
+       if (ifp == NULL) {
+               m_freem(m);
                goto freecopy;
+       }
        if (rt->rt_ifidx == m->m_pkthdr.ph_ifidx && !srcrt &&
            ip6_sendredirects &&
            (rt->rt_flags & (RTF_DYNAMIC|RTF_MODIFIED)) == 0) {