git: bbbe18b31795 - stable/12 - pfsync: NULL check sc before using it
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 13 Dec 2021 13:50:35 UTC
The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=bbbe18b317956f3e0d87a277acc1941222fa8eb9 commit bbbe18b317956f3e0d87a277acc1941222fa8eb9 Author: Kristof Provost <kp@FreeBSD.org> AuthorDate: 2021-12-02 13:32:21 +0000 Commit: Kristof Provost <kp@FreeBSD.org> CommitDate: 2021-12-13 08:54:15 +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 8feaea615867..d6016766ddcc 100644 --- a/sys/netpfil/pf/if_pfsync.c +++ b/sys/netpfil/pf/if_pfsync.c @@ -1741,9 +1741,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);