From nobody Thu Sep 19 13:03:24 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 4X8bL474cZz5WYCK; Thu, 19 Sep 2024 13:03:24 +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 4X8bL45bQpz4rBY; Thu, 19 Sep 2024 13:03:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1726751004; 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=c1MN+OWurJt4koMP8ZRVZudr0gSW5i5ECdEYom/mhgE=; b=exy5X+ubBRHd/suffgfa/KSt82BCTB+unIXejX8yTRk6443lMujlpDIjWgmGZ0EfFOnQ9s EgRMjnwlhBPIrQGKI0l2Ec74fOmWbiPAFYpKUB8bclvopAVgxEDcJAVW4EW9ifEBN8QLwL E9hSXhea7gFTGXsJlLCzlnZA432sA4EZgP9WDHAJ5OazqC0FmeRNhLHW0mpi0A6EzuZP8A NHg+2+T2OYlsbORFmoOunsb0tfdrJvgXrtfVkoS/j0mRhPbPn1NqFVx+orZhE5i+cKJbV+ wgyspGEuW2mxjCsaYq4B3/PaLK0MyJdA5s9ZPhJy9BmhbE90HDbuQmiw2LXogg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1726751004; a=rsa-sha256; cv=none; b=knRXQMXwxHJSqdTGqmay8kxmW9eIvF+ZNFQI05FiSdW38oFEJdeY8FsJ9kftcyrViSQX+y PiQVbVmhKtCnZsOcWrPYjiy1uOQt/z5Lu52C0qozWFhwPECvXdAlMUJ19ZrlYtxWBMSQ86 xK2Fsi41waA4/6OmTlSmUqpPP45/CPLIjQj0c5bCdvfqCseiu8TvYcYrhpU4enbeigphGc a0W8SGOWbn8G83Xqn1NpQNVHXpOOe6RQ4fLSW5uYF5hw3AxUwGq75/zKX2Qd7bHSiraPMC xPPovKADvUVuwYPU8qcaC9txT1yzw6YJwoC7t1HsuGsk8arPfoYxX17J7ssOow== 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=1726751004; 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=c1MN+OWurJt4koMP8ZRVZudr0gSW5i5ECdEYom/mhgE=; b=JBfwwFjWTieo55MYdBLdtFN9AZtw6RcweP4q5T3VxQVpEOOa5s7jcaUhn7iH3FVRpMiy07 J+ZyxMO4hhuEura7xA+dRjpX0mB08qDvXf8igDvbMErN+h6cQOSGAAxcNMwHgMzq7pMn1e 20p698E5pq5uR/JIwLbu3wcDPE4KLRA8qU3gxLPqsaTg5QLtMP63Kce3VA5pU996HqjA9X WQJL17eIZSwiqqwTZM2CfTt8X1UNjY5oc8kJOzNyK3x8pU5BXkhLE1CqEvoLH0ZjnO5CBe fVpFIRl2TifactJDKsVVTTybFp/x+KL/Nyx6j4LnyW1E8mfHj/8FSCpi2luX3w== 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 4X8bL45Cqsz15tn; Thu, 19 Sep 2024 13:03:24 +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 48JD3OLI000184; Thu, 19 Sep 2024 13:03:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48JD3Oxj000181; Thu, 19 Sep 2024 13:03:24 GMT (envelope-from git) Date: Thu, 19 Sep 2024 13:03:24 GMT Message-Id: <202409191303.48JD3Oxj000181@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 0b3294327ae3 - releng/14.0 - pf tests: ensure we don't confuse different ICMP types 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/releng/14.0 X-Git-Reftype: branch X-Git-Commit: 0b3294327ae3f91c3638a985fe1513dee74a2582 Auto-Submitted: auto-generated The branch releng/14.0 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=0b3294327ae3f91c3638a985fe1513dee74a2582 commit 0b3294327ae3f91c3638a985fe1513dee74a2582 Author: Kristof Provost AuthorDate: 2024-07-09 09:22:18 +0000 Commit: Mark Johnston CommitDate: 2024-09-19 12:58:04 +0000 pf tests: ensure we don't confuse different ICMP types When creating a state for ICMP (v4 or v6) packets we only used the ID, which means that we could confuse different ICMP types. For example, if we allowed neighbour discovery but not ICMPv6 echo requests an ND packet could create a state that the echo request would match. Test that this is now fixed. Approved by: so Security: FreeBSD-EN-24:16.pf Reported by: Enrico Bassetti MFC after: 1 day Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit b9f0dbc3d006e0b904ee4275d54459f4edd65bb8) --- tests/sys/netpfil/pf/Makefile | 1 + tests/sys/netpfil/pf/icmp6.sh | 89 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) diff --git a/tests/sys/netpfil/pf/Makefile b/tests/sys/netpfil/pf/Makefile index 70c0c300d7ad..2c47cd367748 100644 --- a/tests/sys/netpfil/pf/Makefile +++ b/tests/sys/netpfil/pf/Makefile @@ -13,6 +13,7 @@ ATF_TESTS_SH+= altq \ fragmentation_pass \ get_state \ icmp \ + icmp6 \ killstate \ macro \ map_e \ diff --git a/tests/sys/netpfil/pf/icmp6.sh b/tests/sys/netpfil/pf/icmp6.sh new file mode 100644 index 000000000000..35d20c83cc4f --- /dev/null +++ b/tests/sys/netpfil/pf/icmp6.sh @@ -0,0 +1,89 @@ +# +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (c) 2024 Rubicon Communications, LLC (Netgate) +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. + +. $(atf_get_srcdir)/utils.subr + +common_dir=$(atf_get_srcdir)/../common + +atf_test_case "zero_id" "cleanup" +zero_id_head() +{ + atf_set descr 'Test ICMPv6 echo with ID 0 keep being blocked' + atf_set require.user root + atf_set require.progs scapy +} + +zero_id_body() +{ + pft_init + + epair=$(vnet_mkepair) + ifconfig ${epair}a inet6 2001:db8::2/64 up no_dad + + vnet_mkjail alcatraz ${epair}b + jexec alcatraz ifconfig ${epair}b inet6 2001:db8::1/64 up no_dad + + # Sanity check + atf_check -s exit:0 -o ignore \ + ping -c 1 2001:db8::1 + + jexec alcatraz pfctl -e + pft_set_rules alcatraz \ + "set block-policy drop" \ + "antispoof quick for { egress ${epair}b }" \ + "block all" \ + "pass out" \ + "pass in quick inet6 proto IPV6-ICMP icmp6-type 135" \ + "pass in quick inet6 proto IPV6-ICMP icmp6-type 136" \ + "pass out quick inet6 proto IPV6 from self to any" + + # Now we can't ping + atf_check -s exit:2 -o ignore \ + ping -c 1 2001:db8::1 + + # Force neighbour discovery + ndp -d 2001:db8::1 + + # Verify that we don't confuse echo request with ID 0 for neighbour discovery + atf_check -s exit:1 -o ignore \ + ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 2001:db8::1 \ + --replyif ${epair}a + + jexec alcatraz pfctl -ss -vv + jexec alcatraz pfctl -sr -vv +} + +zero_id_cleanup() +{ + pft_cleanup +} + +atf_init_test_cases() +{ + atf_add_test_case "zero_id" +}