From nobody Wed Jul 31 07:41:12 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 4WYkYP1y7gz5RPHT; 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 4WYkYP0Wzkz4qgD; 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=fb5jzVfWktrZkppaaTd60sHNUZFJS+WrX197nyPU0Ig=; b=ttGc6z+tOG9h55WYhIHK6nSmGYcn30tK821E2pU4h3zdspP6HvhlyBWcCVgwt94clRvtTS 8+xSvueTW0y8eK962dEQ+6pu4ClitxPL+7QhHhPwjlIBuCQ/LuGw49iR7vPTjE4IDz4DV2 Q0axtnyWNWeQMJusTGstYxEvTXVjigbKzra24ADEirXgKY1MTkwTb2igZw9NEGlRYg3MxV WlkdzUtp/leuPX+hjoNoMQHJrQbnssJmeIYuGh6pNw5xEC4Aq+owMDxa4TzuLOLUAFpFPe 7IgYVABX40sWaWQMvYPTRftC0WpNdqL3V7ISikhG6kXAPsa1zAMpIs1z4JPJyA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1722411673; a=rsa-sha256; cv=none; b=yQd3xX4oTUZIJQhrZFRBWE01klD+tQNpCWb2gzdkaj50DDooORKgJ7sbzvA6wYl3vnmeqv NdCI1eCyU8kaXtO4SZM/sm/6czx8z29nzXwx59woV1zwRvkaGqhDLHiOJ9tOB7RP5PMfxo RjZf3wCEhRy6TQvGQB+t26Bnt5wUTDmHcQDW+ykJbOD5n2fH5+2hydXQPX/Hh269HVo/tK Xe6YOp6f+rg1ceI8N9St91xuUrqcjGabcCbFCxHKhwtMmQy+GHHYnG27I2rkC0D/KBI9do gv/bCOULSf4pI2lk6ns2L0Nw7NQA0kS2iGPsbtu3q5XNLtIyT90SV5fKsaxnZQ== 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=fb5jzVfWktrZkppaaTd60sHNUZFJS+WrX197nyPU0Ig=; b=VfeaOSDGMy/MaonIBAn7EUBAXG/ntPapikAx/sttFKndIrmfoqc4TFof4KdDJ4+7g5Wb1D l0ubF0yxxpwjhk2+3wFfCZtSRdMNBzCbZ/61KQSi4SL/d1xB0QgVoJrO/CyqwRgE1uied0 cIKaZkT7pWiDWVll8v6gzEsLNNnvuJGZf1ujDmGZSkkTmM24oO96JB2bEfhklDmTfXRv1g o7a8+2I3pmu4MjHo+dgTmdyy5a9JyWFlGgn7mb+UU9f5NWKeP1ATe0OMA7oD+remhXVnV0 kNAx04jAUj+YsT3LAw4eXQynncLunQflUOgMCSS7v+S2NnFQQJje0fzKxmSQGg== 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 4WYkYP07Tszs3M; 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 46V7fCQf084870; Wed, 31 Jul 2024 07:41:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46V7fCmk084867; Wed, 31 Jul 2024 07:41:12 GMT (envelope-from git) Date: Wed, 31 Jul 2024 07:41:12 GMT Message-Id: <202407310741.46V7fCmk084867@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: 3e1f815655ef - stable/14 - 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/14 X-Git-Reftype: branch X-Git-Commit: 3e1f815655ef66963bc8f9ea9fbd691f2eddd2e8 Auto-Submitted: auto-generated The branch stable/14 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=3e1f815655ef66963bc8f9ea9fbd691f2eddd2e8 commit 3e1f815655ef66963bc8f9ea9fbd691f2eddd2e8 Author: Kristof Provost AuthorDate: 2024-07-09 09:22:18 +0000 Commit: Kristof Provost CommitDate: 2024-07-31 07:39:53 +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 1083f89a5502..9b793417c1d8 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 \ 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" +}