From nobody Wed Jul 17 21:55:27 2024 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 4WPV9W5GRkz5QT5s; Wed, 17 Jul 2024 21:55:27 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WPV9W3FvDz4pF2; Wed, 17 Jul 2024 21:55:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721253327; 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=wdG9NvxAAS/IuWsnIUX5kXOpfP9zaAmssrIVZU0TY0U=; b=nBW/z/UGofo7874Z81QMp6NDbc0hcU3svZ8+B4iBm1zAc6dom4lUjsm8OYMimK6fKLJNGx wXQ4M+r/y3VEmAtARjpD7/sj/0ePPpyu0YqufM1nnBzioqcJfKKcQ7+/KpKzeEUXm5FCF/ o851d/FnxmNausg2NvAJoasss+Bqz+kEbRCJ239u9UpXZgQnJm+3lAcKSsi2EH0q7GZCZz 9eC+GG2K01tvPcYxP+azkNUjwNFk8CWVOuhReZt1meGIC6NS2tx5U7rZGGOD/VGgsGvlOU qxMhMlG4L0MU9xNB9IDVlsM9qO3O1jZyQkIH7HIAirmDbuJTFdnccHi0j1G4yw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1721253327; a=rsa-sha256; cv=none; b=t4YmuC0OlTlFwY0n+GTqFF/ujv0kBV8V2b1tE+MbXnxT83ML/8dFxMwD5X9nBc6Ma67g+w JkvjyL5QQ8xslqVzV0MUwHw2g1AhLGAwjx1D/dWpmLCDy7WA8iDWq/pFnvq2Jp0E4qmdzu nnr6BWUq+xh/m4bENBMAC1Amlj+UNdOPHJ3ziFaaLkjI1UcvdNm7HKu64BChz0aRSx6cbF 88I0WKE8xaf/nM51gP/pN8fih9f/M8huVMVjcQSv2DEijGVMW+2WjGwJFZyDlNIManCaEk Mm2moCEPnKtGzm7YSolg0++j5ovlYOkLL1nfB0ZICD1zfFN1IdFyl5Nfl4WRfg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721253327; 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=wdG9NvxAAS/IuWsnIUX5kXOpfP9zaAmssrIVZU0TY0U=; b=rqZqoVD2h4kRUtHeTfy132CBFK9EaU5hwANHCIkHYDPEMWIpPrktggrhN6+a+sjtv7ujep LRVhR5kR4iSko4R/MAn48/E2yOI0pI39/k566QTTgLhy0G34ouXuGjUgT8z0TGSrpDuzd6 BcOnL2ZohKb9HTol+9/rXXpQGviY0kHDYksfxI7P0qE1ay/feOswzOAIbQc72FD2Exp4Cg J4S2O0VrhmCsvvczFuCv9eNKQCDvXhnsqpWYVAqatLTFYgXqUim4Ef6cGJ63o3MDpc/SSr VclIvd+wxtlwAQu5L3xvmKCNJjCBjaPPtmOG0Xfffb2YclX6Xh/OuB+IEpfsaA== 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 4WPV9W2svszMBB; Wed, 17 Jul 2024 21:55:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 46HLtR9J096832; Wed, 17 Jul 2024 21:55:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46HLtROa096829; Wed, 17 Jul 2024 21:55:27 GMT (envelope-from git) Date: Wed, 17 Jul 2024 21:55:27 GMT Message-Id: <202407172155.46HLtROa096829@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 5324cf4f1cf9 - stable/13 - pf: fix sctp deadlock 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-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/stable/13 X-Git-Reftype: branch X-Git-Commit: 5324cf4f1cf9d93351f966d4a76cf0389d08f3c6 Auto-Submitted: auto-generated The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=5324cf4f1cf9d93351f966d4a76cf0389d08f3c6 commit 5324cf4f1cf9d93351f966d4a76cf0389d08f3c6 Author: Kristof Provost AuthorDate: 2024-07-09 18:49:49 +0000 Commit: Kristof Provost CommitDate: 2024-07-17 21:54:35 +0000 pf: fix sctp deadlock It is possible for pf_test_state_sctp() to find a state and still return PF_DROP (or not PF_PASS, to be exact). In that case we would run pf_test_rule() unconditionally, but this would overwrite the (locked!) state pointer pf_test_state_sctp() gave us. As a result we will later deadlock, trying the lock the already locked state. Do what we do for UDP and TCP, and explicitly check s for NULL before we run pf_test_rule(). MFC after: 1 week Sponsored by: Orange Business Services (cherry picked from commit a9639adaedb4d67340c4ae386fe8fcd18e4a8a21) --- sys/netpfil/pf/pf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 97ae44cff69f..e99886a2d120 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -7310,7 +7310,7 @@ pf_test(int dir, int pflags, struct ifnet *ifp, struct mbuf **m0, struct inpcb * V_pfsync_update_state_ptr(s); r = s->rule.ptr; a = s->anchor.ptr; - } else { + } else if (s == NULL) { action = pf_test_rule(&r, &s, pd.dir, kif, m, off, &pd, &a, &ruleset, inp); } @@ -7838,7 +7838,7 @@ pf_test6(int dir, int pflags, struct ifnet *ifp, struct mbuf **m0, struct inpcb V_pfsync_update_state_ptr(s); r = s->rule.ptr; a = s->anchor.ptr; - } else { + } else if (s == NULL) { action = pf_test_rule(&r, &s, pd.dir, kif, m, off, &pd, &a, &ruleset, inp); }