From nobody Mon Apr 29 16:15:58 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 4VSpNH1lQbz5JcKC; Mon, 29 Apr 2024 16:15:59 +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 4VSpNH11cSz4VVb; Mon, 29 Apr 2024 16:15:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714407359; 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=RMWfuDaHhrJBxQI51rDbtwXxp1s9DgNoj5KjYz/OEmE=; b=mF8HPN/fpKsfMVdhj7m38mx5RgeqCg8U4XVDKWXeb3bqrdJw9XrqdpxMTyXv7CYIm3HxPy tRrd9RO1OYdUlYMe6mRVW/IQ7lm3BkYKCxPah+CmL3dL6AAIRy/krPOhD1g5tQgrs6rvTd jGaAm5pCYXNa35l5KYRMnkJkLvgr3+YkToI/4p7rQmSnw3TEE1V6ntX4XlMVtpOuvrVF7B rSyAJ+0vrIfyY8sVX3itBh9GEGJ/dkJKscUIfO9mURi/5WVztlLtEZoL1Hhc60cU/gsIgS WlWgMTbxQWpKUxgJvafjSoDCbCmWRDTqmsSbzrGiQhxBgpaqvIp9LCiAFyHkxA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1714407359; a=rsa-sha256; cv=none; b=yuLmfLZRpqrouETl8JrqKmvp8Ho5HkPkVkhjVQZls3YOf/oIb65Ho64VtYokeh1re1hTdL uwPER+M7xl9G5tXOAlI0/WkwoXiheFUNKzGSdHLu+UKKLT72fFV9TrpdjZMQQFTPhepkpz rmA//4BbH1xBW95tuDWqEHF6Owg0qfPEzdV+I7h1IiftIcYk0191QNhyajTyq84p1tU3VW MgcPRB0C97T1g6c1KwTPAL+zFgUGpv9kAYRl8Y29we4ryVfp0oEUW0VpSnkomSgdsf1nW9 xxINHZbUv6FOHa30GCVvVWXjtzqkp7vQDwsfOdjK3RnFGTJv9VNVE9Y8c4L8DQ== 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=1714407359; 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=RMWfuDaHhrJBxQI51rDbtwXxp1s9DgNoj5KjYz/OEmE=; b=ZuEtTTJ8gOjv9NQ62CIR0Ms1W36ViX2nqK2fyyjLSL8gr/yPWK4Z1jU8EXzTHttRFdFDj1 pvz9YbN9ZrOYhP8Oab3LK/YHioPxZkVr8iXePulZYGE7MGmo1eBk7Bc6rv6WG6KcEBOS1j m6ImpzcN1PxDMN9NJpitWJaD51Nm0iPHjvglCKsPAOxDhVjuT35zkrK3rLc19DE6LfwcDs yNTNJY1tGzQazNTz0tq7y43pMlOolMNF2+6Xtw+eqG2dJf1XN0t1QniEAY9xoSVWEKauLM t1RFwMvZhSImLG/Is57XXR82pTUYz24edIvrE11q9bOdIBBWVGB9L8POWDwURQ== 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 4VSpNH0Vgxz1FZ0; Mon, 29 Apr 2024 16:15:59 +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 43TGFw6I050259; Mon, 29 Apr 2024 16:15:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43TGFwqe050256; Mon, 29 Apr 2024 16:15:58 GMT (envelope-from git) Date: Mon, 29 Apr 2024 16:15:58 GMT Message-Id: <202404291615.43TGFwqe050256@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: 221d459fbc67 - main - pflow: handle unattached states 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/main X-Git-Reftype: branch X-Git-Commit: 221d459fbc67e0c0565d6c6ea52fe8bbc5466fc7 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=221d459fbc67e0c0565d6c6ea52fe8bbc5466fc7 commit 221d459fbc67e0c0565d6c6ea52fe8bbc5466fc7 Author: Kristof Provost AuthorDate: 2024-04-29 09:51:17 +0000 Commit: Kristof Provost CommitDate: 2024-04-29 16:13:19 +0000 pflow: handle unattached states It's possible for states to be cleaned up (through pf_detach_state()) that have not been fully attached. For example if there's an ID conflict during pf_state_insert(). pflow exports states from pf_detach_state(), so it can get called on such states, but did not account for this and could end up dereferencing a NULL state key. Check for this in export_pflow() and do not export unattached states. See also: https://redmine.pfsense.org/issues/15446 Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/netpfil/pf/pflow.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/netpfil/pf/pflow.c b/sys/netpfil/pf/pflow.c index f3dba7687d05..a437f0259af5 100644 --- a/sys/netpfil/pf/pflow.c +++ b/sys/netpfil/pf/pflow.c @@ -750,6 +750,10 @@ export_pflow(const struct pf_kstate *st) NET_EPOCH_ASSERT(); + /* e.g. if pf_state_key_attach() fails. */ + if (st->key[PF_SK_STACK] == NULL || st->key[PF_SK_WIRE] == NULL) + return; + sk = st->key[st->direction == PF_IN ? PF_SK_WIRE : PF_SK_STACK]; CK_LIST_FOREACH(sc, &V_pflowif_list, sc_next) {