From nobody Wed Jul 31 07:41:13 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 4WYkYP4hbCz5RPC3; Wed, 31 Jul 2024 07:41:13 +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 4WYkYP2rRtz4qgH; Wed, 31 Jul 2024 07:41:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722411673; 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=73dKPLjIWIITkAdmzYi0F/jeuiUMH7o+dfejES2dCO4=; b=ppurHzJBKgaAKciAzzPMs7r0JUvlVOyauO2Fc6tTAqn05de/DqWIuU37aj71atK9BGwxEG /KYyPVSdWNSBHOhQ0cx+kgerWe6mD9kc/+bzLkwKs0H7qgfPEBVjRLtFIiG7YHFzMaotcq F1GnA/9IKcSeGC6ACMhA9G2i4PhYkZ5FtvwYZqB7ya+Bcw3+HBunA7+gzC2qGd3xSNyAfh Cpa9ev7kOOg/rM4TtESRSoxNg95Wqe87YT6YzsQlOZfJoxJLMRUwf9lmXYlyrEy34TBdUs iIZHYokVqGPgMVBJ2REvqHHCzBpgoQEL18NofHN5obwAtYb3i0uaNaKGnW0UFQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1722411673; a=rsa-sha256; cv=none; b=Zgpn+p6vG1ee2BqEBuF8aUSNYNcf2W9rLvYTco+qKg+bHPGSfUFXT3tkqUm/TpIJbgjWLs GYed4xrn1TXywknJyqTtOixYpXCJDmeX/0KoCF4HwVye+uvkAqeP8XwkaryIsm23ZpZK6/ UiaYMW7+r3BtpbqrZvjVJtK4Xi2hk8p1sqe0Lz9W9JQiHSK2DDfY6T6V1bwGBOhrBYUxP+ oNESrQbncjiaUR1ylkmtrwS2fLYW7xrONlXVZPDOBWoPCs4WbPnv7MCRs9s+vGOb9RaUhO 5lOFuPrPxB9F4DiPzudBXx0MlM02tsV91CmaTKVZhpEO3sfapTi6ifxZmz51VA== 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=1722411673; 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=73dKPLjIWIITkAdmzYi0F/jeuiUMH7o+dfejES2dCO4=; b=H+K2/55bsrtxKikuqcGqsf+Je6dO29gg6blOb7wwcm1ss15GUwdw1J27SRK+vPCVi+2YgH p8MbgHzOnfrMnsiES94ZVAJbEvpQTLBDVxIw8OyCZuebIKFVmfIHH7YMklIMJko0zA5XLw uaFKDsShvCEv3pUzctUqNO3b3esrOCgDU5gWkrmmOryRKQ5tmabNPt33hpJFP1AD5Rl1Wj QfHwwGPwEqm5SeV3Qh5lqHqJZp/zFpwxLPtGQ7gV3IKvC7u2nEOxW2W9kHXcp4YbOIhckk MzKTMVwRvtVnaztD0iYn0U4t25qgRB2nlhGYMjwkTSGGtkq3f4gwaE1oSce+9A== 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 4WYkYP2QJgzsQ8; Wed, 31 Jul 2024 07:41:13 +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 46V7fDYt084929; Wed, 31 Jul 2024 07:41:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46V7fDJs084926; Wed, 31 Jul 2024 07:41:13 GMT (envelope-from git) Date: Wed, 31 Jul 2024 07:41:13 GMT Message-Id: <202407310741.46V7fDJs084926@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: 4ebd7fc30ab7 - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 4ebd7fc30ab779b87c055b0d54eabdd97a9fc730 Auto-Submitted: auto-generated The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=4ebd7fc30ab779b87c055b0d54eabdd97a9fc730 commit 4ebd7fc30ab779b87c055b0d54eabdd97a9fc730 Author: Kristof Provost AuthorDate: 2024-07-09 09:22:18 +0000 Commit: Kristof Provost CommitDate: 2024-07-31 07:39:35 +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") (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 ea0d5cb151a2..f033940b4564 100644 --- a/tests/sys/netpfil/pf/Makefile +++ b/tests/sys/netpfil/pf/Makefile @@ -12,6 +12,7 @@ ATF_TESTS_SH+= altq \ fragmentation \ 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" +}