Date: Sat, 1 Feb 2025 10:21:37 +0800 From: Zhenlei Huang <zlei@FreeBSD.org> To: Mark Johnston <markj@FreeBSD.org> Cc: "src-committers@freebsd.org" <src-committers@FreeBSD.org>, "dev-commits-src-all@freebsd.org" <dev-commits-src-all@FreeBSD.org>, "dev-commits-src-main@freebsd.org" <dev-commits-src-main@FreeBSD.org> Subject: Re: git: afc38f1f23ac - main - sysctl: Add a regression test which runs sysctl -a Message-ID: <8668AD0D-5FE3-4C17-A5EB-F0C5862FC62A@FreeBSD.org> In-Reply-To: <202501311522.50VFMfQi062320@gitrepo.freebsd.org> References: <202501311522.50VFMfQi062320@gitrepo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
> On Jan 31, 2025, at 11:22 PM, Mark Johnston <markj@FreeBSD.org> wrote: >=20 > The branch main has been updated by markj: >=20 > URL: = https://cgit.FreeBSD.org/src/commit/?id=3Dafc38f1f23ac3b579144d0d1d0c3fadf= 735d57bd >=20 > commit afc38f1f23ac3b579144d0d1d0c3fadf735d57bd > Author: Mark Johnston <markj@FreeBSD.org> > AuthorDate: 2025-01-31 15:20:04 +0000 > Commit: Mark Johnston <markj@FreeBSD.org> > CommitDate: 2025-01-31 15:22:24 +0000 >=20 > sysctl: Add a regression test which runs sysctl -a >=20 > Run sysctl -a during the test suite so that KASAN/KMSAN have a = chance to > catch something. >=20 > Inspired by https://jprx.io/cve-2024-54507/ That's a damn good example ! >=20 > Reviewed by: jhb, emaste > MFC after: 2 weeks > Sponsored by: Klara, Inc. > Differential Revision: https://reviews.freebsd.org/D48659 > --- > sbin/sysctl/tests/sysctl_test.sh | 57 = ++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 57 insertions(+) >=20 > diff --git a/sbin/sysctl/tests/sysctl_test.sh = b/sbin/sysctl/tests/sysctl_test.sh > index e932626a9f14..dfc32a87b212 100644 > --- a/sbin/sysctl/tests/sysctl_test.sh > +++ b/sbin/sysctl/tests/sysctl_test.sh > @@ -1,3 +1,6 @@ > +# > +# SPDX-License-Identifier: BSD-2-Clause > +# > # Copyright (c) 2022 Yoshihiro Ota <ota@j.email.ne.jp> > # > # Redistribution and use in source and binary forms, with or without > @@ -20,12 +23,64 @@ > # 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. > +# >=20 > sysctl_name=3D"kern.ostype" > sysctl_value=3D"FreeBSD" > sysctl_type=3D"string" > sysctl_description=3D"Operating system type" >=20 > +atf_test_case sysctl_aflag > +sysctl_aflag_head() > +{ > + atf_set "descr" "Exercise all sysctl handlers" > +} > +sysctl_aflag_body() > +{ > + # Avoid using atf_check here since sysctl -ao generates tons of > + # output and it would all otherwise be saved. > + sysctl -ao >/dev/null 2>stderr > + if [ $? -ne 0 ]; then > + atf_fail "sysctl -ao failed" > + elif [ -s stderr ]; then > + cat stderr > + atf_fail "sysctl -ao printed to stderr" > + fi > +} > + > + > +atf_test_case sysctl_aflag_jail > +sysctl_aflag_jail_head() > +{ > + atf_set "descr" "Exercise all sysctl handlers in a jail" > + atf_set "require.user" "root" > +} > +sysctl_aflag_jail_body() > +{ > + local jail > + > + jail=3Dsysctl_test_aflag_jail > + > + # Avoid using atf_check here since sysctl -ao generates tons of > + # output and it would all otherwise be saved. > + jail -c name=3D$jail command=3Dsysctl -ao >/dev/null 2>stderr > + if [ $? -ne 0 ]; then > + atf_fail "sysctl -ao failed" > + elif [ -s stderr ]; then > + cat stderr > + atf_fail "sysctl -ao printed to stderr" > + fi > + > + jail -c name=3D$jail vnet command=3Dsysctl -ao >/dev/null = 2>stderr > + if [ $? -ne 0 ]; then > + atf_fail "sysctl -ao failed" > + elif [ -s stderr ]; then > + cat stderr > + atf_fail "sysctl -ao printed to stderr" > + fi > +} > + > + > atf_test_case sysctl_by_name > sysctl_by_name_head() > { > @@ -106,6 +161,8 @@ sysctl_nflag_tflag_dflag_body() >=20 > atf_init_test_cases() > { > + atf_add_test_case sysctl_aflag > + atf_add_test_case sysctl_aflag_jail > atf_add_test_case sysctl_by_name > atf_add_test_case sysctl_nflag > atf_add_test_case sysctl_eflag
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?8668AD0D-5FE3-4C17-A5EB-F0C5862FC62A>