Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Sep 2021 13:09:20 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: b1e6a792d68e - main - net: Enter a net epoch around protocol if_up/down notifications
Message-ID:  <202109101309.18AD9Kl9048375@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by markj:

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

commit b1e6a792d68e9c59740d5e925405d8d4343d099b
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2021-09-10 13:07:40 +0000
Commit:     Mark Johnston <markj@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+3219af764ead146a3a4e@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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202109101309.18AD9Kl9048375>