From nobody Wed Jul 29 17:49:02 2026 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 4h9KZk6whvz6mZnQ for ; Wed, 29 Jul 2026 17:49:02 +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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4h9KZk42VYz3jWh for ; Wed, 29 Jul 2026 17:49:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1785347342; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZSTYXptfx45+wrocIwrHI2waHJyeCkI1Huhvi7w9INo=; b=DD0tikgFmf7ijCYadqGJQ8U3rzCbIo9fkgj/9GHBvNM3ZUq3nLMf7K4myuiu+TT7TrVvAm DouRNNe/ioRxPzEbfVTBGisyRSa7bWRT5io4AO7VcSSfMZToArWApEtV0HpEJfcNLB3rNO ZGXRs5V7TDJau8lAjmkNCn5ai5L3Z9Trwd57Xoixb1YdI+uFduwQ2qKe8xw7KOcUJOtolU afly+6QkTu+vxBcBGjCpc5t2iiF8KJ6iFqKarfH3dtgAFFomH7Ss5E5/trwKUmDG2kAY9f Osz3s74ST2EVDvZBy3hcZI+0RO940TB5TL4dt6ZtBwdDfQtQs4X9HMTXTIEcyA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1785347342; a=rsa-sha256; cv=none; b=f3oZnXfhfdK0vcWNg+Tj80O0MPECo26NrIv6lObjPVMbbhUn/lTFV3gmkZfOyuVl8AQjuj vyM5L9vHBcJuNAjNnCEGnwTvdgD+ExVFIZG9UFsNAK1718FCjsWYR7yN5maUvH13p/Lnza 5PkdfG8IRs4tnUm8ofs/e2AAuD0A6kXJ20NodNnLmBtoEGicjNS/JBT8UNdH/Iua1yRMqB CORrkZNtP+44FAiy9R4H3jo4JuLFi1Vq4c9LFd7+STjCFrBVbozTLAulmPG7XLP/x3N+ex uVDboXo4WVmr/wmAe2nWAYN4MDQoO2QnbBeCiJn3TH1ocWEhqUsNpkkNZ6xIxw== 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=1785347342; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZSTYXptfx45+wrocIwrHI2waHJyeCkI1Huhvi7w9INo=; b=oUMSRYcJqTjiwCpULdNWyNjF9y7/F2xjsJtim/Q8g9S5/7HmSg8ibLypCCHgHgw7SKkonG OhK6VtfcEom2zQMTot3x3biHlDWGMRLvBWz2isXpLrHTCofTSwHD8ngPGRKb51/zy5HjWI r/oNFX3FyzQmoGvkWrpU90Nq9pgb4VVAhEm9JdjVWNKwRxYiRfxlyKXVQSU+gwTGn06g13 j4sA2dx9rW/wYaiRjHpEPg2CwvoGzaXuJTaEKTVUIorswLiA4qcJpoLbVhAPdHuq+NZGkf LdIyCKBF9Iwnbg+a3p/4HHFqSZyOrK3KuyPOYT0cMY5+5pK5l6+9jbmqBOH9mw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4h9KZk1rHCzcqR for ; Wed, 29 Jul 2026 17:49:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 38ef7 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 29 Jul 2026 17:49:02 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: John Baldwin From: Mark Johnston Subject: git: 825c6f45b147 - stable/14 - wg(4): Add a test that the driver handles a decryption failure 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 List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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/stable/14 X-Git-Reftype: branch X-Git-Commit: 825c6f45b1478a9e4afb0323841597a55199a045 Auto-Submitted: auto-generated Date: Wed, 29 Jul 2026 17:49:02 +0000 Message-Id: <6a6a3d0e.38ef7.8b7c623@gitrepo.freebsd.org> The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=825c6f45b1478a9e4afb0323841597a55199a045 commit 825c6f45b1478a9e4afb0323841597a55199a045 Author: John Baldwin AuthorDate: 2026-07-27 15:37:43 +0000 Commit: Mark Johnston CommitDate: 2026-07-29 17:48:54 +0000 wg(4): Add a test that the driver handles a decryption failure The test uses a fail point to inject a decryption error in OCF while sending a ping across the tunnel. The driver should then fail to respond to the ping and increment the input error counter on the interface. Approved by: so Security: FreeBSD-SA-26:52.if_wg Security: CVE-2026-58085 Reviewed by: markj Sponsored by: Chelsio Communications --- etc/mtree/BSD.tests.dist | 2 + tests/sys/net/Makefile | 1 + tests/sys/net/wg/Makefile | 10 ++++ tests/sys/net/wg/if_wg_nojail.sh | 111 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 124 insertions(+) diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist index 6c50089b4802..1df5af7dccf4 100644 --- a/etc/mtree/BSD.tests.dist +++ b/etc/mtree/BSD.tests.dist @@ -858,6 +858,8 @@ .. routing .. + wg + .. .. netgraph .. diff --git a/tests/sys/net/Makefile b/tests/sys/net/Makefile index a29a8207ee33..7643b4b7f15b 100644 --- a/tests/sys/net/Makefile +++ b/tests/sys/net/Makefile @@ -15,6 +15,7 @@ ATF_TESTS_SH+= if_vlan ATF_TESTS_SH+= if_wg TESTS_SUBDIRS+= if_ovpn +TESTS_SUBDIRS+= wg TESTS_SUBDIRS+= routing # The netmap bridge application is used by if_wg tests. diff --git a/tests/sys/net/wg/Makefile b/tests/sys/net/wg/Makefile new file mode 100644 index 000000000000..7b6ec201605f --- /dev/null +++ b/tests/sys/net/wg/Makefile @@ -0,0 +1,10 @@ +PACKAGE= tests + +TESTSDIR= ${TESTSBASE}/sys/net/wg +BINDIR= ${TESTSDIR} + +ATF_TESTS_SH+= if_wg_nojail + +TEST_METADATA.if_wg_nojail= is_exclusive=true + +.include diff --git a/tests/sys/net/wg/if_wg_nojail.sh b/tests/sys/net/wg/if_wg_nojail.sh new file mode 100644 index 000000000000..0587b992622a --- /dev/null +++ b/tests/sys/net/wg/if_wg_nojail.sh @@ -0,0 +1,111 @@ +# +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (c) 2021 The FreeBSD Foundation +# +# This software was developed by Mark Johnston under sponsorship +# from the FreeBSD Foundation. +# +# 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)/../../common/vnet.subr + +atf_test_case "wg_bad_decrypt" "cleanup" +wg_bad_decrypt_head() +{ + atf_set descr 'Create a wg(4) tunnel over an epair and inject a decryption error' + atf_set require.user root + atf_set require.kmods if_wg +} + +wg_bad_decrypt_body() +{ + local epair pri1 pri2 pub1 pub2 wg1 wg2 + local endpoint1 endpoint2 tunnel1 tunnel2 + + pri1=$(wg genkey) + pri2=$(wg genkey) + + endpoint1=192.168.2.1 + endpoint2=192.168.2.2 + tunnel1=169.254.0.1 + tunnel2=169.254.0.2 + + epair=$(vnet_mkepair) + + vnet_init + + vnet_mkjail wgtest1 ${epair}a + vnet_mkjail wgtest2 ${epair}b + + jexec wgtest1 ifconfig ${epair}a ${endpoint1}/24 up + jexec wgtest2 ifconfig ${epair}b ${endpoint2}/24 up + + wg1=$(jexec wgtest1 ifconfig wg create) + echo "$pri1" | jexec wgtest1 wg set $wg1 listen-port 12345 \ + private-key /dev/stdin + pub1=$(jexec wgtest1 wg show $wg1 public-key) + wg2=$(jexec wgtest2 ifconfig wg create) + echo "$pri2" | jexec wgtest2 wg set $wg2 listen-port 12345 \ + private-key /dev/stdin + pub2=$(jexec wgtest2 wg show $wg2 public-key) + + atf_check -s exit:0 -o ignore \ + jexec wgtest1 wg set $wg1 peer "$pub2" \ + endpoint ${endpoint2}:12345 allowed-ips ${tunnel2}/32 + atf_check -s exit:0 \ + jexec wgtest1 ifconfig $wg1 inet ${tunnel1}/24 up + + atf_check -s exit:0 -o ignore \ + jexec wgtest2 wg set $wg2 peer "$pub1" \ + endpoint ${endpoint1}:12345 allowed-ips ${tunnel1}/32 + atf_check -s exit:0 \ + jexec wgtest2 ifconfig $wg2 inet ${tunnel2}/24 up + + # Generous timeout since the handshake takes some time. + atf_check -s exit:0 -o ignore jexec wgtest1 ping -c 1 -t 5 $tunnel2 + + # No receive errors before injection + ierrs=$(netstat -j wgtest2 -I $wg2 --libxo json,pretty | \ + awk '/received-errors/ { print $2 }') + atf_check_equal "0," "$ierrs" + + # Trigger a decryption error + atf_check -s exit:0 -o ignore \ + sysctl debug.fail_point.crypto.inject_badmsg="1*return" + + atf_check -s exit:2 -o ignore jexec wgtest1 ping -c 1 -t 5 $tunnel2 + + ierrs=$(netstat -j wgtest2 -I $wg2 --libxo json,pretty | \ + awk '/received-errors/ { print $2 }') + atf_check_equal "1," "$ierrs" +} + +wg_bad_decrypt_cleanup() +{ + vnet_cleanup +} + +atf_init_test_cases() +{ + atf_add_test_case "wg_bad_decrypt" +}