From nobody Tue Mar 28 01:18:32 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PlsJS4hW6z42MC2; Tue, 28 Mar 2023 01:18:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PlsJS48tRz4FPg; Tue, 28 Mar 2023 01:18:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679966312; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=e277UKAKcoGSayIYcCjEUESnR4Yyw9leHCJJvYDhJkc=; b=BpzCiUUxaQ2vypree+yWZisPr+en2lMdHlNzHjItR1iGdW8iTVNwNY/wZ3USwD0cTivuqm 2X247W4YN6LLiiuqWMC3docs5at2GwkCgFqbJxW8GuGuFFGJiO9RmJ5nLv/dc0jk206Rxo MAd7Q13bbaHeulfQv/5267kph4qlM/H3nvYIbTfSZuFlomvihy7T+KgrH21ay+8tBNje9N Y6K7GRYqvQflF3BjYu20rWW4jlezS+CQrpmq+L4MxGdxZxxCFVDzGGP/FLz0RUu/PL8+d8 IjBzrqcl4FZ+MFwr58pmSh/pdCnoLHORZLWcoYkvWFlLrmeOSvNstOh3658jdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679966312; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=e277UKAKcoGSayIYcCjEUESnR4Yyw9leHCJJvYDhJkc=; b=ZamHNcGrQFeQjuroSSCPANsTR2Go+v/20nA/krDgwb91eaYX6NhLgDwB4tQgGhylTn9Kmh 7QX5BUxNexpMQKyEkMtGFFVmQ6400qZTKbpj4VVmHBzgPRb8I2qPduwn9TOK0lgayQ0BOr dFrxPAaZi7yHzyIGOZTRydFtsCd471LR9IJNmv2viIDZsKEowOTcfRmkO28V53rCnXK3Sb vyxWPSGLxtP9emAUCUaJR35jHQH5e9RasYEbmPgjZgtKpjoiztwliRVo5ekihXRnncDGvy VCKTsXyXz+TNbW/JkPfwwbXlGIJf6qW6vaylVbMXS8yysqDqUz2bJeT5kXFrUA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1679966312; a=rsa-sha256; cv=none; b=S1GjLy6MdyPV6B6zfiFMFxWWWpvIGrCpxHNBqRO8GVvC9PROQy7Yp6TlA9W9e3uYrtCUBg TQyOy38o4vYu4P6b/DpQ3lFPWYd2H0ScoqyREiwCdrWJtvsoEcadRq+J1iQ/lrAEcONihs IG8KkRbyaE3objkSXHI1yYOItvKYSt0OvnkYFydNJTkQo3/3vFOCrVTDykqKKUwd24r67a o43NQxuAt/s8ZK51HL3wd93sZjJSlW63BkDrdHNMol5Xl/RLqta/YCQ9dCXfM7qqmZmMdK T2+6dfCmLlDnmCooAA30r7UiUBubwWWNGoK3Ctvr19gZCQc9VCc5SIfGc32Wzw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PlsJS3CBgzksy; Tue, 28 Mar 2023 01:18:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 32S1IWen028136; Tue, 28 Mar 2023 01:18:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32S1IWKj028135; Tue, 28 Mar 2023 01:18:32 GMT (envelope-from git) Date: Tue, 28 Mar 2023 01:18:32 GMT Message-Id: <202303280118.32S1IWKj028135@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 01194da28a21 - main - pfsync: hold b_mtx for callout_stop(pd_tmo) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 01194da28a2123a2aa09808319f152fa115f60f1 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=01194da28a2123a2aa09808319f152fa115f60f1 commit 01194da28a2123a2aa09808319f152fa115f60f1 Author: Kristof Provost AuthorDate: 2023-03-22 13:46:25 +0000 Commit: Kristof Provost CommitDate: 2023-03-27 23:17:55 +0000 pfsync: hold b_mtx for callout_stop(pd_tmo) The pd_tmo callout has an associated mutex, which we must hold while calling callout_stop(). Reported by: markj Reviewed by: markj MFC after: 3 days Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D39223 --- sys/netpfil/pf/if_pfsync.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/sys/netpfil/pf/if_pfsync.c b/sys/netpfil/pf/if_pfsync.c index ae3a2e46e26b..4e4bbc9bc8b7 100644 --- a/sys/netpfil/pf/if_pfsync.c +++ b/sys/netpfil/pf/if_pfsync.c @@ -402,7 +402,7 @@ pfsync_clone_destroy(struct ifnet *ifp) { struct pfsync_softc *sc = ifp->if_softc; struct pfsync_bucket *b; - int c; + int c, ret; for (c = 0; c < pfsync_buckets; c++) { b = &sc->sc_buckets[c]; @@ -411,22 +411,25 @@ pfsync_clone_destroy(struct ifnet *ifp) * cleared by pfsync_uninit(), and we have only to * drain callouts. */ + PFSYNC_BUCKET_LOCK(b); while (b->b_deferred > 0) { struct pfsync_deferral *pd = TAILQ_FIRST(&b->b_deferrals); - TAILQ_REMOVE(&b->b_deferrals, pd, pd_entry); - b->b_deferred--; - if (callout_stop(&pd->pd_tmo) > 0) { - pf_release_state(pd->pd_st); - m_freem(pd->pd_m); - free(pd, M_PFSYNC); + ret = callout_stop(&pd->pd_tmo); + PFSYNC_BUCKET_UNLOCK(b); + if (ret > 0) { + pfsync_undefer(pd, 1); } else { pd->pd_refs++; callout_drain(&pd->pd_tmo); - free(pd, M_PFSYNC); } + free(pd, M_PFSYNC); + PFSYNC_BUCKET_LOCK(b); } + MPASS(b->b_deferred == 0); + MPASS(TAILQ_EMPTY(&b->b_deferrals)); + PFSYNC_BUCKET_UNLOCK(b); callout_drain(&b->b_tmo); }