From nobody Wed Aug 21 07:44:54 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 4Wpddz0nGBz5TNp9; Wed, 21 Aug 2024 07:44:55 +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 4Wpddy5Qrgz4Snt; Wed, 21 Aug 2024 07:44:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724226294; 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=5Vl5AQoMmhUZ3/7KBSpFkxuqpDIMbsA+PKUezAzXaSo=; b=fo2Lcw7q2Oz5x9K/QqfJ+1jkwUmKjgPLgRuGoCcI1gVvHMacbYnE3wAJlKIWTIwQtO3SSO tKaK3hqalJQ+WX2zf/P2wCF0DyeoZJte/dzSGAHz8C/3SQwH6G3c4ydEvTz5DyfVdQafb3 XO96a591Ne6RsWUzreP0+zmQoE4MuADfyZTcvGzNILK35+dlc11jAbrK7GwpUQ+62ntmyj Nwi7yljSvWDEhGY6MXnsYo64omMq1nLRB2Uv+0olMjJIpwQBxxF8vVRFAf0/KdLJRPAdXw nf9gHoz+va+booQf9/PYaw6fnLSM3+YbLQWmjdiixptlO5E3ZMMcqTN7sR19Pg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724226294; a=rsa-sha256; cv=none; b=v7I3ViBDF1VFurxB0BbulcaApgE8O0AD/1wLP3NM6HGBfWIHCTREtfO9ANzKZCmZ5GvBtH rAgYZJV9TBjUrgTMn207QNERM6gS/3galpDpTGZxvBbZNj7S9sYqdZNrrna6T0I4i3rhpS c6zbsQaNHZOid10oX5uImp4HqitcohKhD54Y/PNm29MgrKSUNz9Wfm8ji82E15fBXc6o3A SJBbMhkiBqmRypVQOm4tHpv3wpnrpk3XELl3oDfRuJE4JhbHwfAfo6hUzOlQ3feB2J22Dh ubpOTpfuVdreWQGoiG1qeHX3R6Kd8tqexT6v7DlcNzrcOxuaplEWtSZ9pxg1+g== 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=1724226294; 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=5Vl5AQoMmhUZ3/7KBSpFkxuqpDIMbsA+PKUezAzXaSo=; b=jKbhHihOWs5ySuqcsnVDbiKv8/W+tKZywcRzOmeEW0vv/MuvZK99+aPeY2/td5G1l7bqWC OcAN0ayFHpsHp+J0ymRDUOZEU7e3oOsViosV6u9t7iqPR3O1g6Cy7MDfTM+xo6BddB8dlv F5LBjej8R1hbzh1kkb/V3cNAMHDMQGRxckwX6zzBo+DTNC5i8Zr/3uYkv0IZxxtXu3fjHM b0XNCX53PvmFj7C2faXwb6bz/sHOn5gdfDlgtJpXiIpQO2AnBDL5IqtvgBNlxzhXk01X8X EciZ4uVB40KeEw7ilshJMp4UWVhf9jcHTrEezInHndtU2V4ddQMK6aec8EHE7A== 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 4Wpddy530pzZqB; Wed, 21 Aug 2024 07:44:54 +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 47L7isYD088646; Wed, 21 Aug 2024 07:44:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47L7iskx088643; Wed, 21 Aug 2024 07:44:54 GMT (envelope-from git) Date: Wed, 21 Aug 2024 07:44:54 GMT Message-Id: <202408210744.47L7iskx088643@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: 6a7bac2ae796 - releng/13.4 - pf tests: ensure that traceroutes using ICMP work 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/releng/13.4 X-Git-Reftype: branch X-Git-Commit: 6a7bac2ae79667c2b31169a8d0e91410986336fa Auto-Submitted: auto-generated The branch releng/13.4 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=6a7bac2ae79667c2b31169a8d0e91410986336fa commit 6a7bac2ae79667c2b31169a8d0e91410986336fa Author: Kristof Provost AuthorDate: 2024-08-12 10:14:43 +0000 Commit: Kristof Provost CommitDate: 2024-08-21 07:44:16 +0000 pf tests: ensure that traceroutes using ICMP work PR: 280701 Approved by: re (cperciva) MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 34063cb714602972b6d985ad747fc8f66a8daae1) (cherry picked from commit 7024e1066d5aba76dbbc85eb191357da7d32c619) --- tests/sys/netpfil/pf/icmp.sh | 65 +++++++++++++++++++++++++++++++++++++++++++ tests/sys/netpfil/pf/icmp6.sh | 65 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+) diff --git a/tests/sys/netpfil/pf/icmp.sh b/tests/sys/netpfil/pf/icmp.sh index 72b531b08c51..16c4123b8dfe 100644 --- a/tests/sys/netpfil/pf/icmp.sh +++ b/tests/sys/netpfil/pf/icmp.sh @@ -71,7 +71,72 @@ cve_2019_5598_cleanup() pft_cleanup } +atf_test_case "ttl_exceeded" "cleanup" +ttl_exceeded_head() +{ + atf_set descr 'Test that we correctly translate TTL exceeded back' + atf_set require.user root +} + +ttl_exceeded_body() +{ + pft_init + + epair_srv=$(vnet_mkepair) + epair_int=$(vnet_mkepair) + epair_cl=$(vnet_mkepair) + + vnet_mkjail srv ${epair_srv}a + jexec srv ifconfig ${epair_srv}a 192.0.2.1/24 up + jexec srv route add default 192.0.2.2 + + vnet_mkjail int ${epair_srv}b ${epair_int}a + jexec int sysctl net.inet.ip.forwarding=1 + jexec int ifconfig ${epair_srv}b 192.0.2.2/24 up + jexec int ifconfig ${epair_int}a 203.0.113.2/24 up + + vnet_mkjail nat ${epair_int}b ${epair_cl}b + jexec nat ifconfig ${epair_int}b 203.0.113.1/24 up + jexec nat ifconfig ${epair_cl}b 198.51.100.2/24 up + jexec nat sysctl net.inet.ip.forwarding=1 + jexec nat route add default 203.0.113.2 + + vnet_mkjail cl ${epair_cl}a + jexec cl ifconfig ${epair_cl}a 198.51.100.1/24 up + jexec cl route add default 198.51.100.2 + + jexec nat pfctl -e + pft_set_rules nat \ + "nat on ${epair_int}b from 198.51.100.0/24 -> (${epair_int}b)" \ + "pass" + + # Sanity checks + atf_check -s exit:0 -o ignore \ + jexec cl ping -c 1 198.51.100.2 + atf_check -s exit:0 -o ignore \ + jexec cl ping -c 1 203.0.113.1 + atf_check -s exit:0 -o ignore \ + jexec cl ping -c 1 203.0.113.2 + atf_check -s exit:0 -o ignore \ + jexec cl ping -c 1 192.0.2.1 + + echo "UDP" + atf_check -s exit:0 -e ignore -o match:".*203.0.113.2.*" \ + jexec cl traceroute 192.0.2.1 + jexec nat pfctl -Fs + + echo "ICMP" + atf_check -s exit:0 -e ignore -o match:".*203.0.113.2.*" \ + jexec cl traceroute -I 192.0.2.1 +} + +ttl_exceeded_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "cve_2019_5598" + atf_add_test_case "ttl_exceeded" } diff --git a/tests/sys/netpfil/pf/icmp6.sh b/tests/sys/netpfil/pf/icmp6.sh index 35d20c83cc4f..c54b54c20a87 100644 --- a/tests/sys/netpfil/pf/icmp6.sh +++ b/tests/sys/netpfil/pf/icmp6.sh @@ -83,7 +83,72 @@ zero_id_cleanup() pft_cleanup } +atf_test_case "ttl_exceeded" "cleanup" +ttl_exceeded_head() +{ + atf_set descr 'Test that we correctly translate TTL exceeded back' + atf_set require.user root +} + +ttl_exceeded_body() +{ + pft_init + + epair_srv=$(vnet_mkepair) + epair_int=$(vnet_mkepair) + epair_cl=$(vnet_mkepair) + + vnet_mkjail srv ${epair_srv}a + jexec srv ifconfig ${epair_srv}a inet6 2001:db8:1::1/64 no_dad up + jexec srv route add -6 default 2001:db8:1::2 + + vnet_mkjail int ${epair_srv}b ${epair_int}a + jexec int sysctl net.inet6.ip6.forwarding=1 + jexec int ifconfig ${epair_srv}b inet6 2001:db8:1::2/64 no_dad up + jexec int ifconfig ${epair_int}a inet6 2001:db8:2::2/64 no_dad up + + vnet_mkjail nat ${epair_int}b ${epair_cl}b + jexec nat ifconfig ${epair_int}b inet6 2001:db8:2::1 no_dad up + jexec nat ifconfig ${epair_cl}b inet6 2001:db8:3::2/64 no_dad up + jexec nat sysctl net.inet6.ip6.forwarding=1 + jexec nat route add -6 default 2001:db8:2::2 + + vnet_mkjail cl ${epair_cl}a + jexec cl ifconfig ${epair_cl}a inet6 2001:db8:3::1/64 no_dad up + jexec cl route add -6 default 2001:db8:3::2 + + jexec nat pfctl -e + pft_set_rules nat \ + "nat on ${epair_int}b from 2001:db8:3::/64 -> (${epair_int}b:0)" \ + "pass" + + # Sanity checks + atf_check -s exit:0 -o ignore \ + jexec cl ping -c 1 2001:db8:3::2 + atf_check -s exit:0 -o ignore \ + jexec cl ping -c 1 2001:db8:2::1 + atf_check -s exit:0 -o ignore \ + jexec cl ping -c 1 2001:db8:2::2 + atf_check -s exit:0 -o ignore \ + jexec cl ping -c 1 2001:db8:1::1 + + echo "UDP" + atf_check -s exit:0 -e ignore -o match:".*2001:db8:2::2.*" \ + jexec cl traceroute6 2001:db8:1::1 + jexec nat pfctl -Fs + + echo "ICMP" + atf_check -s exit:0 -e ignore -o match:".*2001:db8:2::2.*" \ + jexec cl traceroute6 -I 2001:db8:1::1 +} + +ttl_exceeded_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "zero_id" + atf_add_test_case "ttl_exceeded" }