From nobody Mon Oct 02 22:31:23 2023 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 4RzwfM5d3Qz4wZGw; Mon, 2 Oct 2023 22:31:23 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RzwfM3TnRz3W21; Mon, 2 Oct 2023 22:31:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696285883; 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=yVVzr15WYsquMPAWP01mLs00b6xvefkr7ZfLfXFbwTc=; b=UCGNPu1ue+RHohcWpAsDO72Vkfzga0pRzPq++lUxKHT/4h6H/XsHzushol43jXQJBMRkYF zwMl/XICXBhuvg4WW3RtbhVKhiMSHMBOW08R5aYfdqK1gaV+bRmYZCPiTAKJfkortbTs/v HEh0VRSJfQzM53qDZnntl0Yc3g5v+SkG+qvuvxkCXO6BYQ/So17P8BZu8q2XUxlHNXukgM 6hW8A6j2AoutHnmkHcqG8EbfAeyil7M2baew3UuA5UnnJdmN/AowpxS8psQ2Ve2h0ncywL 7w7oRswIsv6fzqUcxfj39dokX1DDCNlejest/tYZn0L1izdEMgb4NVHn1T+RIg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1696285883; a=rsa-sha256; cv=none; b=O4amfqUVexup8SM9OCnoT7n5DH97Eguuyy6K5cw/bQgxyiVyw4efcUnIhcz6avmugjpDtp EPWgzffR43S8yhHVRVRu/KqjaLttcS3VsqbY2m06XLYIlcjNbMhrPZDWkxvDqJHUDfauQ6 2R9xyjjnfPzPzA/4lEtlz0ShVFmU7WotNACqVNLRnvMGWEa+7DSw06c2YtjVIwU4Nd6jT3 A6QSVC7ooyzUi0a/YUHCwe+IWrCBnygOqEgqIucw3eAczCBLcEG4vvKuv7ZyrBAjC5/s6e Vs4z5rV1bSvwT8FdZfdXxUqDd1+Co0tcfMQAuIHZO/38Z155dr4XJXB9AutZzQ== 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=1696285883; 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=yVVzr15WYsquMPAWP01mLs00b6xvefkr7ZfLfXFbwTc=; b=yIxZ4+/i4YiXeP595vsUJxPxbnR+ot2VP6X3sa25p3ADQqxGrcv3ouVGN9h+yC51k2bGcH 5q6/RkaEC3cKIHGuSh0aUEuaNqJAntS8yE01anrxmiX+W4xwKCUy5zE8tI6zGK8CzqlmLJ esrGIvGo1GrEH019tfceL30Vg0xLwNL5/zNN6dkFl3o4ntVtvtZ9/6twJ5gWmb9SSYJ8cL XPP2mbZVcQymLpFohvj6dHreBjZmwrtSmmfZ3WT3gVppxNTtI8BBXspJMStN2rG0yNZf7N PGktBvbQFcVXKhLVDHw9QGC9igOK20JJwgOf49g+0OJXMTW5kJ1HER0b+T/wsg== 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 4RzwfM2Xb0zWB0; Mon, 2 Oct 2023 22:31:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 392MVNeB099146; Mon, 2 Oct 2023 22:31:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 392MVNW4099143; Mon, 2 Oct 2023 22:31:23 GMT (envelope-from git) Date: Mon, 2 Oct 2023 22:31:23 GMT Message-Id: <202310022231.392MVNW4099143@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 0afcac3e37e9 - main - SIGSYS: add tests 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0afcac3e37e911f7e387ebeb2aae19b2b00ca4cc Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=0afcac3e37e911f7e387ebeb2aae19b2b00ca4cc commit 0afcac3e37e911f7e387ebeb2aae19b2b00ca4cc Author: Konstantin Belousov AuthorDate: 2023-09-25 18:40:28 +0000 Commit: Konstantin Belousov CommitDate: 2023-10-02 22:30:53 +0000 SIGSYS: add tests Reviewed by: dchagin, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D41976 --- tests/sys/kern/Makefile | 1 + tests/sys/kern/sigsys.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/tests/sys/kern/Makefile b/tests/sys/kern/Makefile index f2fe9e7008d9..6396b22005c3 100644 --- a/tests/sys/kern/Makefile +++ b/tests/sys/kern/Makefile @@ -48,6 +48,7 @@ TEST_METADATA.unix_seqpacket_test+= timeout="15" ATF_TESTS_C+= unix_socketpair_test ATF_TESTS_C+= waitpid_nohang ATF_TESTS_C+= pdeathsig +ATF_TESTS_C+= sigsys ATF_TESTS_SH+= coredump_phnum_test ATF_TESTS_SH+= sonewconn_overflow diff --git a/tests/sys/kern/sigsys.c b/tests/sys/kern/sigsys.c new file mode 100644 index 000000000000..75e3816fc158 --- /dev/null +++ b/tests/sys/kern/sigsys.c @@ -0,0 +1,69 @@ +/*- + * Copyright (c) 2023 The FreeBSD Foundation + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + */ + +#include + +#include +#include +#include +#include +#include + +static sig_atomic_t sigsys_cnt; + +static void +sigsys_handler(int signo, siginfo_t *si, void *ucp) +{ + sigsys_cnt++; +} + +ATF_TC(sigsys_test); + +ATF_TC_HEAD(sigsys_test, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Testing delivery of SIGSYS on invalid syscalls"); +} + +ATF_TC_BODY(sigsys_test, tc) +{ + struct sigaction sa; + + memset(&sa, 0, sizeof(sa)); + sa.sa_sigaction = sigsys_handler; + sa.sa_flags = SA_SIGINFO; + ATF_REQUIRE(sigaction(SIGSYS, &sa, NULL) == 0); + + ATF_REQUIRE(syscall(273) == -1); /* reserved */ + ATF_CHECK_ERRNO(ENOSYS, true); + atomic_signal_fence(memory_order_seq_cst); + ATF_CHECK_EQ(1, sigsys_cnt); + + ATF_REQUIRE(syscall(440) == -1); /* SYS_kse_switchin */ + ATF_CHECK_ERRNO(ENOSYS, true); + atomic_signal_fence(memory_order_seq_cst); + ATF_CHECK_EQ(2, sigsys_cnt); + + /* Hope this is enough for say next two months */ + ATF_REQUIRE(syscall(3000000) == -1); + ATF_CHECK_ERRNO(ENOSYS, true); + atomic_signal_fence(memory_order_seq_cst); + ATF_CHECK_EQ(3, sigsys_cnt); + + ATF_REQUIRE(syscall(SYS_afs3_syscall) == -1); + ATF_CHECK_ERRNO(ENOSYS, true); + atomic_signal_fence(memory_order_seq_cst); + ATF_CHECK_EQ(4, sigsys_cnt); +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, sigsys_test); + return (atf_no_error()); +}