From nobody Mon Oct 09 03:43:09 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 4S3lHL1nXQz4wC1J; Mon, 9 Oct 2023 03:43:10 +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 4S3lHL0rQlz4FHw; Mon, 9 Oct 2023 03:43:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696822990; 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=0INFk1kaoM3kRlW+w70BaCC2/u2nz6oGX7P1Cz9Fz5s=; b=NN6L7qQ/1dEt+BdV5WZHisZ5iXBymSWqh7ceARvlvv1vPRuc0rXlSuLSGpueKqipY8asNJ z7zLebEfKXYVz0dGNu3ybXbo13pIEyFaaZ46aGnChkFByDHg1VprzDLBQ/JZkYxmkedQT2 ICwH6yxa+f0t/T5wfRkKMy53ADnIql5a0n2Q91n2S12WJ+fvD3rpKppWRlC0ekOJsmGe38 wlVI/WGpjRvtxmbPOnT/ohblSU3HhhWNXaHwBvcvIc2OrnE5cTDs+PWVYwurB+OdHnzS7K R3b7sK3ixNa5B+3XoS0BfhnP7MGupgI1ra1a7UA0kenf7taJEwJ/y68aD3npog== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1696822990; a=rsa-sha256; cv=none; b=Ao8qr646PSd4n+Q0RYcJinc0xMDyFoFj9ZKXk5YHT3b2J9TolEcTjt9K2qngrF9lIqSGVF AHFW0ofWWf/Ek0zgoe3fcZVEqvbqH75Om4wb0PZUtPAETGngMjE5DkjlRRIt8ooZYCHq2Z Uwu5WjEJ191/9Ru7+R/ogXziRQkkRzit2gg/Nrt8Fjep6T8zD+QGOwRZIoqqW6S9/NMWF8 b/PTd6F8JYBRI0Kqq+EcAJ2UFuqQ9CLQgGtCfPrUfvYs+UPhlz+8ovJYELHAAa6nNndHWr 60JMftwElAs+jHQQu3WKLMy8crI3fsjAUjj1w0Fwwm8sWSfA3aklH0IvbqKCyw== 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=1696822990; 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=0INFk1kaoM3kRlW+w70BaCC2/u2nz6oGX7P1Cz9Fz5s=; b=YfUS4gF4/W/PqTxbfalVF0T1GbPsBpCLuacKNWL/p7nIiwTHCAH+WILB7dppDQUybN0ZxV 5dDQy6wK+4oEavMFrJSLOejYrTWufxadC8m8A+mfbFQfToReMpwefXpDhUyyZOJ6f7Hawj iFJ34tyJYQoGUmUAY0xal0pY5oLbP0Y6HCgb+PvDG//zyMVnyVrmqEz0AOdoEaGQm7TjGD 3EMlFWuvW/1CUbklING947WmfT6l/tHxg+ttxlCtsNOajfZY5c5zpK7Jvo1wg3f56dAgpk mzGXQqTlO0wcgHU8Xxyb/BgZj5WbtyI0ZgX3gQRWOSVbf8SOg69bv4UJRLPz+A== 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 4S3lHK6mcMzg1t; Mon, 9 Oct 2023 03:43:09 +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 3993h9Ir024254; Mon, 9 Oct 2023 03:43:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3993h9ic024251; Mon, 9 Oct 2023 03:43:09 GMT (envelope-from git) Date: Mon, 9 Oct 2023 03:43:09 GMT Message-Id: <202310090343.3993h9ic024251@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: c11f71789d7d - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: c11f71789d7d8f741243c21add8d7c5f0ecea03e Auto-Submitted: auto-generated The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=c11f71789d7d8f741243c21add8d7c5f0ecea03e commit c11f71789d7d8f741243c21add8d7c5f0ecea03e Author: Konstantin Belousov AuthorDate: 2023-09-25 18:40:28 +0000 Commit: Konstantin Belousov CommitDate: 2023-10-09 03:42:17 +0000 SIGSYS: add tests (cherry picked from commit 0afcac3e37e911f7e387ebeb2aae19b2b00ca4cc) --- 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 95d6ef9b7bc0..ec2bbd742956 100644 --- a/tests/sys/kern/Makefile +++ b/tests/sys/kern/Makefile @@ -40,6 +40,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()); +}