Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Mar 2023 16:39:30 GMT
From:      Kristof Provost <kp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 844ad2828a35 - main - pfsync: add missing unlock in pfsync_defer_tmo()
Message-ID:  <202303201639.32KGdUXv071187@gitrepo.freebsd.org>

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

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

commit 844ad2828a35c434b893af4274b1f6c50332dd70
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2023-03-20 13:26:33 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2023-03-20 15:39:14 +0000

    pfsync: add missing unlock in pfsync_defer_tmo()
    
    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)
---
 sys/netpfil/pf/if_pfsync.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sys/netpfil/pf/if_pfsync.c b/sys/netpfil/pf/if_pfsync.c
index f1130ba143f1..4c834c7f0315 100644
--- a/sys/netpfil/pf/if_pfsync.c
+++ b/sys/netpfil/pf/if_pfsync.c
@@ -1827,8 +1827,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);



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