From nobody Thu May 16 12:02:01 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 4Vg7xP41N4z5L83s; Thu, 16 May 2024 12:02:01 +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 4Vg7xP3WYDz4jwf; Thu, 16 May 2024 12:02:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715860921; 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=QwKLXk4Qh7j/K1Ipg5YZSy2FEiqvt6c58x8yWLbJFfY=; b=p7ldlJukMaLR1NGfEj4bB6fF1NTPsHmoAto89NxXk6UWQ/NzVF0NTEArKuFiLMCJC4l+61 AhO5pf006L2leK2/DPmQFFJLmFOpwJQPXGZh9r1B6cqP6ngaPDIXwwGCTnafgSIBvzlACk 8p4sGo3OxMXC1q6DTfpnnMzF2396929NFqtrYo1m5zBHpzzeW+Lv4dD7AZeVL7uP5Xs9X9 DDhxo7XkIRPSV1IZogpkMxnchNfkRm/H6T2Bcw5scCuR7SB35qTEObx2kVqHFFoiMKKi/M LiQu4jZI0cocfTzbNxzxg3B75tWb4G9IDL1FTq+7/NYkvXiyDsHySASIYcxQUQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1715860921; a=rsa-sha256; cv=none; b=dYl04LO++E/ARLTAKOkb1z1v01+k2UJt2Q6G3wlcD3lZkZa+IRzH3gspXNvAok1LQ2OxaY SAVh6CKEZ6fjODWQJkkRbs4RqFjQHS6XBuWvPJS9YGj4X6GxRRebLUXaPVFF/kukSkISXP K4iYXUSQhZnjhuZj91x1XFLCOa36pMLeklBUTJ7p+ZyOUwXdw45+2eizRUJTe/y+HnA57k i7GBmuzTI4h5xN2dzDHpohbq5MJCSWNtu8Wf1AD9CTAPE6KrCXfhxi+heHHYBYH940AW68 dTDJFHzDyePKtNOhS2OdGUgoykp3oc/8CfNg9e2Rpi19OjmvEpfeEUUd9FQRzQ== 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=1715860921; 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=QwKLXk4Qh7j/K1Ipg5YZSy2FEiqvt6c58x8yWLbJFfY=; b=m7NaCy/mB+O4ZxOuYpF59YaWITYnlohRNX2ISgeUiQpjqocgkNhRtkfUytVfTVBTFnBJW5 f4OrE+5te1z9PFAurcNyq9nTwuZ46xbsn3fA7beipVbEbrl2Q5U5D3yOL/iWHMLcZPLaXQ bYq5KKd7DTeDHomaPxksQLRFH3WpVlGiSll2yeZmmp/B5oyG/XuCJjzigEQkTBUhSo+6M0 GwynlqCiDquDDjYXci6T55XBMQEdT+Rpn7tjmXrOxQ+qp8QIDRZddLL0RdPy9fnHVaRPIx sUwUlnFjoHiw/F3dzuDlaFWLEye1bhWup/MPa7NWZQfS5oWC8XJ48p6jAxVJDw== 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 4Vg7xP36m3zxfp; Thu, 16 May 2024 12:02:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 44GC21Bp008553; Thu, 16 May 2024 12:02:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44GC21Mn008550; Thu, 16 May 2024 12:02:01 GMT (envelope-from git) Date: Thu, 16 May 2024 12:02:01 GMT Message-Id: <202405161202.44GC21Mn008550@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: e73147fc7ca6 - stable/14 - pf: always mark states as unlinked before detaching them 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/14 X-Git-Reftype: branch X-Git-Commit: e73147fc7ca6632c7b2499c52f134c93fe664cc6 Auto-Submitted: auto-generated The branch stable/14 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=e73147fc7ca6632c7b2499c52f134c93fe664cc6 commit e73147fc7ca6632c7b2499c52f134c93fe664cc6 Author: Kristof Provost AuthorDate: 2024-05-06 07:43:49 +0000 Commit: Kristof Provost CommitDate: 2024-05-16 07:41:02 +0000 pf: always mark states as unlinked before detaching them Users have reported crashes in pf_test_state_udp() where at least one state key is NULL. That suggests that pf_detach_state() ran concurrently with pf_test_state_udp(). pf_test_state_udp() holds the state lock (aka the id lock), but pf_detach_state() does not. The intent is that detached states are not returned by STATE_LOOKUP/ pf_find_state(), as the state's timeout is set to PFTM_UNLINKED and thus pf_find_state() does not find the state. There are other paths to pf_detach_state() (outside of pf_unlink_state()) though, where we did not set the timeout to PFTM_UNLINKED. Fix those, and assert that the timeout is set correctly when we enter pf_detach_state(). MFC after: 1 week See also: https://redmine.pfsense.org/issues/15413 Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D45101 (cherry picked from commit 301ec2cebb6a3e472af39eb7b98c3b7ff88e04b0) --- sys/netpfil/pf/pf.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 5fc234c5aca9..6874dd59c1f7 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -1325,6 +1325,7 @@ keyattach: sk : NULL); printf("\n"); } + s->timeout = PFTM_UNLINKED; PF_HASHROW_UNLOCK(ih); KEYS_UNLOCK(); uma_zfree(V_pf_state_key_z, sk); @@ -1392,6 +1393,8 @@ pf_detach_state(struct pf_kstate *s) struct pf_state_key *sks = s->key[PF_SK_STACK]; struct pf_keyhash *kh; + MPASS(s->timeout >= PFTM_MAX); + pf_sctp_multihome_detach_addr(s); if (sks != NULL) { @@ -1517,6 +1520,7 @@ pf_state_insert(struct pfi_kkif *kif, struct pfi_kkif *orig_kif, break; if (cur != NULL) { + s->timeout = PFTM_UNLINKED; PF_HASHROW_UNLOCK(ih); if (V_pf_status.debug >= PF_DEBUG_MISC) { printf("pf: state ID collision: "