selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Richard Haines <richard_c_haines@btinternet.com>
To: selinux@vger.kernel.org
Cc: Richard Haines <richard_c_haines@btinternet.com>
Subject: [PATCH 0/1]  selinux-testsuite: Add perf_event tests
Date: Sun,  1 Dec 2019 14:52:37 +0000	[thread overview]
Message-ID: <20191201145238.265621-1-richard_c_haines@btinternet.com> (raw)

This was tested on kernel.org 'next-20191128' as Rawhide kernels
don't yet support the new perf_event hooks.

Note that the default .config enables the following that have been added
to defconfig:
CONFIG_HAVE_PERF_EVENTS=y
CONFIG_PERF_EVENTS=y
CONFIG_TRACEPOINTS=y

To allow testing, the following steps are required to update Fedora
policy:

1) Using the diff below, add the perf_event class and its
   permissions to:
/usr/share/selinux/devel/include/support/all_perms.spt

--- a/all_perms.spt	2019-12-01 14:11:22.304013835 +0000
+++ b/all_perms.spt	2019-11-29 15:11:21.891680000 +0000
@@ -230,6 +230,7 @@
 	class smc_socket all_smc_socket_perms;
 	class bpf all_bpf_perms;
 	class xdp_socket all_xdp_socket_perms;
+	class perf_event { open cpu kernel tracepoint read write };
 ')
 
 define(`all_userspace_class_perms',`


2) Create a cil module 'test_perf.cil' that defines the class:

(class perf_event (open cpu kernel tracepoint read write))
(classorder (unordered perf_event))

Then insert into policy:
semodule -i test_perf.cil

Richard Haines (1):
  selinux-testsuite: Add perf_event tests

 defconfig                     |   6 ++
 policy/Makefile               |   4 +
 policy/test_perf_event.te     | 106 ++++++++++++++++++++
 tests/Makefile                |   4 +
 tests/perf_event/.gitignore   |   1 +
 tests/perf_event/Makefile     |   7 ++
 tests/perf_event/perf_event.c | 178 ++++++++++++++++++++++++++++++++++
 tests/perf_event/test         |  80 +++++++++++++++
 8 files changed, 386 insertions(+)
 create mode 100644 policy/test_perf_event.te
 create mode 100644 tests/perf_event/.gitignore
 create mode 100644 tests/perf_event/Makefile
 create mode 100644 tests/perf_event/perf_event.c
 create mode 100755 tests/perf_event/test

-- 
2.23.0


             reply	other threads:[~2019-12-01 14:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-01 14:52 Richard Haines [this message]
2019-12-01 14:52 ` [PATCH 1/1] selinux-testsuite: Add perf_event tests Richard Haines
2019-12-03 15:15   ` Stephen Smalley
2019-12-03 16:00     ` Richard Haines

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191201145238.265621-1-richard_c_haines@btinternet.com \
    --to=richard_c_haines@btinternet.com \
    --cc=selinux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).