From nobody Mon Jul 29 17:42:57 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 4WXm0d4SVkz5Rg6G; Mon, 29 Jul 2024 17:42:57 +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 4WXm0d2GNSz4MZr; Mon, 29 Jul 2024 17:42:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722274977; 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=aNRicnBa/KPr+tntfmgJCfVGv9BTNVfjCnptPZmdbkY=; b=Njy6qZdl9On7uaqT4yJu7OR6+IA9Rj9x/CF2YCTq8gLwEGuX/LuS1nqudY3lo1copJfZfC sc3eJ2PDhxXerNW94BpcTp0u7QgvpTPVaP3ugWBT5tCI27qkoQqci7gX3DT6io5cxtCSxN zvyzTpDgDAvfwszHHE5HlL1eT0sCheFTk1fETXQYGhyacGcqCWy22OVnD9/M+3BEdMgdoU CoLUyMVQTE004vSAa3V481JYOnETtb+h1DoRU+VF0P9v+yG0oWHe+1i3sWVFwLP2f5qG7n 4vzA45sda28vuibQYVSLKRrrigEGUqPtHeRguO0Feb2P62bP/ZRy6WgkIrctBg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1722274977; a=rsa-sha256; cv=none; b=POHB+6XbDSqS4dAeiiqPnmqPYDra+O/aZBr5nntLOPPSk1JuRk5xURiHVTfXRszmJRnoel jwqaVEuXestjqN3Nxe0fR5DXiC2ZTb9WJkK5eMwrDeV2HdYcv6i2BIfSt0iuPM/U3qZw4J Y10iapxufOnM/jgtUK3jY637/DHDxdENx6XZa3F+diNsl6p+kCvkpJHzcxzK7z2ztrl3PO KCi8Ti5NXW+P9kHNZVI/HtHZv9xLvQLvAIrHgDaVuzFR++xAzdE5Wlc4NFf/zn6fH5+zKc BccWZRD1rHuopkcwoL/ibqc/QKrG++QhKi42cMEZGaNGXj6ePlV4j0UDsphMdg== 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=1722274977; 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=aNRicnBa/KPr+tntfmgJCfVGv9BTNVfjCnptPZmdbkY=; b=BaeyudYP0CP6DAwXCmav4iiNnP4LWSg2IfeaykZRxYsDSYaDOljJfvfd0fgwIzYte5cWLO bVscLxaVMDqhTd4hPefTMxmUq2ExdlpxPr53E5lGZI39CIYgsshViKv/UQOry29eMATFsm +6eQepD9AGEsQNZIBJkBvnDFIZXM3X9jS334aNRsgg5AoZRk0lVEPzwdcpw3eFjak+O8la SccxU1PLsTQSnEpJ6qapI98T+0Gk0Nz6Ijy+CmI79vYhtetxKd1IdMnqyyU/XtOJD4rQz+ CrNNNesYRNX20IIv/8hRHYfpF+LiBYwq+RB2QoAtokv7Jd8MvqV9QhZ8fiJxiQ== 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 4WXm0d1m3xzkdq; Mon, 29 Jul 2024 17:42:57 +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 46THgvWX023338; Mon, 29 Jul 2024 17:42:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46THgv58023335; Mon, 29 Jul 2024 17:42:57 GMT (envelope-from git) Date: Mon, 29 Jul 2024 17:42:57 GMT Message-Id: <202407291742.46THgv58023335@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: b9f0dbc3d006 - main - 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: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b9f0dbc3d006e0b904ee4275d54459f4edd65bb8 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=b9f0dbc3d006e0b904ee4275d54459f4edd65bb8 commit b9f0dbc3d006e0b904ee4275d54459f4edd65bb8 Author: Kristof Provost AuthorDate: 2024-07-09 09:22:18 +0000 Commit: Kristof Provost CommitDate: 2024-07-29 17:42:26 +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. Reported by: Enrico Bassetti MFC after: 1 day Sponsored by: Rubicon Communications, LLC ("Netgate") --- 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 6b57260796ed..f4dd36d9e35d 100644 --- a/tests/sys/netpfil/pf/Makefile +++ b/tests/sys/netpfil/pf/Makefile @@ -16,6 +16,7 @@ ATF_TESTS_SH+= altq \ fragmentation_no_reassembly \ get_state \ icmp \ + icmp6 \ if_enc \ limits \ loginterface \ 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" +}