From nobody Fri Aug 16 09:45:39 2024 X-Original-To: dev-commits-src-main@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 4WlcYc16R6z5SYxq; Fri, 16 Aug 2024 09:45:40 +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 4WlcYc08zHz43dl; Fri, 16 Aug 2024 09:45:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1723801540; 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=zaMCn7b1YjRlPzp4ow2VOKdd0viE4sBu8pwQZgzXSWI=; b=lXR7yPY3XRKzIdQBYL58P7wo9JxAAtYey2ZcQ7J6pOZkX6ECqTOufTik6o7tcFddXBL/dU J6DeVBh3vWDGWsAWzmK5vF3rVKVnxyVXF3l0GBp94IuulVOwECwzVPNjZBpvpbpP3w5onI tJB6zqupd1jOEZqc1s75TyImMA5UUFG1EmEJZc5T7zYU3hf8il3NZNo6tP0wk5T7oKqd5b s9ph7ss2ScX7NdKKyzd0KHpcRaxL1MKU7wlKoyxBixP6zb5nlOyEXOGDvgItkWTCZA7omi Mg0KXJNfB278rCedGdehhCpYnzPfZXI0XaqN+5kbmTCdZrDZoRn7SyH90lS1+A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1723801540; a=rsa-sha256; cv=none; b=vgBi19BR6fXklRlpN7dqT5r5HZ31pJpJ8gNj7+3ma1nvl0dSZjlNISqsG9xnoDWJygNrH8 OXVTWJ8L9agj6S7sjolEUVAbi4ijA8cLAJGDp9Tlsv94qRxQFbns0QTHhPAK92QlNISHKk vsbdgm3Q5aJSwA5s/oFQJszUJ/VQjw6EBr8crXtAndirLieuGyWiFFO1BNEtwwyVsq7V1e nBMr41EITl6jP7ZjWaebegTPFlk1wk7J24IsFlC9xcaQyHBjFAmVFrBKB8RSe/0vzDV/16 BmRGsVd4HK+j3c1poGZaZ+10+w3HyDnmcqfBeoWi7s1Ks8ZGeO6CVKCciVzyUA== 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=1723801540; 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=zaMCn7b1YjRlPzp4ow2VOKdd0viE4sBu8pwQZgzXSWI=; b=K3IUIdYMv7K1yTnizz/9Sd/ND8zbieYv6AJphvOIdkJaGZASuRoccBD9XezBcUMTXkHTwI uy2cbxPAM69gc6OyliuOZPl741vULSv4ROg+6HDOnZpLMYLM+XBIYB6I36wHtxCIIGL4wR +Knw4TXRv/Bz3Eu/YQchxlHKOuacT2KpBOcP0MXThcXQAYD4HfEt4IKXBcA+CkOOWl0IfO ZqkmjoZDvAQoyBJ4IAJs265rt2Q6OWgnlflBYePBlZTZeIvUYdpq7YHd2B/IGUG5RsMSnB wnQ1utizLvuSNux7WOP2C5MhVGrVYD4mUJCJMhfFDjQFoxvqQIp/rQgQBt+oJA== 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 4WlcYb6kTRz11HL; Fri, 16 Aug 2024 09:45:39 +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 47G9jdFP085900; Fri, 16 Aug 2024 09:45:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47G9jdQU085897; Fri, 16 Aug 2024 09:45:39 GMT (envelope-from git) Date: Fri, 16 Aug 2024 09:45:39 GMT Message-Id: <202408160945.47G9jdQU085897@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: 788f194f6064 - main - pf: 'sticky-address' requires 'keep state' List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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: 788f194f60641dc3cdf7084c7286d6c9683fd238 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=788f194f60641dc3cdf7084c7286d6c9683fd238 commit 788f194f60641dc3cdf7084c7286d6c9683fd238 Author: Kajetan Staszkiewicz AuthorDate: 2024-08-16 08:08:16 +0000 Commit: Kristof Provost CommitDate: 2024-08-16 09:43:00 +0000 pf: 'sticky-address' requires 'keep state' When route_to() processes a packet without state, pf_map_addr() is called for each packet. Pf_map_addr() will search for a source node and will find none since those are created only in pf_create_state(). Thus sticky address, even though requested in rule definition, will never work. Raise an error when a stateless filter rule uses sticky address to avoid confusion and to keep ruleset limitations in sync with what the pf code really does. Reviewed by: kp Differential Revision: https://reviews.freebsd.org/D46310 --- sbin/pfctl/parse.y | 4 ++++ sys/netpfil/pf/pf_ioctl.c | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y index d07a3fdc188e..724ffefcd7d9 100644 --- a/sbin/pfctl/parse.y +++ b/sbin/pfctl/parse.y @@ -5388,6 +5388,10 @@ filter_consistent(struct pfctl_rule *r, int anchor_call) problems++; } } + if (r->rpool.opts & PF_POOL_STICKYADDR && !r->keep_state) { + yyerror("'sticky-address' requires 'keep state'"); + problems++; + } return (-problems); } diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 5467ebbed2eb..d22ffc2245cb 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -2207,6 +2207,11 @@ pf_ioctl_addrule(struct pf_krule *rule, uint32_t ticket, (TAILQ_FIRST(&rule->rpool.list) == NULL)) error = EINVAL; + if (rule->action == PF_PASS && rule->rpool.opts & PF_POOL_STICKYADDR && + !rule->keep_state) { + error = EINVAL; + } + if (error) { pf_free_rule(rule); rule = NULL;