The branch main has been updated by markj:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=b1e6a792d68e9c59740d5e925405d8d4343d099b

commit b1e6a792d68e9c59740d5e925405d8d4343d099b
Author:     Mark Johnston <ma...@freebsd.org>
AuthorDate: 2021-09-10 13:07:40 +0000
Commit:     Mark Johnston <ma...@freebsd.org>
CommitDate: 2021-09-10 13:07:40 +0000

    net: Enter a net epoch around protocol if_up/down notifications
    
    When traversing a list of interface addresses, we need to be in a net
    epoch section, and protocol ctlinput routines need a stable reference to
    the address.
    
    Reported by:    syzbot+3219af764ead146a3...@syzkaller.appspotmail.com
    Reviewed by:    kp, melifaro
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D31889
---
 sys/kern/uipc_domain.c | 2 ++
 sys/net/if.c           | 6 ++++++
 2 files changed, 8 insertions(+)

diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c
index d572e0ec19db..9092ff335eb0 100644
--- a/sys/kern/uipc_domain.c
+++ b/sys/kern/uipc_domain.c
@@ -516,6 +516,8 @@ pfctlinput(int cmd, struct sockaddr *sa)
        struct domain *dp;
        struct protosw *pr;
 
+       NET_EPOCH_ASSERT();
+
        for (dp = domains; dp; dp = dp->dom_next)
                for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
                        if (pr->pr_ctlinput)
diff --git a/sys/net/if.c b/sys/net/if.c
index 8d2a66471836..83a0b07805ee 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -2195,14 +2195,17 @@ static void
 if_unroute(struct ifnet *ifp, int flag, int fam)
 {
        struct ifaddr *ifa;
+       struct epoch_tracker et;
 
        KASSERT(flag == IFF_UP, ("if_unroute: flag != IFF_UP"));
 
        ifp->if_flags &= ~flag;
        getmicrotime(&ifp->if_lastchange);
+       NET_EPOCH_ENTER(et);
        CK_STAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link)
                if (fam == PF_UNSPEC || (fam == ifa->ifa_addr->sa_family))
                        pfctlinput(PRC_IFDOWN, ifa->ifa_addr);
+       NET_EPOCH_EXIT(et);
        ifp->if_qflush(ifp);
 
        if (ifp->if_carp)
@@ -2218,14 +2221,17 @@ static void
 if_route(struct ifnet *ifp, int flag, int fam)
 {
        struct ifaddr *ifa;
+       struct epoch_tracker et;
 
        KASSERT(flag == IFF_UP, ("if_route: flag != IFF_UP"));
 
        ifp->if_flags |= flag;
        getmicrotime(&ifp->if_lastchange);
+       NET_EPOCH_ENTER(et);
        CK_STAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link)
                if (fam == PF_UNSPEC || (fam == ifa->ifa_addr->sa_family))
                        pfctlinput(PRC_IFUP, ifa->ifa_addr);
+       NET_EPOCH_EXIT(et);
        if (ifp->if_carp)
                (*carp_linkstate_p)(ifp);
        rt_ifmsg(ifp);
_______________________________________________
dev-commits-src-main@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main
To unsubscribe, send any mail to "dev-commits-src-main-unsubscr...@freebsd.org"

Reply via email to