Skip to content

Commit

Permalink
pfsync: add missing unlock in pfsync_defer_tmo()
Browse files Browse the repository at this point in the history
The callout for pfsync_defer_tmo() is created with
CALLOUT_RETURNUNLOCKED, because while the callout framework takes care
of taking the lock we want to run a few operations outside of the lock,
so we unlock ourselves.

However, if `sc->sc_sync_if == NULL` we return without releasing the
lock, and leak the lock, causing later deadlocks.
Ensure we always release the bucket lock when we exit pfsync_defer_tmo()

PR:		268246
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC (Netgate)

(cherry picked from commit 844ad28)
  • Loading branch information
kprovost authored and fichtner committed Mar 28, 2023
1 parent cb0917a commit 85724e9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sys/netpfil/pf/if_pfsync.c
Original file line number Diff line number Diff line change
Expand Up @@ -1830,8 +1830,10 @@ pfsync_defer_tmo(void *arg)

PFSYNC_BUCKET_LOCK_ASSERT(b);

if (sc->sc_sync_if == NULL)
if (sc->sc_sync_if == NULL) {
PFSYNC_BUCKET_UNLOCK(b);
return;
}

NET_EPOCH_ENTER(et);
CURVNET_SET(sc->sc_sync_if->if_vnet);
Expand Down

0 comments on commit 85724e9

Please sign in to comment.