From nobody Wed Apr 10 02:21:01 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 4VDmlf1DTJz5GXsR; Wed, 10 Apr 2024 02:21: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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VDmld68nBz4Jww; Wed, 10 Apr 2024 02:21:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712715661; 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=qM8Ti9K32Kf91DkN38YDmDApCDp2zQenrqBETlMuAhY=; b=oUl1rcxQGaSdw6sX8iyo6AkG5osvzW6zv1Z1cvGOrSQLWKdMFFma6F/17vkDgyl81F03ye GLkRL/Pny7ErsIcuhWHWkgMV+usvYyXUWMaCRi/jOKa5r4nQ6eDjkajKNQmzWiYwfc5LLj eYVYEqFmljJGjm+UmwP5a90Oq5DdRJU9YCZGI/iowh2H+T6VTpLSNu1xqZxTXbrohzpqHW b3OGfxkVdpttUQNAZNX9CwbMhenUeKB+1hAUHJul/UQGJwuY+XUf5vLa6WA24CoVvn27AH 6JaML165iusYYj0Nv9jG4suwEmAvu0GeKBjhldhRwY9702m3SgxhR8zt8uj6TA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712715661; a=rsa-sha256; cv=none; b=doguwzXVIm9mwi2uG7s79qYDt/vBLsL7zWxW6Z5CFNIoq5z28/znFgC7CWZtrwzJdZNlsn hERR6oo/OZliimrxYT5eCUJEheMrXG7UWxOofReZNxqo5K2BbcQPT5HAMx4Zb1m7E9pjPx BlQw9Td9tZLIOWylDLmZInvatog21wT9QxMHKIoA3jpYT2hVDkad38s9CzCwdGzrOPoX3J YELnC3g9JOSIM46enUsHna6vjsltOvnQQR/EtMJX32OvwKaprbUPSmC8RYcVdm8AZibBCT qrRrVnt1eOnYbx/1vACtf+t5rNusDs3+jXwFqcIvmlWUjyu7kwS+/pbfz/nElw== 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=1712715661; 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=qM8Ti9K32Kf91DkN38YDmDApCDp2zQenrqBETlMuAhY=; b=Y6VHpQOKmqtAJ1jIuDe/mGENlMs7Hgl3TTOxnwMDH/1mcAfzdNofH6vhnxbUF1Ov0kJqq9 isZahHsuhtdEmDfmebi99tMrsceWOXDYLqMyeeSV/xWvgDt6irwZacBQkGnF6dQiODpBcY kb3Q2RozCXvtWoRvi7wt2wxdbXguljN9vLAIOpn64ycEpFLIYl5to/NqrH4gjeHGplsYLN dOF5s/DDPMleY5uqJ8ufg7w1YsRLkG6BrK2wEvotMUP/JYuuhTz5P5rVH2CUivAIkJF1LK ZXwjk6JIgmlL7UHjzvNF38slFtq16ETwXDZyu6U9ZKjGXzzdyVH9di3DuLMQ8A== 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 4VDmld5nJKzJSZ; Wed, 10 Apr 2024 02:21:01 +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 43A2L1GL080128; Wed, 10 Apr 2024 02:21:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43A2L1iw080110; Wed, 10 Apr 2024 02:21:01 GMT (envelope-from git) Date: Wed, 10 Apr 2024 02:21:01 GMT Message-Id: <202404100221.43A2L1iw080110@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jake Freeland Subject: git: 054a4720591f - main - tests: Add ktrace regression test for shm_open 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: dev-commits-src-all+owner@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: jfree X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 054a4720591f0c98579bccef2751fd458ee4f71f Auto-Submitted: auto-generated The branch main has been updated by jfree: URL: https://cgit.FreeBSD.org/src/commit/?id=054a4720591f0c98579bccef2751fd458ee4f71f commit 054a4720591f0c98579bccef2751fd458ee4f71f Author: Jake Freeland AuthorDate: 2024-04-10 02:18:11 +0000 Commit: Jake Freeland CommitDate: 2024-04-10 02:19:03 +0000 tests: Add ktrace regression test for shm_open Verify that a capability violation is recorded when shm_open(2) is called with a non-anonymous path. Approved by: markj (mentor) Reviewed by: markj MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D44733 --- tests/sys/kern/ktrace_test.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/sys/kern/ktrace_test.c b/tests/sys/kern/ktrace_test.c index 49e2ed05fed9..21868441c687 100644 --- a/tests/sys/kern/ktrace_test.c +++ b/tests/sys/kern/ktrace_test.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -474,6 +475,38 @@ ATF_TC_BODY(ktrace__cap_cpuset, tc) "cpuset_setaffinity"); } +ATF_TC_WITHOUT_HEAD(ktrace__cap_shm_open); +ATF_TC_BODY(ktrace__cap_shm_open, tc) +{ + struct ktr_cap_fail violation; + sigset_t set = { }; + pid_t pid; + int error; + + /* Block SIGUSR1 so child does not terminate. */ + ATF_REQUIRE(sigaddset(&set, SIGUSR1) != -1); + ATF_REQUIRE(sigprocmask(SIG_BLOCK, &set, NULL) != -1); + + ATF_REQUIRE((pid = fork()) != -1); + if (pid == 0) { + /* Wait until ktrace has started. */ + CHILD_REQUIRE(sigwait(&set, &error) != -1); + CHILD_REQUIRE_EQ(error, SIGUSR1); + + CHILD_REQUIRE(shm_open("/ktrace_shm", O_RDWR | O_CREAT, + 0600) != -1); + CHILD_REQUIRE(shm_unlink("/ktrace_shm") != -1); + exit(0); + } + + cap_trace_child(pid, &violation, 1); + ATF_REQUIRE_EQ(violation.cap_type, CAPFAIL_NAMEI); + error = syscallabi(violation.cap_svflags); + ATF_REQUIRE_STREQ(sysdecode_syscallname(error, violation.cap_code), + "shm_open2"); + ATF_REQUIRE_STREQ(violation.cap_data.cap_path, "/ktrace_shm"); +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, ktrace__cap_not_capable); @@ -484,5 +517,6 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, ktrace__cap_sockaddr); ATF_TP_ADD_TC(tp, ktrace__cap_namei); ATF_TP_ADD_TC(tp, ktrace__cap_cpuset); + ATF_TP_ADD_TC(tp, ktrace__cap_shm_open); return (atf_no_error()); }