From nobody Sun May 12 00:08:37 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 4VcNJ55S7Zz5JbSS; Sun, 12 May 2024 00:08:37 +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 4VcNJ540hbz4t99; Sun, 12 May 2024 00:08:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715472517; 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=mcjvWdaMpPki2BHF2AscVF2jqhUqFpIPqzh1oQayV70=; b=iUBc4eRaQ/iyZ9yvR5RyzxLoJWNguYkdjA2bZ/q/Sd0NE7Oaf4bZX4M6c11OK1G/V14sH4 a+yPobXREqrwlpdgfIrLr2AgOmYPVHzy5oIjSo3/1rA1P2m4YIE3yLEy1B6JuydHjEfYAN FT1Bkrmz7rmnZoo6qlPUizxmUi+8TFIN9gmZ422hXcNHGYkzzXahvqDMexU2fTSHLeY0D1 wEIRCPz8cgBqzBzqn1d78OeeKjQQFwnV/MtDscmvE09+F3MH0rRGLbZd6MoNjQ6YLjIhFA Qz1dsI+HTym/QmFTsWCSBf2x8b+MHFEiI8p/25MzFfnNjdC3spzNKyuFNHiw6g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1715472517; a=rsa-sha256; cv=none; b=Rq9cOJYrJ7bku+rA5pZnOIbJiHZR4BUubYuMIbfimdFQtkZjS9qhIHZo4Gqv5VVkzGxHte H1nHVa5+v+MpmDo6CHJb2OFtRUsoi3NwBlelfYen0VLrKYqrYmHRutrKvqeX70EL/Xvewe StlkDf5dtb2gyhoBG2fJc/RlpSl5/h9HHvLEzo6qVx951cxbf3TZe7V1CD+PbNsiMRR8Mo 4ilGQCHtr3o7MXghyQmSMRRu5RYyNTsxjtXVf+J8pwCa5hP1Lgv2VQstJem2ebMGyGuWVY v1Rg7uBJ+UbMhp1j3GACUnj0z0ky+mj9yOe+Vhy9iW1q5hCuxq+rUUhm8jTmtA== 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=1715472517; 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=mcjvWdaMpPki2BHF2AscVF2jqhUqFpIPqzh1oQayV70=; b=lVnbJD9bxFY+72YzV5ClJzHbK95moF401o5kk+DeNI+VwrAkXEIhyHdBnUHOQQQ3F+B6Vv Z3omAunIs22xAgN7YXRxFBxKb90DrnxLoNiBLuv+oA3pwPCQ7jRWkOY8G/VCZmVNb4BBe1 5xx8Lz3UgjBciGX37UdxuCEB1KegH9HBvJ2uNLPqEdR8yH2oRn3lg1HaAeMzS57gg4qEM3 Tbwec8Ca1dUXc5og/9iBzJseWGC8bwZUEeUfOALe1wwWFU2C4+h+niMkcKllg3EExbYzr7 /ZiHC/5ixPVLiN8XunoeY0ivvQ4OK9fQSSXXeOJMzaGsMiwfEaHwkyJ/wIq8+g== 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 4VcNJ52m6yzhh8; Sun, 12 May 2024 00:08:37 +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 44C08bnm002231; Sun, 12 May 2024 00:08:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44C08b93002228; Sun, 12 May 2024 00:08:37 GMT (envelope-from git) Date: Sun, 12 May 2024 00:08:37 GMT Message-Id: <202405120008.44C08b93002228@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Jake Freeland Subject: git: a94eacb13977 - stable/14 - 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-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/stable/14 X-Git-Reftype: branch X-Git-Commit: a94eacb139772114a68030ca8987d6bd8e67a4ab Auto-Submitted: auto-generated The branch stable/14 has been updated by jfree: URL: https://cgit.FreeBSD.org/src/commit/?id=a94eacb139772114a68030ca8987d6bd8e67a4ab commit a94eacb139772114a68030ca8987d6bd8e67a4ab Author: Jake Freeland AuthorDate: 2024-04-10 02:18:11 +0000 Commit: Jake Freeland CommitDate: 2024-05-11 23:57:44 +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 (cherry picked from commit 054a4720591f0c98579bccef2751fd458ee4f71f) --- 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()); }