git: 27bd812c5c92 - main - pfsync: NULL check sc before using it
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 06 Dec 2021 12:25:44 UTC
The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=27bd812c5c92af9e7acdbf100bd98166a717bb76 commit 27bd812c5c92af9e7acdbf100bd98166a717bb76 Author: Kristof Provost <kp@FreeBSD.org> AuthorDate: 2021-12-02 13:32:21 +0000 Commit: Kristof Provost <kp@FreeBSD.org> CommitDate: 2021-12-06 12:25:13 +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 --- 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 1aa5e6c0b066..166ac428fd9b 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);