git: 9a663b668c05 - stable/13 - pfsync: NULL check sc before using it
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 13 Dec 2021 13:50:34 UTC
The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=9a663b668c05ceca0d5bc99665166e11b00c3420 commit 9a663b668c05ceca0d5bc99665166e11b00c3420 Author: Kristof Provost <kp@FreeBSD.org> AuthorDate: 2021-12-02 13:32:21 +0000 Commit: Kristof Provost <kp@FreeBSD.org> CommitDate: 2021-12-13 13:49:27 +0000 pfsync: NULL check sc before using it In pfsync_defer() we must wait to lock sc until we've ensured it's not NULL. MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D33240 (cherry picked from commit 27bd812c5c92af9e7acdbf100bd98166a717bb76) --- sys/netpfil/pf/if_pfsync.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sys/netpfil/pf/if_pfsync.c b/sys/netpfil/pf/if_pfsync.c index 7208444d65d7..9b760f63e134 100644 --- a/sys/netpfil/pf/if_pfsync.c +++ b/sys/netpfil/pf/if_pfsync.c @@ -1739,9 +1739,12 @@ pfsync_defer(struct pf_kstate *st, struct mbuf *m) if (m->m_flags & (M_BCAST|M_MCAST)) return (0); + if (sc == NULL) + return (0); + PFSYNC_LOCK(sc); - if (sc == NULL || !(sc->sc_ifp->if_flags & IFF_DRV_RUNNING) || + if (!(sc->sc_ifp->if_flags & IFF_DRV_RUNNING) || !(sc->sc_flags & PFSYNCF_DEFER)) { PFSYNC_UNLOCK(sc); return (0);