Compare commits

...
Sign in to create a new pull request.

626 commits

Author SHA1 Message Date
Milos Malik
534e38f96f test if virtqemud can execute udevadm
Recent virt-install testing with various USB devices revealed
SELinux denials which are triggered when the virtqemud process
executes the udevadm command. The TC reproduces the situation.

In order to support this functionality, I believe that SELinux
policy should allow the execution and transition to the udev_t
domain. The TC looks for appropriate policy rules and file
context patterns.

The TC covers RHEL-236185.
2026-08-18 13:01:14 +00:00
Veronika Syncakova
332b82ec4e Skip the RHEL 110090 phase if iio_device_t is not defined.
The test phase is specifically looking for iio_device_t.
2026-08-14 08:39:19 +00:00
Veronika Syncakova
194bac23df Adujst test to hardware limitations.
If CPU boost control is unavailable, the tuned-adm verify returns 1.

-i  do not treat missing/non-supported tunings as errors

ERROR: verify: failed: device cpu0: 'boost' = 'None', expected '1'
WARNING: Unable to set boost on cpu 'cpu0'. Neither per-policy boost nor intel_pstate no_turbo is
available.
2026-08-14 08:36:03 +00:00
Akhil Kohli
6ed096cf7f selinux-policy/m4-bad-data: add M4 bad-data tests for modular policy builds
Add beakerlib/TMT coverage and fixtures for M4 preprocessing of modular
policy builds: .if to all_interfaces.conf, .te + interfaces to .tmp
(then checkmodule), and .fc to .mod.fc, using live support macros from a
selinux-policy checkout and a snapshotted modular M4 recipe.

33 test cases (42 harness pass steps) with minimal standalone fixtures.

Each case is its own rlRun phase in runtest.sh. Covers interface path
validation (including duplicates and broken gen_require), .te arity
edge cases, post-M4 checkmodule failures from bad interface expansion,
.fc path edge cases, M4-to-semodule_package E2E, and .fc content where
labeling validation is deferred to sefcontext_compile.

When SELINUX_POLICY_SRC is unset, clones fedora-selinux/selinux-policy
using a host-detected branch (f$VERSION_ID on Fedora, c${major}s
otherwise), overridable with SELINUX_POLICY_BRANCH.

Signed-off-by: Akhil Kohli <akkohli@redhat.com>
2026-08-13 10:26:03 +02:00
Milos Malik
712c3f71d3 set immutable bit on the restorecond PID file
The restorecond service does not really need its PID file, which means
that neither the systemd process nor the restorecond process should
create it or remove it.

Removal attempts are detected, because the test sets the immutable
bit on the PID file and then it looks for timeout messages in journal.
2026-08-11 15:04:43 +00:00
Ondrej Mosnacek
e7ec6c8148
kernel/avc_tracepoint: fix to work on AWS Graviton3 CPUs
The --call-graph dwarf argument requires hardware fetures that may not
be implemented on some platforms (e.g. aarch64 AWS Graviton3 CPUs). Use
just plain -g instead, which will hopefully work anywhere. The stack
trace doesn't really matter that much anyway, as we are just testing
that the tracepoint is available and working.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2026-08-10 12:04:35 +02:00
Zdenek Pytela
b1a11e8d06 Change default context for /var/named
The selinux-policy commit adding support for bind packages with suffixes
also changes default context for /var/named and adds a few more
explicit entries.

This test update makes an adjustment to the current state.
2026-08-05 07:45:36 +00:00
Zdenek Pytela
6235e6ffdd Changes adapting to bind packages with suffixes
The bind package now provides executables with suffixes, e.g.
"/usr/bin/named-9.18". That includes the main daemon named, rndc and
other tools. Links to the actual executables are provided using the
alternatives tool.

Subsequently, the named test is now being updated using the readlink command
to get canonical file names.
2026-08-05 07:45:36 +00:00
Milos Malik
e5badb50c6 add a new basic test which covers the qat service
Recently filed bug reports revealed that SELinux prevents the qat_init.sh
process from the following actions:
 * accessing (syscall = newfstatat) the /dev/hugepages directory
 * creating (syscall = mkdir) the /dev/hugepages/qat directory
 * setting permissions/ownership (syscall = fchownat)

The TC reproduces the situation.

In order to support the qat service functionality, I believe that
SELinux policy should allow these actions. The TC looks for appropriate
policy rules and file context patterns.

The TC covers RHEL-211077 and RHEL-211089.
2026-07-24 14:44:41 +02:00
Veronika Syncakova
5cc4776f3b Test that rhsmcertd have access to gconf_home_t site-packages
Test case for RHEL-106483
2026-07-22 13:31:26 +00:00
Veronika Syncakova
d5072cf5ed Test if crashing process in a nspawn container triggers an AVC denial.
If a process crashes in an nspawn container started either via machinectl start or systemd-nspawn -bD ...
it triggers an AVC denial, even if the container is under /var/lib/machines/.

Tests RHEL-139983
2026-07-22 13:28:07 +00:00
Veronika Syncakova
39d1965d56 Fix to accommodate the new attribute sys_resource_type
Allow the sys_resource capability to each domain which is allowed to
execute generic programs in system bin directories without domain
transition when the coreutils_bin_sys_resource tunable is on. If the
tunable is off, which is the default state, the capability is
dontaudited instead.

This test was nout counting with dontaudit rule beforehand. No avc will be present if the tunable
is off.
2026-07-22 13:25:15 +00:00
Veronika Syncakova
1213f7b91d Fix fail during install in /libselinux/setfiles-in-chroot-env
If epel is present, the release version was not detected.
2026-07-22 11:13:34 +02:00
Veronika Syncakova
e62cab0e38 Fix for /libselinux/matchpathcon-in-chroot-env
If epel repo was installed, the release version was not recognized.
2026-07-22 11:10:59 +02:00
Milos Malik
f03d5ff12b test if the bootupd service can talk to SSSD
A recently filed bug report revealed that SELinux prevents the
bootupd service and its children processes from talking to SSSD.
The TC reproduces the situation on machines created by bootc.

In order to support this scenario, I believe that SELinux policy
should allow the necessary access. The TC looks for appropriate
policy rules and file context patterns.

The TC covers RHEL-174888.
2026-06-29 12:14:27 +00:00
Petr Matyas
6f2828a431 Move oom-compiler-failure from gitlab
Verify that checkpolicy and checkmodule abort cleanly when memory is
exhausted during compilation, rather than producing a potentially
incorrect output binary.
The test constrains the virtual address space of the compiler subprocess
to 8 MB via ulimit -v, which is sufficient for process startup but not
for parsing a full targeted policy binary. Both compilers are exercised
using binary input (checkpolicy -b, checkmodule -b) against the active
policy store. Assertions: non-zero exit status and no output file
produced under OOM.
Tested on RHEL 9, RHEL 10, and RHIVOS 2.0 on x86_64 and aarch64.
VROOM-40721
2026-06-29 10:41:30 +02:00
Ondrej Mosnacek
bcf00d44c6
kernel/overlayfs-mmap-bugs: test for execmem regression
The original CVE fix has a bug in that it incorrectly checks execmem
permission for the mounter domain. Test for the regression in the test
so that we can verify its fix.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2026-06-16 13:44:16 +02:00
Milos Malik
56b168c4ac add SELinux beaker library URL to the cups* tests
The following exception is raised when the cups* tests are executed
via 'wow --distro ... --case ...':

  ERROR  Failed to add <Task /CoreOS/selinux-policy/Regression/cups-lpd-and-similar [TC#305784]> due issue with TMT Metadata: Error in processing libraries from {'url': 'https://src.fedoraproject.org/tests/selinux.git', 'ref': 'main', 'name': '/selinux-policy/cups-lpd-and-similar'}. Raised exception was:
  ERROR  Unable to add one of testcases due to wrong metadata - See `--ignore-invalid` option
2026-06-12 15:16:19 +02:00
Milos Malik
62e5369698 add missing IDs to recently created tests
Ideally, each test should have a unique ID. These IDs can then be
used by various test case management and/or reporting tools.
2026-06-04 10:33:01 +02:00
Milos Malik
50869431bb run the internal checkpolicy tests
The checkpolicy source RPM contains not only checkpolicy sources but
also checkpolicy tests. Purpose of this automated test is to run them
with the current versions of libsepol and checkpolicy components.
2026-06-03 14:37:36 +00:00
Ondrej Mosnacek
9a7d3d69fb
Add a test for overlayfs mmap bugs (CVE-2026-46054)
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2026-05-28 14:14:02 +02:00
Jiri Jaburek
c8430211e0 make tests use the selinux-policy library directly
The original library(foo/bar) syntax was used via RPM Provides
on old RHTS / Beaker infra, and tmt translates it to fetching
libraries from https://github.com/beakerlib/, ie.

  https://github.com/beakerlib/selinux-policy

This location then contains a wrapper redirect back to this
repo with tests.

Let's avoid the external Github round-trip and just link to the
library directly via local references.

Also change the epel library link to the modern syntax.

Signed-off-by: Jiri Jaburek <jjaburek@redhat.com>
2026-05-14 08:38:48 +00:00
Jiri Jaburek
affc7c2cfc use epel/epel instead of distribution/epel library
The README on

  https://github.com/beakerlib/distribution/tree/master/epel

states that

  This is a compatibility layer to overcome a transitional
  phase from distribution/epel to epel/epel.

So use epel/epel instead.

Signed-off-by: Jiri Jaburek <jjaburek@redhat.com>
2026-05-14 08:38:48 +00:00
jan janasek
8e93cd9553 fix: replace rlCheckMakefileRequires with rlCheckDependencies
Signed-off-by: jjanasek <jjanasek@redhat.com>
2026-05-14 08:22:46 +00:00
Jiri Jaburek
45f0c8b295 fix recommends/requires typos, remove empty link
This fixes additional tmt lint issues.

Signed-off-by: Jiri Jaburek <jjaburek@redhat.com>
2026-05-11 17:11:13 +02:00
Jiri Jaburek
f9bd3e27ea avoid inheriting top-level main.fmf metadata into plans
This fixes nearly all tmt lint errors, since plans cannot have
'test:' and other test-related keywords.

Signed-off-by: Jiri Jaburek <jjaburek@redhat.com>
2026-05-11 17:11:13 +02:00
Jiri Jaburek
714022cf54 remove top-level main.fmf typo: tags
The fmf metadata keyword is 'tag', so 'tags' did nothing.

To avoid changing the behavior (adding a 'generic' tag to all tests),
I simply removed the keyword.

Signed-off-by: Jiri Jaburek <jjaburek@redhat.com>
2026-05-11 17:11:13 +02:00
Milos Malik
dd707fd653 test if power-profiles-daemon can watch /sys/firmware/acpi/
One of the reported selinux-policy bugs revealed that SELinux
prevents the power-profiles-daemon from watching the /sys/firmware/acpi
directory. The TC only reproduces the situation when the right HW
is available.

In order to support this functionality, I believe that SELinux
policy should allow this access. The TC looks for appropriate
policy rules and file context patterns.

The TC covers RHEL-105423.
2026-04-23 12:05:52 +00:00
Veronika Syncakova
18274abc2a test if systemd-tmpfiles-clean.service triggers an AVC denial 2026-04-13 10:11:28 +00:00
Zdenek Pytela
0badb50946 systemd-generators test: do not execute test for 2 generators
Since systemd v260 [1], support for System V service scripts has been
removed. As a part of this change, systemd-rc-local-generator and
systemd-sysv-generator were also removed.
This commit makes the relevant test parts run only if the generators
executables exist.

[1] https://github.com/systemd/systemd/releases/tag/v260-rc1
2026-04-13 08:02:25 +00:00
Milos Malik
5e3d738a08 test if nfs-server-generator can create/control its UDP sockets
After introducing the systemd_nfs_generator_t domain, a bug report was
filed which revealed that SELinux prevents the nfs-server-generator
from creating and controling its UDP sockets. The TC reproduces the
situation.

In order to support all functions of the nfs-server-generator program,
I believe that SELinux policy should allow these actions. The TC looks
for appropriate policy rules and file context patterns.

The TC covers RHEL-111556.
2026-04-13 07:47:16 +00:00
Milos Malik
8b6da4df0e add psi=1 to the kernel command line
For a successful run of the /selinux-policy/systemd-oomd test we
need the Pressure Stall Information (PSI) to be available.
From now on, the test add the psi=1 parameter to the kernel
command line and reboots the machine. The test should pass after
a reboot.
2026-04-13 07:30:27 +00:00
Milos Malik
53baf4175f instruct TMT to expect SELinux denials
The /selinux-policy/kernel-confined-exec test intentionally triggers
SELinux denials. TMT framework sees them as a problem unless told
otherwise. From now on, the TMT will expect them.
2026-04-13 07:30:27 +00:00
Milos Malik
337204b766 test if restorecond service times out occasionally
A recently reported customer case revealed that the restorecond
service occasionally fails to start because of a timeout. The
exact reproducer is unknown, but the TC reproduces a similar
situation (mislabeled /run/restorecond.pid file) which also leads
to timeouts.

In order to fix the problem, the restorecond service is no longer
a forking type of service. It is a single type of service. The TC
checks this parameter too.

The TC covers RHEL-142541 and RHEL-165247.
2026-04-09 12:56:50 +00:00
Veronika Syncakova
fdcacccc89 Test if selinux-policy owns tree with interface files
Recently filed report revealed that certain files are not owned by the selinux-policy package.
This situation is generally described in the following document and should be fixed:

    https://docs.fedoraproject.org/en-US/packaging-guidelines/UnownedDirectories/

Purpose of this test is to find out if the issue is fixed or not.

TC coveres: RHEL-141659 + RHEL-157952 + FC-1681
2026-04-08 08:45:47 +00:00
Veronika Syncakova
ed43635ec8 Test that seunshare/sandbox doesn't execute shell commands when given
filenames with special characters.

The test was co-authored by Gemini and Claude.

TC coveres: RHEL-144055
2026-04-08 08:09:56 +00:00
Milos Malik
4df7f3f716 test if logwatch scripts can check files in /run/netns
Recent logwatch + selinux-policy testing revealed that SELinux
prevents one of the logwatch scripts from checking files labeled
nsfs_t located under /run/netns directory. The TC reproduces the
situation.

In order to support the 'df' command functionality (executed by
one of the scripts, syscall = newfstatat), I believe that SELinux
policy should allow this access. The TC looks for appropriate
policy rules and file context patterns.

The TC covers RHEL-160896 and RHEL-160897.
2026-03-31 11:29:17 +00:00
Milos Malik
a47e772046 test if valkey service can manage RDMA sockets
Recent valkey + selinux-policy testing revealed that SELinux prevents
the valkey-server processes from creating and manipulating of RDMA
sockets when the valkey-rdma package is installed. The TC reproduces
the situation.

In order to enable the functions brought by the valkey-rdma package,
I believe that SELinux policy should allow the access. The TC looks
for appropriate policy rules and file context patterns.

The TC covers RHEL-154814 and RHEL-161115.
2026-03-26 18:04:17 +01:00
Veronika Syncakova
5caabc667c Test that the corecmd_bin_sys_resource permits sys_resource capability request when turned on.
TC covers RHEL-141858

The issue appears to be caused by the coreutils-single package, which introduces additional
prctl() system calls, that request sys_resource capability, leading to AVC denials.
2026-03-26 12:46:05 +00:00
Milos Malik
eb4ef74ed8 test if iio-sensor-proxy can read iio:devices
A CentOS stream 10 user reported that SELinux denials are triggered
when their device with a running iio-sensor-proxy service is rotated.
Further analysis revealed that iio-sensor-proxy cannot perform the
following activities:
 * read various character devices - /dev/iio:device*
 * create a UDP socket
 * write into in_accel_x_en, in_accel_y_en, in_accel_z_en files
   stored under /sys
 * add a new directory for a HID sensor device connected via PCI

The TC does not reproduce the situation.

In order to support the cooperation of iio-sensor-proxy and various
devices, I believe that SELinux policy should allow these actions.
The TC looks for appropriate policy rules and file context patterns.

The TC covers RHEL-110090.
2026-03-23 15:23:06 +00:00
Ondrej Mosnacek
a011b35f36
Add a test for unexpected denials from sysctl -a
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2026-03-12 13:22:29 +01:00
Veronika Syncakova
c628fff622 test if setroubleshootd process does not cause an AVC when trying to read /root/.rpmmacros
TC covers RHEL-142548 and RHEL-147470

If the setroubleshoot-server package is installed then the SELinux denial appears each time
the setroubleshootd process analyzes any SELinux denial, because the setroubleshootd process
executes the rpm command to find out which package owns some file.
2026-03-10 11:34:40 +00:00
Milos Malik
321b81e717 test if dhcpc hook can execute resolvectl
Recent selinux-policy + dhcpcd + systemd-resolved testing revealed
SELinux denials caused by dhcpc hooks running the resolvectl program.
The TC reproduces the situation.

In order to support the dhcpcd service and its hooks fully, I believe
that SELinux policy allow the necessary actions. The TC looks for
appropriate policy rules and file context patterns.

The TC covers RHEL-147153 and RHEL-147155.
2026-03-06 13:27:25 +00:00
Milos Malik
58e1983bb7 install the package which brings the kdump service
On Fedora rawhide, the kdump service is no longer brought by
the kexec-tools package. The kdump-utils package is necessary
for a successful run of this test on Fedora rawhide.
2026-03-06 13:25:31 +00:00
Milos Malik
2309f39aeb do not test services which are not available
Many tests contain test phases called "real scenario". Purpose of
these phases is usually to test a service which belongs to a particular
package. If the service (systemd unit file) is not available for any
reason, it makes no sense to run the test phase - it would fail.
Other test phases may still be worth running.
2026-03-02 14:44:55 +01:00
Ondrej Mosnacek
35144ba78d
kernel/CVE-2025-71085: fix netlabel setup
The original reproducer would break network traffic outside IPv6
localhost- make sure there are default rules for unlabeled traffic so
that the machine doesn't lose network connectivity during test.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2026-02-24 11:35:17 +01:00
Ondrej Mosnacek
0d794bfa99 Add test for CVE-2025-71085
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2026-02-24 08:32:32 +00:00
Stepan Broz
ac9d3e14dd selinux-policy/switcheroo-control-and-similar: Adjust subtest relevancy
RHEL-93335 fixed in RHEL-9.7
RHEL-93535 fixed in RHEL-10.1

Do not test for lower versions.
2026-02-23 13:14:09 +00:00
Stepan Broz
99d4f9ac36 selinux-policy/samba-bgqd-and-similar: Adjust subtest relevancy
RHEL-95985 fix in RHEL-9.8
RHEL-93731 fix in RHEL-10.2

Do not test in lower versions.
2026-02-23 13:13:22 +00:00
Stepan Broz
519738f773 policycoreutils/restorecon-ignores-missing: Adjust relevancy
RHEL-123885 fixed in RHEL-8.10
RHEL-110181 expected in RHEL-10.2
RHEL-123884 expected in RHEL-9.8

Do not test on lower versions.
2026-02-23 13:12:23 +00:00
Ondrej Mosnacek
dc54730c66
Add test for unexpected fanotify denials on anonymous pipes
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2026-02-16 10:13:08 +01:00
Jan Onderka
d8f25d24a7 TMT IDs added to few tests 2026-02-12 14:07:43 +01:00
Milos Malik
79e29ad421 do not modify systemd services directly
When tests run in image mode, it's impossible to modify files under
/usr/lib/systemd/system because the filesystem is read-only.
Unfortunately, some tests try to do that which leads to their failures.
In order to avoid these failures, any systemd service file which
requires a modification needs to be copied to /etc/systemd/system/
directory (read-write mode) and modified there.

Purpose of this change is to increase the number of passing tests
in image mode.
2026-01-27 16:48:45 +01:00
Milos Malik
f3c0386194 improve the gnome-remote-desktop test
The gnome-remote-desktop service was not configured properly and
that's why the test failed for a long time. The issue should be
fixed now.
2026-01-23 18:21:27 +00:00
Milos Malik
1402404f9d test if python code produces deprecation messages related to SWIG
When python modules are imported, DeprecationWarning messages can
appear. They are caused by the Swig code used in those modules.
Purpose of this TC is to find them.

The TC covers RHEL-118812, RHEL-138405 and RHEL-138406.
2026-01-12 13:05:48 +00:00
Stepan Broz
40243c00aa systemd-journal-upload: Adjust test relevancy
The only sub-test present currently is fixed in RHEL-9.7 and RHEL-10.0.
Do not test below these versions.
2026-01-07 07:03:13 +00:00
Jan Onderka
7ccb3c22cc setting additional audit-rules package as recommend for policycoreutils/load_policy 2025-12-19 11:47:50 +01:00
Jan Onderka
8e7a591a84 libselinux/setenforce test update audit-rules package dependency for RHEL10+ and making test fail if 'auditctl' is not present on the system 2025-12-18 16:20:58 +01:00
Milos Malik
54a83ea1e5 add metadata and fix description+summary
Unfortunately, the test was merged even if some metadata was missing.
Additionally, the description and summary contains characters which
are not allowed based on the output of: tmt tests lint.

Both problems should be fixed now.
2025-12-03 13:32:10 +01:00
Milos Malik
5f241c5352 test if 'restorecon -i' ignores missing filesystem objects
A recently reported customer case revealed that the restorecon
program produces error messages even if it was executed with
the '-i' option. In such case no error messages should appear
when the inspected filesystem objects are missing.

The TC reproduces the situation when old libselinux/policycoreutils
packages are installed.

The TC covers RHEL-110181 and RHEL-123884.
2025-11-25 22:50:31 +01:00
Milos Malik
4d5af50a2a fix few failing tests
Package installation attempts may fail, but the rest of test code
may still succeed. Expected exit codes were updated.
2025-11-24 08:29:41 +01:00
Stepan Broz
06e24b7df4 power-profiles-daemon-and-similari: adjust RHEL-100718 relevancy
Do not test this phase under RHEL-9.7 as it was only fixed there.
2025-11-18 14:16:16 +00:00
Therese Cornell
c49440dfb5 cups-browsed-and-similar: Ignore specific AVC denial
on RHEL/centos-9 due to RHEL-47401
2025-11-17 11:16:37 -05:00
Milos Malik
98bb59b158 test if dhcpcd-run-hooks can write into /etc/chrony.conf file
A recent dhcpcd + selinux-policy testing revealed that SELinux
prevents the running dhcpcd-run-hooks script from writing into
/etc/chrony.conf file on s390x machines. The TC reproduces the
situation, which is accompanied by the following error message:

  dhcpcd[...]: /usr/libexec/dhcpcd-run-hooks: line 132: /etc/chrony.conf: Permission denied

In order to support the intended dhcpcd-run-hooks function and
to avoid such errors in the journal, I believe that SELinux
policy should allow the access. The TC looks for appropriate
policy rules and file context patterns.

The TC covers RHEL-113937 and RHEL-113941.
2025-11-13 08:21:12 +00:00
Milos Malik
752ee72f5a test if stress-ng can read+write+map /secretmem anon inodes
Recently, a regular kernel + stress-ng testing revealed that SELinux
prevents the stress-ng program from writing (syscall = ftruncate)
and reading (syscall = mmap) the /secretmem anon inodes. The TC
reproduces the situation.

In order to enable various stress-ng functions, I believe that SELinux
policy should allow the actions mentioned above. The TC looks for
appropriate policy rules and file context patterns.

The TC covers RHEL-116154 and RHELTEST-2022.
2025-11-13 08:16:15 +00:00
Milos Malik
5842e54015 fix the targetd-and-similar test
The automated test runs the following command which produces an error:

  # targetctl clear
  Traceback (most recent call last):
    File "/usr/bin/targetctl", line 7, in <module>
      sys.exit(main())
               ~~~~^^
    File "/usr/lib/python3.14/site-packages/rtslib/targetctl.py", line 79, in main
      funcs[sys.argv[1]](savefile)
      ~~~~~~~~~~~~~~~~~~^^^^^^^^^^
  TypeError: clear() takes 0 positional arguments but 1 was given
  # echo $?
  1
  #

Even though SELinux is not the cause, the test fails because of the error.
To work around that problem, the expected exit code is between 0 and 255 now.
2025-11-13 08:13:39 +00:00
jan janasek
d4ebe95f73 renaming type test_file_t
On rhel9 there is a another type with this name so it is colliding,
so my_test_file_t will be used in this test futher.

Signed-off-byt: jan janasek <jjanasek@redhat.com>
2025-11-10 13:09:08 +01:00
Milos Malik
ff7b5b9147 enable the systemd-oomd test for RHEL-10
Because the systemd-oomd package is available on RHEL-10, the TC
is also relevant there.
2025-10-25 08:33:23 +02:00
jan janasek
ec5c6a6306 adding test coverage for unknown permissions
Unknown permissions are now handled as errors in CIL.
With selinux >= 3.0: a CIL module, which contains unknown permissions,
cannot be inserted via semodule -i. Error messages appear.

Signed-off-by: jan janasek <janjanasek@redhat.com>
2025-10-22 09:03:25 +02:00
Stepan Broz
c04e1fa7a8 valkey-and-similar: Adjust relevancy
This currently only verifies RHEL-108982 (should be fixed in RHEL-9.8)
and RHEL-102631 (fixed in RHEL-10.1), disable the test anywhere else
for now.
2025-10-14 19:31:48 +02:00
Vit Mojzis
caa904c01f Fix "adjust" statements
Whenever a key is defined in the tmt hierarchy and some child also
defines that key, the child's will overwrite the previous one. The "+"
changes the operation to "append", so the content of key+ in the child
is added to the existing key.

Meaning that any "adjust" statement in a test plan using a test that
defines it's own "adjust:" is ignored.

Since we are expecting other statements to be appended to the "adjust"
sections, the content of each section needs to be a single list item as
opposed to a set of key-value pairs (first line needs to start with a
hyphen).

- Replace all "adjust:" sections with "adjust+:" in order to honor any
  adjustments further up the tree (parent tests, or test plans).
- Fix malformed "adjust" sections (sets of key-value pairs)

Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
2025-10-09 20:22:22 +02:00
Vit Mojzis
33fd7a4bdf Increase the time limit when testing RHIVOS preload
The preload scripts cause all tests to take significantly longer than
usual, often triggering timeouts with current time limits.

Increase the time limit to 1500%.

https://issues.redhat.com/browse/VROOM-29315

Usage:
  tmt -c rhivos_preload=true run

  or

  context:
    rhivos_preload: true
2025-10-09 20:21:17 +02:00
Milos Malik
36d28b09f5 fix a syntax error
A syntax error appears when the following test is executed:
 * policycoreutils/semodule-rebuild-if-modules-changed

The problem is a missing "then" word in the test code.
2025-10-02 13:58:11 +02:00
Milos Malik
1eb61b3a69 exclude unsuitable tests from image mode testing
Tests which are not suitable (various reasons) for image mode
testing will get the avoidImageMode tag. If their conditions improve,
the tag can be removed.
2025-09-26 14:45:52 +02:00
Milos Malik
0d14d2424a find tests which do reboots and tag them properly
These tests should have the 'reboot' tag. The tag can then be used
as a filter for running tests.
2025-09-25 19:48:11 +02:00
Milos Malik
447bd53465 add a general plan for image mode testing
The newly added image-mode plan runs all relevant tests except for
those which:
 * are broken
 * require multiple hosts
 * do reboots
 * are not suitable for image mode environments

The image-mode test plan does not recognize tiers. That may change
in the future.
2025-09-25 16:33:18 +02:00
Jan Onderka
af6d8ea145 policycoreutils linux system roles test disable for RHIVOS 2025-09-16 15:22:46 +02:00
Milos Malik
d2d1130211 inform the framework to expect SELinux denials
Some tests intentionally trigger SELinux denials during their run
and there is no need to fail because of them. The default value
of avc check is not suitable for these tests.
2025-09-04 11:35:02 +02:00
Milos Malik
14479be1b9 perform the rules check on RHEL-10/CentOS stream 10 only
Currently, the SELinux denial shown in RHEL-77071 is not reproducible
on RHEL-9 or CentOS stream 9. It makes no sense to check the SELinux
policy rule existence there. The test code relevancy was updated.
2025-08-28 16:36:40 +02:00
Milos Malik
a68d8721c6 test if systemd-machined can inspect dead/empty images
Recent systemd-machined + selinux-policy testing revealed that
SELinux prevents the systemd-machined processes from creating
and removing the following directories and files:
 * /run/systemd/nspawn/
 * /run/systemd/nspawn/locks/
 * /run/systemd/nspawn/locks/inode-*

In order to support various systemd-machined and machinectl functions,
I believe that SELinux policy should allow above-mentioned actions.
The TC looks for appropriate policy rules and file context patterns.

The TC covers RHEL-105966 and RHEL-108849.
2025-08-27 08:30:40 +00:00
jan janasek
160b772afe adding gating guideline to README
Adds documentation to the README file to explain the test tiering system and its role in our gating process.
This clarifies the meaning of 'tier: 1/2/3' metadata and explains that older tags (e.g., tag:Tier1) have been deprecated.

Signed-off-by: Jan Janasek <jjanasek@redhat.com>
2025-08-26 13:03:09 +00:00
jan janasek
a74ee6af17 tag:Tier clean up
Removed redundant tags (e.g., Tier2/Tier3 and Tier2se/Tier3se) from all tests
with "tier: 2" and "tier: 3" metadata. The "tier" metadata is used instead.

Signed-off-by: Jan Janasek <jjanasek@redhat.com>
2025-08-26 13:03:09 +00:00
jan janasek
7e37b29514 fix .fmf metadata
all tests with CI-Tier-1 tag should have "tier: 1" in their metadata,
also removing tags Tier1 and Tier1se and lastly tests with "tier: 2"
and "tier: 3" should not have CI-Tier-1 tag.

Signed-off-by: Jan Janasek <jjanasek@redhat.com>
2025-08-26 13:03:09 +00:00
Milos Malik
7a6077caac fix several failing tests
Several automated tests were updated, because they were failing on
RHEL-10 machines. The list of reasons follows:
 * incorrect test relevancy
 * unimportant SELinux denials
 * newly defined SELinux labels
 * missing metadata
2025-08-26 07:55:35 +00:00
Milos Malik
22bdc812bb test if fapolicyd can connect to systemd-machined via its socket
A combined fapolicyd + systemd-machined + selinux-policy testing
revealed that SELinux prevents the fapolicyd processes from connecting
to the systemd-machined process via its UNIX socket located at:
/run/systemd/userdb/io.systemd.Machine. The TC reproduces the situation.

In order to support this behavior dictated by the nsswitch configuration,
I believe that SELinux policy should allow this action. The TC looks for
appropriate policy rules and file context patterns.

The TC covers RHEL-77071.
2025-08-18 14:47:05 +02:00
Milos Malik
16ec518546 add new test which covers the valkey* services
The valkey component is a replacement for the redis component. The
automated test covers basic functions of the valkey* services.

The TC covers RHEL-102631.
2025-08-18 08:25:14 +00:00
Zdenek Pytela
bbaec0906e Update systemd-oomd test
Do not check the type of /proc/pressure with matchpathcon because
the type is assigned using genfscon which is not recognised by
userspace tools.

Ensure that the /etc/systemd/system/-.slice.d and
/etc/systemd/system/user@.service.d directories exist before
creating files in them.
2025-08-11 13:41:35 +02:00
Milos Malik
bd01c13f8c test if recent systemd generators issues are fixed
Recent selinux-policy testing revealed that policies for various systemd
generators are not complete. For example:
 * SELinux prevented the vsftpd-generator program from executing commands
like mkdir, ls, ln, gawk etc.
 * SELinux prevented systemd-cryptsetup-generator from creating files like
/run/systemd/generator/systemd-cryptsetup@luks*.service

In order to support the functionality of various systemd generators,
I believe that SELinux policy allow the actions mentioned above. The TC
looks for appropriate policy rules and file context patterns.

The TC covers RHEL-98656, RHEL-100415 and RHEL-100721.
2025-07-28 09:06:36 +02:00
Vit Mojzis
9948e7bcf0 libsemanage/verify-options-in-semanage-conf: Extend error messages
Userspace 3.9 changes the error message to "OSError: No data available".

Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
2025-07-25 21:17:30 +02:00
Milos Malik
b663bc4abf test if tuned-ppd can watch certain dirs under /sys
Several recent bug reports revealed that SELinux prevents the tuned-ppd
processes from using the inotify_add_watch syscall on the following
directories:

 * /sys/devices/system/cpu/intel_pstate (permission: watch)
 * /sys/firmware/acpi (permission: watch_reads)

In order to support the expected tuned-ppd behavior, I believe that
SELinux policy should allow these actions. The TC looks for appropriate
policy rules and file context patterns.

The TC covers RHEL-101686, RHEL-101687, BZ#2358952 and their duplicates.
2025-07-25 15:40:44 +00:00
Milos Malik
7093be1ae3 test if power-profiles-daemon can switch between profiles
A recently reported bug revealed that SELinux prevents the
power-profiles-daemon processes from writing to the following file:

 * /sys/devices/system/cpu/cpufreq/policy6/energy_performance_preference

The TC does not reproduce the situation usually.

In order to support the intentional behavior of the daemon when
power cable gets unplugged/plugged, I believe that SELinux policy
should allow the action. The TC looks for appropriate policy rules
and file context patterns.

The TC covers RHEL-100718.
2025-07-25 14:39:46 +00:00
Ondrej Mosnacek
0c58cf0a60
kernel: make flamegraph generation opt-in
To avoid running code from untrusted repositories, make the generation
of flamegraphs optional (via a test parameter) and disabled by default.
The test parameter should only be set to 1 as needed when running the
test manually and kept disabled in automated test runs.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2025-07-24 17:05:11 +02:00
Milos Malik
c857e84cc9 test if mdevctl (virtnodedevd_t) can create dirs under /etc/mdevctl.d/
A recent libvirt testing of mediated devices revealed that SELinux
prevents the mdevctl process (executed by the virtnodedevd service)
from creating directories under /etc/mdevctl.d/. The TC reproduces
the situation.

In order to enable the expected mdevctl behavior, I believe that
SELinux policy should allow this action. The TC looks for appropriate
policy rules and file context patterns.

The TC covers RHEL-98559.

test if virtqemud can reset PCI devices

Recently, an experimental libvirt + selinux-policy testing that
SELinux prevents the rpc-virtqemud process from writing (syscall =
openat) into /sys/bus/pci/devices/0000:00:00.0/config file. The TC
reproduces the situation.

In order to support the nodedev-reset function and to avoid unnecessary
SELinux denials, I believe that SELinux policy should allow this
action. The TC looks for appropriate policy rules and file context
patterns.

The TC covers RHEL-101417.
2025-07-24 08:14:25 +00:00
Zdenek Pytela
fc90e68930 Add basic test which covers systemd-oomd 2025-07-23 15:37:36 +00:00
Milos Malik
be07ded929 skip certain tests on RHEL-10 because of their irrelevance
The following tests are not relevant for RHEL-10 because the required
packages are not available for RHEL-10:
 * /selinux-policy/caddy-and-similar
 * /selinux-policy/cups-pdf-and-similar
 * /selinux-policy/ntpsec-and-similar
2025-07-23 13:37:45 +02:00
Milos Malik
7ac017780e add a basic systemd-importd test
Recently, exploratory systemd-importd + selinux-policy testing revealed
that SELinux prevents the systemd-importd service from creating and
deleting the /run/systemd/io.systemd.Import socket. The TC reproduces
the situation.

In order to support the systemd-importd service start with the default
configuration, I believe that SELinux policy should allow the actions
listed above. The TC looks for appropriate policy rules and file
context patterns.

The TC covers RHEL-98490.
2025-07-23 09:25:05 +00:00
Milos Malik
dff2d2b919 adapt to policies with reduced set of types and rules
There are policies which define less types and rules than the targeted
policy. The executed automated tests should adapt if they still make sense.
2025-07-14 10:52:51 +00:00
Ondrej Mosnacek
f0131ccaca
kernel/selinux-testsuite: bump upstream ref
The only important commit is 72e60b601832 ("policy/test_secretmem.te:
add anon_inode perms required in Linux v6.16-rc5"), which fixes the
testsuite to work on 6.16-rc5+ kernels.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2025-07-09 11:38:04 +02:00
Milos Malik
bca963344a reconsider the set of broken tests
Check if all tests tagged with rhel9_broken or rhel10_broken are
really broken. If not, remove the tag. If there are other broken
tests not yet tagged, assign them the relevant broken tag.
2025-06-24 15:26:24 +02:00
Petr Lautrbach
0e555c68c6 Skip bootc-e2e tests
bootc-e2e tests requires specific environment related to image mode. The
image is prepared using buildah and later booted. This is not supported
in this test suite (yet)

Signed-off-by: Petr Lautrbach <lautrbach@redhat.com>
2025-06-23 20:26:54 +02:00
Milos Malik
967d55a3a3 make sure that whole /etc is labeled correctly
The rlSELibraryLoaded() now makes sure that the /etc directory and
its subdirectories are labeled correctly. If they are mislabeled,
a lot executed tests can trigger unnecessary SELinux denials.
2025-06-23 17:43:33 +00:00
Ondrej Mosnacek
27ab7e5e8a
kernel/selinux-testsuite: bump ustream commit ref
Mainly to pull "tests/inet_socket: properly detect IPSEC support", which
makes the testsuite run successfully on automotive RHEL again.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2025-06-23 15:57:12 +02:00
Milos Malik
c7425fefd1 skip the RHEL-2616 test phase on RHEL-9.x
Even though the RHEL-2616 bug was investigated on RHEL-9.x, it's
not fixed and it got auto-closed. Until a solution is found or the
bug is escalated, the automated test will skip the particular test
phase.
2025-06-16 10:13:57 +02:00
Milos Malik
4d517e7d9b show the size and label of /etc/tuned/ppd_base_profile
Instead of comparing the SELinux label of that file against a fixed
value, show the label and the file size.
2025-06-13 06:55:17 +00:00
Amith Kumar
4a8550185c Fix rhel-9 avc causing deny_rules test failure
The upstream selinux-policy/deny-rules test suite failed during its run
on rhel-9. Cause of failure is an AVC denial triggered by modprobe
command while executing module_load. Fix the test code to address the
AVC & test failure.

Signed-off-by: Amith Kumar <apeetham@redhat.com>
2025-06-13 05:16:33 +05:30
Ondrej Mosnacek
1b68d30d64
kernel/selinux-testsuite: bump ustream commit ref
This pulls various fixes and new tests.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2025-06-10 15:43:30 +02:00
Milos Malik
1481683fec test if tuned-ppd can create /etc/tuned/ppd_base_profile with correct label
Several reported BZs revealed that the tuned-ppd process can
create an incorrectly labeled ppd_base_profile file under the
/etc/tuned directory if the file does not exist. The TC reproduces
the situation.

In order to fix this issue, SELinux policy should define a filename
transition rule which ensures that the correct SELinux label is applied
when the file is created. The TC looks for appropriate policy rules
and file context patterns.

The TC covers bz#2359851, bz#2361423 and their duplicates.
2025-06-10 12:39:42 +00:00
Milos Malik
450f6475d0 provide a dummy certificate for the smtpd service
The opensmtpd service does not start when the /etc/pki/tls/cert.pem
file is missing. Let's provide an empty file to work around this
issue.
2025-06-10 12:26:23 +00:00
Milos Malik
faa792f255 test if exim can find /proc/sys/net/ipv6/conf/all/disable_ipv6
A regular exim + selinux-policy testing performed on Testing Farm
machines revealed that SELinux prevents the exim processes from
searching the /proc/sys/net/ipv6/conf/all/disable_ipv6 file. The
TC reproduces the situation on TF machines.

In order to avoid unnecessary SELinux denials, I believe that
SELinux policy should allow this access. The TC looks for appropriate
policy rules and file context patterns.

The TC covers RHEL-94268.
2025-06-10 11:15:49 +00:00
Milos Malik
7b73a19fe5 modify tests to cope with a missing selinux-policy-* packages
Even though the tests require various selinux-policy-* packages,
some of packages may not be available on all platforms and
architectures. It can also happen that SELinux policy store is
installed in an unusual location. The tests should cope with both
situations.
2025-06-09 16:24:18 +02:00
Ondrej Mosnacek
b873a41d17
kernel/selinux-testsuite: apply patch series to cover cap2_userns
We need to ensure that at least one cap2_userns permission has test
coverage to check a formal box somewhere. Apply an upstream patch series
that adds this coverage.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2025-06-06 16:04:20 +02:00
Milos Malik
a6904ef9bc test if gdm can talk to switcheroo via D-bus
A recently filed customer case revealed that SELinux prevents
dbus-broker processes (executed by GDM or gnome-shell) from
communicating to switcheroo-control processes. The TC reproduces
the situation.

In order to support various GNOME features, I believe that SELinux
policy should allow this action. The TC looks for appropriate
policy rules and file context patterns.

The TC covers RHEL-93335 and RHEL-93535.
2025-06-06 11:01:24 +00:00
Petr Matyas
c809f6be4f Update dependencies of policycoreutils setfiles test
Proper list of dependecies is necessary as not all distros
have every package preinstalled, for example on RHIVOS
we didn't have e2fsprogs in the system, while on more general use systems
it is included almost always, which is why it wasn't causing problems before
2025-06-05 17:29:53 +00:00
Milos Malik
f548622081 test if samba-bgqd can send data into /var/lib/samba/private/msg.sock/
Recent selinux-policy + samba testing revealed that SELinux prevents
the samba-bgqd process from sending data into UNIX datagram sockets
located in the /var/lib/samba/private/msg.sock/ directory. The TC
reproduces the situation on ppc64le machines.

In order to support the intentional samba-bgqd behavior, I believe
that SELinux policy should allow this action. The TC looks for
appropriate policy rules and file context patterns.

The TC covers RHEL-93731.
2025-06-04 11:39:22 +00:00
Milos Malik
34a1e679ec test if tuned-ppd can talk to SSSD via socket
Recently, a SSSD enabled machine which also runs the tuned-ppd service
revealed that SELinux prevents the tuned-ppd process from writing to
the /var/lib/sss/pipes/nss socket and then connecting to the sssd
process. The TC does not reproduce the situation.

In order to support the communication between tuned-ppd and SSSD
(tuned-ppd <-> nsswitch <-> SSSD), I believe that SELinux policy
should allow the actions. The TC looks for appropriate policy rules
and file context patterns.

The TC covers BZ#2367076.
2025-06-02 09:34:21 +00:00
Petr Lautrbach
9fbaa60c55 Test selabel_lookup with local fcontext modifications
In specific conditions, it was not possible to override default file
context using `semanage fcontext`. The test imitates the right condition
and checks whether it works as expected.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=2360183
2025-05-29 15:48:05 +02:00
Milos Malik
03d60e2e84 run the services only if they are present
Not all tested services are available for all architectures. Some
tests fail when they try to start/stop service which is not present.
Let's make the tests more robust.
2025-05-27 13:56:18 +02:00
Milos Malik
fed18a00fb test if dependency on /sbin/service is gone
Scriptlets of the setroubleshoot package now run the auditctl program
directly instead of running the /sbin/service command which belongs
to the initscripts-service package. The TC checks if the dependency
was removed.

The TC covers BZ#2365614 and RHEL-90842.
2025-05-26 08:54:27 +00:00
Amith Kumar
cc300caa91 Fix failing deny_load_module testcase
The selinux-policy/deny-rules test suite failed during recent test runs
on Fedora-rawhide. The cause of failure seems to be missing deny rules
compatible to recent rawhide release. Fix the test code and address the
failures.

Signed-off-by: Amith Kumar <apeetham@redhat.com>
2025-05-21 19:23:27 +05:30
Stepan Broz
937d363e84 chronyd-and-similar: Adjust relevancy of bz#2173604
Do not test bz#2173604 on RHEL-9.2 or lower.
2025-05-16 16:12:44 +00:00
Jan Onderka
56d272ebd8 semanage_setfiles-selinux_restorecon: work with multiple SELINUXTYPES
Enable test execution with different SELINXTYPE than 'targeted',
otherwise the test ends with failure due to hardcoded 'targeted' policy
and expected pki_tomcat_etc_rw_t type might not be present at current
policy
2025-05-15 12:08:47 +02:00
Milos Malik
b8c668a567 add missing FMF ids into selected tests
Just adding the FMF ids. No functional changes in the tests.
2025-05-13 18:39:11 +00:00
Jan Onderka
07867a3e8f add uniq ID and fusa tag to tests 2025-05-13 18:10:23 +00:00
Stepan Broz
79e1779579 systemd-machined-and-similar: Adjust subtest relevancies
- Do not test "RHEL-76352-RHEL-77087-RHEL-78088" on RHEL-9.5 or below
- Do not test "RHEL-85379-RHEL-86528" on RHEL-9.6 or below
2025-05-13 07:47:38 +00:00
Stepan Broz
7e8b5cffe4 perf_event-and-related: do not test bz2229936 on RHEL<9.3 2025-05-12 11:13:11 +02:00
Stepan Broz
e340f43c20 exim-and-similar: Adjust subtest relevancy
Do not test "RHEL-14110 + RHEL-14186" and "RHEL-21902 + RHEL-21903" on
RHEL-9 lower than 9.4.
2025-05-07 09:23:17 +00:00
Stepan Broz
c4ad09fc7a systemd-localed: Adjust test relevancy
Do not test "bz#2240159 + RHEL-16715 + RHEL-16716" on RHEL-9 versions
RHEL-9.3 or lower.
2025-05-05 15:57:27 +00:00
Stepan Broz
4cb40a2a47 opensmtpd-and-similar: Adjust subtest relevancy
Do not test "bz#2246115" and "bz#2208696" on RHEL-9.3 or below.
2025-05-05 15:35:01 +00:00
Stepan Broz
3ba64529c7 bz538089-plymouth-operations-denied-during-boot: Adjust relevancy of bz#2184803
Do not test bz#2184803 on RHEL-9.2 or lower.
2025-05-05 15:12:14 +00:00
Stepan Broz
c7f2624eb5 dhcpcd-and-similar: Adjust relevancy of RHEL-15326
Do not test RHEL-15326 on RHEL-9.3 or lower RHEL-9.
2025-05-05 15:06:43 +00:00
Stepan Broz
4f908fc2eb restorecond-fcontext-equivalences: Adjust relevancy of RHEL-5032
Do not test "RHEL-5032" on RHEL-9.3 or below.
2025-05-05 14:57:21 +00:00
Stepan Broz
9266ddc41b cups-pdf-and-similar: Adjust relevancy of bz#2234765
Do not test bz#2234765 on RHEL-9.2 or lower.
2025-05-05 14:49:33 +00:00
Stepan Broz
5d60a68f27 ntpsec-and-similar: Adjust subtest relevancy
Do not test "bz#2246805 + RHEL-15085" on RHEL-9.3 or lower.
2025-05-05 14:46:52 +00:00
Stepan Broz
6b8128b891 journalctl-and-similar: Adjust subtest relevancy
Do not test "bz#2136189 + bz#2153782" on RHEL-8 version below RHEL-8.8, and
RHEL-9 versions below RHEL-9.4.
2025-05-05 14:44:32 +00:00
Stepan Broz
6075ad3af5 anon_inode-and-similar: Adjust relevancy of RHEL-11792
Do not test RHEL-11792 on RHEL-9.3 or lower.
2025-05-02 10:28:57 +02:00
Jan Onderka
524c361afe Add NoRHIVOS tag to semanage-root-on-nfs test 2025-04-30 10:17:16 +00:00
Jan Onderka
6a1e7f4399 skip man page test if no present on the system 2025-04-30 10:17:16 +00:00
Milos Malik
e05b9a7cbb test if journalctl can connect to systemd-nspawn machine
A customer case revealed that not all commands mentioned in the
RHEL-76352 bug were resolved in the selinux-policy component. The
TC executes the missed ones.

In order to support the journalctl ability to access virtual machines,
I believe that SELinux policy should allow the dbus-broker processes
to read the /var/lib/machine/<virtual-machine> directories. The TC
looks for appropriate policy rules and file context patterns.

The TC covers RHEL-85379 and RHEL-86528.
2025-04-30 10:15:11 +00:00
Milos Malik
18fce0c6cc ensure the audit-rules package is installed on RHEL-10
The audit-rules package is not built for RHEL-9.x, but it is built
for RHEL-10.x. The SELinux beakerlib library should count with that.
2025-04-29 16:32:47 +02:00
Milos Malik
75afe321fa require the audit-rules package
When the SELinux beaker library is imported, the auditd configuration
is modified and the auditd service is restarted. The audit-rules package
is necessary for success of the operation, because it brings the
auditctl command.
2025-04-29 08:10:52 +02:00
Stepan Broz
e3660e97bc chronyd-and-similar: Adjust test relevancy
Do not test "RHEL-82299 + RHEL-82308" and "chronyd-restricted" on RHEL
lower than 9.7 or 10.1 respectively.
2025-04-25 12:28:13 +00:00
Amith Kumar
6ed3370e17 fix homectl test case failures
The selinux-policy/systemd-homed test suite failed during recent test
run on Fedora-rawhide. Root cause of failure appears to be changed
behavior of command "homectl passwd". Fix the test code to address the
failures. Couple of other ERRORs are due to import failure of
selinux-policy/common library which is out-of-scope of this fix.

Signed-off-by: Amith Kumar <apeetham@redhat.com>
2025-04-23 08:32:25 +05:30
Stepan Broz
4cb4fb9cad tuned-ppd-and-similar: Adjust test relevancy
The "tuned-ppd" package was introduced in RHEL-9.5.
2025-04-17 18:24:56 +00:00
Stepan Broz
59307b7ba6 systemd-run-and-similar: Adjust test relevancy
Do not test "RHEL-61928 + RHEL-62185" on RHEL-9.6 or lower.
2025-04-17 18:22:38 +00:00
Stepan Broz
c2ff2147e9 systemd-modules-load-and-similar: Adjust test relevancy
Do not test RHEL-54591 on RHEL-9.5 or lower. Fixed in RHEL-9.6 by RHEL-61453.
2025-04-17 18:19:59 +00:00
Stepan Broz
3b84c2b165 systemd-sysctl-and-similar: Adjust test relevancy
Do not test "RHEL-56988 + RHEL-58380" on RHEL 9.5 or lower.
2025-04-17 18:18:01 +00:00
Zdenek Pytela
094cc6f8c0 Update systemd-generators test
The loop42 device file is used by other tests, so the name was changed
to loop17 not to clash.

Minor improvements.
2025-04-17 18:15:10 +00:00
Stepan Broz
1ecae443e0 systemd-notify-and-similar: Adjust test relevancy
Do not test "RHEL-25514 + RHEL-25605" on RHEL-9.4 or lower.
Also, upload ssh.exp so that the test works correctly in 1minutetip.
2025-04-17 18:11:55 +00:00
Stepan Broz
06e6c863af systemd-tmpfiles-and-similar: Adjust test relevancy
Do not execute this test on RHEL 9.4 or lower.
2025-04-17 18:10:38 +00:00
Stepan Broz
3064e34888 boothd-and-similar: Adjust relevancy for RHEL-9
RHEL-57104 and other are fixed in RHEL-9.6, RHEL-8 works
2025-04-17 15:55:38 +00:00
Stepan Broz
1fcc75ae83 boothd-and-similar: Adjust relevancy
Don't test RHEL-57104 + RHEL-58060 and RHEL-57104 on RHEL-9.5 or lower.

Test still FAILs in real-scenario on RHEL-9.5 and lower.
2025-04-17 15:55:38 +00:00
Stepan Broz
4e9e25f314 power-profiles-daemon-and-similar: Adjust test relevancy
Do not test RHEL-61117 on RHEL-9.5 and lower.
2025-04-17 15:52:35 +00:00
Stepan Broz
0f5ba83544 selinux-policy/dmidecode-and-similar: Adjust relevancy
Do not test RHEL-16104 on RHEL<9.5
2025-04-17 15:49:32 +00:00
Stepan Broz
2215420c41 dhcpcd-and-similar: Adjust test relevancy
Do not test "bz#2269708 + bz#2270733" on RHEL 9.4 and lower.
2025-04-17 15:48:32 +00:00
Stepan Broz
5f0d894eaa logwatch-and-similar: Adjust test relevancy
Do not test RHEL-34135 on RHEL-9.4 and lower
2025-04-17 15:40:56 +00:00
Milos Malik
e07c1a96fb fix the systemd-journal-upload test for RHEL-9.x
One of the test phases failed on RHEL-9.6 because the systemd_conf_t
type is not defined there. The issue should be fixed now.
2025-04-15 16:58:53 +00:00
Milos Malik
5ea123d59e add FMF id for the selinux-testsuite 2025-04-15 14:26:28 +02:00
Milos Malik
51aa683abb test if gdm can talk to tuned-ppd via D-bus
Recent tuned-ppd + gdm + selinux-policy testing revealed that SELinux
prevents the D-bus communication between gdm and tuned-ppd. The TC
reproduces the situation which is accompanied by the following record
in the systemd journal:

  test-vm dbus-broker[...]: A security policy denied :1.54 to send method call
  /org/freedesktop/UPower/PowerProfiles:org.freedesktop.DBus.Properties.GetAll to :1.43.

In order to enable the bi-directional communication, I believe that
SELinux policy should allow sending D-bus messages between these
2 domains. The TC looks for appropriate policy rules and file context
patterns.

The TC covers RHEL-85849.
2025-04-09 06:05:58 +00:00
Milos Malik
9b73e15e1e test if pcscd works OK with NoNewPrivileges=yes
Recent pcscd + selinux-policy testing revealed SELinux denials which
are caused by the NoNewPrivileges=yes option present in the following
file:
 * /usr/lib/systemd/system/pcscd.service

The SELinux denials are also accompanied by the following errors in
the systemd journal:

  pcscd[...]: 00000000 ../src/pcscdaemon.c:704:main() cannot create /run/pcscd/pcscd.pid: Permission denied
  pcscd[...]: 61013391 ../src/pcscdaemon.c:843:clean_temp_files() Cannot remove /run/pcscd/pcscd.pid: No such file or directory

In order to support the intentional changes and avoid these SELinux
denials, I believe that SELinux policy should allow the nnp_transition
for the pcscd_t domain. The TC looks for appropriate policy rules.

The TC covers BZ#2355930, BZ#2356058 and BZ#2357154.
2025-04-03 14:46:31 +02:00
Jan Onderka
08a8075869 Metadata update with NoRHIVOS or fusa tags 2025-04-01 12:06:21 +00:00
Milos Malik
a7b41e8ca1 separate failing tests from no-tier tests
Apply the failinfedora tag to the tests which fail on Fedora rawhide.
Add a special test plan for regular runs of these failing tests.

Make sure that the no-tier test plan contains tests which succeed on
Fedora rawhide.
2025-04-01 08:28:41 +02:00
Milos Malik
3702d34999 test if pcm-sensor-server can run on machines with many CPUs
Recent selinux-policy + pcm testing on machines with multiple CPUs
revealed that SELinux prevents the pcm-sensor-server process from
doing various operation. The TC reproduces that situation on the
right HW.

In order to support the expected functions of pcm-sensor-server,
I believe that SELinux policy should allow these actions. The TC
looks for appropriate policy rules and file context patterns.

The TC covers RHEL-80452.
2025-03-26 14:30:15 +00:00
Milos Malik
1663f9c1b1 test if systemd generators can send data to /run/systemd/journal/socket
Recent system roles testing revealed that SELinux prevents various
systemd generators from sending any data into /run/systemd/journal/socket.
The TC does not reproduce the situation.

In order to enable the use case in which systemd-journald is replaced
by rsyslog, I believe that SELinux policy should allow these actions.
The TC looks for appropriate policy rules and file context patterns.

The TC covers RHEL-75879.
2025-03-26 12:39:46 +00:00
Milos Malik
8db47446be test if virtqemud can detach devices or libvirt is macTableManager
Testing of various virtualization scenarios revealed that SELinux
prevents the virtqemud processes from writing into following files:
 * /sys/bus/pci/devices/0000:00:05.0/driver_override
 * /sys/class/net/virbr0/brif/vnet5/learning

The TC reproduces these situations.

In order to support the use cases described in the following bugs,
I believe that SELinux policy should allow the write actions. The
TC looks for appropriate policy rules and file context patterns.

The TC covers RHEL-65266 and RHEL-65385.
2025-03-21 12:53:43 +01:00
Milos Malik
59cff7b143 test if chronyc can talk to the restricted chronyd via socket
Recent selinux-policy + chrony testing revealed that SELinux prevents
communication between chronyc and the restricted chronyd service. The
TC reproduces the situation.

In order to enable this use case, I believe that SELinux policy
should allow the communcation in both directions. The TC looks
for appropriate policy rules.

The TC covers RHEL-82299 and RHEL-82308.
2025-03-20 09:44:13 +00:00
Jan Onderka
5a9000d76f Metadata update of PURPOSE files with expected inputs and outputs 2025-03-17 15:21:56 +01:00
Jan Onderka
f5e7b11152 Metadata update for systemd-sysctl-and-similar test and adding NoRHIVOS tag 2025-03-12 17:02:44 +01:00
Petr Lautrbach
b1adfa9c2b selinux-policy/policy-rpm-macros: Use our version
https://github.com/fedora-selinux/selinux-policy-macros has not been
touched for years and it will obsoleted soon.

With this update:

- add runtest.sh from fedora-selinux/selinux-policy-macros as this
repository and rename it to selinux-policy-macros.runtest.sh

- update selinux-policy-macros.runtest.sh to use MACRO_FILE env variable
if exists

- update runtest.sh to export MACRO_FILE variable so that both tests use
the same file

- use ssh_sysadm_login instead of zabbix_... boolean as zabbix is in
EPEL in RHEL like repositories
2025-03-10 16:41:43 +01:00
Petr Lautrbach
d55f7ad6ae setsebool: Do not test aliases for non-existing booleans
In CentOS Stream 10 some modules were moved from selinux-policy to
selinux-policy-epel which is available only in EPEL. It caused problem
with non-existing booleans and their aliases. With this change, an alias
is not checked when a new boolean does not exist.

Fixes:
    Error getting active value for puppet_manage_all_files
    [   PASS   ] :: Command 'getsebool puppet_manage_all_files 2>&1 | tee /tmp/tmp.nx2NlWq1zd' (Expected 0, got 0)
    [  BEGIN   ] :: Running 'getsebool puppetagent_manage_all_files 2>&1 | tee -a /tmp/tmp.nx2NlWq1zd'
    Error getting active value for puppetagent_manage_all_files
    [   PASS   ] :: Command 'getsebool puppetagent_manage_all_files 2>&1 | tee -a /tmp/tmp.nx2NlWq1zd' (Expected 0, got 0)
    [  BEGIN   ] :: Running 'uniq -c /tmp/tmp.nx2NlWq1zd | grep '2 ''
    [   FAIL   ] :: Command 'uniq -c /tmp/tmp.nx2NlWq1zd | grep '2 '' (Expected 0, got 1)
2025-03-10 12:20:06 +01:00
Milos Malik
dbbbfb5d2c fix tests which fail or cause other tests to fail
The modified tests used to fail on RHEL-10 or they caused other tests
to fail on RHEL-10. The reasons are various:
 * dependency on SELinux types which are no longer defined
 * insufficient test cleanup
 * unexpected exit codes
 * virtual vs. bare metal environment differences

These problems should be fixed now.
2025-03-05 10:42:13 +01:00
Milos Malik
a310ff9f85 fix tests which fail in other environments
The modified tests were failing because:
 * the running restorecond service causes problems to the subsequent tests
 * an irrelevant bug was tested
 * the bind component is available in multiple versions
 * rpm output contained unnecessary whitespaces

These issues should be fixed now.
2025-02-27 08:25:04 +01:00
Milos Malik
b4cacd7c55 improve tests which fail because of conflicts
There are 2 tests which require conflicting packages. To run them
successfully, the conflicting packages need to installed/removed in
the right order.

2 additional tests got fixed too.
2025-02-25 14:27:11 +01:00
Milos Malik
3d1e1a1ca3 increase the duration of tests which timed out
There are booth commands which may stall the automated test execution.
Let's run them with a 20 second deadline.

There are other tests which need more time to finish when executed
on slower machines. Their duration got extended.
2025-02-24 15:34:53 +01:00
Milos Malik
d1fffc88e8 test if 'bootupctl adopt-and-update' works well
Recent bootupd + bootupctl testing revealed that SELinux prevents
the bootupd processes from the following actions:
 * removal of the /boot/bootupd-state.json file
 * execution of findmnt, mount, udevadm, grub2-install, lsblk commands
 * automatic transition into their SELinux domains

The TC reproduces the situation on EFI configured machines.

In order to support the adopt-and-update feature, I believe that
SELinux policy should allow these actions. The TC looks for
appropriate policy rules and file context patterns.

The TC covers RHEL-66584 and RHEL-70849.
2025-02-19 18:32:05 +00:00
Milos Malik
6026118dcc test if tlshd can access network and certificates
Recent ktls-utils + NVME testing revealed that SELinux prevents
the tlshd processes from doing the following activities:
 * reading the /etc/resolv.conf file
 * creating and managing a UDP socket
 * searching the /etc/pki/tls/certs directory
 * reading the certificate files under /etc/pki/tls/certs/
 * reading the /proc/sys/net/ipv6/conf/all/disable_ipv6 file
 * searching the /proc/sys/net/ipv6 directory
 * creating and managing a netlink route socket

The TC does not reproduce the situation. There is a dedicated
automated test for this purpose.

In order to enable the expected tlshd functionality, I believe that
SELinux policy should allow these actions. The TC looks for appropriate
policy rules and file context patterns.

The TC covers RHEL-74424.
2025-02-17 15:31:48 +00:00
Milos Malik
783121a5a4 test if virt-admin can connect to virt* daemons via admin sockets
Recent virtualization CI test runs discovered SELinux denials when
the virt-admin tool tries to connect to the virtqemud process. The
TC reproduces the situation via systemd-run.

In order to support the following scenario, I believe that SELinux
policy should allow the necessary operations:

 * the virt-admin program is running as unconfined_service_t because
it was executed by a process running as unconfined_service_t and the
virt-admin process wants to talk to the virtqemud process

The TC looks for appropriate policy rules and file context patterns.

The TC covers RHEL-77620.
2025-02-12 13:05:05 +00:00
Milos Malik
5bcfcf4b08 test if virtqemud can access CD/DVD device on host
Recent virtualization + CD/DVD + selinux-policy testing revealed
that SELinux prevents the rpc-virtqemud processes from accessing
SCSI devices on the host. The TC reproduces the situation.

In order to enable this use case, I believe that SELinux policy
should allow the access. The TC looks for appropriate policy rules
and file context patterns.

The TC covers RHEL-76104.
2025-02-11 15:25:07 +00:00
Milos Malik
255c7cda92 test if machinectl can kill VMs running under systemd-machined
Recent systemd-machined + selinux-policy testing revealed that SELinux
prevents the machinectl command (consequently the systemd-machined
process) from stopping, rebooting or powering off the VMs. The TC
reproduces the situation.

In order to support this documented functionality, I believe that
SELinux policy should allow these actions. The TC looks for appropriate
policy rules and file context patterns.

The TC covers RHEL-76352, RHEL-77087 and their duplicates.
2025-02-10 10:43:16 +00:00
Zdenek Pytela
5660ee6918 Check for bin/sulogin, not for /sbin/sulogin
With Unify_bin_and_sbin [1] in progres, majority of commands have
already been moved from /usr/sbin to /usr/bin in Fedora 42 and newer,
therefore the strings check in /usr/lib/systemd/systemd-sulogin-shell
should rather use bin/sulogin.

This commit fixes the following test failure:
[   FAIL   ] :: Command 'strings /usr/lib/systemd/systemd-sulogin-shell | grep /sbin/sulogin' (Expected 0, got 1)

[1] https://fedoraproject.org/wiki/Changes/Unify_bin_and_sbin
2025-02-06 12:08:09 +01:00
Milos Malik
70d0bb7140 add basic test which covers the tuned-ppd service
Sooner or later, the tuned-ppd service will be confined by SELinux
policy and this automated test should find out if basic functions
of the program/service are affected or not.

The TC covers RHEL-69450 and RHEL-69526.
2025-02-05 06:53:26 +00:00
Milos Malik
1938ff73cb fix gating tests which fail or time out
Several automated tests fail during gating because of:
 * known test code issues
 * too short duration
 * additional SELinux policy changes

The identified problems should be fixed now.
2025-02-04 19:46:35 +01:00
Jan Onderka
8519ca13a7 rpm-suppress-stderr: Drop '--installroot' from 'dnf download'
'dnf download' does not download rpm files if joined with --installroot option.

Fixes:
    [  BEGIN   ] :: Running 'dnf download --installroot=/tmp/tmp.Bw3ejLevcz/lower rpm-plugin-selinux selinux-policy selinux-policy-targeted '
    Updating Subscription Management repositories.
    Unable to read consumer identity

    This system is not registered with an entitlement server. You can use subscription-manager to register.

    No package rpm-plugin-selinux available.
    Exiting due to strict setting.
    Error: No package rpm-plugin-selinux available.
    [   FAIL   ] :: Command 'dnf download --installroot=/tmp/tmp.Bw3ejLevcz/lower rpm-plugin-selinux selinux-policy selinux-policy-targeted ' (Expected 0, got 1)
2025-02-04 12:36:41 +01:00
Ondrej Mosnacek
9dce63b31d
kernel/selinux-testsuite: apply patch to fix hang on CS10
This applies the following patch that fixes behavior with the latest
RHEL-10 kernels:
https://lore.kernel.org/all/20250131152122.1452103-1-omosnace@redhat.com/

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2025-01-31 16:26:12 +01:00
Milos Malik
5a5d3a227c test if systemd-ssh-generator can read /dev/vsock
SELinux denials recently found on Beaker machines revealed that
SELinux prevents the systemd-ssh-generator processes from reading
the /dev/vsock device. The TC reproduces the situation.

In order to enable the ssh-generator which belongs to new systemd
builds, I believe that SELinux policy should allow the access. The
TC looks for appropriate policy rules and file context patterns.

The TC covers RHEL-72549.
2025-01-29 07:50:40 +00:00
Milos Malik
ed1316d819 test if boothd can connect to systemd-machined via socket
Recent selinux-policy + boothd + systemd-machined testing revealed
that SELinux prevents the boothd process from connecting to the
systemd-machined process via the /run/systemd/userdb/io.systemd.Machine
socket. The TC reproduces the situation.

In order to support the boothd and systemd-machined cooperation and
to avoid unnecessary SELinux denials, I believe that SELinux policy
should allow the access. The TC looks for appropriate policy rules
and file context patterns.

The TC covers RHEL-75471.
2025-01-28 12:56:09 +00:00
Milos Malik
6292a9158b test if virtqemud can access USB devices attached to VMs
Recent virtualization + SELinux policy testing revealed that SELinux
prevents the virtqemud process from accessing the USB devices which
are attached to VMs. The TC reproduces the situation.

In order to support this use case and to avoid unnecessary SELinux
denials, I believe that SELinux policy should allow the access. The
TC looks for appropriate policy rules and file context patterns.

The TC covers RHEL-74230.
2025-01-28 12:45:22 +00:00
Petr Lautrbach
c225414cf3 Update a file context and relabel
Verifies: https://issues.redhat.com/browse/RHEL-73348
2025-01-27 20:08:29 +01:00
Petr Lautrbach
512ac533f6 sestatus has been moved to /usr/bin on modern systems
https://fedoraproject.org/wiki/Changes/Unify_bin_and_sbin

Fixes:
    [   FAIL   ] :: Command 'rpm -ql policycoreutils | grep /usr/sbin/sestatus' (Expected 0, got 1)
2025-01-22 15:18:19 +01:00
Milos Malik
559446d543 test if sysadm_u or staff_u can talk to libvirt-dbus
A recent cockpit-machines testing in SELinux enabled environments
revealed that SELinux prevents certain confined users from
communicating to the libvirt-dbus service. The TC reproduces the
situation for users derived from sysadm_u and staff_u.

In order to support the scenario, I believe that SELinux policy
should allow the D-bus communication in both directions. The TC
looks for appropriate policy rules and file context patterns.

The TC covers RHEL-73914.
2025-01-22 07:38:38 +00:00
Milos Malik
1b8d7bd95f test if systemd-machined can open+ioctl /dev/vsock
Recent systemd-machined + selinux-policy testing revealed that
SELinux prevents the systemd-machined processes from accessing
the /dev/vsock device. The TC reproduces the situation.

In order to support the expected systemd-machined functionality,
I believe that SELinux policy should allow this access. The TC
looks for appropriate policy rules and file context patterns.

The TC covers RHEL-74280.
2025-01-22 07:14:13 +00:00
Milos Malik
8cbf323d54 test if policy installation in container works as expected
A recent podman + selinux-policy testing revealed too many
"Operation not supported" messages in a scenario which tries
to install selinux-policy packages inside a container. The TC
reproduces the situation.

In order to fix the problem, changes were made in both components:
libsemanage and selinux-policy. Purpose of the TC is to find out
if such error messages still appear or not.

The TC covers RHEL-70632.
2025-01-22 06:58:13 +00:00
Milos Malik
6be8a93147 update the failing tests with the latest findings
Several automated tests had to be updated to reflect the latest
findings (new bugs, new rules because of denials) from testing on
various machines.
These tests also need to work in environments where the tested
services or their policies are not yet present. Test phases
relevancy is important.
2025-01-16 12:55:26 +01:00
Milos Malik
774bd87aac improve failing tests and add missing nitrate metadata
1 test was failing because of a test code issue.
1 test was missing an important test phase.

The number of tests which are missing their nitrate metadata
should be again smaller.
2025-01-13 12:59:22 +00:00
Milos Malik
0109a9a414 test if samba-bgqd can talk to cupsd via socket
Recent cups + samba + selinux-policy testing revealed SELinux
denials which appear when a samba-bgqd process communicates
with the cupsd process via the /run/cups/cups.sock file. The
TC reproduces the situation.

In order to support the use case and avoid these SELinux denials,
I believe that SELinux policy should allow the necessary actions.
The TC looks for appropriate policy rules and file context patterns.

The TC covers RHEL-72860 and RHEL-72861.
2025-01-07 14:11:32 +01:00
Milos Malik
02fe4ae17a test if GDM can talk to iio-sensor-proxy via D-bus
Recent gdm + iio-sensor-proxy + selinux-policy testing revealed that
SELinux prevents the D-bus communication between the gdm service
and the iio-sensor-proxy service. The TC reproduces the situation.

In order to support their intentional collaboration (for example:
net.hadess.SensorProxy.ClaimAccelerometer), I believe that SELinux
policy should allow the D-bus communication in both directions. The
TC looks for appropriate policy rules.

The TC covers RHEL-70850.
2024-12-11 08:35:52 +01:00
Milos Malik
25874c879b test if virtqemud can use sched_getaffinity syscall on VM
A recent virt* and selinux-policy testing revealed that rpc-virtqemud
process triggers SELinux denial as a reaction to the "virsh vcpuinfo"
command. The TC reproduces the situation.

In order to provide the detailed domain vcpu information successfully,
I believe that SELinux policy should allow this action. The TC looks
for appropriate policy rules.

The TC covers RHEL-69920.
2024-12-09 10:50:38 +00:00
Petr Lautrbach
b0f6b28c82 libsemanage: drop disconnect tests
It tests wrong behavior which is fixed in the latest libsemanage and
in order not to break test runs on older systems lets drop it.

Fixes:
    semanage_handle_create(): 0x4f782c0
    semanage_disconnect(0x4f782c0): 0
    semanage_connect(0x4f782c0): 0
    semanage_handle_destroy(0x4f782c0)
    [   FAIL   ] :: Command './test_connect handle reversed' (Expected 134, got 0)
2024-12-04 18:36:42 +00:00
Milos Malik
46a86a1ff1 do not trigger RHEL-47401 on RHEL-9.x
Current decision on RHEL-47401 is not to fix it. In order to avoid
unnecessary failures (or waiving), the test scenario will not be
tested on RHEL-9 and CentOs stream 9 machines.
2024-12-04 09:44:20 +00:00
Milos Malik
af82a85d6d test if samba-bgqd can search /etc/cups/ and /run/cups/
Recent selinux-policy + cups + samba-bgqd testing revealed SELinux
denials which are triggered when the samba-bgqd service is started
on a machine where cups* packages are installed. The TC reproduces
the situation.

In order to support the intended samba-bgqd functionality, I believe
that SELinux policy should allow these actions. The TC looks for
appropriate policy rules and file context patterns.

The TC covers RHEL-69512 and RHEL-69517.
2024-12-04 07:11:10 +00:00
Milos Malik
0efb4046b1 add various virt-install test scenarios
test if memory device can be attached to a VM

TBA later

The TC covers RHEL-65038.

test if VM can start with multiqueue virtio interface

TBA later

The TC covers RHEL-65373.

test if VM can start with an isolated port

TBA later

The TC covers RHEL-65383.

test if VM with NUMA setting can start

TBA later

The TC covers RHEL-65789.

test if nbdkit enabled VM can start

TBA later

The TC covers RHEL-56029 and RHEL-69118.
2024-12-03 13:41:42 +00:00
Milos Malik
9c7a2f4fb4 fix requirements, relevancy and checks
The AVC subtest can be disabled, because all modified tests look for
SELinux denials directly.

At least 1 of the modified tests had an incorrect or incomplete list of
package requirements.

At least 1 of the modified tests had an incorrect relevancy.
2024-11-29 16:05:22 +01:00
Milos Malik
b64b1c6467 test if samba-bgqd can collaborate with rpcclient
A recent samba + selinux-policy testing revealed that SELinux
prevents the rpcclient command from enumerating printers. The
TC reproduces the situation.

A follow-up testing revealed that the samba-bgqd service, which
plays an important role in this scenario, is not confined by
SELinux.

In order to support the expected rpcclient + samba-bgqd functionality,
I believe that SELinux policy should allow the necessary actions.
The TC looks for policy rules and file context patterns which
reflect the fact that the samba-bgqd program is now confined
by SELinux.

The TC covers RHEL-53124 and RHEL-64908.
2024-11-13 08:06:22 +00:00
Petr Lautrbach
68d3f4d812 Test semanage operation with /var/lib/selinux on NFS
Verifies: RHEL-60503
2024-11-11 13:42:47 +01:00
Milos Malik
e978f12992 modify tests to run successfully on CentOS stream machines
Some tests failed when executed on CentOS-stream machines because of
insufficient code conditions. From now on, this problem should not
happen anymore.
2024-11-06 13:57:29 +01:00
Milos Malik
2e6dd329b8 add basic test which covers the gnome-remote-desktop service
Sooner or later, the gnome-remote-desktop service will be confined
by SELinux policy and this automated test should find out if basic
functions of the program/service are affected or not.

The TC covers RHEL-35877.

During the development of the automated test, a new SELinux denial
was identified and reported. The reproducer is already part of this
test.

In order to support various functions of the grdctl program, I believe
that SELinux policy should allow the gnome-remote-desktop-daemon
processes to watch (syscall = inotify_add_watch) the
/etc/gnome-remote-desktop directory. The TC looks for appropriate
policy rules and file context patterns.

The TC covers BZ#2321236.
2024-10-26 10:00:43 +00:00
Milos Malik
386ee4ea46 test if systemd-run works inside systemd-run service
Recently, debugging of unrelated systemd issue revealed that SELinux
prevents a successful execution of systemd-run inside systemd-run
session. The TC reproduces the situation.

In order to support the above-mentioned scenario, I believe that
SELinux policy should allow the dbus-broker to read/write from/to
UNIX stream socket owned by the systemd session. The TC looks for
appropriate policy rules.

The TC covers RHEL-61928 and RHEL-62185.
2024-10-23 08:06:48 +00:00
Milos Malik
597fc277da fill in the missing metadata in some tests
Now, all tests in the repository should have their nitrate id and
UUID in their main.fmf file.
2024-10-21 15:19:06 +00:00
Petr Lautrbach
deaf7662f4 Test rpm transaction for stderr output
Commands stderr output should be hidden unless it's fatal error

Verifies: https://issues.redhat.com/browse/RHEL-59192
2024-10-18 14:48:15 +00:00
Milos Malik
c3676f738b add basic test which covers the tlshd service
Sooner or later, the tlshd service will be confined by SELinux
policy and this automated test should find out if basic functions
of the program/service are affected or not.

The TC covers RHEL-29439 and RHEL-42672.
2024-10-16 11:52:44 +00:00
Zdenek Pytela
981c13333c Install linuxptp for the chrony test
In Fedora 41+, the timemaster_t type is available only when the
linuxptp-selinux package is installed. It is pulled in by linuxptp if
linuxptp-selinux exists, so linuxptp is a safe requirement working
for older releases, too.
2024-10-14 13:17:32 +02:00
Milos Malik
cb72821400 add basic test which covers pcm-sensor-server
Sooner or later, the pcm-sensor-server will be confined by SELinux
policy and this automated test should find out if basic functions
of the pcm-sensor-server program/service are affected or not.

The TC covers RHEL-52838.
2024-10-11 18:17:18 +00:00
Milos Malik
f179552e1b do not test services which are not present
Try to install packages which bring the services if they are
not present already.
Skip the "real scenario" test phase if the service is missing.
2024-10-08 08:14:51 +00:00
Milos Malik
239992b457 add test metadata which were missing
Recently created tests were missing FMF ids and Nitrate ids.
Newly created SELinux types are slightly different from what I expected.
Both issues are solved now.
2024-10-08 07:59:49 +00:00
Milos Malik
94564f402a run stress-ng only if secretmem_t is defined
The test phase covers both BZ#2270895 and RHEL-60837 because they
the same. The test phase should not be executed in environments
where the following SELinux type is not defined:
 * secretmem_t
2024-10-07 11:14:08 +00:00
Milos Malik
8ed58cb4ea add basic test which covers power-profiles-daemon
Sooner or later, the power-profiles-daemon will be confined by SELinux
policy and this automated test should find out if basic functions
of the power-profiles-daemon program/service are affected or not.

The TC covers RHEL-61117.
2024-10-07 09:21:31 +00:00
Milos Malik
b5a0def0c7 add basic test which covers switcheroo-control
Sooner or later, the switcheroo-control will be confined by SELinux
policy and this automated test should find out if basic functions
of the switcheroo-control program/service are affected or not.

The TC covers RHEL-24268.
2024-10-07 09:11:14 +00:00
Milos Malik
3184400050 add basic test which covers systemd-mountfsd
Recently, the systemd-mountfsd program/service got confined by SELinux.
Purpose of this automated test is to cover the basic scenarios in
which the daemon is used. The systemd-mountfsd man page was used as
the source of test scenarios/ideas.
2024-10-07 09:06:40 +00:00
Milos Malik
4ca2560ddd add basic test which covers iio-sensor-proxy
Sooner or later, the iio-sensor-proxy will be confined by SELinux
policy and this automated test should find out if basic functions
of the iio-sensor-proxy program/service are affected or not.

The TC covers RHEL-17346.
2024-10-07 07:49:08 +00:00
Milos Malik
2aa1759692 test if systemd-homed can read /var/cache/systemd/home/
Several recent BZ reports revealed that SELinux prevents the
systemd-homed processes from reading the /var/cache/systemd/home/
directory. The TC reproduces the situation.

In order to support the expected systemd-homed functionality, I believe
that SELinux policy should allow the action. The TC looks for
appropriate policy rules and file context patterns.

The TC covers BZ#2036108 and its duplicates.
2024-10-04 11:49:13 +00:00
Milos Malik
6b1406c6b2 test if systemd-modules-load can read /run/modprobe.d/*.conf
A recent cockpit CI + selinux-policy + FIPS testing revealed that
SELinux prevents the systemd-modules-load processes from reading
files stored in the /run/modprobe.d/ directory. The TC reproduces
the situation.

In order to support the documented locations for modprobe config
files, I believe that SELinux policy should allow the action. The
TC looks for appropriate policy rules and file context patterns.

The TC covers RHEL-54591.
2024-10-03 12:55:42 +00:00
Milos Malik
c9a5369366 test if systemd-journal-upload can read /run/systemd/journal-upload.conf.d/
A recent systemd + selinux-policy testing revealed that SELinux
prevents the systemd-journal-upload processes from reading the
the /run/systemd/journal-upload.conf.d/ directory. The TC reproduces
the situation.

In order to support the documented locations where systemd-journal-upload
configurations can be located, I believe that SELinux policy should
allow this action. The TC looks for appropriate policy rules and
file context patterns.

The TC covers RHEL-57774.
2024-10-03 11:54:36 +00:00
Milos Malik
2b36306eb2 test if 'hostapd_cli ping' can run as a systemd service
A recent testing of a documented hostapd + freeradius use case
revealed that SELinux prevents the hostapd processes from writing
to a control socket located in /tmp. The TC reproduces the situation.

In order to support the documented use case, I believe that SELinux
policy should allow the action. The TC looks for appropriate policy
rules and file context patterns.

The TC covers RHEL-59683.
2024-10-03 07:48:29 +00:00
Jan Onderka
2b631b367f Set time duration for tests seliabel-functions and selinux_restorecon-functions 2024-09-30 09:54:43 +00:00
Milos Malik
f471756eb4 fix the "unable to detect release version" situation
The yum process is sometimes not able to detect the Fedora version.
From now on, the --releasever option will be included on the command
line.
2024-09-24 18:15:56 +00:00
Petr Lautrbach
186b346eed Some SELABEL_ options are only supported in SELABEL_CTX_FILE
Since
65c8fd457b
selabel_open() would fail if used with unsupported option

Fixes:
    selabel_open - ERROR: Invalid argument
    selabel_options: SELABEL_OPT_PATH = (null), SELABEL_OPT_SUBSET = (null), SELABEL_OPT_VALIDATE = 0, SELABEL_OPT_BASEONLY = 0
    Executing: selabel_open(SELABEL_CTX_MEDIA, &selabel_option, 4)
    :: [ 07:57:09 ] :: [   FAIL   ] :: Command './test_open CTX_MEDIA NULL NULL 0 0' (Expected 0, got 22)
2024-09-24 16:18:45 +02:00
Milos Malik
9245b35ac6 test if boothd can talk to kernel via UNIX socket
A recent booth + selinux-policy testing revealed that SELinux
prevents the boothd processes from reading the /run/systemd/userdb/
directory and connecting through the io.systemd.DynamicUser socket
stored in it. The TC reproduces the situation.

In order to support the intended boothd functionality, I believe that
SELinux policy should allow these actions. The TC looks for appropriate
policy rules and file context patterns.

The TC covers RHEL-57104 and RHEL-58060.
2024-09-19 10:46:49 +00:00
Milos Malik
917da0db4b test if systemd-sysctl can read files under /run/sysctl.d/
A recently filed issue revealed that SELinux prevents the
systemd-sysctl from reading the files stored under the /run/sysctl.d/
directory. The TC reproduces the situation.

In order to support this documented sysctl specific location,
I believe that SELinux policy should allow the action. The TC
looks for SELinux denials that may appear when reproducing the
scenario.

The TC covers RHEL-56988 and RHEL-58380.
2024-09-19 10:04:46 +00:00
Milos Malik
4f44f21f57 test if new dhcpcd instance can kill an old instance
Because the ISC dhcp is no longer maintained by upstream, the dhcpcd
package is used as a replacement. Unfortunately, SELinux prevents
a new dhcpcd instance from communicating to and terminating the old one.
The TC does not reproduce the situation.

In order to support the intented dhcpcd functionality, I believe that
SELinux policy should allow these actions. The TC looks for appropriate
policy rules and file context patterns.

The TC covers RHEL-33081 and RHEL-43417.
2024-09-18 15:47:51 +00:00
Milos Malik
28a763c2e0 mark tests which are failing on RHEL-10
Tests which require the EPEL repository are tagged with rhel10-epel.
Tests which fail for other reasons are tagged with rhel10_broken.
2024-09-12 15:53:29 +02:00
Zdenek Pytela
9d0f01d9c3 Fix the phase for secretmem anon_inode type
The fix for bz#2270895 contains a transition when a secretmem type of
anon_inode class is to be created, similar to io_uring and userfaultfd.
2024-09-11 16:30:54 +00:00
Zdenek Pytela
7615b2d8c7 Do not check if "%{_sbindir}" rpm macro is used
With Changes/Unify_bin_and_sbin [1] in process, policy sources
stopped to refer to executables with full path using the "%{_bindir}"
and "%{_sbindir}" rpm macros.

[1] https://fedoraproject.org/wiki/Changes/Unify_bin_and_sbin
2024-09-11 16:27:13 +00:00
Milos Malik
34b7237513 do not rely on /etc/firewalld/lockdown-whitelist.xml
Recently, the automated test started failing because the following
file was not present: /etc/firewalld/lockdown-whitelist.xml.

From now on, the test should not fail because of this.
2024-09-10 07:53:36 +00:00
Ondrej Mosnacek
2401e40bac
kernel: improve kernel pkg name detection
When kernel-uk-virt is installed, the rpm query returns more than one
result, leading to (non-fatal) errors in the Setup phase. Query for the
kernel image path instead to avoid this.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2024-09-09 11:29:40 +02:00
Milos Malik
0b5f4b8236 add a new boothd test
Recently, the boothd program got confined by SELinux. Purpose of
this automated test is to find out if basic scenarios work as
expected under the current SELinux policy.

The TC covers RHEL-45907.
2024-08-30 11:31:09 +00:00
Ondrej Mosnacek
5e03405ed4 Add a test for two-way SCTP association setup
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2024-08-29 10:06:21 +00:00
Ondrej Mosnacek
6efe97887e
kernel/selinux-testsuite: apply a patch for ELN/EL10 compatibility
Fedora ELN / RHEL-10 has disabled CONFIG_NET_KEY, so apply a patch that
allows the testsuite to succeed by skipping the key_socket test when it
is not supported.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2024-08-28 15:18:33 +02:00
Vit Mojzis
b30e460af8 libselinux/matchpathcon: Add the previous fix to the correct test
Commit ab42eb93 added the change to another test by mistake.

Fixes:
  # cd libselinux/setfiles-in-chroot-env
  # 1minutetip 1MT-CentOS-Stream-9
  # ./runtest.sh

  yum -y install filesystem libselinux libselinux-utils python3-libselinux policycoreutils --installroot=/tmp/tmp.WhKcf2BrOe  --skip-broken'
  Unable to detect release version (use '--releasever' to specify release version)
  Error: Failed to download metadata for repo 'epel': Cannot prepare internal mirrorlist: Status code: 404
  [   FAIL   ]

Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
2024-08-16 13:46:58 +02:00
Vit Mojzis
ab42eb9378 libselinux/matchpathcon: Work around yum issue on CentOS 9
Fixes:
  # cd libselinux/setfiles-in-chroot-env
  # 1minutetip 1MT-CentOS-Stream-9
  # ./runtest.sh

  yum -y install filesystem libselinux libselinux-utils python3-libselinux policycoreutils --installroot=/tmp/tmp.WhKcf2BrOe  --skip-broken'
  Unable to detect release version (use '--releasever' to specify release version)
  Error: Failed to download metadata for repo 'epel': Cannot prepare internal mirrorlist: Status code: 404
  [   FAIL   ]

Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
2024-08-15 23:36:22 +02:00
Milos Malik
705e5154fa test if cups-browsed can access /root/.cups/lpoptions
A recent cups + selinux-policy testing revealed that SELinux prevents
the cups-browsed processes from accessing the /root/.cups/lpoptions
file. The TC reproduces the situation.

In order to support the cups-browsed ability to access the lpoptions
file, I believe that SELinux policy should allow the access. Either
file context patterns need to change or an appropriate policy rule
need to be added. The TC looks for these changes.

The TC covers RHEL-47401.
2024-08-03 06:20:00 +00:00
Milos Malik
ed49590c43 test if stalld works with the queue_track backend
Recent changes (BPF code that is involved in the queue_track
backend) in the stalld component trigger SELinux denials because
SELinux policy does not expect such a behavior. The TC reproduces
the situation.

In order to support this new feature, I believe that SELinux policy
should allow the necessary actions. The TC looks for appropriate
policy rules and file context patterns.

The TC covers RHEL-50356.
2024-08-02 16:04:27 +00:00
Milos Malik
a2c9af2d18 fix tests which fail for known reasons
The chronyd test does not produce non-printable characters now.

The libvirt-dbus test phases relevancy is improved now.
2024-08-02 17:29:13 +02:00
Milos Malik
a915243c7d recognize the new virt* policy and adapt checks
Instead of checking Fedora or CentOS or RHEL version, the decision
to adapt should be made according to the defined SELinux policy types
or attributes.

The TC also covers RHEL-40834.
2024-07-30 16:05:32 +02:00
Milos Malik
1fa9327a33 avoid showing of unprintable characters in the output
Unprintable characters in the test output can cause problems
when importing test results to the Report Portal.
The problem should be fixed now.
2024-07-30 13:27:03 +02:00
Milos Malik
1d726848e6 skip irrelevant phases and install required packages
If required packages are not installed, the tests will try to install
them (only 1 attempt per test will be done).

Certain test phases may not be relevant if:
 * required SELinux types/attributes are not defined
 * required programs/files are not installed
 * required packages are not available
2024-07-26 18:12:20 +02:00
Milos Malik
96d9e69fc4 test if systemd-machined can create socket in /run/systemd/machine/
Recent cockpit + systemd + selinux-policy testing revealed that
SELinux prevents the systemd-machined process (started by the
machinectl command) from doing the following actions:
 * creating the /run/systemd/machine directory
 * creating the /run/systemd/machine/io.systemd.Machine socket
 * unlinking the /run/systemd/machine/io.systemd.Machine socket
The TC reproduces the situation.

In order to support the basic machinectl functions, I believe that
SELinux policy allow these actions. The TC looks for appropriate
policy rules and file context patterns.

The TC covers RHEL-49567.
2024-07-26 09:48:20 +00:00
Milos Malik
1ea9253e58 add basic test coverage of the libvirt-dbus service
A recent cockpit + selinux-policy testing revealed that SELinux
prevents libvirt-dbus processes from connecting to virtqemud
processes. The TC reproduces the situation.

The libvirt-dbus service is confined by SELinux now. The TC covers
basic scenarios in which the service is used. The TC looks for
appropriate policy rules and file context patterns.

The TC covers RHEL-46893.
2024-07-26 09:18:37 +00:00
Milos Malik
5a7dbcf733 increase the chances of successful "yum install" runs
Package installations via yum can fail for many reasons. For example:
 * unsatisfied package dependencies
 * repository availability problems
 * unrecognized command line options

Hopefully, this change helps the yum command to run successfully
when such issues occur.
2024-07-24 13:21:02 +02:00
Milos Malik
ad41a9d3c2 fix problematic tests
Avoid problems caused by test failures or tests getting stuck.
2024-07-23 11:34:23 +02:00
Milos Malik
9aa7176654 update test relevancy to match the expectations
Certain test phases or tests are not relevant for CentOS stream 9.
2024-07-19 13:30:29 +02:00
Milos Malik
64f5b0129b keep the rlSETranslateBoolean() up-to-date
Make sure the upstream and downstream version of the rlSETranslateBoolean
function is the same. Otherwise, differences can cause problems
when running tests which use the function.
2024-07-18 14:19:26 +02:00
Milos Malik
3e4943c596 add missing metadata to the tests
Some tests were missing important TCMS metadata. Now, the problem
should be fixed.
2024-07-10 17:18:28 +00:00
Petr Lautrbach
c4bc437c3f Improve README
- rename to README.md
- add basic instruction how to run tests on localhost

Signed-off-by: Petr Lautrbach <lautrbach@redhat.com>
2024-07-10 08:57:28 +00:00
Milos Malik
1800d74961 test if matchpathcon works fine in chroot environment
A recent anaconda testing on Fedora rawhide machines revealed a
regression in the libselinux code which leads to segfaults. The TC
reproduces the situation.

The TC uses 2 reproducers (python code, binary command) to find out
if the problem is present or not. Both of them should pass when the
problem is fixed.

The TC covers BZ#2295428 and RHEL-46558.
2024-07-10 09:32:35 +02:00
Milos Malik
ba1ba298ba add a basic test which covers systemd-tmpfiles
A recently filed Jira issue revealed that SELinux prevents staff_u
 users from executing the systemd-tmpfiles program (via the following
service: /usr/lib/systemd/user/systemd-tmpfiles-setup.service).
The TC reproduces the situation.

In order to support the systemd-tmpfiles-setup.service functions
for confined users, I believe that SELinux policy should allow
the access described above. The TC looks for appropriate policy
rules and file context patterns.

The TC covers RHEL-40374 and RHEL-44191.
2024-06-27 07:40:50 +00:00
Milos Malik
0a9a89b021 add a basic test which covers systemd-nsresourced
Recently, the systemd-nsresourced program became confined by SELinux.
Purpose of this TC is to test the basic systemd-nsresourced scenarios.
The TC looks for appropriate policy rules and file context patterns.

The TC covers BZ#2290477.
2024-06-25 07:23:46 +00:00
Zdenek Pytela
bbea4d16a3 Use "${PREFIX}/run/named" for context check
Change context check from "${PREFIX}/var/run/named" to
"${PREFIX}/run/named" which matches the actual filesystem state
created and used by the bind-chroot service.
2024-06-24 12:11:18 +00:00
Milos Malik
725813a7af update relevancy of the bootupd test
The bootupd package is built for the following architectures:
 * aarch64
 * ppc64le
 * s390x
 * x86_64

The automated TC should be executed on these architectures too.
2024-06-20 15:12:31 +00:00
Milos Malik
12c66e8685 do not run the anon_inode test on s390x machines
The automated test causes problems when executed on s390x machines.
From now on, the test should not be executed there.
2024-06-19 13:42:52 +02:00
Milos Malik
06b265a3ea test if virt-admin can connect to all virt sub-daemons
A recently filed bug report revealed that SELinux prevents the
virt-admin command from connecting to various virtualization sub-daemons
using the admin connection. The TC reproduces the situation.

In order to support this virt-admin feature, I believe that SELinux
policy should allow the access. The TC looks for appropriate policy
rules.

The TC covers BZ#2291273.
2024-06-14 18:20:23 +00:00
bgrech
d77cf2fc66 add NoRHIVOS tag for tests unrelated to rhivos testing 2024-06-13 12:21:44 +00:00
bgrech
794e066599 RHIVOS adaptations
Modify sysd rfkill tests to run kernel-modules install specifically for kernel-automotive in the appropriate system under test
2024-06-13 12:21:44 +00:00
Ondrej Mosnacek
e1d2c9835a
kernel/xfrm-refcount-overflow: fix kernel pkg name detection
Do it the same way as in commit 3e8824e0aa ("kernel/selinux-testsuite:
fix kernel pkg name detection").

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2024-06-07 11:24:58 +02:00
Ondrej Mosnacek
9e9a717326
kernel/...: fix --skip-broken detection for DNF5
The detection of this flag is broken with DNF5, because it now only
appears under `dnf install --help`. Also, DNF5 now implements the logic
we want (skipping packages that are not available, rather than "broken")
under a new --skip-unavailable flag.

Therefore, detect both using `dnf install --help` and also check for
--skip-unavailable first.

Without this fix the tests try to install each package one by one with
DNF5, which is suboptimal.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2024-06-07 09:58:36 +02:00
Jan Onderka
60efdf58a5 Disable unrelated tests to RHIVOS 2024-05-28 14:34:39 +02:00
Milos Malik
e08af3f6df add tags to tests which depend on EPEL packages
Tests which depend on EPEL packages should be tagged properly.
Such tests should not be executed in environments where the EPEL
repository is not available.
2024-05-22 18:23:24 +02:00
Milos Malik
c162dadbbe test if bootupd can search under /sys/firmware/efi/efivars
A recent bootupd + selinux-policy testing revealed that SELinux
prevents the bootupd daemon from getattr/search-ing (syscall=statx)
the /sys/firmware/efi/efivars directory. The TC reproduces the
situation on machines equipped by EFI system partition.

In order to support the bootupd functions on EFI machines, I believe
that SELinux policy should allow this access. The TC looks for
appropriate policy rules and file context patterns.

The TC covers RHEL-36289.
2024-05-20 13:20:55 +00:00
Milos Malik
ab5c434f53 improve the failing tests
The /policycoreutils/setfiles_binary test: the --downloaddir option
is not recognized by the latest version of DNF. The option is removed
now.

The /other/update-packages test: the --skip-broken option is not
recognized by the latest version of DNF. The option is removed now.

The /selinux-policy/install-uninstall-dsp-packages test: let's not
run this test together with other tests, because it often finds
a problem that brakes the environment for the following tests.
2024-05-18 11:21:13 +02:00
Milos Malik
29b9cb2a5c add a basic apol test
Main purpose of the automated test is to find out if the apol tool
can read and analyze the SELinux policies currently installed on
the system.

Because the apol tool is a graphical one, a working X session is
needed to conduct the testing procedure.
2024-05-09 15:17:40 +00:00
Zdenek Pytela
6f6051b574 Uninstall selinux-policy-mls before the actual tests start
Removing selinux-policy-targeted is actually not caused by particular
packages, but it is rather an effect of current usage of conditional
dependencies in DSP packages:
Requires:       (%{name}-selinux if selinux-policy-%{selinuxtype})
which can lead to uninstallation of selinux-policy-targeted when both
selinux-policy-targeted and selinux-policy-mls are installed.
2024-05-07 01:01:15 +02:00
Milos Malik
55c2934207 test if sepolgen-ifgen complains about illegal character
Several bug reports pointed out that the installation, reinstallation
or upgrade of the selinux-policy-devel package produces the following
error message:

  Illegal character '"'

Further investigation revealed that there are unexpected/redundant
parentheses in the /usr/share/selinux/devel/include/contrib/virt.if
file, which also cause the following error messages when the
sepolgen-ifgen command is executed:

  Missing interface definition for virt_pid_filetrans
  Missing interface definition for virt_systemctl

The TC is able to reproduces the problem when executed on a not yet
fixed package. The TC passes when the problem is fixed.

The TC covers BZ#2254169, BZ#2254206, BZ#2277925.
2024-05-06 08:54:27 +00:00
Milos Malik
2e11118f7a test if logwatch's sendmail can search for disable_ipv6
A recent SELinux policy + logwatch testing revealed that SELinux
prevents the sendmail process (executed by the logwatch timer) from
searching the /proc/sys/net/ipv6/conf/all/ directory and finding
the disable_ipv6 file. The TC reproduces the situation on machines
with special IPv6 configuration.

In order to avoid unnecessary SELinux denials being triggered during
the situation, I believe that SELinux policy should allow the access.
The TC looks for appropriate rules and file context patterns.

The TC covers BZ#2183432 and RHEL-34135.
2024-05-02 14:24:12 +00:00
Milos Malik
4e1655b3f3 make the upstream tests up-to-date
Some upstream tests diverged from their downstream versions. Let's
synchronize them.
2024-04-30 14:19:57 +00:00
Milos Malik
744686d75a do not run broken tests in tier plans
Automated tests which break the machines where they run should not
be executed via tier plans. Test results coming from broken machines
have little value to reviewers.
2024-04-29 08:39:33 +00:00
Zdenek Pytela
479b08630f Explicitly exclude packages which make the test fail 2024-04-29 06:49:08 +00:00
Milos Malik
0791bbe53a remove unnecessary requires
The setools/seinfo test does not really need the SELinux beaker
library to work correctly. The lines which require this library
were removed.
2024-04-19 19:19:19 +02:00
Milos Malik
7f4c2828eb add important downstream tests to upstream repo
To improve the quality of upstream testing, some important
downstream tests are moved to the upstream repository.
2024-04-19 17:26:05 +02:00
Ondrej Mosnacek
ed0073cc4c Add a test for problematic NOP options left behind by NetLabel
When NetLabel is configured to send unlabeled traffic, it should fully
remove CIPSO options from the IP packets. This test verifies that they
are indeed removed (and not just replaced with IPOPT_NOP or IPOPT_END).

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2024-04-18 17:18:54 +00:00
Milos Malik
674ade6166 move more downstream tests to upstream repository
The following automated tests are important for upstream testing
too and that's why they should be moved from the downstream repo
to the upstream one.
2024-04-17 11:04:50 +02:00
Milos Malik
f10ccbe5cb add new test which covers various ABRT services
A lot of recently filed BZs revealed and confirmed that SELinux
prevents the abrt-dump-journal-core processes from:
 * writing to /run/systemd/userdb/io.systemd.* sockets
 * connecting to various UNIX streams owned by systemd* processes

The TC reproduces the situation.

In order to support the expected ABRT functions, I believe that
SELinux policy should allow above-mentioned actions. The TC looks
for appropriate SELinux policy rules and file context patterns.

The TC covers BZ#2274709 and other duplicates.
2024-04-16 12:58:37 +00:00
Milos Malik
cc86664885 improve other tests which fail on CentOS-stream-10
Some components/packages are not available on CentOS-stream-10,
which leads to conclusion not to run the affected tests/phases there.

The /var and /run directories very often contain mislabeled files
and directories. In order to find discrepancies between file context
patterns and type_transition rules defined in the SELinux policy,
the restorecon command is needed.
2024-04-15 16:09:41 +02:00
Milos Malik
24ce6bf2de make the cups-browsed service running
The cups-browsed service does not start with the default configuration.
In order to perform a basic SELinux testing, the cups-browsed
configuration needs to be modified (for example: BrowsePoll).
2024-04-11 09:55:46 +02:00
Milos Malik
26a276d5c9 fix the tests which fail on CentOS-stream-10
The rlImport command fails in many tests because the epel-release
package is not available for RHEL-10 or CentOS-stream-10 yet.
As a workaround, an additional exit code 1 is accepted now.
2024-04-04 16:35:36 +00:00
Dalibor Pospisil
50ee0226ec selinux-policy/Library/common: ignore auditd stopped
do not fail if auditd was not running before
2024-04-04 09:33:13 +00:00
Milos Malik
af629f99a2 test if stress-ng can create anon_inode objects
A recently filed Fedora bug revealed that SELinux prevents the
stress-ng processes from creating anon_inode objects via the
memfd_secret syscall. The TC reproduces the situation.

In order to support the expected stress-ng functonality, I believe
that SELinux policy should allow the action. The TC looks for
appropriate policy rules.

The TC covers BZ#2270895.
2024-03-27 15:30:28 +01:00
Milos Malik
6a777019bc improve the incorrectly written io_uring checks
I wrote certain io_uring checks incorrectly, because I misunderstood
the comments in the RHEL-11792 ticket. They should be correct now.

In order to properly test the io_uring feature, the feature needs to
be enabled (it is by default on Fedora). If the kernel command line
does not contain the "io_uring" string, the automated test adds the
necessary options and reboots the machine.
2024-03-27 10:57:41 +00:00
Milos Malik
703bfed49f add a new test which covers the logwatch service
A recent selinux-policy + logwatch testing revealed that SELinux
prevents the uptime process (executed by the logwatch service)
from reading the /run/systemd/sessions/ directory. The TC reproduces
the situation.

In order to avoid unnecessary SELinux denials, I believe that SELinux
policy should allow this access. The TC looks for appropriate policy
rules and file context patterns.

The TC covers BZ#2270484.
2024-03-26 08:27:46 +00:00
Milos Malik
e58558fe84 add a new sulogin test
A recently filed Fedora bug revealed that SELinux prevents the
sulogin processes from using:
 * the fsetxattr syscall (relabelfrom+relabelto) on /dev/tty*
 * the ioctl syscall (checkpoint_restore capability)

The TC reproduces the situation.

Because the relabel* permissions seem to be necessary for a successful
run of the sulogin command, SELinux policy should allow them.
On the other hand, the checkpoint_restore capability does not seem
to be necessary, which means that SELinux policy should dontaudit it.

The TC covers BZ#2265391.
2024-03-25 10:33:35 +01:00
Milos Malik
cf326c1181 test if dhcpcd can read the /run/netns directory
A recent dhcpcd + selinux-policy testing revealed that SELinux
prevents the dhcpcd processes from reading the /run/netns directory
when it exists. The TC reproduces the situation.

In order to support the expected dhcpcd functionality, I believe
that SELinux policy should allow the access. The TC looks for
appropriate policy rules and file context patterns.

The TC covers BZ#2269708 and BZ#2270733.
2024-03-21 16:08:34 +00:00
Milos Malik
5389b5acb3 test if plymouthd can access /dev/kmsg
Recent testing revealed that SELinux prevents the plymouthd processes
from accessing the /dev/kmsg device. The TC reproduces the situation.

In order to support the expected plymouthd functionality, I believe
that SELinux policy should allow the access. The TC looks for
appropriate policy rules and file context patterns.

The TC covers BZ#2256442.
2024-03-18 16:09:16 +00:00
Milos Malik
60daf3c47d clean up the tests metadata
Metadata of certain tests became outdated. Purpose of this change is:
 * include the rest of components into main.fmf
 * remove the failinfedora tag from tests which pass on Fedora
 * add the failinfedora tag to tests which fail on Fedora or
   which should not be executed
2024-03-18 15:12:13 +00:00
Zdenek Pytela
03fc444e76 Update the install-uninstall-dsp-packages test
Particular changes:
- install also DSP packages which do not distribute its custom SELinux
  module in a subpackage with the "-selinux" suffix (Fedora only)
- use rlLogWarning to display warnings
- list /var/run entries not having an equivalent rule in /run
- make use of the DEBUG variable to keep output files
  with various data after the test finishes:
-- list files in /run which have incorrect context
-- list installed packages
-- list SELinux modules, permissive and unconfined domains
-- check if dbus communication is defined bidirectionally
2024-03-18 13:42:48 +00:00
Ondrej Mosnacek
4024dfa46f
kernel/selinux-testsuite: another hotfix for install_t workaround
I can't believe I got it wrong AGAIN... I missed the ! operator.... Now
it should be correct, as was finally able to test it.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2024-03-11 10:12:42 +01:00
Milos Malik
fd803298d8 fix the synce4l test
The _cmd patterns may not be present in the /etc/synce4l.conf file.
The automated test should not fail because of them.
2024-03-11 07:19:31 +00:00
Ondrej Mosnacek
d95d39273f
kernel/selinux-testsuite: hotfix for install_t workaround
The version comparison is wrong. Fix it.

Fixes: 485e8279b7 ("kernel/selinux-testsuite: remove install_t references on RHEL6")
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2024-03-08 09:26:56 +01:00
Ondrej Mosnacek
586855095d
Add a test for XFRM refcount underflow
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2024-03-04 13:40:26 +01:00
Milos Malik
b2097912cc test if 'notself' and 'other' keywords are supported
SELinux userspace 3.6 recognizes new keywords: notself, other.
 * https://github.com/SELinuxProject/selinux/releases/tag/3.6

Purpose of this automated test is to find out whether their
implementation matches the expected functionality.
2024-03-04 10:49:58 +00:00
Ondrej Mosnacek
485e8279b7
kernel/selinux-testsuite: remove install_t references on RHEL6
Otherwise the policy fails to build there.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2024-02-29 16:12:35 +01:00
Ondrej Mosnacek
e1ad035bde
kernel/selinux-testsuite: add workaround for CONFIG_QFMT_V2=n
This is needed for the testsuite to be runnable on RH automotive
kernels.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2024-02-28 10:38:41 +01:00
Ondrej Mosnacek
87346d0760
kernel/selinux-testsuite: add workaround for CONFIG_SCSI_ISCSI_ATTRS=n
This is needed for the testsuite to be runnable on RH automotive
kernels.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2024-02-26 20:02:10 +01:00
Ondrej Mosnacek
3e8824e0aa
kernel/selinux-testsuite: fix kernel pkg name detection
The directory may also be owned by <name>-modules-core rather than
<name>-core in some cases. Use the "config" file as the reference
instead.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2024-02-26 20:02:10 +01:00
Milos Malik
156e7d934e test if systemd-notify can send into /run/systemd/notify
A recently filed customer case revealed that SELinux prevents the
systemd-notify processes from sending data into UDP socket (to a
process waiting on the other side of /run/systemd/notify socket).
The TC reproduces the situation.

In order to support the expected functions of systemd services
(especially type=notify), I believe that SELinux policy should
allow the actions. The TC looks for appropriate policy rules and
file context patterns.

The TC covers RHEL-25514 and RHEL-25605.
2024-02-21 08:26:44 +00:00
Ondrej Mosnacek
2b69b8c347
kernel/selinux-testsuite: hotfix for RHEL-6
The install_t workaround for rpm-ostree doesn't work on RHEL-6, so make
it conditional on /run/ostree-booted, so that it is only applied when
necessary.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2024-02-15 14:22:25 +01:00
Milos Malik
85a3f368bd adapt to semanage port dealing with duplicated local customization
The semanage command from older policycoreutils versions (<= 3.6-1.el9)
behaves in a certain way when a duplicated port context pattern is added.
It does not add the pattern but produces the following message:

  ValueError: Port <protocol>/<number> already defined

The semanage command from new policycoreutils versions (>= 3.6-2.el9)
behaves differently when a duplicated port context pattern is added.
It adds the pattern and produces the following message:

  Port <protocol>/<number> already defined, modifying instead

Above-mentioned differences in behavior have some consequences for the
automated test when removing a duplicated port context pattern. If the
automated test should pass, it needs to anticipate both possibilities.
2024-02-15 08:09:55 +01:00
Ondrej Mosnacek
1a3d30f8dd kernel/selinux-testsuite: add a fix and a workaround for rpm-ostree
1. Bump the upstream commit to pull in [1].
2. Apply a workaround to compensate for [2] not yet being applied
   everywhere where it matters.

[1] f9f4a604b5
[2] https://github.com/fedora-selinux/selinux-policy/pull/2029

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2024-02-13 08:46:14 +00:00
Milos Malik
d5d0a48cc8 add a new test plan which covers reboot actions
The test plan covers the following actions:
 * update packages to the latest versions available
 * reboot
 * collect SELinux denials that appeared since reboot
2024-02-08 22:27:40 +01:00
bgrech
4119cf83ed Add support for rpm-ostree as a package manager for installDeps 2024-02-07 16:01:30 +00:00
Milos Malik
c7297bd7a3 test if colord can use NoNewPrivileges
Recently, openQA testing of new colord version (1.4.7-1) revealed
that SELinux prevents the colord process transition from init_t
to colord_t domain. The TC reproduces the situation.

In order to support the existing colord functionality together with
the newly added systemd unit option (NoNewPrivileges=true), I believe
that SELinux policy should allow the action. The TC looks for
appropriate policy rules and file context patterns.

The TC covers BZ#2259679.
2024-02-06 15:49:35 +00:00
Milos Malik
12ea165a34 test if sysadm_u can run dmidecode via sudo
A recently filed customer case revealed that SELinux prevents the
sysadm_u users from running the dmidecode command via sudo which
has the input/output logging enabled. The following error message
appears during the action:

  sudo: unable to open /var: Permission denied

The TC reproduces the situation.

In order to support the above-mentioned configuration, I believe that
SELinux policy should allow the necessary actions. The TC looks for
appropriate policy rules and file context patterns.

The TC covers RHEL-16104.
2024-02-06 14:24:00 +00:00
Milos Malik
53adb45651 add the chronyd test to upstream repo
The chrony component is frequently used by various users on Fedora
and RHEL, so it makes sense to run this TC in upstream testing too.
There are no changes in the TC functionality.
Moving the downstream TC to upstream repo.

The TC covers RHEL-18219.
2024-02-06 13:39:21 +00:00
Milos Malik
3ea1adb99b test if exim can send into /var/spool/exim/exim_daemon_notify
A recent exim testing on RHEL-8 and RHEL-9 revealed that SELinux
prevents the exim processes from sending data into the abstract
socket: /var/spool/exim/exim_daemon_notify. The TC reproduces the
situation when executed in the right environment.

In order to support all the expected actions over the daemon
notifier socket, I believe that SELinux policy should allow the
sendto permission. The TC looks for appropriate policy rules and
file context patterns.

The TC covers RHEL-21902 and RHEL-21903.
2024-01-23 12:57:20 +00:00
Zdenek Pytela
5994b16d67 Add a test phase for "/run equivalency status" check
Check which equivalency is in place and if there are incompatible
entries.
2024-01-19 14:29:52 +00:00
Zdenek Pytela
97bec02b0a Make a few small changes and add comments to the Install phase 2024-01-19 14:29:52 +00:00
Zdenek Pytela
71a582c833 Split the "Install and Uninstall" phase test into two 2024-01-19 14:29:52 +00:00
Zdenek Pytela
dd611e50af Test systemd-generators
Display some basic system information and list generators which are
confined and which are not, then run particular tests with some
adjustments for:
- systemd-network-generator
- systemd-fstab-generator
- systemd-rc-local-generator
- systemd-sysv-generator
- selinux-autorelabel-generator
and finally run again all generators with default settings as an effect
of "systemctl daemon-reload".
2024-01-18 18:30:10 +00:00
Milos Malik
b25abf5f67 fix known issues in 3 automated tests
1) opensmtpd-and-similar test:
The opensmtpd service needs to be started before an email can be sent
via the mailx command. The original order led to the following error:

  /root/dead.letter 17/564
  s-nail: ... message not sent

2) deny-rules test:
The deny-rules test intentionally triggers SELinux denials. These
SELinux denials should not be reported as errors or warnings.

3) systemd-modules-load-and-similar test:
Not all kernel modules required by the RDMA services are available
on all machines. To avoid unnecessary failures, the test phase
devoted to bz#1942267 will be skipped on such machines.

The automated tests should be fixed now.
2024-01-16 18:04:46 +01:00
Zdenek Pytela
29d2c154d9 Remove all check against the lockdown class
The lockdown SELinux class was removed from kernel and no check is now
performed in the SELinux lockdown hook as a comprehensive fix for all
the SELinux lockdown-class related problems class was rejected, so no
test checks using the lockdown class are now pertinent.
The lockdown-class checks are now not in any supported systems kernels.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=2017848
2024-01-04 22:09:17 +01:00
Milos Malik
f80d8f1fea adapt to testing under confined users too
The root user on a system is usually not confined by SELinux (context:
unconfined_u:unconfined_r:unconfined_t), but there are security
standarts which require the root user to be confined by SELinux
(context: sysadm_u:sysadm_r:sysadm_t).
In order to use this automated test on such systems, certain code
changes were necessary.
2024-01-02 13:12:32 +00:00
Milos Malik
26edd45004 adapt to modified sedispol commands
The sedispol tool recognizes several commands. Before the checkpolicy
version 3.6 was introduced, one of the commands was 'u' which displayed
unknown handling setting. With the new version, the 'u' command prints
SELinux users which are defined and the 'U' command displays the unknown
handling setting.
2023-12-18 17:21:57 +01:00
Milos Malik
3b016979c5 enable more repos for rebuild purposes
If the rebuild (src -> bin) of setools component should be successful,
additional repositories (rhel-CRB, beaker-CRB) need to be enabled.
2023-12-12 16:47:29 +01:00
Milos Malik
b7731c9f63 test if deny rules are implemented/recognized
The version 3.6 of SELinux userspace brings a new policy feature
called deny rules. Purpose of this basic test is to find out if
the deny rules function as expected.

The automated test covers the following scenarios:
 * file read prevention
 * file execution prevention
 * file removal prevention
 * directory search prevention
 * process ptrace prevention
 * kernel module load prevention
2023-12-07 13:27:23 +01:00
Milos Malik
ea51c05219 test if smtpd can manipulate the /run/smtpd.pid file
A recent opensmtpd testing revealed that SELinux prevents the smtpd
process from creating and manipulating the /run/smtpd.pid file. The
TC reproduces the situation.

In order to successfully start and run the opensmtpd service, I believe
that SELinux policy should allow these actions. The TC looks for
appropriate policy rules.

The TC covers RHEL-15175.
2023-12-05 13:19:25 +00:00
Milos Malik
ef0547613f test if setools can be built with userspace packages
A recent rebuild testing in COPR revealed that the setools package
cannot be built with the latest SELinux userspace (version 3.6).
The TC reproduces the situation.

In order to have a well-functioning set of tools for SELinux policy
analysis which works together with the new version of SELinux
userspace, I believe that the problem needs to be fixed.

The TC covers BZ#2251915 and RHEL-18067.
2023-12-05 13:21:49 +01:00
Milos Malik
ef67d0deea test the actions recognized by sedismod and sedispol
Since SELinux user-space 3.6 was introduced, the sedismod and sedispol
programs are able to perform various actions non-interactively when
the following options are supplied: -a, --actions. In previous versions,
these actions were only usable in the interactive mode.
From now on, the automated test also covers these options.
2023-11-23 19:25:59 +00:00
Milos Malik
bc9e323cd4 add a basic test of the getpolicyload program
SELinux user-space version 3.6 introduced a new program called
getpolicyload. Unfortunately, there is no man page which would
describe the program.

Purpose of this automated test is to test the basic function of
the getpolicyload program that is obvious from its behavior.
2023-11-21 10:00:21 +01:00
Milos Malik
fec8a04787 add Makefiles to tests executed via STI
Certain automated tests do not have Makefiles, which prevents them
from being executed by STI means. The situation leads to error messages
like this one:

  FAIL test selinux/selinux-policy/... do not know how to run test

In order to successfully execute them, appropriate Makefiles will
be added.
2023-11-16 15:14:09 +00:00
Milos Malik
8d1a0ebb57 test if definitions of policy interfaces are correct
A recent testing of the sepolgen-ifgen tool revealed that certain
policy interface definitions are not correct. The TC reproduces
the situation.

Even though the problem exists (unnoticed) for some time already,
I believe that we should ship valid and correctly defined policy
interfaces.

The TC covers RHEL-2616.
2023-11-15 21:16:35 +01:00
Milos Malik
f477da1bf5 test if dhcpcd can use the bpf capability
A recent dhcpcd testing revealed that SELinux denials appear when
the dhcpcd service (in default configuration) is started on RHEL-9.
The TC reproduces the situation.

In order to avoid such SELinux denials, I believe that SELinux policy
should either allow or dontaudit them. The TC looks for appropriate
policy rules.

The TC covers RHEL-15326.
2023-11-08 08:35:33 +00:00
Milos Malik
5fc4b5a48e test fcontext equivalences via the restorecond service
A recent bug report revealed that the restorecond service (after its
start) mislabels files in the /usr/bin/ directory when its configuration
file (/etc/selinux/restorecond.conf) contains the following line:
/bin/*

Further investigation revealed that the problem is caused by the
selinux-policy component which does not define a file context
equivalency between /bin and /usr/bin (/bin is a symlink to /usr/bin).

The TC reproduces the situation and it also tests other symlinks which
are present in /. The restorecond service behaved correctly the whole
time.

The TC covers RHEL-5032.
2023-11-07 08:33:04 +00:00
Milos Malik
da27245fd7 test if tlp can search /var/lib/snapd/
A lot of reported BZs revealed that SELinux prevents the tlp processes
from searching (syscall = newfstatat) under the /var/lib/snapd directory
when the snapd package is installed. The TC reproduces the situation.

Based on the last comment in BZ#1888699, I believe that SELinux policy
should dontaudit the access. The TC looks for appropriate policy rules.

The TC covers BZ#2221019 and its duplicates.
2023-11-06 16:53:08 +00:00
Milos Malik
7582d85628 fix the relevancy of tests failing on centos stream
Apparently, the first attempt to adjust the relevancy was not
complete. So here is another one.
Certain tests should not be executed on centos-stream 8 or 9 at all,
because packages required by those tests are not available there.
Certain tests need to reflect the fact that SELinux policies which
confine the tested programs are not present on all versions of RHEL,
CentOS or Fedora.
2023-11-03 20:45:01 +01:00
Milos Malik
b7da677d10 test if ntpd can connect to 4460/tcp port
A recently filed BZ report revealed that SELinux prevents the ntpd
service (which belongs to the ntpsec package) from connecting to
the 4460/tcp port when it is configured to use the NTS servers. The
TC reproduces the situation.

In order to support the NTS standart for the ntpd service, I believe
that SELinux policy should allow the action. The TC looks for appropriate
policy rules, port context and file context patterns.

The TC covers BZ#2246805 and RHEL-15085.
2023-11-02 18:30:32 +00:00
Milos Malik
3ef0170d87 test if smtpctl can connect to /run/smtpd.sock
A recent opensmtpd testing revealed that SELinux prevents the smtpctl
processes from connecting to the /run/smtpd.sock socket. The TC
reproduces the situation.

In order to support the basic function of sending emails via opensmtpd
means, I believe that SELinux policy should allow the above-mentioned
action. The TC looks for appropriate policy rules and file context
patterns.

The TC covers BZ#2246115.
2023-11-02 13:22:12 +00:00
Milos Malik
b720e41367 adjust the relevancy of tests failing on centos stream
Certain tests should not be executed on centos-stream 8 or 9 at all,
because packages required by those tests are not available there.
Certain tests need to reflect the fact that SELinux policies which
confine the tested programs are not present on all versions of RHEL,
CentOS or Fedora.
2023-11-02 13:34:21 +01:00
Milos Malik
d5c1f98be6 test if sudo dnf works for confined administrators
A recently filed customer report revealed that SELinux prevents the
confined administrator (derived from sysadm_u, having sysadm_r role)
from running the "sudo dnf update" command. The TC reproduces the
situation.

Because BZ#1910077 was not fixed on the sudo side, various commands
end up triggering SELinux denials and consequently, they need to be
fixed on the selinux-policy side. It is an unfortunate solution, but
a necessary one if we want to achieve a successful run of such commands.

The TC covers BZ#2233065 and RHEL-1679.
2023-11-01 12:07:41 +00:00
Milos Malik
8ddb24101c test if spamd can search the /var/lib/snapd directory
A recently filed BZ report revealed that SELinux prevents the spamd
processes from searching (syscall = newfstatat) the /var/lib/snapd
directory when the snapd package is installed. The TC reproduces
the situation.

Because the spamassassin service logs indicate that the spamd functions
are not affected by the denied access, I believe that SELinux policy
should dontaudit the action. The TC looks for appropriate policy rules
and file context patterns.

The TC covers BZ#2207725.
2023-11-01 11:36:35 +00:00
Milos Malik
d12a67259d add missing ids into tests
When the `tmt test export` command is used on a test, a unique id
is generated for the test and the id is added into the main.fmf file
of the test. More information about these ids can be found at:

 * https://tmt.readthedocs.io/en/stable/spec/core.html#spec-core-id

From now on, all tests in the selinux-policy directory will have
their ids present.
2023-10-25 16:37:38 +00:00
Amith Kumar
c6da0b9818 Identify conflicts during installation of dsp packages
Add testcode to selinux-policy/install-uninstall-dsp-packages test suite
to discover conflicts during third-party or dsp selinux package
installations. The code installs-uninstalls relevant packages collected
from all the available repos and checks for failures / AVC errors.

Signed-off-by: Amith Kumar <apeetham@redhat.com>
2023-10-25 14:19:43 +05:30
Milos Malik
cb9ae062ac test if exim can create dirs under /var/spool/exim/input/
A recently filed customer report revealed that SELinux prevents
the exim's sendmail program from creating new directories under the
/var/spool/exim/input/ directory. The TC reproduces the situation.

In order to support the whole functionality of exim (especially the
split_spool_directory configuration option), I believe that SELinux
policy should allow the action. The TC looks for appropriate policy
rules and file context patterns.

The TC covers RHEL-14110 and RHEL-14186.
2023-10-23 15:54:21 +00:00
Milos Malik
af206491b2 test if fio utility can use io_uring:cmd on NVME devices
A recent fio testing performed on machines which have NVME devices
revealed that SELinux prevents the fio processes from using the cmd
permission of the io_uring class. The TC reproduces the situation
on such machines.

In order to support the io_uring functionality of the fio utility,
I believe that SELinux policy should allow this action. The TC
looks for appropriate policy rules and file context patterns.

The TC covers RHEL-11792.
2023-10-23 09:41:49 +00:00
Milos Malik
956f6ef06e test copy-from,copy-to,reboot commands in systemd-machined test
As pointed out in BZ#1900869, some of the machinectl commands still
do not work as expected. As a result of manual testing, I added more
policy rules to the testpolicy module which, hopefully, improves the
situation.
2023-10-20 05:57:09 +00:00
Zdenek Pytela
5f44de3a21 Fix incorrect rlIsFedora usage
Since the ba723f4941 (Update test for virtualization daemons) commit,
the virtualization daemons test branches based on Fedora version, but
rlIsFedora was used incorrectly, making the condition always succeed.
2023-10-18 13:27:52 +02:00
Zdenek Pytela
ba723f4941 Update test for virtualization daemons
Since Fedora 40, virt policy has been split into 2 modules.
There are new types for hypervisor drivers in the main policy module and
also new types for secondary drivers in the virt_supplementary module.
2023-10-16 12:28:56 +02:00
Milos Malik
e1f30f13fb test if numad can use the ipc_owner capability
A scenario which combines the numad service, a libvirt VM and the
following libvirt configuration option revealed that SELinux prevents
the numad processes from using the ipc_owner capability:

  <vcpu placement="auto" />

In order to support the whole numad functionality, I believe that
SELinux policy should allow the action. The TC looks for appropriate
policy rule.

The TC covers BZ#2026968 and RHEL-2415.
2023-10-12 14:33:14 +00:00
Milos Malik
16b6e607cb unmark tests which pass in Fedora rawhide
Remove the failinfedora tag from the automated tests which pass in
Fedora rawhide.
2023-10-11 20:45:27 +02:00
Milos Malik
037f2d7d1d mark tests which fail in Fedora rawhide
Tag the automated tests which fail in Fedora rawhide: failinfedora.
2023-10-11 13:34:56 +02:00
Zdenek Pytela
46ea4b4457 Update anon_inode test for F40
Previously, selinux-policy allowed all operations on anonymous inodes
for all domains. Since F40, individual types for each anon inode type
(userfaultfd and io_uring for the moment) were defined and common
userfaultfd/io_uring usage was allowed to individual domains.
This test was adjusted to align with the new F40 state.
2023-10-09 08:25:42 +00:00
Milos Malik
1e53ae8823 test if systemd-localed can create /etc/X11/xorg.conf.d/
A recently filed bug report revealed that SELinux prevents the
systemd-localed processes from creating the /etc/X11/xorg.conf.d
directory if it does not exist. The TC reproduces the situation.

In order to enable the legacy systemd-localed functionality,
I believe that SELinux policy should allow the action. The TC
looks for appropriate policy rules and file context patterns.

The TC covers BZ#2240159.
2023-10-03 13:52:57 +00:00
Milos Malik
8698c26ae9 fix the type differences: stas_t vs. nvme_stas_t
Even though the new policy for nvme-stas component was tested
multiple times (as can be seen in BZ#2111414 and RHEL-1557),
a SELinux type naming problem was introduced by various selinux-policy
builds. For example:
 * stas_t vs. nvme_stas_t
 * stas_exec_t vs. nvme_stas_exec_t
 * stas_var_run_t vs. nvme_stas_var_run_t
 * stas_cache_t vs. nvme_stas_cache_t

In order to make the automated test correct and reliable, the SELinux
policy checks executed by the test will use the nvme_* prefixed types,
because they are present in the latest selinux-policy builds.
2023-09-25 07:16:37 +00:00
Milos Malik
58842891ba add the kdump test to upstream repo
The kexec-tools component is frequently used by various users on Fedora
and RHEL, so it makes sense to run this TC in upstream testing too.
There are no changes in the TC functionality.
Moving the downstream TC to upstream repo.

The TC covers BZ#2236876.
2023-09-22 11:25:50 +00:00
Milos Malik
ac2bb3d8e0 test if stacctl and stafctl work as expected
A recent testing of new policy for the stacd and stafd services
revealed that SELinux prevents the stacctl and stafctl programs
from communicating with the daemons via D-bus (send_msg permission).
The TC reproduces the situation.

In order to support the D-bus communication in both directions
(unconfined -> stas_t, stas_t -> unconfined_t), I believe that
SELinux policy should allow the action. The TC looks for appropriate
policy rules.

The TC covers RHEL-1557.
2023-09-20 15:58:59 +02:00
Milos Malik
482173eb71 fix test relevancy and add test IDs
Certain test phases are not relevant for RHEL-8 and they fail because
of that fact.

Certain tests still require the setools package, which
is not really needed for their successful run.

Many tests lack the FMF (generated) ID.

Several tests still contain the TIPfail tags (related to the Test
Improvement Project which was discontinued a long time ago).

These issues should be fixed now.
2023-09-12 14:25:05 +02:00
Petr Sklenar
6299781214 Update selinux-policy/cups-pdf-and-similar/main.fmf
test is testing cups-pdf
2023-09-12 09:50:17 +00:00
Zdenek Pytela
4f7fc855e6 Do not run pam_console test on Fedora 39 and newer
The pam_console module was removed from pam in favor of a more complex
solution in systemd-logind in Fedora 39 [1], therefore the test is not
applicable there and will not be in the future releases.

[1] https://fedoraproject.org/wiki/Changes/RemovePamConsole
/home/zpytela/devel/tests-fedora/selinux
2023-09-06 11:42:42 +00:00
Milos Malik
475669fa18 update relevancy of 3 tests
The following tests were failing on RHEL-9 because some of their
test phases were executed even if they were not relevant:
 * selinux-policy/bootupd-and-similar
 * selinux-policy/bz562833-chrooted-named-file-contexts
 * selinux-policy/systemd-machined-and-similar

The issues should be fixed now.
2023-09-01 06:25:25 +00:00
Milos Malik
23c3caa982 test if cups-pdf can connect to /run/systemd/userdb/io.systemd.DynamicUser
A recent samba and cups-pdf testing revealed that SELinux prevents
the cups-pdf processes from connecting to UNIX stream socket:
 * /run/systemd/userdb/io.systemd.DynamicUser (kernel_t)

The TC reproduces the situation.

In order to support the whole cups-pdf functionality, I believe that
SELinux policy should allow the action. The TC looks for appropriate
policy rules.

The TC covers BZ#2234765.
2023-08-30 15:02:03 +02:00
Milos Malik
1423878d55 do not finish prematurely when cups-pdf package is present
The cups-pdf package is available in the EPEL repository for RHEL-8
and RHEL-9. The test should NOT finish prematurely if the cups-pdf
package is installed. The test should fail if the cups-pdf package
cannot be installed even if the test tried to install it from EPEL.
2023-08-30 11:17:17 +02:00
Milos Malik
fc767823c1 do not require abrt, use recommend instead
The abrt* packages are not available on RHEL-9, which means that
one of the test phases would fail if this change was not done.
The test phase dedicated to /usr/sbin/abrtd will be executed only
if the file is present.
2023-08-23 12:49:30 +02:00
Milos Malik
23f0ff9714 disable the pager when running journalctl under root
The journalctl command usually runs the less command as a pager.
The less command usually saves the performed actions in a history
file called ~/.lesshs*.
This sequence of commands can produce SELinux denials when executed
under the root user, because the less' history file is located in
the /root directory.

We believe that the number of programs (SELinux domains) which have
write access to the /root directory should be kept limited.

In order to avoid SELinux denials related to /root/.lesshs* files,
the journalctl command will be executed with the --no-pager option.
2023-08-17 11:29:26 +02:00
Milos Malik
d3c91b68fd add the bind test to upstream repo
The bind component is frequently used by various users on Fedora
and RHEL, so it makes sense to run this TC in upstream testing too.
There are no changes in the TC functionality.
Moving the downstream TC to upstream repo.
2023-08-15 14:28:41 +00:00
Milos Malik
57b58b0d59 test if perf (running as sysadm_t) can use the bpf syscall
A recent perf + perf_event testing revealed that SELinux prevents the
sysadm_u user from using the bpf syscall (permission: prog_run, class:
bpf) when running the perf program. The TC reproduces the situation.

In order to enable the sysadm_u user to use all perf features, I believe
that SELinux policy should allow this action. The TC looks for
appropriate policy rules.

The TC covers BZ#2229936.
2023-08-11 07:59:52 +00:00
Petr Lautrbach
91109dac9f Does sepolicy generate --application detect writeable locations?
Signed-off-by: Petr Lautrbach <lautrbach@redhat.com>
2023-08-09 10:57:04 +00:00
Ondrej Mosnacek
a695917478
kernel/selinux-testsuite: fix kernel package detection
There is no /lib/modules/.../vmlinuz file on RHEL-7 kernels, so just use
the parent directory, which should be owned by the same package.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2023-08-03 17:54:43 +02:00
Milos Malik
f52d187782 do not call epelyum when yum is missing
There are environments where yum is not present. The epelyum function
is based on the yum command and if the yum command is not present,
it makes no sense to call the epelyum function.
2023-07-24 16:04:07 +00:00
Ondrej Mosnacek
5ab7ce1a0c
kernel/selinux-testsuite: improve kernel package detection
Instead of relying on the existing kernel package naming and versioning
conventions, which are subject to change in RHEL, determine the main
kernel package name via `rpm -qf "/lib/modules/$(uname -r)/vmlinuz"` and
derive the rest from that.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2023-07-21 13:36:10 +02:00
Ondrej Mosnacek
2b3d261501
kernel/selinux-testsuite: enable SCTP peeloff tests on RHEL-9 as appropriate
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2023-07-21 12:56:13 +02:00
Milos Malik
bd2e475cd9 do not fail when /run/chrony-dhcp/ is missing
The /run/chrony-dhcp/ directory is not created on RHEL-8.x during
the test scenario. The TC should not fail because of this fact.
2023-07-19 06:49:54 +00:00
Milos Malik
0443a95a9b test if policy defines the anon_inode class
The BZ which introduced the anon_inode class into SELinux policy
was missing an automated test coverage until now.

The TC covers BZ#1954145.
2023-07-18 11:23:22 +02:00
Milos Malik
769c99ed48 do not call epelyum when dnf or yum is missing
There are environments where neither dnf nor yum are present. In such
environments, it makes no sense to call the epelyum function.
2023-07-17 12:39:22 +02:00
Milos Malik
38125be172 test if targetd can search under /proc/sys/net/
Recent targetd testing revealed that SELinux prevents the targetd
process from searching under the /proc/sys/net/ directory and reading
the /proc/sys/net/ipv6/conf/all/disable_ipv6 file. The TC reproduces
the situation.

In order to support the expected functionality of the targetd service,
I believe that SELinux policy should allow above-mentioned actions.
The TC looks for appropriate policy rules and file context patterns.

The TC covers BZ#2222199.
2023-07-13 09:46:10 +02:00
Milos Malik
bf25ac6f26 add the targetd test to upstream repo
The targetd component is also used by various users on Fedora
and RHEL, so it makes sense to run this TC in upstream testing too.
There are no changes in the TC functionality.
Moving the downstream TC to upstream repo.
2023-07-12 08:39:32 +00:00
Ondrej Mosnacek
9bcbe2e024
kernel/selinux-testsuite: bump ustream commit ref
This mainly pulls in the new inet_socket/mptcp subtest that provides
coverage for the MPTCP protocol.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2023-07-04 13:10:50 +02:00
Milos Malik
4b66a79266 test if bootupd can search under /boot/efi/EFI
Recent bootupd testing revealed SELinux denials which were triggered
because the bootupd process wanted to use the following access:
 * getattr (syscall=statx) on /boot/efi directory (dosfs_t)
 * search (syscall=openat) on /boot/efi/EFI directory (dosfs_t)

The TC reproduces the situation on machines where /boot/efi/EFI is
mounted accordingly.

In order to enable the expected functionality of the bootupd service,
I believe that SELinux policy should allow the accesses mentioned
above. The TC looks for appropriate policy rules.

The TC covers BZ#2218106.
2023-06-29 12:30:36 +02:00
Zdenek Pytela
a1c679b5e7 Change file and process context for bootupd
The service has been confined in the latest policy, so the
/usr/libexec/bootupd executable is labeled bootupd_exec_t
and the process bootupd_t.
2023-06-28 09:16:21 +00:00
Milos Malik
db5f56d258 work around the dnf5 issue when --skip-broken is not recognized
The SELinux beaker library calls the yum/dnf command and the
"--skip-broken" option is placed before the "install" word on the
command line. Such command line executed on Fedora rawhide leads to
the following error message:

  Unknown argument "--skip-broken" for command "dnf5". Add "--help" for
  more information about the arguments.

In order to work around this issue, the "install" word was moved before
the rest of options. Manual testing revealed that this approach works
on Fedora rawhide.
2023-06-23 10:41:42 +02:00
Milos Malik
8b0f575ac2 add the boinc test to upstream repo
The boinc-client component is also used by various users on Fedora
and RHEL, so it makes sense to run this TC in upstream testing too.
There are no changes in the TC functionality.
Moving the downstream TC to upstream repo.
2023-06-22 12:25:58 +00:00
Milos Malik
67fe54314a add the thttpd test to upstream repo
The thttpd component is frequently used by various users on Fedora
and RHEL, so it makes sense to run this TC in upstream testing too.
There are no changes in the TC functionality.
Moving the downstream TC to upstream repo.
2023-06-22 12:25:17 +00:00
Milos Malik
7a375ff479 add the exim test to upstream repo
The exim component is frequently used by various users on Fedora
and RHEL, so it makes sense to run this TC in upstream testing too.
There are no changes in the TC functionality.
Moving the downstream TC to upstream repo.
2023-06-22 12:23:36 +00:00
Milos Malik
a32b536cd2 adapt to [gs]etxattr() which replace l[gs]etxattr()
New version of SELinux user-space (3.4) brought a change that affects
this automated test. Functions like lgetxattr and lsetxattr were replaced
by functions getxattr and setxattr.

TBA
2023-06-21 09:24:31 +00:00
Zdenek Dohnal
d0f436fbbc selinux-policy: Stop cupsd after cups-browsed test
CUPS service is a dependency of cups-browsed service, so it has to be
stopped once we're done with cups-browsed testing manually.
2023-06-20 16:54:14 +00:00
Milos Malik
12ec984e07 add new test which covers watch* permissions
In comparison to kernel, which recognizes various watch permissions,
SELinux policy does not recognize them yet. But that situation should
change soon.
Purpose of the TC is to find out if the same watch* permissions recognized
by kernel are also recognized by SELinux policy.

The TC covers BZ#1915034.
2023-06-20 16:36:59 +00:00
Milos Malik
d3052eecb1 add test which covers new records in capability2 class
In comparison to kernel, which recognizes capabilities like perfmon,
bpf and checkpoint_restore, SELinux policy does not recognize them yet.
But that situation should change soon.
Purpose of the TC is to find out if these capabilities recognized
by kernel are also recognized by SELinux policy.

The TC covers BZ#1915264.
2023-06-20 16:22:35 +00:00
Zdenek Pytela
506cb9f2d9 Replace all /var/run matchpathcon checks with /var/run/pcp
New versions of pcp use only the /run/pcp directory for storing all
runtime files. The old default file context rules were removed from
the policy.
2023-06-20 11:58:11 +00:00
Ondrej Mosnacek
733f960966
Narrow down relevancy in some tests
Make it reflect the current status in RHEL to avoid running the test
where it doesn't make sense.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2023-06-12 14:28:57 +02:00
Milos Malik
35c64114c2 add new automated test which covers the opensmtpd service
A recently filed BZ revealed that SELinux prevents the opensmptd
service from starting. The TC reproduces the situation. Here is
a short of summary of smptd actions that were denied:

 * chroot syscall on /var/empty/smtpd (sys_chroot permission)
 * chmod syscall on /var/spool/smtpd/temporary (fowner permission)
 * bind syscall on /var/run/smtpd.sock (create permission)
 * chmod syscall on /var/run/smtpd.sock (setattr permission)

In order to enable the expected functionality of the opensmtpd service,
I believe that SELinux policy should allow these actions. The TC looks
for appropriate policy rules and file context patterns.

The TC covers BZ#2208696.
2023-06-06 09:16:12 +00:00
Milos Malik
f5c43be61e improve the test to clean-up after itself
Restore the restorecond service to its original state.
The restorecond service should not stay running if it was not
running before execution of the test.
2023-06-05 15:36:19 +02:00
Milos Malik
b1ff618211 do not test virt* services which are not present
The automated test fails during its execution because not all virt*
services are always present.
2023-05-31 18:45:01 +02:00
Milos Malik
215a9d1ffb improve the tests which end with a timeout
Certain tests end up with a timeout because they run the ncat
program in the background and they do not stop it. The framework
which runs the tests apparently cannot cope with this fact.
2023-05-31 10:10:08 +02:00
Milos Malik
79eea844d1 test if various processes can use mmap syscall on io_uring
As many reported BZs confirm, various QEMU related programs use
the io_uring interface, but SELinux prevents them from using the
mmap syscall on it. The TC reproduces a similar situation.

In order to support the io_uring interface fully, I believe that
SELinux policy should allow the map permission on the anon_inode
class. The TC looks for appropriate policy rules.

The TC covers BZ#2025714, BZ#2187745 and their duplicates.
2023-05-19 15:55:58 +00:00
Ondrej Mosnacek
bdffd24e92
kernel/labeling_before_policy_load: misc tweaks
- ensure the current booted kernel is set as default
  (fixes the case where a newer kernel package has been installed since
   boot)
- add Beaker compat workaround
- add descriptions to most rlRun asserts
- run zipl also after the cleanup `dracut -f` invocation

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2023-05-18 16:19:56 +02:00
Ondrej Mosnacek
f6cb99446a
kernel/mount-options-memleak: run zipl if it's installed
On s390x zipl needs to be run after grubby for the settings to be
applied correctly.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2023-05-17 11:29:47 +02:00
Ondrej Mosnacek
a7e47a4b19
kernel/mount-options-memleak: print kernel cmdline after reboot
This may help diagnose unexpected issues with the test.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2023-05-17 11:29:00 +02:00
Ondrej Mosnacek
2dfd5cafcb
kernel/mount-options-memleak: fix REBOOTCOUNT variable name
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2023-05-17 10:30:48 +02:00
Ondrej Mosnacek
7ce3757ef6 Add a test for memory leak when SELinux mount options are used
Such memory leak was fixed upstream in the past. This test verifies that
it remains fixed.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2023-05-16 13:54:25 +00:00
Ondrej Mosnacek
a54b9e0d6b
kernel-confined-exec: add test for coredump disabled via /usr/bin/false
Systemd may disable coredumps by setting kernel.core_pattern to
"|/usr/bin/false", so this needs to work.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2023-05-11 15:37:59 +02:00
Zdenek Pytela
6fc4e1ae72 Run systemd-homed test only if systemd_homed_t exists
The systemd-homed service is not confined yet so no particular type
is assigned to the executable and the process, neither there are rules
in place to make the service run successfully.
2023-04-28 16:33:52 +00:00
Milos Malik
cfcc523174 create drop-in file only if /etc/ssh/sshd_config.d/ exists
The rlSEConfigureSSH function produced the following error message:

  /usr/share/beakerlib/testing.sh: line 896: /etc/ssh/sshd_config.d/001-enable-password.conf: No such file or directory

when the /etc/ssh/sshd_config.d directory did not exist.
To avoid such situations in the future, the 001-enable-password.conf
file will be created only if the /etc/ssh/sshd_config.d/ directory
exists.
2023-04-25 13:06:23 +02:00
Milos Malik
7f42d25157 detect the package after the program is installed
Packages which belong to non-usual repositories may be installed
during the Setup phase, but not sooner because the framework running
the tests does not know the repositories. It makes no sense to run
the following command before the program is installed:

 * rpm -qf /path/to/program

All the required packages should be installed after finish of the
rlSESatisfyRequires function.
2023-04-22 11:37:48 +00:00
Milos Malik
d25c4ccdfc add new test which covers various virtualization daemons
Recently, the libvirt daemon was restructured into several smaller
daemons. Each of them will be confined by SELinux. This test
case should test if these smaller daemons cooperate with SELinux
policy and looks for any SELinux denials.

This TC runs only basic scenarios like start, restart, stop on
various virtualization services. It also tests SELinux contexts of
those virtualization processes and their file context patterns.
2023-04-22 11:20:49 +00:00
Milos Malik
e3b384c85f enable the SSH login via password for common users
Some of the automated tests require the SSH password authentication
to be enabled in order to succeed. The following file is added into
/etc/ssh/sshd_config.d/ directory to enable it:
 * /etc/ssh/sshd_config.d/001-enable-password.conf
2023-04-20 12:04:09 +02:00
Milos Malik
e17c855d2a move reliable downstream tests to upstream repo 2023-04-11 18:10:56 +02:00
Milos Malik
f76b1f7794 skip the rpmdb-migrate phases if the service is missing
The rpmdb-migrate service is not available on all RHELs or Fedoras.
To avoid unnecessary failures, the rpmdb-migrate test phases will
be skipped if the service is not installed.
2023-03-24 13:21:58 +01:00
Ondrej Mosnacek
2c82db3d51
semodule-rebuild-if-modules-changed: fix RHEL version check (take 2)
Rework the conditional so that the new part of the test runs everywhere
except specified old version cases. Before this it wouldn't be run on
Fedora, CentOS, or RHEL>=10.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2023-03-24 10:15:21 +01:00
Ondrej Mosnacek
85268e7d6a
semodule-rebuild-if-modules-changed: add libsemanage as component in metatada
The bulk of the logic is implemented inside libsemanage, so add to the
component list, so that the test is run also on changes in libsemanage.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2023-03-23 16:23:59 +01:00
Ondrej Mosnacek
cdc801666e
semodule-rebuild-if-modules-changed: fix RHEL version check
The comparisons were inverted by accident - fix them.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2023-03-23 16:23:22 +01:00
Milos Malik
067f66fc4a quickly end tests which require unavailable packages
Some packages are only available for Fedora or for older RHELs.
It makes no sense to run certain tests in environments where their
required packages are not unavailable.
2023-03-22 12:14:07 +01:00
Ondrej Mosnacek
93eca7b0a9 policycoreutils/semodule-rebuild-...: add coverage for dontaudit
Test that semodule --refresh works correctly with the disable_dontaudit
flag.

This currently requires the following patch to pass:
https://lore.kernel.org/selinux/20230309143741.346749-1-omosnace@redhat.com/

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2023-03-21 15:15:30 +00:00
Milos Malik
92d69db177 modify daemons_use_tty in tests which use systemd-run
In order to allow a running systemd service to print an output onto
console, the daemons_use_tty boolean needs to be enabled. Otherwise
the following error message appears:

  Failed to start transient service unit: Connection reset by peer

The daemons_use_tty boolean is disabled by default.
2023-03-21 11:38:38 +01:00
Milos Malik
179cfabade complete the list of required packages
Some of the automated tests call programs which are not required
in any form (package name or program location). The problem should
be fixed now.
2023-03-07 09:45:45 +00:00
Milos Malik
b6e50398b5 test if systemd-timesyncd can watch the /run/systemd/ directory
The use of the systemd-timesyncd service revealed that SELinux
prevents the systemd-timesyncd processes from watching (syscall =
inotify_add_watch) the /run/systemd/ directory. The TC reproduces
the situation.

In order to successfully start the systemd-timesyncd service in
enforcing mode, I believe that this access should be allowed in
SELinux policy. The TC looks for appropriate policy rules and
file context patterns.

The TC covers BZ#2175137.
2023-03-06 15:59:28 +00:00
Ondrej Mosnacek
a4390a7a1e
kernel/selinux-testsuite: bump upstream commit
Notable changes:
- fixed DH prime format in 'keys' test
- native quota support now used for ext4 when available
  - needs special exception on RHEL-7 where it is broken
- fixed stderr noise from 'yes' command
- fixed SIGIO tests to work under CONFIG_LEGACY_TIOCSTI=n

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2023-03-06 14:31:52 +01:00
Milos Malik
c020488428 require full program locations instead of package names
When a program is moved from one package to another package,
automated tests which require the first package may fail. In order
to improve the situation, it's safer to require the full program
location instead of a package name, that may change over time.
2023-02-27 12:38:28 +01:00
Milos Malik
1250828d11 add new test which covers the bootupd service
This TC covers the bootupd service and its basic scenario with
default configuration.

Purpose of this TC is to find any SELinux interferences with the
bootupd service.

The TC covers BZ#2029478 and BZ#2044508.
2023-02-14 11:22:09 +00:00
Milos Malik
a9d77b420c add new test which covers the synce4l service
This TC covers the synce4l service and its basic scenario with
default configuration.

Purpose of this TC is to find any SELinux interferences with the
synce4l service.

The TC covers BZ#2158402.
2023-02-14 11:20:53 +00:00
Milos Malik
43db7fa18a test if journalctl's pager can use the prctl syscall
TBA later

The TC covers BZ#2136189 and BZ#2153782.
2023-02-08 07:41:01 +00:00
Milos Malik
6feeb9872e test if ModemManager can create /sys/class/net/*/qmi/pass_through file
Recently, various modem users reported that SELinux prevents the
ModemManager service from working with netlink route sockets and
from creating the /sys/class/net/*/qmi/pass_through file. The TC
does not reproduce the situation.

In order to support the full functionality of ModemManager service,
I believe that SELinux policy should allow these actions. The TC
looks for appropriate policy rules.

The TC covers BZ#2145005, BZ#2149560 and BZ#2149954.
2023-02-03 15:39:14 +01:00
Milos Malik
c202ed9d6e add new test which covers the nfs-idmapd service
This TC covers the nfs-idmapd service and its basic scenario with
default configuration.

Purpose of this TC is to find any SELinux interferences with the
nfs-idmapd service.
2023-02-03 08:16:08 +00:00
Milos Malik
3e70b4f33b test if rpmdb-migrate service works successfully
The upgrade procedure from Fedora 36 to Fedora 37 revealed that
SELinux prevents the rpmdb-migrate service from executing the
bash, rpm and rm programs. The TC reproduces the situation
without performing the upgrade.

In order to support the functionality of the rpmdb-migrate service,
I believe that SELinux policy should allow these actions. The TC
looks for appropriate policy rules and file context patterns.

The TC covers BZ#2164752.
2023-02-02 15:13:03 +00:00
Milos Malik
9b3bfcded4 enable the systemd-homed service before using it
The systemd-homed service is disabled by default. If the TC should
succeed, the service needs to be enabled.
2023-02-02 15:02:44 +00:00
Ondrej Mosnacek
ca2936720a kernel-confined-exec: refine policy expectations
Don't be strict about the 'execute' permission and instead check for
[the lack of] transitions. Also drop entrypoint checking as it's not
really relevant.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2023-01-27 16:36:09 +00:00
Milos Malik
a79a74c223 do not use ramfs_t for /dev/shm/.#cred* files
The TC needs to adapt to changes introduced by the following commit:

8e908b8d98
2023-01-26 10:41:24 +01:00
Milos Malik
d7ee07804b exclude the /var/ARTIFACTS when running restorecon
A lot of running services create various FS objects under the
/var or the /run directories. These objects may get SELinux
labels which are different than what file context database specifies.

To reveal such discrepancies, many automated tests run the
"restorecon -Rv /run /var" command.

Unfortunately, the command affects SELinux contexts of files
and directories stored under /var/ARTIFACTS/. For example:
the rlFileBackup function uses this location as storage.

To avoid unpleasant effects of the restorecon command on anything
stored under /var/ARTIFACTS, the restorecon command intentionally
excluded that directory.
2023-01-23 15:55:29 +01:00
Milos Malik
e0866a22fe fix the failing tests
Not all packages required by the tests were installed. The issue
should be fixed now.

Relevancy of certain tests was set incorrectly. The issue should
be fixed now.

At least 1 test runs longer than its specified duration. The issue
should be fixed now.
2023-01-23 12:47:27 +00:00
Milos Malik
1bf5991b55 test if icecast can rotate its log files
When the icecast service is running for a long time, its log files
become large enough so that they will be rotated. Unfortunately,
SELinux prevents the rename of old log files. The TC reproduces
the situation.

In order to support the functionality of `logsize` and `logarchive`
options, I believe that SELinux policy should allow the actions.
The TC looks for appropriate policy rules and file context patterns.

The TC covers BZ#2156763.
2023-01-23 12:33:11 +00:00
Milos Malik
b719355a36 add the icecast test into upstream repo
The existing icecast test is being moved from the downstream repository
to the upstream repository.
There are few changes in the test, for example: required packages,
relevant architectures, supported distros.
2023-01-23 12:33:11 +00:00
Zdenek Pytela
42c323c8e3 selinux-policy: update systemd-notify test
The systemd-notify binary was not expected to use as a separate service,
but rather a helper to notify PID 1 about some particular service state.
This includes user services.
Calling sd_notify API is also supported from running services.
2023-01-20 09:54:41 +00:00
Milos Malik
afff1ecfd4 test if sepolicy manpage can generate all man pages
A new test phase was added. Purpose of the test phase is to find
out whether the `sepolicy manpage` command can generate man pages
for all SELinux domains without triggering an error or traceback.

The TC covers BZ#1416372.
2023-01-17 15:27:53 +01:00
Milos Malik
b6ec2fee8d test if sepolicy manpage can generate manpage in HTML form
The sepolicy tool can generate man pages for specific SELinux domains.
When the sepolicy tool was instructed to generate man pages in HTML
form (--web), the generated HTML files were very incomplete. The TC
reproduces the situation.

The newly added TC checks if the sepolicy manpage command works
correctly. The checks related to the sepolicy manpage command
were removed from the sepolicy-generate TC.

The TC covers BZ#1989840.
2023-01-17 11:43:37 +01:00
Zdenek Pytela
ad7293e725 selinux-policy: Do not test if rpmdb can access host name services
Unlike originally reported in bz#1461313 and in some duplicates,
rpmdb does not need access to resolv.conf and sssd any longer.
Refer to https://bugzilla.redhat.com/show_bug.cgi?id=1461313#c73
for more information.
2023-01-09 16:28:59 +00:00
Milos Malik
a59d3c04ad test if journal-offline can relabel the journal files
Recently, the new versions of systemd component revealed that SELinux
prevents the journal-offline command from relabeling (syscall=fsetxattr)
the systemd journal files. The TC reproduces the situation.

Because the relabeling of journal files is an intentional operation,
which happens when the systemd journal is rotated, I believe that
SELinux policy should allow it. The TC looks for appropriate policy
rules.

The TC covers BZ#2075527 and BZ#2152823 and their duplicates.
2022-12-14 10:03:04 +01:00
Ondrej Mosnacek
96c98bb01d
kernel/selinux-testsuite: bump upstream commit
Effective changes:
- fix the policy to allow the new user_namespace::create permission
  where needed
- fix the code to build without warnings with latest SELinux userspace

The rest is various cleanups or changes not affecting Fedora/RHEL.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-12-12 16:19:39 +01:00
Ondrej Mosnacek
e70a8df7c8 Add coverage for the hardening of executing binaries by the kernel
See the test description/Bugzilla for more details.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-12-09 10:40:36 +00:00
Milos Malik
202b220c73 add new test which covers the stacd and stafd services
SELinux policy now contains a new policy module which confines the
stacd and stafd services, which belong to the nvme-stas package.
This TC covers basic scenarios of running the services in default
configuration. The TC also looks for appropriate policy rules and
file context patterns.

The TC covers BZ#2111414.
2022-12-07 08:29:32 +00:00
Milos Malik
677e8492b9 test if systemd-rfkill can use the bpf capability
Recent RHEL-9.2 instalation testing revealed that SELinux prevents
the systemd-rfkill processes from using the bpf capability. The TC
does not reproduce the situation unless the right HW is available.

In order to support the full functionality of the systemd-rfkill
program, I believe that SELinux policy should allow this action.
The TC looks for appropriate policy rule.

The TC covers BZ#2149390.
2022-12-02 19:48:14 +01:00
Milos Malik
de80db37fe add new test which covers systemd-machined
The use of systemd-machined and systemd-nspawn services revealed that
SELinux still prevents various actions they do. The TC reproduces the
situation.

In order to support the documented functionality of systemd-machine,
I believe that SELinux policy should allow these actions. The TC
looks for appropriate policy rules and file context patterns.

The TC covers BZ#1847545, BZ#1900869, BZ#1900888 and their duplicates.
2022-12-02 08:41:50 +00:00
Milos Malik
f1b7777fbf bring all downstream changes to the upstream tests
Downstream and upstream versions of certain automated tests
diverged before the duplicates were removed.

Now, they should be in sync.
2022-12-01 18:42:46 +01:00
Milos Malik
a7d24f4292 test if ladvd produces any SELinux denials
The test should look for any SELinux denials that appear during
its run. No matter which process triggered them.
2022-11-28 15:50:21 +01:00
Petr Lautrbach
8effe6fd87 Use ausearch --input-logs
CI systems don't necessary attach stdin to terminal and this option make
`ausearch` to use audit logs as input for searching.
2022-11-24 11:30:48 +01:00
Milos Malik
162cc22a2e enable tests if their required packages are available
Some tests were ending prematurely because their required packages
were not available. Fortunately, more and more packages are available
in the EPEL repository now and the situation has changed.

Some tests require packages which are not available on any RHEL and
most likely will not be available there at all.
2022-11-23 10:53:11 +01:00
Milos Malik
d1caaec9e2 add a simplified version of rlSESatisfyRequires()
If the framework which runs the automated tests does not install
all required packages (listed in Makefile) before the tests are
started, then rlSESatisfyRequires() installs the required packages
during the run of the tests.
2022-11-22 14:14:16 +01:00
Milos Malik
b28143f1cc don't look for watch* permissions where they aren't defined
The watch* permissions are not defined by SELinux policy on RHEL-8.x.
2022-11-21 11:44:04 +01:00
Milos Malik
889bc16ec3 install required packages from EPEL repository
For successful run, some tests require certain EPEL packages to be
installed.
2022-11-10 15:20:13 +00:00
Petr Lautrbach
3727a6ade6 Adjust duration to 20m in linux-system-roles.selinux-tests
Fixes:
    Maximum test time '10m' exceeded.
    Adjust the test 'duration' attribute if necessary.
    https://tmt.readthedocs.io/en/stable/spec/tests.html#duration
2022-11-10 15:38:16 +01:00
Milos Malik
09f8be4247 test if stalld can read /sys/kernel/security/lockdown
Recent stalld testing identified the following error messages in the
systemd journal:

  stalld[...]: stalld: Permission denied

Deeper investigation revealed that SELinux prevents the stalld
processes from reading the /sys/kernel/security/lockdown file. The
TC reproduces the situation.

In order to avoid the error messages, I believe that SELinux policy
should allow the access. The TC looks for appropriate policy rules
and file context patterns.

The TC covers BZ#2140673.
2022-11-07 18:28:29 +01:00
Milos Malik
7773d77b0b fix the shell script name executed in the Makefile
Now the Makefile runs the test.sh file instead of the runtest.sh file.
2022-11-04 12:04:33 +01:00
Milos Malik
61ef9e6185 add the Tier test plans
Purpose of the Tier1 test plan is to gather all Tier1 tests in this
repository.

Purpose of the Tier2 test plan is to gather all Tier2 tests in this
repository.

Purpose of the Tier3 test plan is to gather all Tier3 tests in this
repository.
2022-11-02 08:10:34 +00:00
Amith Kumar
8f54ba515e harden tools to block rogue python modules
Add test to policycoreutils/Regression suite which verifies bug 2128976
and ensures that irrelevant python scripts are not given precedence over
tools like semanage.

Signed-off-by: Amith Kumar <apeetham@redhat.com>
2022-11-01 18:39:40 +00:00
Milos Malik
289ec8d0b8 use a larger file for mkfs.xfs testing
The automated test used to work with 100MB files. Unfortunately,
the mkfs.xfs program started to complain recently:

  Filesystem must be larger than 300MB.

In order to use the automated test successfully in the future,
the allocated space was increased to 400MB.
2022-11-01 10:52:27 +01:00
Milos Malik
efc6c0b001 test if systemd can read symlinks under /var/lib/
The use of DynamicUser and StateDirectory features of systemd
in customer environments revealed that SELinux prevents the systemd
processes from reading the symbolic links under /var/lib directory.
The TC reproduces the situation.

Detailed information can be found at:
 * https://www.redhat.com/sysadmin/systemd-secure-services

In order to fully support the systemd secure services feature,
I believe that SELinux policy should allow this access. The TC
looks for appropriate policy rules and file context patterns.

The TC covers BZ#2118784.
2022-10-25 08:14:52 +00:00
Petr Lautrbach
31f776e00a Can libsepol handle users declared in modules?
https://bugzilla.redhat.com/show_bug.cgi?id=2136212
2022-10-21 15:33:30 +02:00
Milos Malik
7eff6e0a47 test if blueman-mechanism can read ~/.local/lib/python*/site-packages/
The use of blueman-mechanism service revealed that SELinux prevents
the blueman-mechanism process from reading the content of
/root/.local/lib/python3.10/site-packages/ directory. The TC reproduces
the situation.

Because the blueman-mechanism program is written in Python, it makes
sense to look for locally installed Python modules. In order to
support the basic Python principles, I believe that SELinux policy
should allow this access. The TC looks for appropriate policy rules
and file context patterns.

The TC covers BZ#2027044.
2022-09-23 12:38:51 +02:00
Milos Malik
8d27520fad add new automated test which covers the caddy service
This TC covers the caddy service and its basic scenario with
default configuration.

Purpose of this TC is to find any SELinux interferences with the
caddy service.

The TC covers BZ#1706651 and BZ#2122886.
2022-09-23 08:44:52 +02:00
Ondrej Mosnacek
269502e64d
kernel/labeling_before_...: use --regenerate-all also during cleanup
Otheriwse older kernel entries would still have our injected scripts in
the initramfs after test execution.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-09-15 15:20:55 +02:00
Ondrej Mosnacek
ef2646911d
Port kernel tests from downstream
Forward-port of downstream kernel tests that haven't been upstreamed
yet, manually converted to TMT.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-09-13 14:24:47 +02:00
Ondrej Mosnacek
25176f01ce
kernel/genfs_fallback: use vfat instead of ramfs
ramfs is now treated as an xattr-supporting filesystem and has the
fs_use_trans directive in the base policy. Thus switch to vfat, which is
still genfs.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-09-13 11:06:41 +02:00
Ondrej Mosnacek
03bf3a0e70
kernel/selinux-testsuite: fail hard when PR/patch application fails
Replace the current soft fallback to raw GIT_BRANCH when a required PR
or Patchwork patch fails to merge/apply with a hoard failure, similar to
what we do when cloning the repo fails.

The main motivation is to not have CKI treat this situation as a
failure, but it also a good practice to ensure we either run the
intended version of the test or no test at all.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-08-31 10:23:41 +02:00
Ondrej Mosnacek
21a2855558
kernel/selinux-testsuite: bump upstream commit to c592d7f
Effective changes:
* fix for https://gitlab.com/redhat/centos-stream/tests/kernel/kernel-tests/-/issues/1352
* major testsuite policy refactoring
* various minor fixes/tweaks

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-08-30 20:18:33 +02:00
Milos Malik
d86b1fb0ce test if stalld can get+set scheduling for all domains
TBA later

The TC covers BZ#2105038.
2022-08-25 15:18:26 +02:00
Milos Malik
75e8d39310 ensure that selinux-policy-{minimum,mls,targeted} are installed
For unknown reasons, selinux-policy-{minimum,mls,targeted} packages
are not installed or their available versions differ from each other.
Let's work around the issue.
2022-08-22 09:24:25 +00:00
Milos Malik
d121114f70 test if systemd-modules-load can work with /dev/kmsg and systemd-journal
Recent RDMA testing revealed that systemd-modules-load processes
cannot use openat syscall on /dev/kmsg and cannot use connect syscall
on /run/systemd/journal/socket because SELinux denies that. The
TC reproduces the situation when executed on a machine equipped
with RDMA (Infiniband) HW.

Because this scenario should work, I believe that SELinux policy
should allow above-mentioned actions. The TC looks for appropriate
policy rules and file context patterns.

The TC covers BZ#2088257 and BZ#2088258.
2022-08-15 16:48:26 +02:00
Ondrej Mosnacek
c3dd00f4bc
semodule-rebuild-if-modules-changed: test changing booleans
Extend the test to verify correct behavior when a boolean setting
override is injected. Also add auto-detection of the --refresh /
--rebuild-if-modules-changed command-line option support, which
indicates the expected level of functionality. (And we also need to
ensure that --refresh is used when supported because the other option
may be removed in the future.)

Additionally, we need to work around the fact that the exact binary
policy content can now be different depending on if the optimized code
path has been taken. Do this by toggling a boolean before introducing
injected customizations, thus obtaining the expected policy content for
the case after `semodule --refresh`.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-08-02 15:03:48 +02:00
Ondrej Mosnacek
a77df42754
semodule-rebuild-if-modules-changed: expand vars early
This will make the test output more explicit.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-08-02 15:03:48 +02:00
Milos Malik
98145eff71 add Makefile to enable runs via STI
Some CI frameworks still use STI which depends on existence of the
Makefile. In order to run this TC successfully in such frameworks,
the Makefile was added. Test description was also improved.
2022-08-02 10:00:37 +02:00
Milos Malik
09061d2739 test if semanage can import port definitions correctly
Recent testing revealed that `semanage import` cannot import
SELinux port definitions correctly if `port -D` is present
among them. The TC reproduces the situation.

The TC covers BZ#2063353 and BZ#2108174.
2022-07-27 10:12:11 +02:00
Ondrej Mosnacek
de353795c2
kernel/selinux-testsuite: use correct linker to build kernel modules
Start applying a testsite patch that fixes kernel module build for
kernels built with clang + with LTO enabled.

Fixes: https://gitlab.com/redhat/centos-stream/tests/kernel/kernel-tests/-/issues/1272
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-07-18 13:25:02 +02:00
Milos Malik
01e114b092 test how semanage handles spaces in fcontext patterns
The semanage tool refuses (for some time already) fcontext patterns
which contain spaces. The TC checks if other whitespace characters
are treated the same way.

The TC covers BZ#1893545.
2022-07-15 13:27:05 +00:00
Milos Malik
7f95c9d3a2 add new test which covers the bgpd service
SELinux policy confines the bgpd program (the bgpd service as well).
This TC covers basic scenarios of running the service in default
configuration. The TC also looks for appropriate policy rules and
file context patterns.

The TC covers BZ#2055578.
2022-07-15 07:47:41 +00:00
Milos Malik
606eccfd75 test if stalld can use sched_setattr on kernel
Recent stalld testing revealed that SELinux prevents the stalld
processes from using the sched_setattr syscall on the running
kernel threads. The TC does not reproduce the situation.

In order to avoid the SELinux denials and support all functions
of the stalld service, SELinux policy should allow the use of
sched_setattr syscall. The TC looks for appropriate policy rules.

The TC covers BZ#2102224.
2022-06-30 09:51:02 +02:00
Milos Malik
7710067379 test if dhclient-script can access /run/chrony-dhcp/ and its content
Frequent use of the dhclient program in various environments revealed
that SELinux prevents the /etc/dhcp/dhclient.d/chrony.sh script from
appending to files stored in the /run/chrony-dhcp/ directory. The TC
reproduces the situation.

Because the /etc/dhcp/dhclient.d/chrony.sh script is brought by the
chrony package and the scripts in the /etc/dhcp/dhclient.d/ directory
are by default executed by the dhclient-script program, I believe that
SELinux policy should allow the access. The TC looks for appropriate
policy rules and file context patterns.

The TC covers BZ#2035117, BZ#2093709 and BZ#2094155.
2022-06-28 08:47:39 +00:00
Milos Malik
9c17ff1ea7 add new systemd-creds test
One of the new systemd features allows passing secret credentials
to various services, but SELinux prevents all sd-mkdcreds processes
running as init_t from accessing all /dev/shm/.#cred* files. The
TC reproduces the situation.

In order to support this systemd feature, SELinux policy should allow
these actions. The TC looks for appropriate policy rules and file
context patterns.

The TC covers BZ#2096857 and BZ#2097681.
2022-06-27 13:36:09 +00:00
Milos Malik
9cb79c94c6 test if setfiles works correctly in chroot-ed environment
Recent use of the setfiles program in chroot-ed environment revealed
the following error messages:

  /usr/sbin/setfiles: Could not set context for /usr/include:  No such file or directory

The problem was identified and fixed in the libselinux code. Purpose
of this TC is to test whether the fixfiles behaves correctly in such
environments.

The TC covers BZ#2094683.
2022-06-27 12:17:09 +00:00
Milos Malik
0566a3c889 test if fedora-third-party process can read /etc/passwd file
Recent manual testing of the fedora-third-party-refresh service
revealed that SELinux prevents the fedora-third-party process from
reading the /etc/passwd file. The TC reproduces the situation.

Interestingly, the fedora-third-party-refresh service starts and
succeeds even if the access is denied, which means that SELinux
policy can either allow or dontaudit the access. The TC looks for
appropriate policy rules and file context patterns.

The TC covers BZ#2093453.
2022-06-23 16:11:28 +00:00
Milos Malik
341a2e48ca test if stalld can use sched_getattr on kernel
Recent stalld testing revealed that SELinux prevents the stalld processes
from using the sched_getattr syscall on the running kernel. The TC
does not reproduce the situation.

In order to fix the SELinux denials, SELinux policy should either
allow or dontaudit the use of sched_getattr syscall. The TC looks
for appropriate policy rules.

The TC covers BZ#2096776.
2022-06-14 16:36:47 +02:00
Milos Malik
b322ded769 test if ksmctl process can create /sys/kernel/mm/ksm/run file
Recent use of the ksm service revealed that SELinux prevents the
ksmctl process from creating the run file in the /sys/kernel/mm/ksm/
directory. The TC reproduces the situation.

The ksmctl binary contains the following locations (the strings command
found them):
 * /sys/kernel/mm/ksm/run
 * /sys/kernel/mm/ksm/max_kernel_pages

In order to make the ksm service fully functional, I believe that
SELinux policy should allow the create access to these files. The
TC looks for appropriate policy rules and file context patterns.

The TC covers BZ#2091416, BZ#2091417 and BZ#2091418.
2022-06-09 15:32:49 +00:00
Ondrej Mosnacek
66bf874bec kernel/selinux-testsuite: bump upstream commit
The only effective difference is that the broken SCTP ASCONF tests will
now be skipped, see:
3e93ece73d

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-06-08 09:27:31 +00:00
Zdenek Pytela
12dd91c7d4 avoid testing empty CIL modules
SELinux user-space version 3.3 and higher does not support loading
of empty CIL modules. If such version is installed, one of the test
phases will be skipped. This commit changes existing code to using
rlTestVersion.
2022-06-07 15:43:51 +00:00
Milos Malik
b0e50d2418 test if stalld process can use sched_setattr syscall
The following messages found in the systemd journal revealed that
the stalld service cannot perform all operations it wants:

stalld[...]: boost_with_deadline failed to boost pid 0: Operation not permitted
stalld[...]: boost_with_fifo failed to boost pid 0: Operation not permitted
stalld[...]: boost_with_deadline failed to boost pid 0: Permission denied
stalld[...]: boost_with_fifo failed to boost pid 0: Permission denied

Unfortunately, SELinux policy contains a dontaudit rule which hides
SELinux denials triggered by the stalld service in this situation.

In order to fix the issue, SELinux policy should allow the sys_nice
capability and the setsched permission to the stalld_t labeled processes.
The TC runs the stalld service and looks for such rules.

The TC covers BZ#2092864.
2022-06-06 13:34:21 +00:00
Ondrej Mosnacek
f24d1087c7 Add a test for self keyword support in type rules
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-06-03 14:44:51 +00:00
Milos Malik
db10d20932 add new test which covers the ksm service
The ksm service will be sooner of later confined by SELinux.
Purpose of this automated test is to find out whether the SELinux
policy does not prevent the ksm service from doing what is
expected.

The TC covers BZ#2021131.
2022-05-25 20:43:24 +02:00
Milos Malik
9ff6e590c0 test if systemd-run can run interactive shell
New automated test which covers basic functions of the systemd-run program.
Based on bugs filed in the past, SELinux interferes with systemd-run
often, which indicates that such an automated test is definitely needed.

The TC covers BZ#1647162 and BZ#1980241.
2022-05-17 09:11:33 +02:00
Amith Kumar
81bb79481d policycoreutils: fix main.fmf file
Automated tests executed via TMT/FMF are failing due to absence of relevant packages.
Fix the main.fmf file to match the list of required packages/programs in `Makefile`.

Signed-off-by: Amith Kumar <apeetham@redhat.com>
2022-05-11 04:56:25 +05:30
Ondrej Mosnacek
fd520ce6f3
Add a test for bogus warning in selinux_ima_measure_state()
Verifies:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ce2fc710c9d2b25afc710f49bb2065b4439a62bc

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-05-10 15:31:19 +02:00
Milos Malik
00be497d47 add a new test which covers systemd-notify
The systemd-notify program is confined by SELinux, but there was no
SELinux related test coverage sofar. This automated TC will contain
some basic scenarios and should improve this situation.

As described in BZ#1903106, current SELinux policy is one of the
factors which prevent systemd from proper notify handling. Missing
rules in SELinux policy lead to the following error message:

  Failed to invoke barrier: Connection timed out

The TC covers BZ#1903305, looks for appropriate SELinux policy rules
and it also reproduces the scenario.

What if an unconfined service tries to use the systemd-notify?
Will it work successfully without SELinux denials?
2022-05-09 07:58:50 +00:00
Milos Malik
dbc896ebd6 test if policy rebuild affects layered containers
Following error messages appeared when 2 containers (one derived
the other) both manipulate the SELinux policy store:

  libsemanage.semanage_commit_sandbox: Error while renaming
  /var/lib/selinux/targeted/active to /var/lib/selinux/targeted/previous.
  (Invalid cross-device link).
  semodule:  Failed!
  Error: error building at STEP "RUN semodule -B": error while running
  runtime: exit status 1

Purpose of this automated test is to find out if this situation still
happens or not.

The TC covers BZ#2068085.
2022-05-04 13:17:48 +00:00
Milos Malik
be596e9ba1 adapt to different validatetrans behavior
Error messages produced by the validatetrans tool have changed.
The TC needs to adapt.
2022-05-03 12:44:51 +02:00
Milos Malik
a575a54b9a update the rngd test to the latest version
TBA
2022-04-28 15:07:07 +02:00
Ondrej Mosnacek
c1d19b8516
kernel/selinux-testsuite: disable Beaker AVC check
Add AVC_ERROR=+no_avc_check into test environment to disable Beaker's
AVC check, as this test produces s lot of expected AVC denials.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-04-27 15:38:12 +02:00
Ondrej Mosnacek
46081dbdf1
kernel/synflood: disable the test due to being unreliable
The test doesn't detect the presence of the performance issue reliably
across machines and architectures, so disable it for now.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-04-27 14:42:52 +02:00
Milos Malik
2d47988950 add the ModemManager test to upstream repo
The ModemManager component is frequently used by various users on
Fedora and RHEL, so it makes sense to run this TC in upstream testing
too.
There are no changes in the TC functionality.
Moving the downstream TC to upstream repo.
2022-04-26 13:31:40 +00:00
Milos Malik
58ae65cd1e unset the default context for /var/ARTIFACTS
Many automated tests run the "restorecon -Rv /run /var" command
to ensure that file-system objects stored in these locations are
labeled correctly. Unfortunately, the command affects SELinux
contexts of files/directories stored under /var/ARTIFACTS/. For
example: the rlFileBackup function uses this location as well.
To avoid such unpleasant effects, the default SELinux context for
/var/ARTIFACTS directory is now set to /proc equivalent (meaning:
no default context).
2022-04-26 13:18:49 +00:00
Milos Malik
f1ffb0bbe5 remove all rhts-environment.sh includes
The rhts-environment.sh files are not needed anymore.
The include of beakerlib.sh is sufficient.
2022-04-26 13:18:49 +00:00
Milos Malik
1ddf81f5f1 make the expect scripts executable
Many automated tests use various expect scripts. Some of these scripts
were not executable, which means that they did not work successfully.
Now, all expect scripts have the UNIX permissions set to be executable.
2022-04-26 13:18:49 +00:00
Milos Malik
7c76f01ca2 convert metadata of other tests to TMT/FMF 2022-04-26 13:18:49 +00:00
Milos Malik
814a670ca5 convert metadata of all libselinux tests to TMT/FMF 2022-04-26 13:18:49 +00:00
Milos Malik
c6b49a41ef convert metadata of all libsemanage tests to TMT/FMF 2022-04-26 13:18:49 +00:00
Milos Malik
9d5fef0179 convert metadata of all libsepol tests to TMT/FMF 2022-04-26 13:18:49 +00:00
Milos Malik
1bf77a6669 convert metadata of all selinux-policy tests to TMT/FMF 2022-04-26 13:18:49 +00:00
Milos Malik
1bf11b6606 convert metadata of all policycoreutils tests to TMT/FMF 2022-04-26 13:18:49 +00:00
Milos Malik
61078d379a convert metadata of all checkpolicy tests to TMT/FMF 2022-04-26 13:18:49 +00:00
Milos Malik
521001ac7a add the dhcpcd test to upstream repo
The dhcpcd component is frequently used by various users on Fedora
and RHEL, so it makes sense to run this TC in upstream testing too.
There are no changes in the TC functionality.
Moving the downstream TC to upstream repo.
2022-04-26 09:11:31 +00:00
Milos Malik
8dfebbced5 add the blueman test to upstream repo
The blueman component is used by various users on Fedora, so it
makes sense to run this TC in upstream testing too.
There are no changes in the TC functionality.
Moving the downstream TC to upstream repo.
2022-04-26 07:58:32 +00:00
Milos Malik
7a1caf666f add a CI-for-tests plan
This plan should run only tests that have been modified in the given
pull request.
2022-04-25 06:09:41 +00:00
Milos Malik
86053995e5 add new test which covers the stalld service
SELinux policy now contains a new policy module which confines the
stalld service. This TC covers basic scenarios of running the service
in default configuration. The TC also looks for appropriate policy
rules and file context patterns.

The TC covers BZ#2042614.
2022-04-22 12:14:05 +02:00
Ondrej Mosnacek
94b4e53487
kernel/selinux-testsuite: apply an urgent fix to the ioctl test
The ioctl number is not consistent across arches. The fix adds the
numbers for other arches to make the test work on all arches again.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-04-21 11:21:10 +02:00
Milos Malik
6cde87c598 end tests quickly if required packages are not installed
If required packages are not installed at the beginning of the
automated test, it makes no sense to run the test, because it would
fail anyway.
2022-04-21 09:52:36 +02:00
Ondrej Mosnacek
120532d05e
kernel/selinux-testsuite: always run in /root
Running in paths containing ':' or in /tmp doesn't work, so make sure
that the testsuite is run in /root.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-04-20 17:07:44 +02:00
Ondrej Mosnacek
fff6691dcd
kernel/selinux-testsuite: bump upstream commit
...and remove some workarounds that are no longer needed. Also add code
to enable/disable SCTP client peeloff tests based on where SCTP client
peeloff is currently fixed in RHEL.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-04-20 17:07:44 +02:00
Milos Malik
5914ae131f do not run the nasd test on RHEL
The nas package is available for various versions of Fedora, but it's
not available for any RHEL. The automated test will exit immediately
if executed on RHEL.
2022-03-25 13:51:41 +01:00
Milos Malik
1270f13156 add the firewalld test to upstream repo
The firewalld component is frequently used by various users on Fedora
and RHEL, so it makes sense to run this TC in upstream testing too.
There are no changes in the TC functionality.
Moving the downstream TC to upstream repo.
2022-03-23 19:18:28 +00:00
Milos Malik
6b44611dd2 add the hostapd test to upstream repo
The hostapd component is frequently used by various users on Fedora
and RHEL, so it makes sense to run this TC in upstream testing too.
There are no changes in the TC functionality.
Moving the downstream TC to upstream repo.
2022-03-23 19:05:41 +00:00
Milos Malik
538b465413 add new nasd test
Introducing a basic automated test which covers the nasd service.
2022-03-22 11:55:45 +01:00
Milos Malik
66fc71a9d1 skip irrelevant test phases
Test phase devoted to BZ#2056207 and BZ#2056999 should not be executed
on RHEL-8.x, because the SELinux denials do not appear there.
2022-03-18 20:33:56 +01:00
Milos Malik
a8158ee0bf remove users forcefully
Sometimes the userdel commands end up with the following error:

  userdel: user <username> is currently used by process <PID>

which leads to a situation where the subsequent useradd commands
(which use the same username) also end up with an error:

  useradd: user <username> already exists

To avoid such errors, the '-f' option was added to all userdel
commands.
2022-03-14 08:39:51 +01:00
Ondrej Mosnacek
8b7e684a0d Add a test for semodule --rebuild-if-modules-changed
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-03-01 12:58:06 +01:00
Milos Malik
7a766b5ecd install the required packages
For unknown reason, the selinux-policy-mls package is not installed
before execution of the TC, even though it it a required package.
From now on, the TC will install the package explicitely.
2022-02-24 13:17:44 +00:00
Milos Malik
aa575878d4 test if systemd-sysctl can read files under /proc/sys/ directory
Recent systemd-sysctl testing revealed that the systemd-sysctl process
wants to read certain files located under /proc/sys/ directory, but
SELinux denies that access. The TC reproduces the situation.

Because the systemd-sysctl service is executed by default during each
reboot, I believe that SELinux policy should allow the service to
work successfully. The TC looks for appropriate policy rules and file
context patterns.

The TC covers BZ#2056207 and BZ#2056999.
2022-02-23 10:31:50 +01:00
Petr Lautrbach
c6c5a1fbe6 semodule-l-checksum: checksum format changed
In the latest update, the checksum format in `semodule -l --checksum`
changed from "$SHA256" to "sha256:$SHA256"
2022-02-19 11:26:57 +01:00
Ondrej Mosnacek
003e7202d6 kernel/sctp_peer_label_bug: sleep before open_assoc
It seems none of the attempts to synchronize before connecting are good
enough - add some extra sleep time to the beginning of open_assoc().

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-02-14 23:41:18 +01:00
Ondrej Mosnacek
fab242726e kernel/sctp_peer_label_bug: timeout the server
In case of a bug/error, the server may end up hanging, so make sure it
terminates in some reasonable time.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-02-14 23:39:54 +01:00
Ondrej Mosnacek
c776c35f82 kernel/sctp_peer_label_bug: subscribe to events early (server)
This is needed to avoid a race condition.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-02-14 23:39:52 +01:00
Ondrej Mosnacek
7b6ee73ecb Add a test for two-way SCTP association setup
This test reproduces a bug that may cause an AVC with sctp_socket,
association, unlabeled_t, unlabeled_t (and also another bug related to
SCTP peeloff on the client side).

SCTP code taken and modified from selinux-testsuite's sctp subtest.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-02-13 21:14:49 +01:00
Ondrej Mosnacek
06baee37d5 Revert "Add preliminary SCTP client-side peeloff coverage"
This reverts commit 8b59d115d3.

Never mind, I realized this is not actually needed...

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-02-13 16:04:21 +01:00
Ondrej Mosnacek
8b59d115d3 Add preliminary SCTP client-side peeloff coverage
Add a variant of the selinux-testsuite test that adds a patch adding
coverage for SCTP client peeloff so that we can conveniently verify
related bugs until the fix and testsuite coverage are merged upstream.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-02-13 14:48:46 +01:00
Milos Malik
7323ae1899 test the lockdown class only if it defined
The lockdown class was removed from SELinux policy in BZ#2017848.
There are test phases in various automated tests which look for
policy rules related to the lockdown class. These tests were failing.
From now on, they should not fail because the problematic test phases
are skipped.
2022-02-03 14:35:12 +01:00
Zdenek Pytela
bb05179a30 Change default context for timesync runtime files
With the fix for bz#1822131, the default file context for
/run/systemd/timesync and /run/systemd/timesync/synchronized
changed to systemd_timedated_var_run_t, so the test requires
to be updated, too.
Additionally, rules for checking access to the directory and file
for systemd-timesyncd need to be updated.
2022-02-01 20:38:06 +00:00
Milos Malik
45e145b4e1 add the amanda test to upstream repo
The amanda component is frequently used by various users on Fedora
and RHEL, so it makes sense to run this TC in upstream testing too.
There are no changes in the TC functionality.
Moving the downstream TC to upstream repo.
2022-02-01 20:06:23 +00:00
Milos Malik
c0794774fb quit immediately if the anon_inode class is not defined in policy
It makes no sense to run the test in environments where the anon_inode
class is not defined.
2022-01-27 17:27:40 +01:00
Milos Malik
6f3d0475b2 delete all users at the end
When the first user is deleted before the second user is created,
they will have the same UID and the systemd processes will be
confused. The confusion leads to incorrect SELinux labels on
subdirectories of /run/user/<UID>/.

By deleting all users at the end, we ensure that each of
them will have a different UID and their directories will be
labeled correctly.
2022-01-26 20:09:36 +01:00
Ondrej Mosnacek
ee424688c6 kernel/ocontext-race: disable the test on s390x
Only at most 2-CPU s390x machines are available in Beaker and the bug is
not reproducible on them, so just disable the test on s390x.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-01-24 10:22:03 +01:00
Milos Malik
14a6d433c1 add the cockpit test to upstream repo
The cockpit* services are frequently used by various users on Fedora
and RHEL, so it makes sense to run this TC in upstream testing too.
There are no changes in the TC functionality.
Moving the downstream TC to upstream repo.
2022-01-19 17:46:00 +01:00
Zdenek Pytela
64bda4528c Fix a typo in the "/sys/firmware/efi/efivars" path
While the filesystem name for efi variables is efivarfs and the relevant
type efivarfs_t, the path for the variables list reads just efivars, so
rlSEMatchPathCon needs to be used with the correct path.
2022-01-18 10:57:42 +01:00
Ondrej Mosnacek
5672c531ab Add test for ocontext race condition in the kernel
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-01-14 15:20:04 +01:00
Zdenek Pytela
41dfc8126e Update efivars path in selinux-policy/systemd-modules-load-and-similar
With the selinux-policy fix for bz#1972372 in RHEL 9, the efivarfs_t
type is assigned to /sys/firmware/efi/efivars instead of
/sys/firmware/efi as such label should presumably be only on the
efivarfs filesystem, not the entire /sys/firmware/efi.
2022-01-12 12:06:21 +00:00
Milos Malik
edffc3122c test if the checksum option is mentioned in help/manpages
The test phase checks if the newly added checksum option is listed
in the help message and in the semodule man page.
2022-01-12 12:01:43 +00:00
Milos Malik
df22c3b60b exit the tests if their required services are missing
Services like systemd-homed and systemd-userdbd are available on Fedora,
but they are not available on RHEL. It makes no sense to run their tests
in environments, where the services are not available. Without these
services being present the tests would fail.
2022-01-12 11:43:03 +01:00
Ondrej Mosnacek
dca9d3c17e kernel/selinux-testsuite: use HTTPS git URL
Recently GitHub has deprecated the git:// protocol and cloning now fails
with this message:
```
fatal: remote error:
  The unauthenticated git protocol on port 9418 is no longer supported.
Please see https://github.blog/2021-09-01-improving-git-protocol-security-github/ for more information.
```

The only reason that git:// was being used instead of https:// was
allowing the test to run on RHEL-5, which has problems with accessing
GitHub via HTTPS due to protocol disparity. By now it should be okay to
throw RHEL-5 under the bus and use the https:// URL.

Since we are definitely making this test unable to run on RHEL-5, also
remove all RHEL-5-specific hacks from the code.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-01-11 11:37:54 +01:00
Milos Malik
e12be9d139 fix the /proc/net/unix SELinux context check
The test phase failed because the following command returned <<none>>:

  matchpathcon /proc/net/unix

SELinux policy does not define a default label for the /proc/net/unix
file. The file inherits its SELinux context from the /proc filesystem.
As a fix, a simple 'ls -Z' command is used to check the SELinux context.

The test phase also covers BZ#2038963 and BZ#2038157, because the same
issue appears on RHEL-8 and Fedora 35.
2022-01-11 09:06:39 +01:00
Milos Malik
9329983a57 test if smbcontrol can read the /proc/net/unix file
Recent smbcontrol testing in certain environments revealed that
the smbcontrol process wants to read the /proc/net/unix file, but
SELinux denies that access. The TC reproduces the situation.

Not sure why the smbcontrol process wants to access the /proc/net/unix
file, but current SELinux policy allows a lot of SELinux domains to
read that file, which means that the behavior is pretty common.
The TC looks for appropriate allow rule.

The TC covers BZ#2033873.
2022-01-06 10:51:50 +01:00
Milos Malik
9cc7eb5ca3 test if user can check status of its user manager
Recent confined users testing revealed that SELinux prevents the
user_u user from checking the status of its user@<UID> service.
The TC reproduces the scenario.

The TC checks the related file context patterns and looks for
appropriate policy rules which make this scenario working again.

The TC covers BZ#2017838.
2021-12-10 14:07:28 +01:00
Milos Malik
0dab3f0467 update the cups-lpd test to the latest version
The downstream version of the automated test covers more bugs than
the upstream version. Before the downstream test can be replaced by
a wrapper that calls the upstream one, both versions should be in
sync.
2021-12-07 19:55:26 +00:00
Milos Malik
32c565fc64 test if smbcontrol can work with netlink_route_socket + udp_socket
Recent smbcontrol testing revealed that SELinux prevents the program
from creating and using netlink_route sockets and UDP sockets. The TC
reproduces the situation.

Even though the smbcontrol program did not require such permissions
in previous versions, I believe that SELinux policy should allow the
program to do these actions. Otherwise, the following error messages
will keep on appearing:

  ERROR: Could not determine network interfaces, you must use a interfaces config line

The TC covers BZ#2025931, BZ#2027740, BZ#2027751.
2021-12-07 19:07:37 +00:00
Milos Malik
2efd81d899 add the smbcontrol test to upstream repo
The smbcontrol program is frequently used by various users on Fedora
and RHEL, so it makes sense to run this TC in upstream testing too.
There are no changes in the TC functionality.
Moving the downstream TC to upstream repo.
2021-12-07 19:07:37 +00:00
Petr Lautrbach
4e4c91dbc4 Test semodule -l --checksum 2021-12-02 14:54:52 +01:00
Milos Malik
282a711d46 test if the nfsdcld service is confined on RHEL-8
The same issue as described in BZ#1834234 is reproducible on RHEL-8.
It will be tested the same way.

The TC covers BZ#2026588.
2021-11-25 10:31:26 +01:00
Milos Malik
bf766edd95 fix 2 failing test phases
Test phase devoted to BZ#1614236 looked for getattr and open permissions,
but they are not listed in the bug report. The only permission mentioned
in the bug report is read and that will be tested from now on.

Because BZ#1878094 is not yet fixed, the cleanup phase finds certain
SELinux denials that appeared during the run of the automated test.
These SELinux denials are related to the way systemd and SELinux policy
handle the creation of objects under /run/user/<UID>/ directory.
Because they are not related to D-bus services, they will be ignored
from now on.
2021-11-01 07:26:25 +00:00
Ondrej Mosnacek
b0f7063a8d kernel/selinux-testsuite: bump upstream commit
Pull in a fix that allows the testsuite to succeed on kernels with
CONFIG_IP_TABLES=n (e.g. Fedora ELN kernels; future RHEL 10+ kernels).

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-10-27 13:52:48 +02:00
Milos Malik
735763c486 require the service command instead of its package
Recently, the service command was moved from the initscripts package
to the initscripts-service package. The service command is necessary
for operations with audit daemon, because it's not possible to
restart the audit daemon using the systemctl command.

Now, the SELinux beaker library requires the /usr/sbin/service command
instead of a package name.
2021-10-13 20:35:51 +02:00
Ondrej Mosnacek
c1eb053801 kernel/selinux-testsuite: bump upstream ref
This pulls in the lockdown test removal, which will be needed for
successful testing of new kernels.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-10-13 11:02:27 +02:00
Milos Malik
37adc8484f avoid testing empty CIL modules
SELinux user-space of version 3.3 and higher does not support loading
of empty CIL modules. If such version is installed, one of the test
phases will be skipped.
2021-10-07 14:24:29 +02:00
Amith Kumar
d16f70fe3a sepolicy::anon_inode Add test for bz1974559
Add a new selinux-policy testsuite to address issues related to tclass
anon_inode and also verifies bug 1974559. In this case, selinux policy
denies write permissons to userfaultfd syscall.

Signed-off-by: Amith Kumar <apeetham@redhat.com>
2021-10-01 01:33:51 +05:30
Milos Malik
8b594e7b59 do not start the hybrid-sleep / hibernate services by default
Some machines do not survive the start of systemd-hybrid-sleep or
systemd-hibernate services, even though their configuration contains
PrivateDevices=yes. They simply do not wake up.
To avoid such problems, one of the test phases will not be executed
unless the environment variable REAL_SCENARIOS is set to true.
2021-09-30 11:39:04 +02:00
Ondrej Mosnacek
0f43ff1aad kernel/selinux-testsuite: bump upstream ref
This revision integrates two patch series and adds a fix for:
https://gitlab.com/cki-project/kernel-tests/-/issues/750

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-09-27 10:52:19 +02:00
Ondrej Mosnacek
153042bdad kernel/selinux-testsuite: guard against missing unconfined_service_t
RHEL-6 didn't have unconfined_service_t yet, so we must skip the fd::use
workaround there.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-09-24 12:02:53 +02:00
Ondrej Mosnacek
08dcaa3534 kernel/selinux-testsuite: patch the policy for restraint
When this test in run via restraint (e.g. on Beaker), it inherits some
file descriptors originating from it, labeled unconfined_service_t. This
leads to a huge amount of denials when test programs are exectuted.

To work around this, add a rule to the policy that allows the test
domains to inherit these descriptors from unconfined_service_t.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-09-22 22:41:55 +02:00
Ondrej Mosnacek
818ae3f6ba kernel/selinux-testsuite: exclude vsock_socket on RHEL kernels without required fix
Kernels before 4.18.0-314.el8 lack the bugfix that is required for this
test to pass, so exclude it on these kernels.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-09-08 16:22:27 +02:00
Ondrej Mosnacek
180ee684de kernel/selinux-testsuite: update vsock_socket build fix patch
On RHEL-7.2, also the vsock_socket class is missing from the policy -
update the patch to v2, which also checks for the presence of the class.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-09-08 13:56:22 +02:00
Ondrej Mosnacek
7a66f3c2ad kernel/selinux-testsuite: apply a patch to fix building on RHEL-7
I missed that the new vsock_socket subtest fails to build on RHEL-7.
Apply a patch that excludes it when the necessary header/definition is
not available.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-09-07 20:07:06 +02:00
Ondrej Mosnacek
87fa61ef9c kernel/selinux-testsuite: fix module_load test on clang-built kernels
CKI is running the testsuite also on clang-built kernels, which need the
modules to be built using clang, too. Apply pending patches from
upstream to make the testsuite work on these kernels.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-09-06 13:09:44 +02:00
Ondrej Mosnacek
25396ff474 kernel/selinux-testsuite: bump upstream commit
This adds a new VSOCK test and drops an already merged bugfix.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-09-06 13:06:46 +02:00
Milos Malik
c40e0ae160 skip not relevant test phases on RHEL-8
The automated tests also contain test phases which cover Fedora bugs.
These test phases should not be executed on RHEL-8, because they are
not relevant there.
2021-08-17 13:03:00 +02:00
Zdenek Pytela
134253d980 selinux-policy: do not test watch in systemd-timesyncd on RHEL < 9
The watch permissions are present only in RHEL 9 and Fedora,
so the subtests for watch should not be executed in the systemd-timesyncd
test on a system with RHEL up to version 8.
2021-08-12 10:54:30 +00:00
Ondrej Mosnacek
b96679e022 kernel/selinux-testsuite: apply patch to fix failure on BTRFS
The capable_sys test is failing on F35 without his patch, because BTRFS
doesn't support the FIBMAP ioctl.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-08-04 15:14:13 +02:00
Petr Lautrbach
a335bae5ea Install ansible-playbook using pip3
Sometimes ansible is not available as rpm in repositories, but it should
be possible to install ansible using pip3

Fixes:
    [   FAIL   ] :: Checking for the presence of ansible rpm
    [   FAIL   ] :: Command 'ansible-playbook -i localhost, -c local -v tests_all_purge.yml' (Expected 0, got 127)
2021-08-04 08:24:58 +02:00
Amith Kumar
c07abebad6 selinux-policy: Add test for bug1942267
Add an rdma test case to selinux-policy test suite which verifies
bug1942267. The fix checks for avc generated by rdma service.
2021-07-29 18:28:51 +00:00
Petr Lautrbach
5fe4b9e652 selinux_set_callback: fix SETENFORCE callback test
When enforcing is switched to permissive and back to enforcing before
the status is updated, the SETENFORCE callback is not called as the state is
same as before.

Also avc_init is deprecated:
    test_callback.c:62:5: warning: ‘avc_init’ is deprecated: Use avc_open and selinux_set_callback [-Wdeprecated-declarations]
2021-07-29 12:25:33 +02:00
Petr Lautrbach
f248ce123e python-bindings: Fixes for Fedora CI
- fixed indentation

- the test requires python3-pip
Fixes:
    Running 'PipVersion=$(pip3 show selinux | grep Version)'
    /usr/share/beakerlib/testing.sh: line 891: pip3: command not found

- import sys
Fixes:
    Running 'python3 -c 'import selinux; rc = selinux.is_selinux_enabled(); sys.exit(rc)''
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    NameError: name 'sys' is not defined
2021-07-29 11:25:51 +02:00
Patrik Koncity
b70174e2e9 Don't run lockdown-class test on RHEL-8.x
Don't run lockdown-clast test scenario on
RHEL's 8.x machines.
Add conditionals to fix that.
2021-07-21 14:55:08 +02:00
Vit Mojzis
d686d5b10c policycoreutils/setfiles_binary: fix yaml formatting
Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
2021-07-16 14:42:09 +02:00
Vit Mojzis
99db07804e policycoretuils: add new test for setfiles with binary policy
setfiles didn't allow using "-c" parameter (binary policy) when path was
specified. Verify that setfiles now gives the same results regardless of
weather binary policy was provided.

The TC covers BZ#1973754

Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
2021-07-09 17:17:41 +02:00
Milos Malik
44e725eeff correct policy rule checks related to /sys/power/state
One policy rule check related to BZ#1968610 was incorrect,
because it assumed that the /sys/power/state is a directory,
but it is a file.
Now, it is correct.
2021-07-01 11:08:57 +02:00
Milos Malik
72a7f9e565 test if systemd-sleep can create new file in /sys/power directory
Recent testing of the hybrid-sleep service on RHEL-8 revealed that
SELinux prevents the systemd-sleep process from creating the state
file in /sys/power/ directory.

I believe this action should be allowed, because the behavior is
expected, the scenario is supported and security is not violated.

Unfortunately, the TC cannot reproduce the scenario because it's
difficult to wake up the machine after invoking the hybrid-sleep
service.

The TC looks for appropriate policy rules and file context patterns.

The TC covers BZ#1968610.
2021-06-29 07:57:48 +00:00
Milos Malik
d33212fe88 skip the real scenario if the service is missing
The systemd-timesyncd service is present on both RHEL-8 and Fedora,
but may not be present on other RHELs, even though the policy which
confines the systemd-timesyncd program is present there.
If the systemd-timesyncd service is not present then the TC checks
policy definitions only (types, rules, file context patterns etc.)
If the systemd-timesyncd service is present then the TC will also
test basic actions of the service (start, restart, status etc.)
2021-06-24 13:36:18 +02:00
Milos Malik
9ecceccc71 add new test which uses pam_limits and nonewprivs
The pam_limits.so module can apply various limits on users, groups
and other domains. Purpose of this TC is to find out if these limits
do not interfere with current SELinux policy.

If nonewprivs limit is used on confined or unconfined users, SELinux
denials with { nnp_transition } appear when users log in. The TC
reproduces the situation.
I believe this operation should be allowed to make the security feature
work. The TC looks for appropriate SELinux policy rules.

The TC covers BZ#1958819.
2021-06-08 18:33:36 +00:00
Ondrej Mosnacek
9b9952f92c kernel/selinux-testsuite: update metadata to better match TCMS
...to allow switching the TCMS entry to refer directly here via a FMF
link. Note: I'm not adding the tags, as most of those is
RHEL/RH-specific and they can be maintained just in TCMS.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-05-27 19:03:38 +00:00
Milos Malik
0fdeb90e08 configure sshd to allow password auth for users
Several TCs rely on the fact that tested users can login via SSH
using a password, but this option is disabled by default. If the
TCs should succeed the option must be enabled at least temporarily,
which is done in this change.
2021-05-27 06:01:03 +00:00
Zdenek Pytela
eb78c1e3eb Remove all references to anon_inodefs_t
Since kernel commit 3836a03d978e ("anon_inodes: mark the anon inode
private") - i.e. for over 10 years ago (!) - anon_inodefs inodes are no
longer exposed to LSMs so all rules containing reference to the
anon_inodefs_t type were removed from selinux-policy.
2021-05-24 13:19:58 +00:00
Milos Malik
69871d74cc test if fapolicyd can watch* various mount points
Recent testing of fapolicyd with the latest SELinux policy, which
introduced various watch* permission, revealed that SELinux prevents
the fapolicyd from using fanotify_mark syscall on various mount
points like /dev/shm, /boot etc. The TC reproduces the situation
and it also looks for appropriate policy rules.

I believe these actions should be allowed, because they are expected
from the fapolicyd process.

The TC covers BZ#1932225.
2021-05-20 10:47:43 +00:00
Milos Malik
71a4371e20 add the accounts-daemon test to upstream repo
The accountsservice package is available in various versions of
RHEL and Fedora. The accounts-daemon service is also used in these
environments, so it makes sense to run this TC in upstream testing
too.
Moving the downstream TC to upstream repository.
There are only slight changes when comparing the upstream and
downstream version of this TC.
2021-05-20 10:25:08 +00:00
Milos Malik
2bb9a41b7e add the cups-lpd test to upstream repo
The cups-lpd package is available in various versions of RHEL
and Fedora. The cups-lpd service is also used in these
environments, so it makes sense to run this TC in upstream
testing too.
Moving the downstream TC to upstream repository.
There are only slight changes when comparing the upstream and
downstream version of this TC.
2021-05-20 10:23:53 +00:00
Milos Malik
2f3961e36d add the acpid test to upstream repo
The acpid component is used in various versions of RHEL and Fedora,
so it makes sense to run this TC in upstream testing too.
Moving the downstream TC to upstream repository.
There are slight changes in the TC functionality when comparing
the downstream and the upstream version.
2021-05-20 10:22:38 +00:00
Milos Malik
fa8b441345 add the policykit test to upstream repo
The polkit component is used in various versions of RHEL and Fedora,
so it makes sense to run this TC in upstream testing too.
There are no changes in the TC functionality.
Moving the downstream TC to upstream repository.
2021-05-20 10:21:49 +00:00
Milos Malik
18f6387bc8 add the sslh test to upstream repo
The sslh package is available in various versions of Fedora,
so it makes sense to run this TC in upstream testing.
Moving the downstream TC to upstream repository.
There are only slight changes when comparing the upstream and
downstream version of this TC.
2021-05-20 10:20:56 +00:00
Milos Malik
122599c15a add the cups-browsed test to upstream repo
The cups-filters package is available in various versions of
RHEL and Fedora. The cups-browsed service is also used in these
environments, so it makes sense to run this TC in upstream testing
too.
Moving the downstream TC to upstream repository.
There are only slight changes when comparing the upstream and
downstream version of this TC.
2021-05-20 10:19:56 +00:00
Milos Malik
600c907d1e add the pcscd test to upstream repo
The pcsc-lite package is available in various versions of RHEL
and Fedora. The pcscd service is also used in these environments,
so it makes sense to run this TC in upstream testing too.
Moving the downstream TC to upstream repository.
There are only slight changes when comparing the upstream and
downstream version of this TC.
2021-05-20 10:19:12 +00:00
Milos Malik
bcdbcff58c test if usbmuxd can access /proc/1/environ file
Recent testing revealed that the usbmuxd service triggers SELinux
denials during its start. SELinux prevented the usbmuxd process
from accessing the /proc/1/environ file. The TC reproduces the
situation.

I believe this access should be dontaudited in SELinux policy,
because it is not necessary. The TC looks for appropriate policy
rules.

The TC covers BZ#1959747.
2021-05-20 10:01:59 +00:00
Milos Malik
f4761fdb7e test if usbmuxd can call statfs on /sys/fs/cgroup filesystem
Recent testing revealed that the usbmuxd service triggers SELinux
denials during its start, because SELinux prevents the usbmuxd
process from accessing the /sys/fs/cgroup filesystem. The TC is
able to reproduces the situation.

I believe this access should be allowed in SELinux policy. The TC
looks for appropriate policy rules.

The TC covers BZ#1936705.
2021-05-20 10:01:59 +00:00
Milos Malik
30ada8fa61 test if usbmuxd can call statfs on /sys filesystem
Recent testing revealed that the usbmuxd service triggers SELinux
denials during its start. SELinux prevented the usbmuxd process
from accessing the /sys filesystem. The TC reproduces the situation.

I believe this access should be allowed in SELinux policy. The TC
looks for appropriate policy rules.

The TC covers BZ#1930992.
2021-05-20 10:01:59 +00:00
Milos Malik
28aaa75dde skip the policy which is not installed
The TC expected that all SELinux policies are installed before the
TC is executed. If some of them is not installed, one of the test
phases failed.
Now, the test phase checks if particular policy is installed before
calling the D-bus interface on it.
2021-05-14 10:00:47 +02:00
Milos Malik
f422258a04 test if unconfined process can lockdown kernel for integrity purposes
SELinux policy recently introduced a new lockdown class which contains
2 permissions: integrity and confidentiality.
As you know, processes labeled as unconfined_t should be allowed to
use all permissions from all classes, because they are not confined.
Unfortunately, our internal testing revealed that processes running
as unconfined_t are not allowed to use integrity permission.

The TC does not reproduce the scenario, it only checks the existence
of appropriate allow rules.

The TC covers BZ#1929332 and BZ#1933134.
2021-05-13 13:00:14 +00:00
Milos Malik
c0798bf2bc add new test which covers the lockdown class
In comparison to kernel, which recognizes the lockdown class and its
permissions, SELinux policy does not recognize them yet. But that
situation should change soon.
Purpose of the TC is to find out if the same lockdown class and its
permissions recognized by kernel are also recognized by SELinux policy.

The TC covers BZ#1915184.
2021-05-13 13:00:14 +00:00
Milos Malik
e624bebd02 add the usbmuxd test to upstream repo
The usbmuxd component is used in various versions of RHEL and Fedora,
so it makes sense to run this TC in upstream testing too.
Moving the downstream TC to upstream repository.
There are only slight changes when comparing the upstream and
downstream version of this TC.
2021-05-12 08:18:09 +00:00
Ondrej Mosnacek
455409b672 kernel/selinux-testsuite: fix condition for skipping the keys subtest
It actually doesn't work (and doesn't get excluded automatically) on
RHEL-7 either, so change the condition to rhel < 9.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-05-06 11:17:00 +02:00
Ondrej Mosnacek
1a7541ad66 kernel/selinux-testsuite: update the XFS quota bug workaround
The bugfix has been backported in RHEL-8.4, so we can now replace this
with a kernel version check, increasing the coverage on RHEL-8.4 and
above.

Verified that the testsuite still passes on RHEL-8.3, 8.4, and RHEL-9.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-05-05 15:59:35 +02:00
Ondrej Mosnacek
3750c47bc8 kernel/selinux-testsuite: move keys test exclude under RHEL-8
The relevant config option is now enabled on RHEL-9, so we can skip it
on RHEL-8 only to get coverage on RHEL-9 and above.

Tested on latest RHEL-9 VM image.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-05-05 15:40:10 +02:00
Ondrej Mosnacek
f6ee2087e8 kernel/selinux-testsuite: Bump upstream commit
This pulls in two fixes for running on the latest v5.13 kernels.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-05-04 10:36:41 +02:00
Ondrej Mosnacek
118ffc5219 kernel/avc_tracepoint: disable restraint's AVC check
Set AVC_ERROR=+no_avc_check in environment to disable restraint's
built-in AVC check so that it doesn't interpret the (expected) AVCs as
failure.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-04-29 08:14:28 +02:00
Ondrej Mosnacek
d96170f110 kernel/selinux-testsuite: Bump upstream commit
This pulls in a fix to account for the following kernel commit:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v5.12&id=db2e718a47984b9d71ed890eb2ea36ecf150de18

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-04-28 16:36:06 +02:00
Ondrej Mosnacek
8ea2e4bd98 Add a basic test for SELinux AVC tracepoint
See the test description for more info.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-04-28 15:18:14 +02:00
Milos Malik
ca4b8c77c1 test if systemd-timesyncd can watch the / directory
Recent testing revealed, that systemd-timesyncd service wants to
use the inotify_add_watch syscall on the root directory during boot.
Unfortunately, SELinux policy denies that access.
I believe that the access is harmless and should be allowed.
The TC looks for appropriate policy rule.

The TC covers BZ#1949315.
2021-04-28 06:34:56 +00:00
Ondrej Mosnacek
6fc1caeb52 Add a minimal test for the recent setsebool kernel regression
It doesn't have a bugzilla, but better to have a regression test for it.
It's a very low-effort test, but still better than nothing :)

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-04-27 11:00:42 +02:00
Milos Malik
64ddb60efd exit from irrelevant tests quickly
Some tests are not relevant for certain versions of RHEL.
Their execution leads to failures there. After this change,
they will exit quickly and print a short message explaining why.
2021-04-23 19:21:34 +02:00
Amith Kumar
ff195852b2 libsepol-sanity: Add test for bug1838257
Add a sanity test suite which verifies but 1838257. The fix evaluates
the rpm scripts for components libsepol, libsemanage and libselinux.
It looks for obsolete commands like telinit.

Signed-off-by: Amith Kumar <apeetham@redhat.com>
2021-04-21 12:51:19 +00:00
Ondrej Mosnacek
e6f890f6ce kernel/netlabel_many_ifaces: fix relevancy for RHEL
The bug was only fixed in RHEL-8.4, so disable the tests on anything
older.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-04-16 20:51:37 +02:00
Milos Malik
caadab746c test if systemd-modules-load can read files under /sys/firmware/efi
According to several BZ reports, the systemd-modules-load program
wants to read /sys/firmware/efi/efivars/SecureBoot-* files.
Unfortunately, SELinux policy denies that access.
The TC reproduces the issue on machines where the EFI variable FS
is mounted (the /sys/firmware/efi/efivars/ directory exists).

I believe the access is needed for correct function of the
systemd-modules-load service. The TC looks for appropriate
policy rule.

The TC covers BZ#1819161 and its duplicates.
2021-04-16 09:23:56 +02:00
Ondrej Mosnacek
d85b0bfed9 kernel/selinux-testsuite: Bump upstream commit
...to pull in two fixes for the userfaultfd test so it builds
sucessfully on RHEL-7 and remove the associated workaround from the
wrapper.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-04-08 12:02:58 +02:00
Amith Kumar
9e8c0e2107 file-contexts: Add test for bug1822100
Add an semanage case to file-contexts test suite which verifies bug
1822100. The fix checks for the broken pipe error generated by the
'semanage fcontext -l | egrep ..' command.

Signed-off-by: Amith Kumar <apeetham@redhat.com>
2021-04-07 14:46:07 +00:00
Ondrej Mosnacek
9f4cbb46a4 Fix invalid FMF syntax
Fixes:
Invalid yaml syntax: Failed to parse '/home/omosnace/Dokumenty/Fedora/tests/selinux/kernel/genfs_fallback/main.fmf'.
Duplicate key 'adjust' detected.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-04-06 15:25:20 +02:00
Milos Malik
15cc76eaf9 update all rlSE* functions to the latest version
Many changes were done in downstream SELinux beakerlib library and
they were not propagated to upstream. Now, it's fixed.

The audit daemon is restarted everytime the SELinux beakerlib library
is loaded, which usually happens once at the beginning of each test.
This change is necessary because the audit daemon sometimes dies and
gathering of SELinux denials via ausearch relies on fact that audit
daemon is running and logging them. Without a running audit daemon
many tests can pass (false positive) because no SELinux denials were
found.
2021-03-31 07:00:36 +00:00
Ondrej Mosnacek
6548af6fcf Add test for genfscon fallback support
This feature is required for proper support of virtiofs with SELinux.
Add a trivial test that verifies that this feature works via a dummy
SELinux module and ramfs mount.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-03-26 14:30:48 +01:00
Milos Malik
6e4e2d367b disable fapolicyd test on Fedora
The fapolicyd test causes that dnf/yum hangs, which blocks the whole
gating process for 4 hours.
The test will be temporarily disabled so that new selinux-policy
builds could go through gating.
2021-03-19 15:52:24 +01:00
Milos Malik
c0c790f801 test if systemd-sleep can getattr() a partition
Hibernation which uses a swap partition instead of a swap file fails
because SELinux prevents systemd-sleep from getattr operation on the
swap partition. This is a common configuration, which means that
SELinux policy should allow it.

The TC does not reproduce the scenario, it only looks for appropriate
policy rules.

The TC covers BZ#1928539, BZ#1912385, BZ#1926536.
2021-03-11 10:54:30 +00:00
Ondrej Mosnacek
60c10ba7e1 kernel/selinux-testsuite: exclude userfaultfd on old kernels
On RHEL-7 (and other old kernels), __NR_userfaultfd may not be defined
on some arches, so add a kernel version check for now to exclude
userfaultfd test when it would be skipped anyway.

I'll fix this more nicely in upstream, this is just a temporary solution
until that gets merged.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-03-09 15:40:01 +01:00
Milos Malik
3ef78f9446 add the rngd test to upstream repo
The rng-tools component is used in various versions of RHEL and Fedora,
so it makes sense to run this TC in upstream testing too.
There are no changes in the TC functionality.
Moving the downstream TC to upstream repository.
2021-03-04 18:50:23 +00:00
Ondrej Mosnacek
3915ebfb3d kernel/selinux-testsuite: Bump upstream commit
Highlights:
- fixed lockdown and perf_event tests to work with latest Fedora policy
- userfaultfd test added
- removed dependency on `which`

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-03-04 12:39:46 +01:00
Milos Malik
3accb351d0 add the boltd test to upstream repo
The boltd service is available in various Fedoras and RHELs,
so it makes sense to run the TC in upstream testing too.
There are no changes in the TC functionality.
Moving the downstream TC to upstream repo.
2021-03-04 11:09:51 +00:00
Milos Malik
1cdc405991 add the journalctl test to upstream repo
The journalctl command is frequently used by various users on Fedora
and RHEL, so it makes sense to run this TC in upstream testing too.
There are no changes in the TC functionality.
Moving the downstream TC to upstream repo.
2021-03-04 11:08:52 +00:00
Milos Malik
0ff14c9820 add the fwupd test to upstream repo
The fwupd service is available in various Fedoras and RHELs,
so it makes sense to run the TC in upstream testing too.
There are no changes in the TC functionality.
Moving the downstream TC to upstream repo.
2021-03-04 11:07:53 +00:00
Milos Malik
d5312d22c0 add the colord test to upstream repo
The colord service is available in various Fedoras and RHELs,
so it makes sense to run the TC in upstream testing too.
There are no changes in the TC functionality.
Moving the downstream TC to upstream repo.
2021-03-04 10:05:35 +00:00
Milos Malik
9be7e22519 add the numad test to upstream repo
The numad component is used in various versions of RHEL and Fedora,
so it makes sense to run this TC in upstream testing too.
Moving the downstream TC to upstream repository.
There are some minor changes when comparing the upstream and downstream
versions of the TC.
2021-03-03 10:59:21 +01:00
Ondrej Mosnacek
fa3b0fe2ce kernel/synflood: disable on s390x
There are no s390x machines with enough cores to run this test in RH's
Beaker and likely won't be available in any CI system in the near
future. Thus, exclude the test from this arch so that testing doesn't
fail due to lack of matching hardware.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-02-24 16:39:59 +01:00
Milos Malik
a17c57ee31 add the dmidecode test to upstream repo
The dmidecode component is also used by various users on Fedora
and RHEL, so it makes sense to run this TC in upstream testing too.
There are no changes in the TC functionality.
Moving the downstream TC to upstream repository.
2021-02-19 08:18:17 +00:00
Amith Kumar
7b3df8350d pcp-daemons: Fix upstream failures
One of the testcase failed due to absence of chkconfig and initrc
related files. Make existing code compatible with higher versions of
Fedora and fix the failures.

Signed-off-by: Amith Kumar <apeetham@redhat.com>
2021-02-12 09:26:18 +01:00
Petr Lautrbach
f1d94dfd61 policycoreutils/setfiles: Add path to main.fmf 2021-02-05 15:43:57 +01:00
Petr Lautrbach
e48b62767b policycoreutils/setfiles: Make the relabel test robust
- use directory which is not usually mounted as tmpfs
- use own spec_file
- use -F option
- check context of all directories and files inside chroot
2021-02-05 15:28:21 +01:00
Petr Lautrbach
33abfe035c policycoreutils/setfiles: Basic sanity test for setfiles 2021-02-04 18:18:44 +01:00
Ondrej Mosnacek
a01344bd64 Add test for kernel deadlock via setsebool
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-02-03 18:31:03 +01:00
Ondrej Mosnacek
8c1edbd0e4 Make tests-pr.yml more "welcoming" 2021-02-03 18:31:03 +01:00
864 changed files with 40174 additions and 851 deletions

26
README.md Normal file
View file

@ -0,0 +1,26 @@
# SELinux tests
This repository contains set of test for SELinux kernel, userspace and policy.
Tests are written using [beakerlib](https://github.com/beakerlib/beakerlib) with [TMT Metadata Specification](https://tmt.readthedocs.io/en/latest/spec.html).
## Gating Guidelines
Test tiers define a test's priority for our **gating process**.
* **`tier: 1`**: Critical tests that must pass for any code merge.
* **`tier: 2`**: Important but non-critical tests.
* **`tier: 3`**: Non-critical tests.
All other tier metadata (e.g., `tag:Tier1`) is now deprecated.
## Plans
$ tmt plans
Found 5 plans: /plans/ci, /plans/reboot, /plans/tier1, /plans/tier2 and /plans/tier3.
## Usage
Run `tier1` on `localhost`:
# tmt run provision -h local prepare plans -n /plans/tier1 discover execute
# tmt run -l report -h display -v

View file

View file

@ -53,12 +53,17 @@ $(METADATA): Makefile
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 10m" >> $(METADATA)
@echo "RunFor: checkpolicy" >> $(METADATA)
@echo "Requires: checkpolicy man grep mktemp policycoreutils policycoreutils-devel" >> $(METADATA)
@echo "Requires: checkpolicy man grep policycoreutils policycoreutils-devel" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
@echo "Releases: -RHEL4" >> $(METADATA)
@echo "Bug: 533796" >> $(METADATA) # RHEL-5
@echo "Bug: 588294" >> $(METADATA) # RHEL-6
@echo "Bug: 1064603" >> $(METADATA) # RHEL-7
@echo "Bug: 1329217" >> $(METADATA) # RHEL-7
@echo "Bug: 1392394" >> $(METADATA) # RHEL-6
rhts-lint $(METADATA)

View file

@ -1 +1,37 @@
path: /checkpolicy/checkmodule
summary: runs checkmodule with various options to find out if it behaves correctly
description: |+
This TC runs checkmodule with various options to find out if it behaves correctly.
contact: Milos Malik <mmalik@redhat.com>
component:
- checkpolicy
test: ./runtest.sh
framework: beakerlib
recommend:
- checkpolicy
- man
- grep
- policycoreutils
- policycoreutils-devel
duration: 10m
enabled: true
tag:
- CI-Tier-1
- NoRHEL4
- f31friendly
- f32friendly
- targeted
tier: 1
link:
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=533796
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=588294
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=1064603
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=1329217
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=1392394
adjust+:
- enabled: false
when: distro == rhel-4
continue: false
extra-nitrate: TC#0062301
extra-summary: /CoreOS/checkpolicy/Sanity/checkmodule
extra-task: /CoreOS/checkpolicy/Sanity/checkmodule

35
checkpolicy/checkmodule/runtest.sh Normal file → Executable file
View file

@ -27,7 +27,6 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include rhts environment
. /usr/bin/rhts-environment.sh
. /usr/share/beakerlib/beakerlib.sh
PACKAGE="checkpolicy"
@ -41,7 +40,7 @@ rlJournalStart
rlRun "rpm -ql ${PACKAGE} | grep /usr/share/man/.*checkmodule"
rlPhaseEnd
rlPhaseStartTest
rlPhaseStartTest "bz#533796 + bz#588294"
rlRun "checkmodule >& ${TEST_FILE}" 1
rlAssertGrep "unable to open policy.conf" ${TEST_FILE}
rlRun "checkmodule -b >& ${TEST_FILE}" 1
@ -66,23 +65,27 @@ rlJournalStart
rlRun "checkmodule ${TEST_FILE}" 1
rlRun "checkmodule -b ${TEST_FILE}" 1
if rlIsRHEL 5 ; then
rlRun "man checkmodule | col -b | grep -- -d"
if [ -e "/usr/share/man/man8/checkmodule.8.gz" ]; then
rlRun "man checkmodule | col -b | grep -- -d"
fi
rlRun "checkmodule --help 2>&1 | grep -- -d"
fi
rlRun "man checkmodule | col -b | grep -- -h"
rlRun "man checkmodule | col -b | grep -- -U"
if [ -e "/usr/share/man/man8/checkmodule.8.gz" ]; then
rlRun "man checkmodule | col -b | grep -- -h"
rlRun "man checkmodule | col -b | grep -- -U"
fi
rlRun "checkmodule --help 2>&1 | grep -- -h"
rlRun "checkmodule --help 2>&1 | grep -- -U"
rlPhaseEnd
rlPhaseStartTest
rlPhaseStartTest "bz#1064603 + bz#1392394"
for POLICY_KIND in minimum mls targeted ; do
rlRun "checkmodule -M -m -b -o testmod.mod /etc/selinux/${POLICY_KIND}/policy/policy.* >& ${TEST_FILE}" 1
rlRun "grep -i \"checkmodule.*-b and -m are incompatible with each other\" ${TEST_FILE}"
done
rlPhaseEnd
rlPhaseStartTest
rlPhaseStartTest "bz#1329217"
INPUT_FILE="mypolicy.te"
OUTPUT_FILE="mypolicy.output"
rlRun "ls -l ${INPUT_FILE}"
@ -95,6 +98,24 @@ rlJournalStart
fi
rlPhaseEnd
if ! rlIsRHEL 5 6 ; then # semodule_unpackage is not available on RHEL-5 and RHEL-6
rlPhaseStartTest "handle unknown classes and perms"
rlRun "rm -f base.pp base.mod"
rlRun "semodule -E base"
rlRun "semodule_unpackage base.pp base.mod"
for ACTION in allow deny reject ; do
rlRun "checkmodule -b -o base.out -M -U ${ACTION} base.mod"
rlRun "echo -e 'u\nq\n' | sedismod base.out | grep -i \"${ACTION} unknown\""
done
rlRun "checkmodule -m -o mypolicy.out -M -U deny mypolicy.te"
rlRun "ls -l mypolicy.out"
for ACTION in allow reject ; do
rlRun "checkmodule -m -o mypolicy.out -M -U ${ACTION} mypolicy.te 2>&1 | grep -i 'only valid.*base module'"
done
rlRun "rm -f base.pp base.mod base.out mypolicy.out"
rlPhaseEnd
fi
rlPhaseStartCleanup
rlRun "rm -rf ${TEST_FILE} ${TEST_DIR} ${OUTPUT_FILE}"
rlPhaseEnd

View file

@ -1,6 +1,6 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/checkpolicy/Sanity/checkpolicy
# Makefile of /CoreOS/checkpolicy/Sanity/checkpolicy-docs
# Description: covers an issue where manpage included an unsupported option.
# Author: Milos Malik <mmalik@redhat.com>
#
@ -24,7 +24,7 @@
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/CoreOS/checkpolicy/Sanity/checkpolicy
export TEST=/CoreOS/checkpolicy/Sanity/checkpolicy-docs
export TESTVERSION=1.0
BUILT_FILES=

View file

@ -1,4 +1,4 @@
PURPOSE of /CoreOS/checkpolicy/Sanity/checkpolicy
PURPOSE of /CoreOS/checkpolicy/Sanity/checkpolicy-docs
Description: covers an issue where manpage included an unsupported option.

View file

@ -1 +1,37 @@
path: /checkpolicy/checkpolicy-docs
summary: covers an issue where manpage included an unsupported option.
description: |+
Description: covers an issue where manpage included an unsupported option.
Author: Milos Malik <mmalik@redhat.com>
contact: Milos Malik <mmalik@redhat.com>
component:
- setools
- checkpolicy
recommend:
- checkpolicy
duration: 1m
enabled: true
tag:
- CI-Tier-1
- NoRHEL4
- TIPpass_Security
- f31friendly
- f32friendly
- targeted
- NoRHIVOS
tier: 1
link:
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=1328966
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=1328979
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=739866
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=533790
adjust+:
- enabled: false
when: distro == rhel-4
continue: false
extra-nitrate: TC#00612804
extra-summary: /CoreOS/checkpolicy/Sanity/checkpolicy-docs
extra-task: /CoreOS/checkpolicy/Sanity/checkpolicy-docs
id: 8e06af12-0434-448a-aa85-9ed5c854daf9

1
checkpolicy/checkpolicy-docs/runtest.sh Normal file → Executable file
View file

@ -27,7 +27,6 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include rhts environment
. /usr/bin/rhts-environment.sh
. /usr/share/beakerlib/beakerlib.sh
PACKAGE="checkpolicy"

View file

@ -59,6 +59,10 @@ $(METADATA): Makefile
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
@echo "Releases: -RHEL4" >> $(METADATA)
@echo "Bug: 533790" >> $(METADATA) # RHEL-5
@echo "Bug: 739866" >> $(METADATA) # RHEL-6
@echo "Bug: 1328966" >> $(METADATA) # RHEL-7
@echo "Bug: 1328979" >> $(METADATA) # RHEL-7
rhts-lint $(METADATA)

View file

@ -4,4 +4,5 @@ Description: runs checkpolicy with various options to find out if it behaves cor
Author: Milos Malik <mmalik@redhat.com>
This test also covers bz#533790 ( https://bugzilla.redhat.com/show_bug.cgi?id=533790 ).

View file

@ -1,2 +1,41 @@
path: /checkpolicy/checkpolicy
summary: runs checkpolicy with various options to find out if it behaves correctly
description: |+
Description: runs checkpolicy with various options to find out if it behaves correctly
Author: Milos Malik <mmalik@redhat.com>
This test also covers bz#533790 ( https://bugzilla.redhat.com/show_bug.cgi?id=533790 ).
contact: Milos Malik <mmalik@redhat.com>
component:
- setools
- checkpolicy
test: ./runtest.sh
framework: beakerlib
recommend:
- checkpolicy
- setools-console
- selinux-policy-minimum
- selinux-policy-mls
- selinux-policy-targeted
duration: 10m
enabled: true
tag:
- CI-Tier-1
- NoRHEL4
- f31friendly
- f32friendly
- targeted
tier: 1
link:
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=533790
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=739866
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=1328966
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=1328979
adjust+:
- enabled: false
when: distro == rhel-4
continue: false
extra-nitrate: TC#0062302
extra-summary: /CoreOS/checkpolicy/Sanity/checkpolicy
extra-task: /CoreOS/checkpolicy/Sanity/checkpolicy

112
checkpolicy/checkpolicy/runtest.sh Normal file → Executable file
View file

@ -27,7 +27,6 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include rhts environment
. /usr/bin/rhts-environment.sh
. /usr/share/beakerlib/beakerlib.sh
PACKAGE="checkpolicy"
@ -35,9 +34,11 @@ PACKAGE="checkpolicy"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm ${PACKAGE}
rlAssertRpm selinux-policy-minimum
rlAssertRpm selinux-policy-mls
rlAssertRpm selinux-policy-targeted
if rlIsRHEL "<9" ; then
rlAssertRpm selinux-policy-minimum
fi
rlRun "rpm -qa | grep selinux-policy"
rlRun "rpm -qa | grep kernel"
rlRun "uname -a"
TEST_FILE=`mktemp`
TEST_DIR=`mktemp -d`
@ -52,7 +53,7 @@ rlJournalStart
if rlIsRHEL 5 6 ; then
VERSIONS=`seq ${MIN_VERSION} 1 ${MAX_VERSION}`
else
# some versions are skipped because seinfo segfaults when inspecting binary policies between v.20 and v.23"
# some versions are skipped because of BZ#1328979
VERSIONS=`seq ${MIN_VERSION} 1 ${MAX_VERSION} | grep -v -e 19 -e 20 -e 21 -e 22 -e 23`
fi
for CUR_VERSION in ${VERSIONS} ; do
@ -67,7 +68,7 @@ rlJournalStart
done
rlPhaseEnd
rlPhaseStartTest
rlPhaseStartTest "bz#533790"
rlRun "checkpolicy >& ${TEST_FILE}" 1
rlAssertGrep "unable to open policy.conf" ${TEST_FILE}
rlRun "checkpolicy -b >& ${TEST_FILE}" 1
@ -98,11 +99,13 @@ rlJournalStart
rlRun "checkpolicy -c 0 2>&1 | grep \"value 0 not in range\""
rlRun "checkpolicy -t 2>&1 | grep \"option requires an argument\""
rlRun "checkpolicy -t xyz 2>&1 | grep -i \"unknown target platform\""
rlRun "man checkpolicy | col -b | grep -- '-m]'" 1
if [ -e "/usr/share/man/man8/checkmodule.8.gz" ]; then
rlRun "man checkpolicy | col -b | grep -- '-m]'" 1
fi
rlRun "checkpolicy --help 2>&1 | grep -- '-m]'" 1
rlPhaseEnd
rlPhaseStartTest
rlPhaseStartTest "bz#739866"
if rlIsRHEL 5 6 ; then
ACTIVE_POLICY="/selinux/policy"
else
@ -110,8 +113,13 @@ rlJournalStart
fi
rlRun "echo -e 'q\n' | checkpolicy -Mdb ${ACTIVE_POLICY} | tee ${OUTPUT_FILE}"
rlRun "grep -qi -e error -e ebitmap -e 'not match' ${OUTPUT_FILE}" 1
for POLICY_TYPE in minimum mls targeted ; do
if [ ! -e /etc/selinux/${POLICY_TYPE}/policy/policy.* ] ; then
if rlIsRHEL "<9" ; then
LIST="minimum mls targeted"
else
LIST="mls targeted"
fi
for POLICY_TYPE in $LIST ; do
if ! stat /etc/selinux/${POLICY_TYPE}/policy/policy.* >& /dev/null ; then
continue
fi
rlRun "echo -e 'q\n' | checkpolicy -Mdb /etc/selinux/${POLICY_TYPE}/policy/policy.* | tee ${OUTPUT_FILE}"
@ -119,7 +127,7 @@ rlJournalStart
done
rlPhaseEnd
rlPhaseStartTest
rlPhaseStartTest "bz#1328966 + bz#1328979"
if rlIsRHEL 5 6 ; then
ACTIVE_POLICY_TREE="/selinux"
else # RHEL-7 and above
@ -127,11 +135,20 @@ rlJournalStart
fi
MIN_VERSION="15"
MAX_VERSION=`find /etc/selinux/ -name policy.?? | cut -d / -f 6 | cut -d . -f 2 | head -n 1`
for POLICY_TYPE in minimum mls targeted ; do
if rlIsRHEL "<9" ; then
LIST="minimum mls targeted"
else
LIST="mls targeted"
fi
for POLICY_TYPE in $LIST ; do
if ! stat /etc/selinux/${POLICY_TYPE}/policy/policy.* >& /dev/null ; then
rlLog "${POLICY_TYPE} policy file is not available, skipping"
continue
fi
if rlIsRHEL 5 6 ; then
VERSIONS=`seq ${MIN_VERSION} 1 ${MAX_VERSION}`
else
# some versions are skipped because seinfo segfaults when inspecting binary policies between v.20 and v.23"
# some versions are skipped because of BZ#1328979
VERSIONS=`seq ${MIN_VERSION} 1 ${MAX_VERSION} | grep -v -e 19 -e 20 -e 21 -e 22 -e 23`
fi
for CUR_VERSION in ${VERSIONS} ; do
@ -147,8 +164,75 @@ rlJournalStart
done
rlPhaseEnd
rlPhaseStartTest "handle unknown classes and perms"
for ACTION in allow deny reject ; do
rlRun "rm -f policy.out"
rlWatchdog "checkpolicy -M -U ${ACTION} -o policy.out policy.conf.from.secilc" 15
if [ -s policy.out ] ; then
rlRun "echo -e 'U\nq\n' | sedispol policy.out 2>&1 | tee ${OUTPUT_FILE}"
rlRun "grep -i \"${ACTION} unknown\" ${OUTPUT_FILE}"
else
rlFail "policy.out is empty or was not created"
fi
done
rlPhaseEnd
if ! rlIsRHEL '<=8.1'; then
rlPhaseStartTest "sorting ocontexts"
# check -S option in --help
rlRun "checkpolicy --help >$OUTPUT_FILE" 0,1
rlRun "cat $OUTPUT_FILE"
rlAssertGrep "\[-S\]" $OUTPUT_FILE
if [ -e "/usr/share/man/man8/checkmodule.8.gz" ];then
# check -S option in man page
rlRun "PAGER=cat man checkpolicy >$OUTPUT_FILE"
rlRun "cat $OUTPUT_FILE"
rlAssertGrep "\[-S\]" $OUTPUT_FILE
fi
# run checkpolicy with the -S option
rlWatchdog "checkpolicy -S -M -o policy.out policy.conf.from.secilc" 15
rlRun "seinfo policy.out"
rlPhaseEnd
fi
rlPhaseStartTest "Test checkpolicy cil option"
# check -C option without input file
rlRun "checkpolicy -C 2>&1 | grep \"unable to open policy.conf\""
# check -C option with policy.conf file
rlRun "checkpolicy -C -M -o policy.cil policy.conf.from.secilc"
rlAssertGrep "(allow [a-z]*_.* [a-z]*_.* ([a-z]* ([a-z]*)))" policy.cil
# check -C option with policy binary file
rlRun "checkpolicy -C -M -o policy.cil2 -b /sys/fs/selinux/policy"
rlAssertGrep "(allow [a-z]*_.* [a-z]*_.* ([a-z]* ([a-z]*)))" policy.cil2
rlPhaseEnd
if rlIsRHEL '>=9' ; then
rlPhaseStartTest "Test checkpolicy optimize option"
# check -O option without input file
rlRun "checkpolicy -O 2>&1 | grep \"unable to open policy.conf\""
# Create optimized -O binary with policy.conf file
rlRun "checkpolicy -O -M -o policy.opt policy.conf.from.secilc"
rlRun "seinfo policy.opt"
# Create regular binary with policy.conf file
rlRun "checkpolicy -M -o policy.reg policy.conf.from.secilc"
rlRun "seinfo policy.reg"
# Compare size of optimized and regular binary
OPT1=`stat -c %s policy.opt`
REG1=`stat -c %s policy.reg`
rlAssertGreater "Test if regular file size is higher than optimized file" $REG1 $OPT1
# Compare allow rule counts between optimized and regular binary
rlRun "seinfo policy.opt > /tmp/optfile"
OPT_CNT=`grep Allow: /tmp/optfile | tr -s ' ' | sed 's/^ //' | cut -d ' ' -f2`
rlRun "seinfo policy.reg > /tmp/regfile"
REG_CNT=`grep Allow: /tmp/regfile | tr -s ' ' | sed 's/^ //' | cut -d ' ' -f2`
rlAssertGreater "Regular file has higher allow rule than optimized file" $REG_CNT $OPT_CNT
rlPhaseEnd
fi
rlPhaseStartCleanup
rm -f ${OUTPUT_FILE} policy.out
rm -f ${OUTPUT_FILE} policy.out policy.cil policy.cil2 policy.opt policy.reg /tmp/optfile /tmp/regfile
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -0,0 +1,28 @@
summary: Run internal checkpolicy tests
contact: Milos Malik <mmalik@redhat.com>
component:
- checkpolicy
require:
- bison
- checkpolicy
- flex
- gcc
- libsepol-devel
- make
recommend:
- libsepol-static
duration: 5m
enabled: true
tag:
- NoRHEL4
- NoRHEL5
- NoRHEL6
- NoRHEL7
- targeted
- avoidImageMode
adjust+:
- enabled: false
when: distro == rhel-4, rhel-5, rhel-6, rhel-7
because: the test is not relevant there
extra-nitrate: TC#0620041
id: 3df4f40d-61a0-4267-b7db-6ff9f5254406

View file

@ -0,0 +1,58 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/checkpolicy/internal-tests
# Description: Run internal checkpolicy tests
# Author: Milos Malik <mmalik@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2026 Red Hat, Inc.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="checkpolicy"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm ${PACKAGE}
if ! rpm -q libsepol-static >& /dev/null ; then
rlRun "dnf install -y libsepol-static --enablerepo '*'"
fi
rlRun "rpm -qa | grep libsepol | sort"
rlPhaseEnd
rlPhaseStartTest "non-fuzzing tests"
rlRun "dnf download --source ${PACKAGE}"
rlRun "rpm -ivh ${PACKAGE}-*.src.rpm"
rlRun "rm -f ${PACKAGE}-*.src.rpm"
rlRun "tar zxf ~/rpmbuild/SOURCES/${PACKAGE}-*.tar.gz"
rlRun "pushd ${PACKAGE}-*"
rlRun "make test"
rlRun "popd"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "rm -rf ~/rpmbuild ${PACKAGE}-*"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -0,0 +1,21 @@
PURPOSE of /CoreOS/checkpolicy/Regression/oom-compiler-failure
Author: Petr Matyas <pmatyas@redhat.com>
Description: checkpolicy and checkmodule must fail cleanly under OOM conditions
When a policy compiler (checkpolicy, checkmodule) encounters a memory
allocation failure mid-compilation it must abort and return a non-zero exit
status. It must not write a partial or otherwise incorrect output binary,
which could be silently loaded by semodule and corrupt the running policy.
The test constrains the virtual address space of the compiler subprocess to
8 MB using "ulimit -v", which is below the minimum required to compile a real
targeted policy binary but above the threshold needed to load shared libraries
and start execution. Two compilers are exercised:
checkpolicy -b (recompiling the active kernel policy binary)
checkmodule -b (recompiling the base module extracted from the policy store)
Assertions for each compiler:
1. Exit status is non-zero.
2. The output file was not created or is empty.

View file

@ -0,0 +1,18 @@
summary: checkpolicy and checkmodule must fail cleanly under OOM conditions
description: |+
Simulate an out-of-memory condition by capping the virtual address space of
the compiler subprocess with ulimit -v. Verify that both checkpolicy and
checkmodule exit with a non-zero status and do not produce an output binary
when memory is exhausted during compilation.
contact: Petr Matyas <pmatyas@redhat.com>
component:
- checkpolicy
test: ./runtest.sh
framework: beakerlib
require:
- checkpolicy
- policycoreutils
enabled: true
tier: 2
id: 4afebe54-b8f3-41d0-b9bc-91d46d436236

View file

@ -0,0 +1,86 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/checkpolicy/Regression/oom-compiler-failure
# Description: checkpolicy and checkmodule must fail cleanly under OOM
# Author: Petr Matyas <pmatyas@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2026 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
. /usr/share/beakerlib/beakerlib.sh
PACKAGE="checkpolicy"
# Virtual memory limit in KB applied to each compiler subprocess.
# 8 MB is below the minimum needed to parse a real targeted policy binary
# but above the minimum for the process to load its shared libraries and
# start executing. Validated against checkpolicy 3.x on RHEL-10.
MEM_LIMIT_KB=8192
rlJournalStart
rlPhaseStartSetup
rlAssertRpm ${PACKAGE}
rlAssertRpm policycoreutils
rlAssertExists "/usr/bin/checkpolicy"
rlAssertExists "/usr/bin/checkmodule"
rlAssertExists "/usr/bin/semodule_unpackage"
# Locate the active compiled policy on disk.
POLICY_BINARY=$(find /etc/selinux/ -name "policy.*" -type f | head -1)
rlAssertExists "${POLICY_BINARY}"
rlLog "Using policy binary: ${POLICY_BINARY}"
# Extract the base module binary so checkmodule can compile it back.
# semodule_unpackage accepts .pp and writes separate .mod and .fc files.
rlRun "semodule -E base" 0 "Extract base.pp from the active policy store"
rlAssertExists "base.pp"
rlRun "semodule_unpackage base.pp base.mod base.fc" 0 "Unpack base.pp into base.mod"
rlAssertExists "base.mod"
rlLog "base.mod size: $(stat -c %s base.mod) bytes"
rlPhaseEnd
rlPhaseStartTest "checkpolicy fails without producing output under OOM"
rlRun "rm -f policy.oom"
# Run checkpolicy in a child process whose virtual address space is
# capped. exec replaces the shell so ulimit applies only to checkpolicy
# itself, leaving the test harness unaffected.
rlRun -s "bash -c 'ulimit -v ${MEM_LIMIT_KB}; exec checkpolicy -b -M -o policy.oom ${POLICY_BINARY}'" 1-255 \
"checkpolicy must exit non-zero when memory is exhausted"
rlLog "checkpolicy output: $(cat ${rlRun_LOG})"
rlRun "test ! -s policy.oom" 0 \
"checkpolicy must not produce an output binary under OOM"
rlPhaseEnd
rlPhaseStartTest "checkmodule fails without producing output under OOM"
rlRun "rm -f base.oom"
rlRun -s "bash -c 'ulimit -v ${MEM_LIMIT_KB}; exec checkmodule -b -M -o base.oom base.mod'" 1-255 \
"checkmodule must exit non-zero when memory is exhausted"
rlLog "checkmodule output: $(cat ${rlRun_LOG})"
rlRun "test ! -s base.oom" 0 \
"checkmodule must not produce an output binary under OOM"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "rm -f policy.oom base.oom base.pp base.mod base.fc"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -1 +1,31 @@
path: /checkpolicy/sedismod
summary: Does sedismod work correctly?
description: |+
Does sedismod work correctly?
contact: Milos Malik <mmalik@redhat.com>
component:
- checkpolicy
recommend:
- checkpolicy
- selinux-policy-targeted
- expect
- policycoreutils
- psmisc
duration: 10m
enabled: true
tag:
- NoRHEL4
- NoRHEL5
- TIPpass_Security
- TierCandidatesPASS
- f31friendly
- f32friendly
- targeted
tier: 2
adjust+:
- enabled: false
when: distro == rhel-4, rhel-5
continue: false
extra-nitrate: TC#0518635
extra-summary: /CoreOS/checkpolicy/Sanity/sedismod
extra-task: /CoreOS/checkpolicy/Sanity/sedismod

View file

@ -27,12 +27,11 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/bin/rhts-environment.sh || exit 1
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="checkpolicy"
# TODO: repeat for all policy modules that are installed under /etc/selinux
if rlIsFedora ; then
if rlIsFedora || rlIsCentOS ; then
POLICY_FILE="`find /var/lib/selinux/targeted -type d -name base`/hll"
elif rlIsRHEL '<7.3' ; then
POLICY_FILE=`find /etc/selinux/targeted -type f -name base.pp`
@ -44,7 +43,7 @@ rlJournalStart
rlPhaseStartSetup
rlAssertRpm ${PACKAGE}
OUTPUT_FILE=`mktemp`
if rlIsRHEL '>=7.3' || rlIsFedora ; then
if rlIsRHEL '>=7.3' || rlIsCentOS || rlIsFedora ; then
rlRun "semodule -H -E base"
else
rlRun "cp ${POLICY_FILE} ./base.pp.bz2"
@ -75,6 +74,18 @@ rlJournalStart
done
rlPhaseEnd
if sedismod --help | grep -q actions ; then
rlPhaseStartTest "test the non-interactive actions"
rlLog "introduced in version 3.6"
for ACTION in 1 2 3 4 5 6 7 8 9 0 a b c u F v ; do
rlRun "sedismod -a ${ACTION} ${POLICY_FILE} > ${ACTION}.txt"
rlRun "ls -l ${ACTION}.txt"
rlRun "test -s ${ACTION}.txt"
rlRun "rm -f ${ACTION}.txt"
done
rlPhaseEnd
fi
rlPhaseStartCleanup
rlRun "rm -f ${OUTPUT_FILE} ${POLICY_FILE}"
rlPhaseEnd

View file

@ -1 +1,31 @@
path: /checkpolicy/sedispol
summary: Does sedispol work correctly?
description: |+
Does sedispol work correctly?
contact: Milos Malik <mmalik@redhat.com>
component:
- checkpolicy
recommend:
- checkpolicy
- selinux-policy
- expect
duration: 10m
enabled: true
tag:
- NoRHEL4
- NoRHEL5
- f31friendly
- f32friendly
- targeted
tier: 2
link:
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=1303696
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=1337890
adjust+:
- enabled: false
when: distro == rhel-4, rhel-5
continue: false
extra-nitrate: TC#0518626
extra-summary: /CoreOS/checkpolicy/Sanity/sedispol
extra-task: /CoreOS/checkpolicy/Sanity/sedispol
id: bbeea40d-d503-4862-91ee-3bb1b71b7baa

View file

@ -27,7 +27,6 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/bin/rhts-environment.sh || exit 1
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="checkpolicy"
@ -65,10 +64,23 @@ rlJournalStart
rlRun "grep AVTAB ${OUTPUT_FILE}"
rlRun "grep AVTAG ${OUTPUT_FILE}" 1
rlRun "echo -en 'u\nq\n' | sedispol ${POLICY_FILE} >& ${OUTPUT_FILE}"
rlRun "grep permissions ${OUTPUT_FILE}"
rlRun "grep permisions ${OUTPUT_FILE}" 1
rlRun "echo -en 'U\nq\n' | sedispol ${POLICY_FILE} >& ${OUTPUT_FILE}"
rlRun "grep permisions ${OUTPUT_FILE}" 1
rlPhaseEnd
if sedispol --help | grep -q actions ; then
rlPhaseStartTest "test the non-interactive actions"
rlLog "introduced in version 3.6"
for ACTION in 1 2 3 4 5 6 8 c b C r t a p u U F ; do
rlRun "sedispol -a ${ACTION} ${POLICY_FILE} > ${ACTION}.txt"
rlRun "ls -l ${ACTION}.txt"
rlRun "test -s ${ACTION}.txt"
rlRun "rm -f ${ACTION}.txt"
done
rlPhaseEnd
fi
rlPhaseStartCleanup
rlRun "rm -f ${OUTPUT_FILE}"
rlPhaseEnd

1
kernel/CVE-2025-71085/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
reproducer

View file

@ -0,0 +1,35 @@
summary: Test for CVE-2025-71085
description: |
Runs the reproducer for CVE-2025-71085 (taken from the original commit
message).
contact: Ondrej Mosnacek <omosnace@redhat.com>
component:
- kernel
framework: beakerlib
require:
- netlabel_tools
- gcc
duration: 5m
tier: 2
check:
# The reproducer triggers a kernel BUG when the bug is present, so turn
# on the dmesg check.
- dmesg
enabled: true
link:
- relates: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=58fc7342b529803d3c221101102fe913df7adb83
- verifies: https://issues.redhat.com/browse/RHEL-143531
- verifies: https://issues.redhat.com/browse/RHEL-143532
- verifies: https://issues.redhat.com/browse/RHEL-143533
- verifies: https://issues.redhat.com/browse/RHEL-143534
- verifies: https://issues.redhat.com/browse/RHEL-143535
- verifies: https://issues.redhat.com/browse/RHEL-143541
- verifies: https://issues.redhat.com/browse/RHEL-143542
- verifies: https://issues.redhat.com/browse/RHEL-143543
- verifies: https://issues.redhat.com/browse/RHEL-143544
- verifies: https://issues.redhat.com/browse/RHEL-143545
- verifies: https://issues.redhat.com/browse/RHEL-143546
- verifies: https://issues.redhat.com/browse/RHEL-143547
- verifies: https://issues.redhat.com/browse/RHEL-143548
- verifies: https://issues.redhat.com/browse/RHEL-143551
- verifies: https://bugzilla.redhat.com/show_bug.cgi?id=2429026

View file

@ -0,0 +1,48 @@
/* SPDX-License-Identifier: GPLv2 */
/*
* Copyright (c) 2026 Red Hat, Inc.
* Author: Ondrej Mosnacek <omosnace@redhat.com>
* Taken from: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=58fc7342b529803d3c221101102fe913df7adb83
* (Additional copyright/authorship might apply.)
*/
#include <stdlib.h>
#include <arpa/inet.h>
#include <sys/socket.h>
int main(int argc, char **argv)
{
int fd = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
// setup msghdr
int cmsg_size = 2;
int cmsg_len = 0x60;
struct msghdr msg;
struct sockaddr_in6 dest_addr;
struct cmsghdr * cmsg = (struct cmsghdr *) calloc(1, sizeof(struct cmsghdr) + cmsg_len);
msg.msg_name = &dest_addr;
msg.msg_namelen = sizeof(dest_addr);
msg.msg_iov = NULL;
msg.msg_iovlen = 0;
msg.msg_control = cmsg;
msg.msg_controllen = cmsg_len;
msg.msg_flags = 0;
// setup sockaddr
dest_addr.sin6_family = AF_INET6;
dest_addr.sin6_port = htons(31337);
dest_addr.sin6_flowinfo = htonl(31337);
dest_addr.sin6_addr = in6addr_loopback;
dest_addr.sin6_scope_id = 31337;
// setup cmsghdr
cmsg->cmsg_len = cmsg_len;
cmsg->cmsg_level = IPPROTO_IPV6;
cmsg->cmsg_type = IPV6_HOPOPTS;
char * hop_hdr = (char *)cmsg + sizeof(struct cmsghdr);
hop_hdr[1] = 0x9; //set hop size - (0x9 + 1) * 8 = 80
sendmsg(fd, &msg, 0);
return 0;
}

View file

@ -0,0 +1,39 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# SPDX-License-Identifier: GPLv2
# Copyright (c) 2026 Red Hat, Inc.
# Author: Ondrej Mosnacek <omosnace@redhat.com>
# Include Beakerlib environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
rlJournalStart
rlPhaseStartSetup
rlRun "uname -r" 0 "Print kernel version"
rlRun "gcc -o reproducer reproducer.c" 0 "Compile the reproducer"
rlRun "netlabelctl calipso add pass doi:7" 0 "Set up CALIPSO"
rlRun "netlabelctl map del default" 0 "Delete default netlabel map"
rlRun "netlabelctl map add default address:0.0.0.0/0 protocol:unlbl" 0 \
"Set unlabeled traffic by default"
rlRun "netlabelctl map add default address:::/0 protocol:unlbl" 0 \
"Set unlabeled traffic by default"
rlRun "netlabelctl map add default address:0::1/128 protocol:calipso,7" 0 \
"Set up CALIPSO for localhost only"
rlPhaseEnd
rlPhaseStartTest
# Will trigger a kernel BUG in dmesg or panic when vulnerable
rlRun "./reproducer" 0 "Run the reproducer"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "netlabelctl map del default" 0 "Delete the CALIPSO map"
rlRun "netlabelctl calipso del doi:7" 0 "Unsetup CALIPSO"
rlRun "netlabelctl map add default protocol:unlbl" 0 "Re-add default netlabel map"
rlRun "rm -f reproducer" 0 "Delete the reproducer binary"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -0,0 +1,18 @@
summary: Test SELinux labeling before initial policy load
description: |
Regression test for a bug where SELinux may have printed uninitialized
kernel memory instead of a valid source/target context in AVC denials.
contact: Ondrej Mosnacek <omosnace@redhat.com>
component:
- kernel
framework: beakerlib
require:
- memcached
- policycoreutils
duration: 5m
tier: 2
enabled: true
link:
- verifies: https://bugzilla.redhat.com/show_bug.cgi?id=1758086
environment:
AVC_ERROR: +no_avc_check

View file

@ -0,0 +1,35 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# SPDX-License-Identifier: GPLv2
# Copyright (c) 2022 Red Hat, Inc.
# Author: Ondrej Mosnacek <omosnace@redhat.com>
# Include Beakerlib environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
rlJournalStart
rlPhaseStartSetup
rlRun "uname -r" 0 "Print running kernel version"
rlServiceStart memcached
rlPhaseEnd
rlPhaseStartTest
rlRun "semodule -d memcached" 0
rlRun "ps -Zp \$(pidof memcached) | grep unlabeled_t" 0 \
"The service should be unlabeled now"
rlRun "load_policy" 0
rlRun "semodule -e memcached" 0
rlRun "ps -Zp \$(pidof memcached) | grep unlabeled_t" 1 \
"The service shouldn't stay unlabeled"
rlRun "ps -Zp \$(pidof memcached) | grep system_r:memcached_t:s0" 0 \
"The service should have the correct label"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "setenforce 0" 0 # service may be unlabeled
rlServiceStop memcached
rlRun "setenforce 1" 0
rlServiceRestore memcached
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -0,0 +1,32 @@
summary: Test logging of actual context in AVCs if it is invalid
description: |
Verify that SELinux logs the actual source/target context in a separate
AVC record field in case it is invalid.
contact: Ondrej Mosnacek <omosnace@redhat.com>
component:
- kernel
framework: beakerlib
require:
- type: library
name: /selinux-policy/Library/common
nick: selinux-policy
- attr
- audit
- libselinux-utils
- policycoreutils
- selinux-policy
duration: 15m
tier: 2
enabled: true
adjust+:
- enabled: false
when: distro < rhel-8.1
because: RHEL-8.0 and below is not expected to support this
link:
- verifies: https://bugzilla.redhat.com/show_bug.cgi?id=1670039
- verifies: https://bugzilla.redhat.com/show_bug.cgi?id=1719666
environment:
AVC_ERROR: +no_avc_check
check:
- how: avc
result: xfail

View file

@ -0,0 +1,101 @@
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# SPDX-License-Identifier: GPLv2
# Copyright (c) 2022 Red Hat, Inc.
# Author: Ondrej Mosnacek <omosnace@redhat.com>
# Include Beakerlib environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
EXE4="reproducer4"
EXE6="reproducer6"
PORT=8000
UNLABELED_CONTEXT="system_u:object_r:unlabeled_t:s0"
INVALID_TCONTEXT="system_u:object_r:banana_t:s0"
INVALID_SCONTEXT="system_u:system_r:tor_t:s0"
INVALID_SCONTEXT_MODULE="tor"
GARBAGE_TCONTEXT="kuřecí řízek"
GARBAGE_TCONTEXT_AUDIT="6B75C5996563C3AD20C599C3AD7A656B"
rlJournalStart
rlPhaseStartSetup
rlImport "selinux-policy/common" # for audit daemon handling
rlRun "uname -r" 0 "Print running kernel version"
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
old_enforce=$(getenforce)
rlLog "Backing up SELinux status: $old_enforce"
rlRun "setenforce 0" 0 "Switching to permissive"
rlPhaseEnd
# helper function for subtests:
function check_avcs() {
local field_main="$1"
local field_raw="$2"
local invalid_ctx="$3"
rlRun "LANG=en_US ausearch --input-logs -ts $audit_ts --raw -m AVC | \
grep -E '^type=AVC .* $field_main=$UNLABELED_CONTEXT' \
>tmpavcs" 0 "Collect AVCs"
unlabeled_avcs=$(cat tmpavcs | wc -l)
unlabeled_avcs_with_rawcon=$(cat tmpavcs | \
grep " $field_raw=$invalid_ctx" | wc -l)
rlAssertEquals "Check that all AVCs with $field_main=unlabeled have $field_raw= with the correct label" \
$unlabeled_avcs $unlabeled_avcs_with_rawcon
rlRun "cat tmpavcs" 0 "Print checked AVCs"
}
rlPhaseStartTest "trawcon"
rlRun "touch foo" 0 "Creating the foo test file"
rlRun "setfattr -n security.selinux -v $INVALID_TCONTEXT foo" 0 \
"Setting SELinux xattr of foo to an invalid value"
audit_ts="$(date +'%x %T')"; sleep 1.1
rlRun "runcon system_u:system_r:sshd_t:s0 cat foo" 0 \
"Generating AVCs with invalid tcontext"
check_avcs tcontext trawcon "\"$INVALID_TCONTEXT\""
rlPhaseEnd
rlPhaseStartTest "trawcon-garbage"
rlRun "touch foo" 0 "Creating the foo test file"
rlRun "setfattr -n security.selinux -v '$GARBAGE_TCONTEXT' foo" 0 \
"Setting SELinux xattr of foo to a garbage value"
sleep 1.1; audit_ts="$(date +'%x %T')"; sleep 1.1
rlRun "runcon system_u:system_r:sshd_t:s0 cat foo" 0 \
"Generating AVCs with invalid tcontext"
check_avcs tcontext trawcon "$GARBAGE_TCONTEXT_AUDIT"
rlPhaseEnd
rlPhaseStartTest "srawcon"
function gen_scontext_unlabeled_avc() {
local fifo="$1"
# Start bash with tor label, then make it invalid,
# and try to do something under the invalid label:
runcon "$INVALID_SCONTEXT" \
bash -c "cat $fifo > /dev/null; </usr/bin/echo >/dev/null" &
semodule -d "$INVALID_SCONTEXT_MODULE"
echo go! >$fifo
wait %1
semodule -e "$INVALID_SCONTEXT_MODULE"
}
sleep 1.1; audit_ts="$(date +'%x %T')"; sleep 1.1
rlRun "mkfifo tmpfifo" 0
rlRun "gen_scontext_unlabeled_avc tmpfifo" 0 \
"Generating AVCs with invalid scontext"
check_avcs scontext srawcon "\"$INVALID_SCONTEXT\""
rlPhaseEnd
rlPhaseStartCleanup
rlRun "setenforce $old_enforce" 0 "Restoring SELinux status"
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -0,0 +1,7 @@
# Minimal Makefile for standard-test-roles-beakerlib
R="RhtsRequires: perf"
run:
chmod +x runtest.sh
./runtest.sh

View file

@ -0,0 +1,30 @@
summary: Basic test for SELinux AVC tracepoint support
description: |
Tests basic functionality of the built-in kernel tracepoint for audited
SELinux denials that has been introduced in kernel v5.10.
See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=dd8166212d9a2eca3181567c953d5687aea4d7dc
contact: Ondrej Mosnacek <omosnace@redhat.com>
component:
- kernel
framework: beakerlib
require:
- perf
duration: 5m
tier: 2
enabled: true
adjust+:
- enabled: false
when: distro < rhel-8.5
because: RHEL-8.5 and below are not expected to support this
- enabled: false
when: distro < fedora-35
because: This feature may not be available in kernels in F34 and below
link:
- verifies: https://bugzilla.redhat.com/show_bug.cgi?id=1954024
environment:
AVC_ERROR: +no_avc_check
check:
- how: avc
result: xfail

View file

@ -0,0 +1,29 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# SPDX-License-Identifier: GPLv2
# Copyright (c) 2021 Red Hat, Inc.
# Author: Ondrej Mosnacek <omosnace@redhat.com>
# Include Beakerlib environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
rlJournalStart
rlPhaseStartSetup
rlRun "uname -r"
rlPhaseEnd
rlPhaseStartTest
rlAssertExists /sys/kernel/tracing/events/avc/selinux_audited/enable
rlRun "perf list | grep avc:selinux_audited"
rlRun "perf record -o perf.data -e avc:selinux_audited -g \
runcon system_u:system_r:kernel_t:s0 echo" 0-255
rlRun "perf script -i perf.data"
rlAssertGreater "'perf script' output should have more than 0 lines" \
"$(perf script -i perf.data | wc -l)" "0"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "rm -f perf.data"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -0,0 +1,22 @@
summary: Regression test for bogus WARNING in SELinux
description: |
Verify that selinux_ima_measure_state() doesn't trigger a bogus
lock-related WARN_ON() when the mutex is held by another task.
contact: Ondrej Mosnacek <omosnace@redhat.com>
component:
- kernel
framework: beakerlib
require:
- policycoreutils
duration: 5m
tier: 2
enabled: true
adjust+:
- enabled: false
when: distro < fedora-36
because: some kernels on Fedora 35 and below don't have the fix
- enabled: false
when: distro < rhel-9.1
because: not expected to be fixed earlier than RHEL-9.1
link:
- verifies: https://bugzilla.redhat.com/show_bug.cgi?id=2050966

View file

@ -0,0 +1,32 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# SPDX-License-Identifier: GPLv2
# Copyright (c) 2022 Red Hat, Inc.
# Author: Ondrej Mosnacek <omosnace@redhat.com>
# Include Beakerlib environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
function trigger_the_bug() {
while true; do echo 0 > /sys/fs/selinux/checkreqprot; done &
while true; do load_policy; done &
sleep 15s
kill $(jobs -p)
wait $(jobs -p)
return 0
}
rlJournalStart
rlPhaseStartSetup
rlRun "uname -r" 0 "Show the running kernel version"
rlPhaseEnd
rlPhaseStartTest
rlRun "trigger_the_bug" 0 "Run the reproducer"
rlRun "dmesg | grep -E 'WARNING:.*selinux_ima_measure_state'" 1 \
"Check that dmesg doesn't contain relevant WARNING lines"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -0,0 +1,25 @@
summary: Test connect(AF_UNSPEC) behavior
description: |
Ensure that connect(AF_UNSPEC) (should disconnect a connected socket)
works correctly under SELinux.
contact: Ondrej Mosnacek <omosnace@redhat.com>
component:
- kernel
framework: beakerlib
require:
- gcc
- nc
- strace
duration: 5m
tier: 2
enabled: true
adjust+:
- enabled: false
when: distro ~< rhel-8.1
because: RHEL-8.0 is not expected to have the bug fixed
- enabled: false
when: distro ~< rhel-7.9
because: RHEL-7.8 and below are not expected to have the bug fixed
link:
- verifies: https://bugzilla.redhat.com/show_bug.cgi?id=1707828
- verifies: https://bugzilla.redhat.com/show_bug.cgi?id=1886305

View file

@ -0,0 +1,46 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
int main(int argc, char **argv)
{
int fd;
struct sockaddr_in addr;
struct sockaddr addr_unspec;
if (argc < 2)
return 2;
fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (fd < 0) {
perror(argv[0]);
return 1;
}
addr.sin_family = AF_INET;
addr.sin_port = htons(atoi(argv[1]));
addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
if (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
perror(argv[0]);
close(fd);
return 1;
}
memset(&addr_unspec, 0, sizeof(addr_unspec));
addr_unspec.sa_family = AF_UNSPEC;
if (connect(fd, (struct sockaddr *)&addr_unspec, sizeof(addr_unspec)) < 0) {
perror(argv[0]);
close(fd);
return 1;
}
close(fd);
return 0;
}

View file

@ -0,0 +1,47 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
int main(int argc, char **argv)
{
int fd;
struct sockaddr_in6 addr;
struct sockaddr addr_unspec;
if (argc < 2)
return 2;
fd = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP);
if (fd < 0) {
perror(argv[0]);
return 1;
}
memset(&addr, 0, sizeof(addr));
addr.sin6_family = AF_INET6;
addr.sin6_port = htons(atoi(argv[1]));
addr.sin6_addr = (struct in6_addr)IN6ADDR_LOOPBACK_INIT;
if (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
perror(argv[0]);
close(fd);
return 1;
}
memset(&addr_unspec, 0, sizeof(addr_unspec));
addr_unspec.sa_family = AF_UNSPEC;
if (connect(fd, (struct sockaddr *)&addr_unspec, sizeof(addr_unspec)) < 0) {
perror(argv[0]);
close(fd);
return 1;
}
close(fd);
return 0;
}

View file

@ -0,0 +1,39 @@
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# SPDX-License-Identifier: GPLv2
# Copyright (c) 2022 Red Hat, Inc.
# Author: Ondrej Mosnacek <omosnace@redhat.com>
# Include Beakerlib environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
EXE4="reproducer4"
EXE6="reproducer6"
PORT=8000
rlJournalStart
rlPhaseStartSetup
rlRun "uname -r" 0 "Print running kernel version"
rlRun "gcc -o $EXE4 reproducer4.c" 0 "Compile the IPv4 reproducer"
rlRun "gcc -o $EXE6 reproducer6.c" 0 "Compile the IPv6 reproducer"
rlRun "nc -4lk $PORT &" 0 "Start IPv4 server"
rlRun "nc -6lk $PORT &" 0 "Start IPv6 server"
rlPhaseEnd
rlPhaseStartTest "IPv4"
rlRun "strace ./$EXE4 $PORT" 0 "Run the IPv4 reproducer"
rlPhaseEnd
rlPhaseStartTest "IPv6"
rlRun "strace ./$EXE6 $PORT" 0 "Run the IPv6 reproducer"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "rm -f $EXE4" 0 "Removing the IPv4 reproducer binary"
rlRun "rm -f $EXE6" 0 "Removing the IPv6 reproducer binary"
rlRun "kill %1" 0 "Kill the IPv4 server"
rlRun "kill %2" 0 "Kill the IPv6 server"
rlRun "wait $(jobs -p | tr '\n' ' ')" 0,143 "Wait for the servers to terminate"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -0,0 +1 @@
reproducer

View file

@ -0,0 +1,21 @@
summary: Verify no invalid denials for fanotify_mark() on an anonymous pipe
description: |
Verify that calling fanotify_mark() on an anonymous pipe just fails
with EINVAL and doesn't fail on SELinux checks earlier.
contact: Ondrej Mosnacek <omosnace@redhat.com>
component:
- kernel
framework: beakerlib
require:
- gcc
duration: 5m
tier: 2
check:
- how: avc
enabled: true
adjust+:
- enabled: false
when: distro < rhel-9
because: On RHEL-8 fanotify mark is allowed on anonymous pipes.
link:
- verifies: https://issues.redhat.com/browse/RHEL-53850

View file

@ -0,0 +1,66 @@
/* SPDX-License-Identifier: GPLv2 */
/* Copyright (c) 2026 Red Hat, Inc. */
/* Author: Ondrej Mosnacek <omosnace@redhat.com> */
#define _GNU_SOURCE
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/fanotify.h>
int main(int argc, char **argv)
{
int ffd, ret, rc, pfd[2];
ret = pipe2(pfd, O_CLOEXEC);
if (ret == -1) {
perror("pipe2");
rc = 2;
goto exit;
}
ffd = fanotify_init(FAN_CLASS_NOTIF, O_RDONLY);
if (ffd == -1) {
perror("fanotify_init");
rc = 2;
goto exit_close_pipes;
}
rc = 0;
ret = fanotify_mark(ffd, FAN_MARK_ADD | FAN_MARK_MOUNT, FAN_ACCESS,
pfd[0], NULL);
if (ret == 0) {
printf("FAIL: fanotify_mark() with FAN_MARK_MOUNT succeeded\n");
rc = 1;
} else if (errno == EINVAL) {
printf("PASS: fanotify_mark() with FAN_MARK_MOUNT failed with EINVAL as expected\n");
} else {
printf("FAIL: fanotify_mark() with FAN_MARK_MOUNT failed with %s\n", strerror(errno));
rc = 1;
}
ret = fanotify_mark(ffd, FAN_MARK_ADD | FAN_MARK_FILESYSTEM, FAN_ACCESS,
pfd[0], NULL);
if (ret == 0) {
printf("FAIL: fanotify_mark() with FAN_MARK_FILESYSTEM succeeded\n");
rc = 1;
} else if (errno == EINVAL) {
printf("PASS: fanotify_mark() with FAN_MARK_FILESYSTEM failed with EINVAL as expected\n");
} else {
printf("FAIL: fanotify_mark() with FAN_MARK_FILESYSTEM failed with %s\n", strerror(errno));
rc = 1;
}
close(ffd);
exit_close_pipes:
close(pfd[0]);
close(pfd[1]);
exit:
return rc;
}

View file

@ -0,0 +1,25 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# SPDX-License-Identifier: GPLv2
# Copyright (c) 2026 Red Hat, Inc.
# Author: Ondrej Mosnacek <omosnace@redhat.com>
# Include Beakerlib environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
rlJournalStart
rlPhaseStartSetup
rlRun "uname -r" 0 "Print kernel version"
rlRun "gcc -o reproducer reproducer.c" 0 "Compile the reproducer"
rlPhaseEnd
rlPhaseStartTest
rlRun "./reproducer" 0 "Run the reproducer"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "rm -f reproducer" 0 "Delete the reproducer binary"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -0,0 +1,7 @@
# Minimal Makefile for standard-test-roles-beakerlib
R="RhtsRequires: policycoreutils"
run:
chmod +x runtest.sh
./runtest.sh

View file

@ -0,0 +1,29 @@
summary: Test genfscon fallback for fs_use_xattr when no xattr support
description: |
Test that a fs_use_xattr filesystem mount falls back to genfscon when it
doesn't have xattr support.
See also:
https://lore.kernel.org/selinux/CAFqZXNsGabHBfV36nNAVLJgEzjkBev-O3YZ1vnmXyVoaDdjiHQ@mail.gmail.com/T/
https://lore.kernel.org/selinux/20210113123802.63563-1-omosnace@redhat.com/
contact: Ondrej Mosnacek <omosnace@redhat.com>
component:
- kernel
framework: beakerlib
require:
- policycoreutils
- dosfstools
duration: 5m
tier: 2
enabled: true
adjust+:
- enabled: false
when: distro < rhel-8.5
because: RHEL-8.5 and below are not expected to support this
- enabled: false
when: distro < fedora-35
because: This feature may not be supported on kernels in F34 and below
link:
- verifies: https://bugzilla.redhat.com/show_bug.cgi?id=1899703
- verifies: https://bugzilla.redhat.com/show_bug.cgi?id=1915825
- verifies: https://bugzilla.redhat.com/show_bug.cgi?id=1937297

View file

@ -0,0 +1,39 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# SPDX-License-Identifier: GPLv2
# Copyright (c) 2021 Red Hat, Inc.
# Author: Ondrej Mosnacek <omosnace@redhat.com>
# Include Beakerlib environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
rlJournalStart
rlPhaseStartSetup
rlRun "uname -r"
rlRun "dd if=/dev/zero of=diskfile bs=4M count=1"
rlRun "mkfs.vfat diskfile"
DEVICE="$(losetup -f)"
rlRun "losetup $DEVICE diskfile"
rlRun "echo '(fsuse xattr vfat (system_u object_r fs_t ((s0) (s0))))' >vfat_xattr.cil"
rlRun "semodule -i vfat_xattr.cil"
rlRun "mkdir /mnt/test-vfat"
rlPhaseEnd
rlPhaseStartTest
rlRun "mount -t vfat $DEVICE /mnt/test-vfat"
rlRun "[ \"\$(secon -t -f /mnt/test-vfat)\" = dosfs_t ]"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "umount /mnt/test-vfat" 0-1
rlRun "rmdir /mnt/test-vfat"
rlRun "semodule -r vfat_xattr" 0-1
rlRun "rm -f vfat_xattr.cil"
rlRun "losetup -d $DEVICE" 0-1
rlRun "rm -f diskfile"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -0,0 +1,26 @@
summary: Reproducer for an out-of-bounds read on getxattr(2)
description: |
Verifies that it is not possible to trigger an out-of-bounds read by
setting the security.selinux xattr to a value containing a null character
and then trying to read back the xattr.
See also: https://git.kernel.org/torvalds/c/efe3de79e0b5
contact: Ondrej Mosnacek <omosnace@redhat.com>
component:
- kernel
framework: beakerlib
require:
- coreutils
- policycoreutils
- attr
duration: 5m
tier: 2
enabled: true
link:
- verifies: https://bugzilla.redhat.com/show_bug.cgi?id=1584307
- verifies: https://bugzilla.redhat.com/show_bug.cgi?id=1595706
environment:
AVC_ERROR: +no_avc_check
check:
- how: avc
result: xfail

View file

@ -0,0 +1,36 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# SPDX-License-Identifier: GPLv2
# Copyright (c) 2018-2022 Red Hat, Inc.
# Author: Ondrej Mosnacek <omosnace@redhat.com>
# Include Beakerlib environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
rlJournalStart
rlPhaseStartSetup
rlRun "uname -r" 0 "Print running kernel version"
rlRun "touch testfile"
reset_enforcing=0
if [ "$(getenforce)" = "Enforcing" ]; then
rlRun "setenforce 0" 0 "Switch to permissive"
reset_enforcing=1
fi
rlPhaseEnd
rlPhaseStartTest
rlRun "setfattr -n security.selinux -v 'a\\0aaaaaaaaaaaaaaaa' testfile" 0 \
"Try to set a label with a null char in it"
rlRun "getfattr -e hex -n security.selinux testfile"
rlRun "getfattr -e hex -n security.selinux testfile | grep -E '0x6100[0-9a-f]+'" 1 \
"Check for junk in the output of getfattr"
rlPhaseEnd
rlPhaseStartCleanup
if [ "$reset_enforcing" -eq 1 ]; then
rlRun "setenforce 1" 0 "Switch back to enforcing"
fi
rlRun "rm -f testfile"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -0,0 +1,26 @@
summary: Test journald performance under SELinux
description: |
Regression test for a bug where systemd-journald suffered a terrible
performance overhead due to SELinux.
contact: Ondrej Mosnacek <omosnace@redhat.com>
component:
- kernel
framework: beakerlib
require:
- perf
- util-linux
- coreutils
- perl-interpreter
- perl-open
- git-core
duration: 30m
tier: 2
enabled: true
adjust+:
- enabled: false
when: distro < rhel-8.3
because: RHEL-8.2 and below are not expected to have the bug fixed
link:
- verifies: https://bugzilla.redhat.com/show_bug.cgi?id=1733259
tag:
- failinfedora

View file

@ -0,0 +1,60 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# SPDX-License-Identifier: GPLv2
# Copyright (c) 2022 Red Hat, Inc.
# Author: Ondrej Mosnacek <omosnace@redhat.com>
# Include Beakerlib environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
# Set this parameter to 1 to also generate a flamegraph.
GENERATE_FLAMEGRAPH="${GENERATE_FLAMEGRAPH:-0}"
FG_URL="https://github.com/brendangregg/FlameGraph"
FG_DIR="FlameGraph"
TARGET_SYMBOL="security_secid_to_secctx"
LIMIT="10.00%"
rlJournalStart
rlPhaseStartSetup
rlRun "uname -r" 0 "Print running kernel version"
if [ "$GENERATE_FLAMEGRAPH" != 0 ]; then
rlRun "git clone $FG_URL $FG_DIR"
fi
rlPhaseEnd
rlPhaseStartTest
JOURNALD_PID=$(pidof systemd-journald)
rlLog "PID of systemd-journald is $JOURNALD_PID"
rlRun "cat /dev/urandom | base64 | logger &" 0 \
"Flood systemd-journald with data"
rlRun "timeout 30s perf record -o perf.data -p $(pidof systemd-journald) -g --call-graph dwarf" 124 \
"Capture perf data on systemd-journald"
rlRun "kill %1"
if [ "$GENERATE_FLAMEGRAPH" != 0 ]; then
rlRun "perf script -i perf.data | $FG_DIR/stackcollapse-perf.pl | $FG_DIR/flamegraph.pl > flamegraph.svg"
fi
rlRun "perf report -i perf.data -g none --pretty raw | grep $TARGET_SYMBOL"
PERCENT="$(perf report -g none --pretty raw | grep $TARGET_SYMBOL | \
grep -Eo '[0-9]+\.[0-9]+%' | head -n 1)"
rlLog "Detected that $TARGET_SYMBOL took up $PERCENT of time (limit $LIMIT)."
rlRun "{ echo \$PERCENT; echo \$LIMIT; } | sort -n | tail -n 1 | grep \$LIMIT" 0 \
"Check that time usage is within limit"
rlPhaseEnd
rlPhaseStartCleanup
rlFileSubmit "perf.data"
if [ "$GENERATE_FLAMEGRAPH" != 0 ]; then
rlFileSubmit "flamegraph.svg"
rlRun "rm -rf $FG_DIR flamegraph.svg"
fi
rlRun "rm -f perf.data"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -0,0 +1,20 @@
summary: Test writing empty value into /proc/self/attr/keycreate
description: |
Verifies that writing an empty value into /proc/<PID>/attr/keycreate
is allowed.
contact: Ondrej Mosnacek <omosnace@redhat.com>
component:
- kernel
framework: beakerlib
require:
- policycoreutils
- gcc
duration: 5m
tier: 2
enabled: true
adjust+:
- enabled: false
when: distro < rhel-8.1
because: RHEL-8.0 and below are not expected to have the bug fixed
link:
- verifies: https://bugzilla.redhat.com/show_bug.cgi?id=1719067

View file

@ -0,0 +1,22 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
int main(void)
{
int fd, r;
fd = open("/proc/self/attr/keycreate", O_WRONLY);
if (fd < 0) {
perror("open");
}
r = write(fd, "", 0);
if (r < 0) {
perror("write");
}
return !!r;
}

View file

@ -0,0 +1,37 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# SPDX-License-Identifier: GPLv2
# Copyright (c) 2022 Red Hat, Inc.
# Author: Ondrej Mosnacek <omosnace@redhat.com>
# Include Beakerlib environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
EXE="reproducer"
rlJournalStart
rlPhaseStartSetup
rlRun "uname -r" 0 "Print running kernel version"
enable_container=0
if semodule -l | grep -q container; then
rlRun "semodule -d container" 0 "Disable the container module"
enable_container=1
fi
rlRun "gcc -o $EXE reproducer.c" 0 "Compile the reproducer"
rlPhaseEnd
rlPhaseStartTest
rlRun "./$EXE" 0 "Run the reproducer"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "rm -f $EXE" 0 "Remove the reproducer binary"
if [ "$enable_container" -eq 1 ]; then
rlRun "semodule -e container" 0 "Re-enable the container module"
fi
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -5,6 +5,9 @@ description: |
This TC verifies that CephFS security label support works as expected.
duration: 30m
tier: 2
adjust:
tag:
- failinfedora
- avoidImageMode
adjust+:
- enabled: false
when: distro < rhel-8

View file

@ -0,0 +1,3 @@
system_u:object_r:etc_t:s0
system_u:object_r:etc_t:s0

View file

@ -0,0 +1,29 @@
summary: Test SELinux labeling before initial policy load
description: |
Verifies that reading/writing SELinux labels works before the first policy
load.
See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3e3e24b42043eceb97ed834102c2d094dfd7aaa6
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c8e222616c7e98305bdc861db3ccac520bc29921
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9530a3e00459cd6eabf050133205e0e8fecbdfc7
contact: Ondrej Mosnacek <omosnace@redhat.com>
component:
- kernel
framework: beakerlib
require:
- dracut
- coreutils
- policycoreutils
- attr
duration: 30m
tier: 2
enabled: true
adjust+:
- enabled: false
when: distro < rhel-8.3
because: RHEL-8.2 and below are not expected to support this
link:
- verifies: https://bugzilla.redhat.com/show_bug.cgi?id=1777525
tag:
- reboot

View file

@ -0,0 +1,17 @@
#!/bin/bash
# called by dracut
check() {
return 0
}
# called by dracut
depends() {
return 0
}
# called by dracut
install() {
inst_hook pre-pivot 50 "$moddir/relabel.sh"
inst_multiple setfiles getfattr
}

View file

@ -0,0 +1,15 @@
#!/bin/bash
function dumpcon() {
getfattr --only-values -n security.selinux "$@" | tr -d '\000'
echo
}
mount -o remount,rw /sysroot
dumpcon /sysroot/etc >/sysroot/etc/labeldump
echo test > /sysroot/etc/testfile
dumpcon /sysroot/etc/testfile >>/sysroot/etc/labeldump
setfiles -vF -r /sysroot \
/sysroot/etc/selinux/targeted/contexts/files/file_contexts \
/sysroot/etc
dumpcon /sysroot/etc/testfile >>/sysroot/etc/labeldump

View file

@ -0,0 +1,60 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# SPDX-License-Identifier: GPLv2
# Copyright (c) 2022 Red Hat, Inc.
# Author: Ondrej Mosnacek <omosnace@redhat.com>
# Include Beakerlib environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
# Beaker compat
if [ -n "$JOBID" ] && [ -n "$TESTID" ]; then
function tmt-reboot() { rstrnt-reboot; }
TMT_REBOOT_COUNT="$REBOOTCOUNT"
fi
rlJournalStart
if [ $TMT_REBOOT_COUNT -lt 1 ]; then
rlPhaseStartSetup "Setup"
rlRun "uname -r" 0 "Kernel version before reboot"
rlRun "install -d /usr/lib/dracut/modules.d/97bz1777525" 0 \
"Install dracut plugin directory for testing"
rlRun "install module-setup.sh relabel.sh /usr/lib/dracut/modules.d/97bz1777525" 0 \
"Install dracut plugin for testing"
rlRun "dracut -f" 0 "Rebuild the initramfs"
rlRun "grubby --set-default /boot/vmlinuz-$(uname -r)" 0 \
"Ensure the current booted kernel is the default"
if command -v zipl >/dev/null; then
rlRun "zipl" 0 "Run zipl"
fi
rlPhaseEnd
rlPhaseStartSetup "Reboot"
tmt-reboot
fi
rlRun "uname -r" 0 "Kernel version after reboot"
rlPhaseEnd
rlPhaseStartTest "Test"
rlLog "Test writing labels (BZ 1777525)"
rlRun "ls -lZ /etc/testfile"
rlRun "ls -lZ /etc/testfile | grep -qF ':etc_t:'" 0 \
"Test that /etc/testfile is labeled correctly"
rlLog "Test reading labels (BZ 1839819)"
rlRun "cat /etc/labeldump"
rlAssertNotDiffer "/etc/labeldump" labeldump-expected.txt
rlPhaseEnd
rlPhaseStartCleanup
rlRun "rm -f /etc/labeldump /etc/testfile" 0 "Remove test files"
rlRun "rm -rf /usr/lib/dracut/modules.d/97bz1777525" 0 \
"Remove the dracut plugin"
rlRun "dracut -f" 0 "Rebuild the initramfs again"
if command -v zipl >/dev/null; then
rlRun "zipl" 0 "Run zipl"
fi
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -0,0 +1,19 @@
summary: Mount options memory leak test
description: |
Test that mounting with SELinux mount options doesn't leave behind
memory leaks.
contact: Ondrej Mosnacek <omosnace@redhat.com>
component:
- kernel
framework: beakerlib
duration: 1h
tier: 2
enabled: true
adjust+:
- enabled: false
when: distro < rhel-7
because: RHEL-6 and below are not worth supporting by this test
link:
- verifies: https://bugzilla.redhat.com/show_bug.cgi?id=2187402
tag:
- reboot

View file

@ -0,0 +1,115 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# SPDX-License-Identifier: GPLv2
# Copyright (c) 2023 Red Hat, Inc.
# Author: Ondrej Mosnacek <omosnace@redhat.com>
# Include Beakerlib environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
# Beaker compat
if [ -n "$JOBID" ] && [ -n "$TESTID" ]; then
function tmt-reboot() { rstrnt-reboot; }
TMT_REBOOT_COUNT="$REBOOTCOUNT"
fi
function installDepsYum() {
local yum="$1"; shift
if "$yum" install --help | grep -q -- --skip-unavailable; then
"$yum" install -y --skip-unavailable $*
elif "$yum" install --help | grep -q -- --skip-broken; then
"$yum" install -y --skip-broken $*
else
for req in $*; do
if ! rpm -q --quiet --whatprovides "$req"; then
"$yum" install -y "$req" || true
fi
done
fi
}
function installDeps() {
if type yum >/dev/null; then
installDepsYum yum "$@"
elif type dnf >/dev/null; then
installDepsYum dnf "$@"
fi
}
rlJournalStart
if [ $TMT_REBOOT_COUNT -lt 1 ]; then
rlPhaseStartSetup
rlRun "uname -r" 0 "Print initial running kernel version"
uname="$(uname -r)"
raw_uname="${uname%+*}"
debug_uname="${raw_uname}+debug"
echo "$uname" >"$BEAKERLIB_DIR/orig_uname"
echo "$debug_uname" >"$BEAKERLIB_DIR/debug_uname"
if [ "$uname" = "$debug_uname" ]; then
rlLog "Already running the debug kernel, nice!"
else
rlLog "Install and boot the debug kernel"
rlRun "installDeps kernel-debug-$raw_uname"
rlRun "grubby --set-default /boot/vmlinuz-$debug_uname"
fi
rlRun "grubby --update-kernel /boot/vmlinuz-$debug_uname --args kmemleak=on" 0 \
"Enable kmemleak on the debug kernel"
if command -v zipl >/dev/null; then
rlRun "zipl" 0 "Run zipl"
fi
tmt-reboot
fi
if [ $TMT_REBOOT_COUNT -lt 2 ]; then
rlRun "uname -r" 0 "Print running kernel version after reboot"
rlRun "cat /proc/cmdline" 0 "Print kernel cmdline after reboot"
rlRun "mkdir -p /mnt/test_mount" 0 \
"Create a directory for the test mount"
rlPhaseEnd
rlPhaseStartTest
rlRun "echo clear > /sys/kernel/debug/kmemleak" 0 \
"Clear the kmemleak buffer"
rlRun "mount -t tmpfs -o context=system_u:object_r:user_tmp_t:s0 tmpfs /mnt/test_mount" 0 \
"Do a context mount"
rlRun "umount /mnt/test_mount" 0 \
"Unmount the context mount"
# For whatever reason this needs to be run twice...
rlRun "echo scan > /sys/kernel/debug/kmemleak" 0 \
"Trigger a kmemleak scan"
rlRun "cat /sys/kernel/debug/kmemleak >/dev/null" 0 \
"Dump the kmemleak buffer once"
rlRun "echo scan > /sys/kernel/debug/kmemleak" 0 \
"Trigger a second kmemleak scan"
rlLog "Check that /sys/kernel/debug/kmemleak is empty"
rlAssertNotDiffer /sys/kernel/debug/kmemleak /dev/null
rlRun "cat /sys/kernel/debug/kmemleak" 0 \
"Dump the kmemleak buffer"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "rmdir /mnt/test_mount" 0 \
"Remove the directory for the test mount"
uname="$(cat "$BEAKERLIB_DIR/orig_uname")"
debug_uname="$(cat "$BEAKERLIB_DIR/debug_uname")"
rlRun "grubby --update-kernel /boot/vmlinuz-$debug_uname --remove-args kmemleak=on" 0 \
"Undo kmemleak enabling"
rlRun "grubby --set-default /boot/vmlinuz-$uname" 0 \
"Switch the default back to the initial kernel version"
if command -v zipl >/dev/null; then
rlRun "zipl" 0 "Run zipl"
fi
tmt-reboot
fi
rlRun "uname -r" 0 \
"Print running kernel version after cleanup reboot"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -0,0 +1,21 @@
summary: Netlabel shouldn't leave NOPs in IP options when removing the CIPSO option
description: |
Test that seeting netlabel to unlabeled doesn't just overwrite CIPSO
options with NOPs, but actually removes them. Some routers may drop
packets with IP options, so this is important.
contact: Ondrej Mosnacek <omosnace@redhat.com>
component:
- kernel
framework: beakerlib
duration: 15m
tier: 2
require:
- gcc
- netlabel_tools
enabled: true
adjust+:
- enabled: false
when: distro < rhel-7
because: RHEL-6 and below are not worth supporting by this test
link:
- verifies: https://issues.redhat.com/browse/RHEL-30904

View file

@ -0,0 +1,179 @@
// SPDX-License-Identifier: GPL-2.0
/*
* A reproducer that checks that CIPSO options are cleared properly
* by NetLabel when it is configured to send unabeled traffic.
*
* Copyright (c) 2024 Red Hat, Inc.
* Author: Ondrej Mosnacek <omosnace@redhat.com>
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
int run_test(int csock, int ssock, const struct addrinfo *clientinfo,
int tnum, size_t expected_opt_length)
{
char byte;
struct iovec iov;
struct msghdr msg;
struct cmsghdr *cmsg;
union {
struct cmsghdr cmsghdr;
char buf[CMSG_SPACE(256)];
} control;
int ret, i, result;
printf("TEST #%i\n", tnum);
byte = 0;
ret = sendto(csock, &byte, 1, 0, clientinfo->ai_addr, clientinfo->ai_addrlen);
if (ret < 0) {
perror("sendto");
exit(2);
}
memset(&iov, 0, sizeof(iov));
iov.iov_base = &byte;
iov.iov_len = 1;
memset(&msg, 0, sizeof(msg));
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_control = &control;
msg.msg_controllen = sizeof(control);
ret = recvmsg(ssock, &msg, 0);
if (ret < 0) {
perror("recvmsg");
exit(2);
}
for (cmsg = CMSG_FIRSTHDR(&msg); cmsg;
cmsg = CMSG_NXTHDR(&msg, cmsg)) {
if (cmsg->cmsg_level != SOL_IP ||
cmsg->cmsg_type != IP_RECVOPTS)
continue;
if (cmsg->cmsg_len - sizeof(struct cmsghdr) > 0) {
printf(" options: ");
for (i = 0; i < cmsg->cmsg_len - sizeof(struct cmsghdr); i++) {
printf("%02x ", (unsigned)(CMSG_DATA(cmsg)[i]));
}
printf("\n");
result = expected_opt_length == cmsg->cmsg_len - sizeof(struct cmsghdr);
goto done;
}
}
printf(" no IP options\n");
result = expected_opt_length == 0;
done:
if (result)
printf(" PASS\n");
else
printf(" FAIL\n");
return result;
}
int main(int argc, char **argv)
{
static const unsigned char TEST_OPTION[] = {
1, // NOP
158, // option type - Experimental
5, // option length
0x12, 0x34, 0x56, // dummy data
1, // NOP
134, // option type - CIPSO
11, // option length
0, 0, 0, 16, // DOI
1, // tag type 1
5, // tag length
0, // alignment octet
1, // sensitivity
0xff, // bitmap of categories
1, // NOP
158, // option type - Experimental
5, // option length
0x12, 0x34, 0x56, // dummy data
};
static const size_t TEST_OPTION_CIPSO_OFF = 7;
static const size_t TEST_OPTION_CIPSO_LEN = 11;
int ret, result, csock, ssock, on = 1;
struct addrinfo hints, *serverinfo, *clientinfo;
if (argc != 3) {
fprintf(stderr, "need 2 arguments!\n");
exit(2);
}
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_DGRAM;
hints.ai_protocol = IPPROTO_UDP;
ret = getaddrinfo(argv[1], argv[2], &hints, &clientinfo);
if (ret < 0) {
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(ret));
exit(2);
}
ret = getaddrinfo(NULL, argv[2], &hints, &serverinfo);
if (ret < 0) {
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(ret));
exit(2);
}
csock = socket(clientinfo->ai_family, clientinfo->ai_socktype,
IPPROTO_UDP);
if (csock < 0) {
perror("client socket");
exit(2);
}
ssock = socket(serverinfo->ai_family, serverinfo->ai_socktype,
IPPROTO_UDP);
if (ssock < 0) {
perror("server socket");
exit(2);
}
ret = setsockopt(ssock, SOL_IP, IP_RECVOPTS, &on, sizeof(on));
if (ret < 0) {
perror("server setsockopt: IP_RECVOPTS");
exit(2);
}
if (bind(ssock, serverinfo->ai_addr, serverinfo->ai_addrlen) < 0) {
perror("server bind");
exit(2);
}
result = 1;
/* TEST 1 - only CIPSO */
ret = setsockopt(csock, SOL_IP, IP_OPTIONS,
TEST_OPTION + TEST_OPTION_CIPSO_OFF,
TEST_OPTION_CIPSO_LEN);
if (ret < 0) {
perror("client setsockopt: IP_OPTIONS");
exit(2);
}
if (!run_test(csock, ssock, clientinfo, 1, 0))
result = 0;
/* TEST 2 - CIPSO surrounded by other options */
ret = setsockopt(csock, SOL_IP, IP_OPTIONS,
TEST_OPTION, sizeof(TEST_OPTION));
if (ret < 0) {
perror("client setsockopt: IP_OPTIONS");
exit(2);
}
if (!run_test(csock, ssock, clientinfo, 2,
(sizeof(TEST_OPTION) - TEST_OPTION_CIPSO_LEN) + 3) & 3)
result = 0;
return result ? 0 : 1;
}

View file

@ -0,0 +1,32 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2024 Red Hat, Inc.
# Author: Ondrej Mosnacek <omosnace@redhat.com>
# Include Beakerlib environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
rlJournalStart
rlPhaseStartSetup
rlRun "gcc -o reproducer reproducer.c" 0 "Build the reproducer"
rlRun "netlabelctl cipsov4 add pass doi:16 tags:1" 0
rlRun "netlabelctl map del default" 0
rlRun "netlabelctl map add default address:0.0.0.0/0 protocol:unlbl" 0
rlRun "netlabelctl map add default address:::/0 protocol:unlbl" 0
rlPhaseEnd
rlPhaseStartTest
rlRun "./reproducer 127.0.0.1 9999" 0 "Run the reproducer"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "rm -f reproducer" 0 "Remove the reproducer binary"
rlRun "netlabelctl map del default" 0
rlRun "netlabelctl cipsov4 del doi:16" 0
rlRun "netlabelctl map add default protocol:unlbl" 0
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -12,7 +12,7 @@ require:
duration: 5m
tier: 2
enabled: true
adjust:
enabled: false
when: distro < rhel-7
because: RHEL-6 and below is too old...
adjust+:
- enabled: false
when: distro < rhel-8.4
because: not fixed below RHEL 8.4...

View file

@ -0,0 +1,6 @@
# Minimal Makefile for standard-test-roles-beakerlib
R="RhtsRequires: attr"
run:
chmod +x runtest.sh
./runtest.sh

View file

@ -0,0 +1,27 @@
summary: Regression test for ocontext kernel structure race condition
description: |
Test that a race condition around the kernel's ocontext structures
doesn't cause an incorrect label to be assigned to files/mounts.
contact: Ondrej Mosnacek <omosnace@redhat.com>
component:
- kernel
framework: beakerlib
require:
- attr
duration: 15m
tier: 2
enabled: true
adjust+:
- enabled: false
when: distro < rhel-7
because: RHEL-6 and below are not worth supporting by this test
- enabled: false
when: arch = s390x
because: No machines likely available with required HW configuration
extra-hardware: |
keyvalue = PROCESSORS >= 4
link:
- verifies: https://bugzilla.redhat.com/show_bug.cgi?id=1969344
- verifies: https://bugzilla.redhat.com/show_bug.cgi?id=2040196
tag:
- avoidImageMode

74
kernel/ocontext-race/runtest.sh Executable file
View file

@ -0,0 +1,74 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# SPDX-License-Identifier: GPLv2
# Copyright (c) 2022 Red Hat, Inc.
# Author: Ondrej Mosnacek <omosnace@redhat.com>
# Include Beakerlib environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
PREFIX=/tmp/repro-
NTHREADS=8
TRIALS=20
function get_file_con() {
getfattr -h --absolute-names --only-values -n security.selinux "$1" | tr -d '\000'
}
function strip_mls() {
# strip the MLS -- mcstrans might be running, leading to different MLS
# fields than expected
sed 's/\([^:]*:[^:]*:[^:]*\):.*$/\1/g'
}
function check_file_con() {
rlAssertEquals "Check expected context of $1" \
"$(get_file_con "$1" | strip_mls)" \
"$(echo "$2" | strip_mls)"
}
rlJournalStart
rlPhaseStartSetup
rlRun "uname -r"
rlRun "test \$(nproc) -ge 4" 0 "Test needs an SMP machine, otherwise it may pass regardless of the bug"
rlRun "tmpdir=\$(mktemp -d)" 0 "Create a temporary directory"
prefix="$tmpdir/repro-"
for (( i = 0; i < $NTHREADS; i++ )); do
rlRun "mkdir -p \"\${PREFIX}$i\"" 0 "Create subdirectory #$i"
done
rlPhaseEnd
for (( k = 0; k < $TRIALS; k++ )); do
rlPhaseStartTest "Trial #$k"
rlRun "load_policy" 0 "Reload SELinux policy to reset internal state"
# NOTE: this must be ran in a single rlRun, otherwise beakerlib
# overhead decreases the chance of a race condition
rlRun "
for (( i = 0; i < $NTHREADS; i++)); do
mount -t tmpfs tmpfs \"\${PREFIX}\$i\" &
done
wait
" 0 "Create $NTHREADS tmpfs mounts at once"
for (( i = 0; i < $NTHREADS; i++)); do
rlRun "touch \"\${PREFIX}$i/file\"" 0 "Create a file in dir #$i"
check_file_con "$PREFIX$i" "unconfined_u:object_r:user_tmp_t"
check_file_con "$PREFIX$i/file" "unconfined_u:object_r:user_tmp_t"
done
for (( i = 0; i < $NTHREADS; i++)); do
rlRun "umount \"\${PREFIX}$i\" &" 0 "Unmount dir #$i"
done
rlPhaseEnd
done
rlPhaseStartCleanup
rlRun "rm -rf \$tmpdir" 0 "Clean up the temporary directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -0,0 +1,27 @@
summary: Regression test for overlayfs mmap/mprotect bugs
description: |
Tests various scenarios with overlayfs and mmap/mprotect syscalls.
This also covers CVE-2026-46054.
contact: Ondrej Mosnacek <omosnace@redhat.com>
component:
- kernel
framework: beakerlib
require:
- selinux-policy-devel
- gcc
duration: 5m
tier: 2
enabled: true
link:
- verifies: https://redhat.atlassian.net/browse/RHEL-127505
- verifies: https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2026-46054
- verifies: https://redhat.atlassian.net/browse/RHEL-185115
- verifies: https://redhat.atlassian.net/browse/RHEL-185117
- verifies: https://redhat.atlassian.net/browse/RHEL-185118
environment:
AVC_ERROR: +no_avc_check
check:
- how: avc
result: xfail
extra-nitrate: TC#0620043
id: 2ee56bc8-01f3-4b77-8cdb-494ad9a12451

View file

@ -0,0 +1,75 @@
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
int main(int argc, const char **argv)
{
const char *file, *context;
void *ptr;
int rdonly, execmem, flags, prot, fd, ctxfd, ret;
if (argc < 4 || argc > 5 ||
(strcmp(argv[2], "RDONLY") && strcmp(argv[2], "RDWR")) ||
(strcmp(argv[3], "SHARED") && strcmp(argv[3], "PRIVATE"))
) {
fprintf(stderr, "Usage %s <file> RDONLY|RDWR\n", argv[0]);
return EINVAL;
}
file = argv[1];
rdonly = strcmp(argv[2], "RDONLY") == 0;
execmem = strcmp(argv[3], "PRIVATE") == 0;
flags = strcmp(argv[3], "PRIVATE") == 0 ? MAP_PRIVATE : MAP_SHARED;
prot = PROT_READ | (!rdonly || execmem ? PROT_WRITE : 0) | (execmem ? PROT_EXEC : 0);
context = argc >= 5 ? argv[4] : NULL;
fd = open(file, rdonly ? O_RDONLY : O_RDWR);
if (fd == -1) {
perror("open");
return 2;
}
/* try direct mmap */
ptr = mmap(NULL, 1, prot, flags, fd, 0);
if (ptr == MAP_FAILED) {
perror("mmap");
return 3;
}
munmap(ptr, 1);
/* try mmap with PROT_NONE followed by mprotect with full access */
ptr = mmap(NULL, 1, PROT_NONE, flags, fd, 0);
if (ptr == MAP_FAILED) {
perror("mmap PROT_NONE");
return 4;
}
if (context) {
ctxfd = open("/proc/self/attr/current", O_RDWR);
if (ctxfd == -1) {
perror("open");
return 6;
}
ret = write(ctxfd, context, strlen(context));
if (ret == -1) {
perror("write");
return 7;
}
close(ctxfd);
}
ret = mprotect(ptr, 1, prot);
if (ret == -1) {
perror("mprotect");
return 5;
}
munmap(ptr, 1);
close(fd);
return 0;
}

View file

@ -0,0 +1,83 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2025 Red Hat, Inc.
# Author: Ondrej Mosnacek <omosnace@redhat.com>
# Include Beakerlib environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
rlJournalStart
rlPhaseStartSetup
rlRun "uname -r" 0 "Print current running kernel version"
SE_USER="$(secon -u --pid $$)"
SE_ROLE="$(secon -r --pid $$)"
SE_TYPE="$(secon -t --pid $$)"
SE_MLS="$(secon -m --pid $$)"
OVERLAYCON="$SE_USER:object_r:test_mountedfile_t:s0"
DYNTRANSCON="$SE_USER:$SE_ROLE:test_access_exploit_t:$SE_MLS"
rlRun "gcc -o map_access map_access.c" 0 \
"Build the test program"
rlRun "chcon -t bin_t map_access" 0 "Relabel the test program"
rlRun "make -f /usr/share/selinux/devel/Makefile test_policy.pp M4PARAM='-D TEST_ROLE=$SE_ROLE -D TEST_TYPE=$SE_TYPE'" 0 \
"Build the test policy"
rlRun "semodule -i test_policy.pp" 0 "Load test policy"
rlRun "mkdir lowerdir upperdir workdir mountpoint" 0 "Create test dirs"
rlRun "touch lowerdir/file_ok lowerdir/file_no_map lowerdir/file_no_read lowerdir/file_no_write" 0 \
"Create test files"
rlRun "chcon -R -t test_lowerfile_t lowerdir workdir upperdir"
rlRun "chcon -t test_lowerfile_no_map_t lowerdir/file_no_map"
rlRun "chcon -t test_lowerfile_no_write_t lowerdir/file_no_write"
rlRun "chcon -t test_lowerfile_no_read_t lowerdir/file_no_read"
rlRun "runcon -t test_mounter_t mount -t overlay none -o 'context=$OVERLAYCON,lowerdir=./lowerdir,upperdir=./upperdir,workdir=./workdir' ./mountpoint" 0 \
"Mount the overlay filesystem"
rlRun ":>/var/log/audit/audit.log; rm -f /var/log/audit/audit.log.*" 0 \
"Clear the audit log"
rlPhaseEnd
rlPhaseStartTest "CVE-2026-46054"
# Bug 1
# Should get below AVC:
# avc: denied { map } for scontext=...test_mounter_t... tcontext=...test_lowerfile_no_map_t... tclass=file
rlRun "runcon -t test_access_full_t ./map_access ./mountpoint/file_no_map RDONLY SHARED" 3 "Test Bug 1"
# Bug 2, result 1
# Shouldn't get below AVC:
# avc: denied { use } for scontext=...test_access_full_t... tcontext=...test_mounter_t... tclass=fd
rlRun "setsebool domain_fd_use 0"
rlRun "runcon -t test_access_full_t ./map_access ./mountpoint/file_ok RDONLY SHARED" 0 "Test Bug 2, result 1"
rlRun "setsebool domain_fd_use 1"
# Bug 2, result 2
# Shouldn't get below AVC:
# avc: denied { read } for scontext=...test_access_full_t... tcontext=...test_lowerfile_t... tclass=file
rlRun "runcon -t test_access_full_t ./map_access ./mountpoint/file_ok RDONLY SHARED" 0 "Test Bug 2, result 2"
# Bug 2, result 3
# Should get below AVC:
# avc: denied { read } for scontext=...test_access_exploit_t... tcontext=...test_mountedfile_t... tclass=file
rlRun "runcon -t test_access_full_t ./map_access ./mountpoint/file_ok RDONLY SHARED $DYNTRANSCON" 5 "Test Bug 2, result 3"
rlPhaseEnd
rlPhaseStartTest "execmem regression"
rlRun "runcon -t test_access_full_t ./map_access ./mountpoint/file_ok RDONLY PRIVATE" 0 "Verify no execmem denied"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "ausearch -i -m avc" 0 "Show AVC denials"
rlRun "umount ./mountpoint"
rlRun "rm -rf lowerdir upperdir workdir mountpoint"
rlRun "semodule -r test_policy" 0 "Unload test policy"
rlRun "make -f /usr/share/selinux/devel/Makefile clean" 0 \
"Clean the test policy"
rlRun "rm -f map_access" 0 "Remove the test program"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -0,0 +1,106 @@
policy_module(test_policy,1.0.0)
type test_lowerfile_t;
files_type(test_lowerfile_t)
type test_lowerfile_no_map_t;
files_type(test_lowerfile_no_map_t)
type test_lowerfile_no_write_t;
files_type(test_lowerfile_no_write_t)
type test_lowerfile_no_read_t;
files_type(test_lowerfile_no_read_t)
type test_mountedfile_t;
files_type(test_mountedfile_t)
type test_mounter_t;
domain_type(test_mounter_t)
allow test_mounter_t self:capability { sys_admin dac_read_search dac_override };
# test_mounter_t has full access to test_lowerfile_t
manage_dirs_pattern(test_mounter_t, test_lowerfile_t, test_lowerfile_t)
manage_files_pattern(test_mounter_t, test_lowerfile_t, test_lowerfile_t)
manage_chr_files_pattern(test_mounter_t, test_lowerfile_t, test_lowerfile_t)
allow test_mounter_t test_lowerfile_t:file map;
# extra permission for execmem regression test
allow test_mounter_t test_lowerfile_t:file { execute };
# test_mounter_t can't map test_lowerfile_t
rw_files_pattern(test_mounter_t, test_lowerfile_no_map_t, test_lowerfile_no_map_t)
# test_mounter_t can't write test_lowerfile_no_write_t
read_files_pattern(test_mounter_t, test_lowerfile_no_write_t, test_lowerfile_no_write_t)
allow test_mounter_t test_lowerfile_no_write_t:file map;
# test_mounter_t can't read test_lowerfile_no_read_t
write_files_pattern(test_mounter_t, test_lowerfile_no_read_t, test_lowerfile_no_read_t)
allow test_mounter_t test_lowerfile_no_read_t:file map;
allow test_mounter_t test_mountedfile_t:dir { getattr setattr };
allow test_mounter_t test_mountedfile_t:filesystem { relabelfrom relabelto mount };
kernel_read_system_state(test_mounter_t)
kernel_read_proc_symlinks(test_mounter_t)
kernel_request_load_module(test_mounter_t)
kernel_search_proc(test_mounter_t)
fs_getattr_xattr_fs(test_mounter_t)
fs_relabelfrom_xattr_fs(test_mounter_t)
mount_entry_type(test_mounter_t)
mount_rw_pid_files(test_mounter_t)
selinux_getattr_fs(test_mounter_t)
files_mounton_all_mountpoints(test_mounter_t)
# Domain with full mountedfile access
type test_access_full_t;
domain_type(test_access_full_t)
manage_dirs_pattern(test_access_full_t, test_mountedfile_t, test_mountedfile_t)
manage_files_pattern(test_access_full_t, test_mountedfile_t, test_mountedfile_t)
allow test_access_full_t test_mountedfile_t:file map;
corecmd_bin_entry_type(test_access_full_t)
# Domain with lowerfile access, but no mountedfile access (exploiting Bug 2)
type test_access_exploit_t;
domain_type(test_access_exploit_t)
manage_files_pattern(test_access_exploit_t, test_lowerfile_t, test_lowerfile_t)
corecmd_bin_entry_type(test_access_exploit_t)
# for dyntransition test_access_full_t -> test_access_exploit_t
allow test_access_full_t self:process { setcurrent };
allow test_access_full_t test_access_exploit_t:process { dyntransition };
# extra permissions for execmem regression test
allow test_access_full_t test_mountedfile_t:file { execute };
allow test_access_full_t self:process { execmem };
attribute test_domain;
typeattribute test_mounter_t test_domain;
typeattribute test_access_full_t test_domain;
typeattribute test_access_exploit_t test_domain;
require {
type TEST_TYPE;
role TEST_ROLE;
}
allow TEST_TYPE test_domain:process transition;
role TEST_ROLE types test_domain;
allow test_domain TEST_TYPE:fd use;
allow test_domain TEST_TYPE:fifo_file rw_inherited_fifo_file_perms;
allow test_domain TEST_TYPE:process { sigchld };
files_search_tmp(test_domain)
term_use_all_terms(test_domain)
userdom_search_user_tmp_dirs(test_domain)

View file

@ -0,0 +1,17 @@
summary: Test that creating a new SELinux context doesn't fail during policy load
description: |
Verifies that there are no ENOMEM errors when the kernel encounters a new
SELinux context during a policy load.
contact: Ondrej Mosnacek <omosnace@redhat.com>
component:
- kernel
framework: beakerlib
require:
- policycoreutils
- diffutils
duration: 10m
tier: 2
enabled: true
link:
- verifies: https://bugzilla.redhat.com/show_bug.cgi?id=1335986
- verifies: https://bugzilla.redhat.com/show_bug.cgi?id=1656787

View file

@ -0,0 +1,36 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# SPDX-License-Identifier: GPLv2
# Copyright (c) 2019-2022 Red Hat, Inc.
# Author: Milos Malik <mmalik@redhat.com>
# Include Beakerlib environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
rlJournalStart
rlPhaseStartSetup
rlRun "uname -r" 0 "Print running kernel version"
rlPhaseEnd
rlPhaseStartTest "bz#1335986 + bz#1656787"
rlRun "dmesg > before.txt"
rlRun "while true; do load_policy; sleep 0.1; done &" 0 \
"Start reloading the policy in a loop"
function runcon_loop() {
for (( i = 0; i < 1024; i++ )); do
runcon -l s0:c$i true || return 1
done
return 0
}
rlRun "runcon_loop" 0 "Run runcon in a loop with varying contexts"
rlRun "dmesg > after.txt"
rlRun "diff before.txt after.txt | grep -e inode_doinit_with_dentry -e context_to_sid" 1
rlPhaseEnd
rlPhaseStartCleanup
rlRun "kill \$(jobs -p)" 0 "Terminate background jobs"
rlRun "wait" 0 "Wait for background jobs to terminate"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -0,0 +1,25 @@
summary: Verify that two-way SCTP association setup doesn't trigger AVCs
description: |
When two SCTP endpoints try to initiate an association
simultaneously with each other, they may hit various corner cases.
This test verifies that this scenario works correctly and that the
resulting association is properly labeled (by peeling it off, which
transfers the label onto the new socket).
contact: Ondrej Mosnacek <omosnace@redhat.com>
component:
- kernel
framework: beakerlib
require:
- make
- gcc
- lksctp-tools-devel
- audit
duration: 10m
tier: 2
enabled: true
adjust+:
- enabled: false
when: distro < rhel-8
because: RHEL-7 and below don't have SCTP SELinux support
link:
- verifies: https://issues.redhat.com/browse/RHEL-48647

View file

@ -0,0 +1,187 @@
// SPDX-License-Identifier: GPLv2
/*
* Copyright (c) 2024 Red Hat, Inc.
* Author: Ondrej Mosnacek <omosnace@redhat.com>
*/
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/sctp.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <unistd.h>
#include <netdb.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
static const char * const TEST_PORTS[] = { "9998", "9999" };
#define ITERATIONS 1000
#define member_size(type, member) sizeof(((type *)0)->member)
#define sizeof_up_to(type, member) (offsetof(type, member) + member_size(type, member))
enum {
PIPE_R = 0,
PIPE_W,
};
int main(int argc, char **argv)
{
int sock, psock, result, flags, index, i, pipefd[2], pipes[2][2];
struct addrinfo hints, *info;
struct sctp_event_subscribe subscr_events;
pid_t fork_pid;
char byte = 0x41, data[1024];
sctp_assoc_t assoc_id;
union sctp_notification *notif;
result = pipe(pipefd);
if (result < 0) {
perror("pipe");
return 1;
}
pipes[0][PIPE_R] = pipefd[0];
pipes[1][PIPE_W] = pipefd[1];
result = pipe(pipefd);
if (result < 0) {
perror("pipe");
return 1;
}
pipes[1][PIPE_R] = pipefd[0];
pipes[0][PIPE_W] = pipefd[1];
fork_pid = fork();
if (fork_pid < 0) {
perror("fork");
return 1;
}
index = !!fork_pid;
close(pipes[!index][PIPE_R]);
close(pipes[!index][PIPE_W]);
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_flags = AI_PASSIVE;
hints.ai_protocol = IPPROTO_SCTP;
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_SEQPACKET;
result = getaddrinfo(NULL, TEST_PORTS[index], &hints, &info);
if (result < 0) {
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(result));
return 1;
}
sock = socket(info->ai_family, info->ai_socktype, info->ai_protocol);
if (sock < 0) {
perror("socket");
return 1;
}
result = bind(sock, info->ai_addr, info->ai_addrlen);
if (result < 0) {
perror("bind");
return 1;
}
if (listen(sock, SOMAXCONN)) {
perror("listen");
return 1;
}
memset(&subscr_events, 0, sizeof(subscr_events));
subscr_events.sctp_association_event = 1;
result = setsockopt(sock, IPPROTO_SCTP, SCTP_EVENTS, &subscr_events,
sizeof_up_to(struct sctp_event_subscribe,
sctp_association_event));
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_protocol = IPPROTO_SCTP;
hints.ai_socktype = SOCK_SEQPACKET;
result = getaddrinfo("127.0.0.1", TEST_PORTS[!index], &hints, &info);
if (result < 0) {
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(result));
return 1;
}
for (i = 0; i < ITERATIONS; i++) {
printf("[%i] ITERATION %i...\n", index, i);
/* synchronize */
result = write(pipes[index][PIPE_W], &byte, 1);
if (result < 0) {
perror("pipe");
return 1;
}
result = read(pipes[index][PIPE_R], &byte, 1);
if (result < 0) {
perror("pipe");
return 1;
}
result = connect(sock, info->ai_addr, info->ai_addrlen);
if (result < 0 && errno != EISCONN) {
perror("connect");
return 1;
}
/* Get assoc_id for sctp_peeloff() */
flags = 0;
result = sctp_recvmsg(sock, data, sizeof(data),
NULL, 0, NULL, &flags);
if (result < 0) {
perror("sctp_recvmsg");
return 1;
}
if ((flags & (MSG_NOTIFICATION | MSG_EOR)) != (MSG_NOTIFICATION | MSG_EOR)) {
fprintf(stderr, "[%i] Invalid sctp_recvmsg response FLAGS: %x\n", index, flags);
return 1;
}
notif = (union sctp_notification *)data;
if (notif->sn_header.sn_type != SCTP_ASSOC_CHANGE) {
fprintf(stderr, "[%i] Invalid sctp_recvmsg response type: %x\n", index, notif->sn_header.sn_type);
return 1;
}
assoc_id = notif->sn_assoc_change.sac_assoc_id;
psock = sctp_peeloff(sock, assoc_id);
if (psock < 0) {
perror("sctp_peeloff");
return 1;
}
data[0] = 42;
result = sctp_sendmsg(psock, data, 1, NULL, 0,
0, 0, 0, 0, 0);
if (result < 0) {
perror("sctp_sendmsg");
return 1;
}
result = sctp_recvmsg(psock, data, sizeof(data),
NULL, 0, NULL, NULL);
if (result < 0) {
perror("sctp_recvmsg");
return 1;
}
if (data[0] != 42) {
fprintf(stderr, "[%i] Invalid sctp_recvmsg response: %d\n", index, (int)data[0]);
return 1;
}
close(psock);
printf("[%i] ITERATION %i SUCCESS!\n", index, i);
}
close(sock);
return 0;
}

View file

@ -0,0 +1,100 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# SPDX-License-Identifier: GPLv2
# Copyright (c) 2024 Red Hat, Inc.
# Author: Ondrej Mosnacek <omosnace@redhat.com>
# Include Beakerlib environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
function installDepsYum() {
local yum="$1"; shift
if "$yum" install --help | grep -q -- --skip-unavailable; then
"$yum" install -y --skip-unavailable $*
elif "$yum" install --help | grep -q -- --skip-broken; then
"$yum" install -y --skip-broken $*
else
for req in $*; do
if ! rpm -q --quiet --whatprovides "$req"; then
"$yum" install -y "$req" || true
fi
done
fi
}
function installDeps() {
if [ -e /run/ostree-booted ]; then
for item in "$@"; do
if ! rpm -q --quiet --whatprovides "$item"; then
rpm-ostree --apply-live -y install "$item"
fi
done
elif type yum >/dev/null; then
installDepsYum yum "$@"
elif type dnf >/dev/null; then
installDepsYum dnf "$@"
fi
}
function check_avc_begin() {
sleep 1.1
date +'%x %T'
sleep 1.1
}
function check_avc_end() {
marker="marker-$RANDOM"
auditctl -m "$marker"
for (( i = 0; i < 100; i++ )); do
if ausearch -i -m user -ts $1 2>/dev/null </dev/null | \
grep -q "$marker"
then
echo $i
break
fi
sleep 0.1
done
ausearch -i -m avc -ts $1 </dev/null
}
rlJournalStart
rlPhaseStartSetup
rlRun "uname -r" 0 "Print kernel version"
# Determine the base kernel package name and version corresponding
# to the currently running kernel. Use this information to derive
# the correct kernel subpackages to install.
if KERNEL_CORE_NVRA="$(rpm -qf "/boot/vmlinuz-$(uname -r)")"; then
KERNEL_CORE_NV="${KERNEL_CORE_NVRA%-*}"
KERNEL_CORE_N="${KERNEL_CORE_NV%-*}"
KERNEL_PKG_VRA="${KERNEL_CORE_NVRA#$KERNEL_CORE_N-}"
KERNEL_PKG_BASE="${KERNEL_CORE_N%-core}"
rlLog "Detected kernel package base name '$KERNEL_PKG_BASE' and version-release.arch '$KERNEL_PKG_VRA'"
rlRun "installDeps $KERNEL_PKG_BASE-modules-extra-$KERNEL_PKG_VRA" 0 "Install extra kernel modules"
else
rlLog "Detected non-RPM running kernel - no extra kernel packages will be installed"
fi
rlRun "gcc -O2 -Wall -o reproducer reproducer.c -lsctp" 0 \
"Compile the reproducer"
rlRun "modprobe sctp" 0 "Ensure SCTP module is loaded"
rlPhaseEnd
rlPhaseStartTest
rlRun "audit_ts=\"\$(check_avc_begin)\""
rlRun "./reproducer" 0 "Run the reproducer"
rlRun "check_avc_end \"\$audit_ts\"" 1 "Check if there are AVC denials"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "rm -f reproducer"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -0,0 +1,8 @@
# Minimal Makefile for standard-test-roles-beakerlib
R="Requires: kernel-modules-extra"
R="RhtsRequires: make gcc lksctp-tools-devel audit kernel-modules"
run:
chmod +x runtest.sh
./runtest.sh

View file

@ -0,0 +1,25 @@
summary: Verify that two-way SCTP association setup doesn't trigger AVCs
description: |
Verify that two-way SCTP association setup doesn't trigger AVCs.
contact: Ondrej Mosnacek <omosnace@redhat.com>
component:
- kernel
framework: beakerlib
require:
- make
- gcc
- lksctp-tools-devel
- audit
- kernel-modules
recommend:
- kernel-modules-extra
duration: 10m
tier: 2
enabled: true
adjust+:
- enabled: false
when: distro < rhel-8
because: RHEL-7 and below don't have SCTP SELinux support
link:
- verifies: https://bugzilla.redhat.com/show_bug.cgi?id=2048251
- verifies: https://bugzilla.redhat.com/show_bug.cgi?id=2015525

View file

@ -0,0 +1,61 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# SPDX-License-Identifier: GPLv2
# Copyright (c) 2022 Red Hat, Inc.
# Author: Ondrej Mosnacek <omosnace@redhat.com>
# Include Beakerlib environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
function check_avc_begin() {
sleep 1.1
date +'%x %T'
sleep 1.1
}
function check_avc_end() {
marker="marker-$RANDOM"
auditctl -m "$marker"
for (( i = 0; i < 100; i++ )); do
if ausearch -i -m user -ts $1 2>/dev/null </dev/null | \
grep -q "$marker"
then
echo $i
break
fi
sleep 0.1
done
ausearch -i -m avc -ts $1 </dev/null
}
rlJournalStart
rlPhaseStartSetup
rlRun "uname -r" 0 "Print kernel version"
for prog in sctp_bz2048251_client sctp_bz2048251_server; do
rlRun "gcc -O2 -Wall -o $prog sctp_common.c $prog.c -lsctp" 0 \
"Compile $prog"
done
rlRun "modprobe sctp" 0 "Ensure SCTP module is loaded"
rlRun "mkfifo flag" 0 "Create a fifo file for test"
rlPhaseEnd
rlPhaseStartTest
rlRun "audit_ts=\"\$(check_avc_begin)\""
rlRun "timeout 30 ./sctp_bz2048251_server -f flag -4 9999 &" 0 "Start the server"
rlRun "read -t 5 <>flag" 0 "Wait for the server to start listening"
rlRun "./sctp_bz2048251_client 127.0.0.1 9999" 0 "Run the client"
rlRun "wait" 0 "Wait for the server to exit"
rlRun "check_avc_end \"\$audit_ts\"" 1 "Check if there are AVC denials"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "rm -f sctp_bz2048251_client sctp_bz2048251_server flag"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -0,0 +1,109 @@
#include "sctp_common.h"
static void usage(char *progname)
{
fprintf(stderr,
"usage: %s [-v] addr port\n"
"\nWhere:\n\t"
"-v Print context and ip options information.\n\t"
"addr IPv4 or IPv6 address (e.g. 127.0.0.1 or ::1).\n\t"
"port Port for accessing server.\n", progname);
exit(1);
}
int main(int argc, char **argv)
{
int opt, sock, result;
struct addrinfo hints, *serverinfo;
bool verbose = false;
struct timeval tm;
socklen_t sinlen;
struct sockaddr_storage sin;
while ((opt = getopt(argc, argv, "v")) != -1) {
switch (opt) {
case 'v':
verbose = true;
break;
default:
usage(argv[0]);
}
}
if ((argc - optind) != 2)
usage(argv[0]);
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_protocol = IPPROTO_SCTP;
hints.ai_socktype = SOCK_SEQPACKET;
result = getaddrinfo(argv[optind], argv[optind + 1], &hints,
&serverinfo);
if (result < 0) {
fprintf(stderr, "Client getaddrinfo: %s\n",
gai_strerror(result));
exit(2);
}
sock = socket(serverinfo->ai_family, serverinfo->ai_socktype,
serverinfo->ai_protocol);
if (sock < 0) {
perror("Client socket");
exit(3);
}
/*
* These timeouts are set to test whether the peer { recv } completes
* or not when the permission is denied.
*/
tm.tv_sec = 4;
tm.tv_usec = 0;
result = setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, &tm, sizeof(tm));
if (result < 0) {
perror("Client setsockopt: SO_SNDTIMEO");
exit(4);
}
result = setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &tm, sizeof(tm));
if (result < 0) {
perror("Client setsockopt: SO_RCVTIMEO");
exit(5);
}
if (listen(sock, SOMAXCONN)) {
perror("Client listen");
close(sock);
exit(1);
}
/* Subscribe to assoc_id events */
result = set_subscr_events(sock, off, on, off, off);
if (result < 0) {
perror("Client setsockopt: SCTP_EVENTS");
return 1;
}
result = open_assoc(sock, serverinfo->ai_addr, serverinfo->ai_addrlen,
verbose);
if (result) {
close(sock);
exit(result);
}
result = receive_assoc(sock, &sin, &sinlen, verbose);
if (result) {
close(sock);
exit(result);
}
result = open_assoc(sock, serverinfo->ai_addr, serverinfo->ai_addrlen,
verbose);
if (result) {
close(sock);
exit(result);
}
close(sock);
exit(0);
}

View file

@ -0,0 +1,132 @@
#include "sctp_common.h"
static void usage(char *progname)
{
fprintf(stderr,
"usage: %s [-4] [-f file] [-v] port\n"
"\nWhere:\n\t"
"-4 Listen on IPv4 addresses only.\n\t"
"-f Write a line to the file when listening starts.\n\t"
" \"nopeer\" message to client, otherwise the peer context\n\t"
" will be retrieved and sent to client.\n\t"
"-v Print context and ip options information.\n\t"
"port Listening port.\n", progname);
exit(1);
}
int main(int argc, char **argv)
{
int opt, sock, result;
socklen_t sinlen;
struct sockaddr_storage sin;
struct addrinfo hints, *res;
char *flag_file = NULL;
bool verbose = false, ipv4 = false;
unsigned short port;
while ((opt = getopt(argc, argv, "4f:v")) != -1) {
switch (opt) {
case '4':
ipv4 = true;
break;
case 'f':
flag_file = optarg;
break;
case 'v':
verbose = true;
break;
default:
usage(argv[0]);
}
}
if ((argc - optind) != 1)
usage(argv[0]);
port = atoi(argv[optind]);
if (!port)
usage(argv[0]);
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_flags = AI_PASSIVE;
hints.ai_protocol = IPPROTO_SCTP;
if (ipv4)
hints.ai_family = AF_INET;
else
hints.ai_family = AF_INET6;
/* sctp_peeloff(3) must be from 1 to Many style socket */
hints.ai_socktype = SOCK_SEQPACKET;
result = getaddrinfo(NULL, argv[optind], &hints, &res);
if (result < 0) {
fprintf(stderr, "Server getaddrinfo: %s\n",
gai_strerror(result));
exit(1);
}
sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
if (sock < 0) {
perror("Server socket");
exit(1);
}
result = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
if (result < 0) {
perror("Server setsockopt: SO_REUSEADDR");
close(sock);
exit(1);
}
result = bind(sock, res->ai_addr, res->ai_addrlen);
if (result < 0) {
perror("Server bind");
close(sock);
exit(1);
}
if (listen(sock, SOMAXCONN)) {
perror("Server listen");
close(sock);
exit(1);
}
/* Subscribe to assoc_id events */
result = set_subscr_events(sock, off, on, off, off);
if (result < 0) {
perror("Client setsockopt: SCTP_EVENTS");
return 1;
}
if (flag_file) {
FILE *f = fopen(flag_file, "w");
if (!f) {
perror("Flag file open");
exit(1);
}
fprintf(f, "listening\n");
fclose(f);
}
result = receive_assoc(sock, &sin, &sinlen, verbose);
if (result) {
close(sock);
exit(result);
}
result = open_assoc(sock, (struct sockaddr *)&sin, sinlen, verbose);
if (result) {
close(sock);
exit(result);
}
result = receive_assoc(sock, &sin, &sinlen, verbose);
if (result) {
close(sock);
exit(result);
}
close(sock);
exit(0);
}

View file

@ -0,0 +1,384 @@
#include "sctp_common.h"
#define member_size(type, member) sizeof(((type *)0)->member)
#define sizeof_up_to(type, member) (offsetof(type, member) + member_size(type, member))
void print_addr_info(struct sockaddr *sin, char *text)
{
struct sockaddr_in *addr4;
struct sockaddr_in6 *addr6;
char addr_str[INET6_ADDRSTRLEN + 1];
switch (sin->sa_family) {
case AF_INET:
addr4 = (struct sockaddr_in *)sin;
inet_ntop(sin->sa_family,
(void *)&addr4->sin_addr,
addr_str, INET6_ADDRSTRLEN + 1);
printf("%s IPv4 addr %s\n", text, addr_str);
break;
case AF_INET6:
addr6 = (struct sockaddr_in6 *)sin;
if (IN6_IS_ADDR_V4MAPPED(&addr6->sin6_addr)) {
inet_ntop(AF_INET,
(void *)&addr6->sin6_addr.s6_addr32[3],
addr_str, INET6_ADDRSTRLEN + 1);
printf("%s IPv6->IPv4 MAPPED addr %s\n",
text, addr_str);
} else if (IN6_IS_ADDR_LINKLOCAL(&addr6->sin6_addr)) {
inet_ntop(sin->sa_family,
(void *)&addr6->sin6_addr,
addr_str, INET6_ADDRSTRLEN + 1);
printf("%s IPv6 local link addr %s scope_id %d\n",
text, addr_str,
((struct sockaddr_in6 *)addr6)->sin6_scope_id);
} else {
inet_ntop(sin->sa_family,
(void *)&addr6->sin6_addr,
addr_str, INET6_ADDRSTRLEN + 1);
printf("%s IPv6 addr %s\n", text,
addr_str);
}
break;
default:
printf("%s Unknown IP family %d\n", text, sin->sa_family);
break;
}
}
int set_subscr_events(int fd, int data_io, int assoc, int addr, int shutd)
{
struct sctp_event_subscribe subscr_events;
memset(&subscr_events, 0, sizeof(subscr_events));
subscr_events.sctp_data_io_event = data_io;
subscr_events.sctp_association_event = assoc;
subscr_events.sctp_address_event = addr;
subscr_events.sctp_shutdown_event = shutd;
/*
* Truncate optlen to just the fields we touch to avoid errors when
* the uapi headers are newer than the running kernel.
*/
return setsockopt(fd, IPPROTO_SCTP, SCTP_EVENTS, &subscr_events,
sizeof_up_to(struct sctp_event_subscribe,
sctp_shutdown_event));
}
/*
* Currently only SCTP_ASSOC_CHANGE, SCTP_PEER_ADDR_CHANGE and
* SCTP_SHUTDOWN_EVENT are enabled via set_subscr_events().
*/
int handle_event(void *buf, char *cmp_addr, sctp_assoc_t *assoc_id,
bool verbose, char *text)
{
union sctp_notification *snp = buf;
char addrbuf[INET6_ADDRSTRLEN];
struct sockaddr_in *sin;
struct sockaddr_in6 *sin6;
const char *ap;
struct sctp_paddr_change *spc;
struct sctp_assoc_change *sac;
struct sctp_remote_error *sre;
struct sctp_send_failed *ssf;
struct sctp_authkey_event *auth_event;
switch (snp->sn_header.sn_type) {
case SCTP_ASSOC_CHANGE:
sac = &snp->sn_assoc_change;
if (verbose)
printf("%s SCTP_ASSOC_CHANGE event for assoc_id: %d ERR: 0x%x\n",
text, sac->sac_assoc_id, sac->sac_error);
if (assoc_id)
*assoc_id = sac->sac_assoc_id;
break;
case SCTP_PEER_ADDR_CHANGE:
spc = &snp->sn_paddr_change;
if (verbose)
/*
* Not all spc_error codes are errors - linux/sctp.h
* (e.g. SCTP_HEARTBEAT_SUCCESS = 0x02)
*/
printf("%s SCTP_PEER_ADDR_CHANGE event for assoc_id: %d ERR: 0x%x\n",
text, spc->spc_assoc_id, spc->spc_error);
if (spc->spc_aaddr.ss_family == AF_INET) {
sin = (struct sockaddr_in *) &spc->spc_aaddr;
ap = inet_ntop(AF_INET, &sin->sin_addr, addrbuf,
INET6_ADDRSTRLEN);
} else {
sin6 = (struct sockaddr_in6 *) &spc->spc_aaddr;
ap = inet_ntop(AF_INET6, &sin6->sin6_addr, addrbuf,
INET6_ADDRSTRLEN);
}
if (verbose) /* Print additional address details */
print_addr_info((struct sockaddr *)&spc->spc_aaddr,
"Peer Address change:\n\t");
switch (spc->spc_state) {
case SCTP_ADDR_AVAILABLE:
if (verbose)
printf("\t%s is available\n", text);
break;
case SCTP_ADDR_UNREACHABLE:
if (verbose)
printf("\t%s is not available - Error: 0x%x\n",
text, spc->spc_error);
break;
case SCTP_ADDR_REMOVED:
if (verbose)
printf("\t%s was removed\n", text);
break;
case SCTP_ADDR_ADDED:
if (verbose)
printf("\t%s was added\n", text);
break;
case SCTP_ADDR_MADE_PRIM:
if (verbose)
printf("\t%s is primary\n", text);
if (cmp_addr) {
if (!strcmp(ap, cmp_addr)) {
if (verbose)
printf("\t%s and is now the new primary\n", text);
return EVENT_ADDR_MATCH;
}
}
break;
case SCTP_ADDR_CONFIRMED:
if (verbose)
printf("\t%s is confirmed\n", text);
break;
default:
if (verbose)
printf("%s unknown state: %d\n", text,
spc->spc_state);
break;
}
break;
case SCTP_SEND_FAILED:
ssf = &snp->sn_send_failed;
if (verbose)
printf("%s SCTP_SEND_FAILED event assoc_id: %d ERR: 0x%x\n",
text, ssf->ssf_assoc_id, ssf->ssf_error);
break;
case SCTP_REMOTE_ERROR:
sre = &snp->sn_remote_error;
if (verbose) /* Error in network byte order - linux/sctp.h */
printf("%s SCTP_REMOTE_ERROR event ERR: 0x%x\n",
text, ntohs(sre->sre_error));
break;
case SCTP_SHUTDOWN_EVENT:
if (verbose)
printf("%s SCTP_SHUTDOWN_EVENT\n", text);
return EVENT_SHUTDOWN;
case SCTP_PARTIAL_DELIVERY_EVENT:
if (verbose)
printf("%s SCTP_PARTIAL_DELIVERY_EVENT\n", text);
break;
case SCTP_ADAPTATION_INDICATION:
if (verbose)
printf("%s SCTP_ADAPTATION_INDICATION event\n", text);
break;
case SCTP_AUTHENTICATION_INDICATION:
auth_event = &snp->sn_authkey_event;
if (verbose) {
printf("%s SCTP_AUTHENTICATION_INDICATION event\n"
"\tauth_event->auth_type: 0x%x\n"
"\tauth_event->auth_flags: 0x%x\n"
"\tauth_event->auth_length: 0x%x\n"
"\tauth_event->auth_keynumber: 0x%x\n"
"\tauth_event->auth_indication: 0x%x\n"
"\tauth_event->auth_assoc_id: %d\n",
text, auth_event->auth_type,
auth_event->auth_flags,
auth_event->auth_length,
auth_event->auth_keynumber,
auth_event->auth_indication,
auth_event->auth_assoc_id);
}
/* SCTP_AUTH_NO_AUTH defined in linux/sctp.h */
if (auth_event->auth_indication == SCTP_AUTH_NO_AUTH)
return EVENT_NO_AUTH;
break;
case SCTP_SENDER_DRY_EVENT:
if (verbose)
printf("%s SCTP_SENDER_DRY_EVENT\n", text);
break;
case SCTP_STREAM_RESET_EVENT:
if (verbose)
printf("%s SCTP_STREAM_RESET_EVENT\n", text);
break;
case SCTP_ASSOC_RESET_EVENT:
if (verbose)
printf("%s SCTP_ASSOC_RESET_EVENT\n", text);
break;
case SCTP_STREAM_CHANGE_EVENT:
if (verbose)
printf("%s SCTP_STREAM_CHANGE_EVENT\n", text);
break;
case SCTP_SEND_FAILED_EVENT:
if (verbose)
printf("%s SCTP_SEND_FAILED_EVENT\n", text);
break;
default:
fprintf(stderr, "%s unknown event: 0x%x\n", text,
snp->sn_header.sn_type);
break;
}
return EVENT_OK;
}
int receive_assoc(int sock, struct sockaddr_storage *sin, socklen_t *sinlen,
int verbose)
{
int result, peeloff_sk = 0, flags;
sctp_assoc_t assoc_id = 0;
char *peerlabel, msglabel[256];
*sinlen = sizeof(*sin);
flags = 0;
result = sctp_recvmsg(sock, msglabel, sizeof(msglabel),
(struct sockaddr *)sin, sinlen,
NULL, &flags);
if (result < 0) {
perror("Server sctp_recvmsg-1");
return 1;
}
if (verbose)
print_addr_info((struct sockaddr *)sin,
"Server SEQPACKET recvmsg");
if (!(flags & MSG_NOTIFICATION) || !(flags & MSG_EOR)) {
printf("Invalid sctp_recvmsg response FLAGS: %x\n",
flags);
return 1;
}
handle_event(msglabel, NULL, &assoc_id,
verbose, "Peeloff Server");
if (assoc_id <= 0) {
printf("Server Invalid association ID: %d\n",
assoc_id);
return 1;
}
peeloff_sk = sctp_peeloff(sock, assoc_id);
if (peeloff_sk < 0) {
perror("Server sctp_peeloff");
return 1;
}
if (verbose) {
printf("Server sctp_peeloff(3) on sk: %d with association ID: %d\n",
peeloff_sk, assoc_id);
}
/* Now get the client msg on peeloff socket */
result = sctp_recvmsg(peeloff_sk, msglabel, sizeof(msglabel),
(struct sockaddr *)sin, sinlen,
NULL, &flags);
if (result < 0) {
perror("Server sctp_recvmsg-2");
close(peeloff_sk);
return 1;
}
if (verbose) {
print_addr_info((struct sockaddr *)sin,
"Server SEQPACKET peeloff recvmsg");
printf("peeloff association ID: %d\n",
assoc_id);
}
peerlabel = strdup("nopeer");
printf("Server PEELOFF peer label: %s\n", peerlabel);
result = sctp_sendmsg(peeloff_sk, peerlabel,
strlen(peerlabel),
NULL, 0,
0, 0, 0, 0, 0);
if (result < 0) {
perror("Server sctp_sendmsg");
close(peeloff_sk);
close(sock);
exit(1);
}
if (verbose)
printf("Server PEELOFF sent: %s\n", peerlabel);
free(peerlabel);
close(peeloff_sk);
return 0;
}
int open_assoc(int sock, struct sockaddr *sin, socklen_t sinlen,
int verbose)
{
int result, peeloff_sk = 0, flags;
sctp_assoc_t assoc_id = 0;
char byte = 0x41, label[1024];
/* otherwise we might connect too fast */
sleep(1);
result = connect(sock, sin, sinlen);
if (result < 0) {
perror("Client connect");
return 1;
}
/* Get assoc_id for sctp_peeloff() */
flags = 0;
result = sctp_recvmsg(sock, label, sizeof(label),
NULL, 0, NULL, &flags);
if (result < 0) {
perror("Client sctp_recvmsg-1");
return 1;
}
if ((flags & (MSG_NOTIFICATION | MSG_EOR)) != (MSG_NOTIFICATION | MSG_EOR)) {
printf("Invalid sctp_recvmsg response FLAGS: %x\n", flags);
return 1;
}
handle_event(label, NULL, &assoc_id, verbose, "Peeloff Client");
if (assoc_id <= 0) {
printf("Client Invalid association ID: %d\n", assoc_id);
return 1;
}
peeloff_sk = sctp_peeloff(sock, assoc_id);
if (peeloff_sk < 0) {
perror("Client sctp_peeloff");
return 1;
}
result = sctp_sendmsg(peeloff_sk, &byte, 1, NULL, 0,
0, 0, 0, 0, 0);
if (result < 0) {
perror("Client sctp_sendmsg");
close(peeloff_sk);
return 1;
}
result = sctp_recvmsg(peeloff_sk, label, sizeof(label),
NULL, 0, NULL, NULL);
if (result < 0) {
perror("Client sctp_recvmsg");
close(peeloff_sk);
return 1;
}
close(peeloff_sk);
return 0;
}

View file

@ -0,0 +1,38 @@
#ifndef _GNU_SOURCE
#define _GNU_SOURCE /* For poll(2) POLLRDHUP - Detect client close(2) */
#endif
#include <arpa/inet.h>
#include <sys/poll.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/sctp.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <stdbool.h>
#include <errno.h>
enum event_ret {
EVENT_OK,
EVENT_ADDR_MATCH,
EVENT_SHUTDOWN,
EVENT_NO_AUTH
};
void print_addr_info(struct sockaddr *sin, char *text);
int set_subscr_events(int fd, int data_io, int assoc, int addr, int shutd);
int handle_event(void *buf, char *cmp_addr, sctp_assoc_t *assoc_id,
bool verbose, char *text);
static const int on = 1, off = 0;
int receive_assoc(int sock, struct sockaddr_storage *sin, socklen_t *sinlen,
int verbose);
int open_assoc(int sock, struct sockaddr *sin, socklen_t sinlen, int verbose);

View file

@ -1,10 +1,24 @@
path: /kernel/selinux-testsuite
summary: Wrapper for selinux-testuite
description: |
This TC runs a functional test suite for the LSM-based SELinux security module.
duration: 60m
tier: 2
adjust:
- enabled: false
when: distro < rhel-5
contact: Milos Malik <mmalik@redhat.com>
component:
- kernel
- selinux-policy
framework: beakerlib
duration: 1h
tier: 1
enabled: true
tag:
- fusa
adjust+:
- enabled: false
when: distro < rhel-6
- enabled: false
when: arch = i386
environment:
AVC_ERROR: +no_avc_check
check:
- how: avc
result: xfail
id: f491d519-a7cd-4acf-8405-67a6afcc678a

View file

@ -35,7 +35,7 @@ PACKAGE="selinux-policy"
# This should be updated as needed after verifying that the new version
# doesn't break testing and after applying all necessary tweaks in the TC.
# Run with GIT_BRANCH=master to run the latest upstream version.
DEFAULT_COMMIT="24bb5c0090710767ff187f1682e5bf355166caa3"
DEFAULT_COMMIT="72e60b6018321a3da9d5e328477e29ee7366e498"
# Default pull requests to merge before running the test.
# If non-empty, then after checking out GIT_BRANCH the listed upstream pull
# requests (by number) are merged, creating a new temporary local branch.
@ -44,7 +44,7 @@ DEFAULT_PULLS=""
DEFAULT_PATCHES=""
# Optional test parameter - location of testuite git.
GIT_URL=${GIT_URL:-"git://github.com/SELinuxProject/selinux-testsuite"}
GIT_URL=${GIT_URL:-"https://github.com/SELinuxProject/selinux-testsuite"}
# Optional test parameter - timeout for detecting lost packets
NETWORK_TIMEOUT=${NETWORK_TIMEOUT:-4}
@ -70,27 +70,21 @@ else
PIPEFAIL_DISABLE=""
fi
if rlIsRHEL 5 ; then
# On RHEL-5 sort -V doesn't work, so just pretend we have the oldest kernel
function kver_ge() { false; }
function kver_lt() { true; }
function kver_le() { true; }
function kver_gt() { false; }
else
function version_le() {
{ echo "$1"; echo "$2"; } | sort -V | tail -n 1 | grep -qx "$2"
}
function version_le() {
{ echo "$1"; echo "$2"; } | sort -V | tail -n 1 | grep -qx "$2"
}
function kver_ge() { version_le "$1" "$(uname -r)"; }
function kver_lt() { ! kver_ge "$1"; }
function kver_le() { version_le "$(uname -r)" "$1"; }
function kver_gt() { ! kver_le "$1"; }
fi
function kver_ge() { version_le "$1" "$(uname -r)"; }
function kver_lt() { ! kver_ge "$1"; }
function kver_le() { version_le "$(uname -r)" "$1"; }
function kver_gt() { ! kver_le "$1"; }
function installDepsYum() {
local yum="$1"; shift
if "$yum" --help | grep -q -- --skip-broken; then
if "$yum" install --help | grep -q -- --skip-unavailable; then
"$yum" install -y --skip-unavailable $*
elif "$yum" install --help | grep -q -- --skip-broken; then
"$yum" install -y --skip-broken $*
else
for req in $*; do
@ -102,7 +96,13 @@ function installDepsYum() {
}
function installDeps() {
if type yum >/dev/null; then
if [ -e /run/ostree-booted ]; then
for item in "$@"; do
if ! rpm -q --quiet --whatprovides "$item"; then
rpm-ostree --apply-live -y install "$item"
fi
done
elif type yum >/dev/null; then
installDepsYum yum "$@"
elif type dnf >/dev/null; then
installDepsYum dnf "$@"
@ -121,25 +121,34 @@ function boolSet() {
rlJournalStart
rlPhaseStartSetup "Install"
# Determine the base kernel package name and version corresponding
# to the currently running kernel. Use this information to derive
# the correct kernel subpackages to install.
if KERNEL_CORE_NVRA="$(rpm -qf "/boot/vmlinuz-$(uname -r)")"; then
KERNEL_CORE_NV="${KERNEL_CORE_NVRA%-*}"
KERNEL_CORE_N="${KERNEL_CORE_NV%-*}"
KERNEL_PKG_VRA="${KERNEL_CORE_NVRA#$KERNEL_CORE_N-}"
KERNEL_PKG_BASE="${KERNEL_CORE_N%-core}"
rlLog "Detected kernel package base name '$KERNEL_PKG_BASE' and version-release.arch '$KERNEL_PKG_VRA'"
KERNEL_PKGS="
$KERNEL_PKG_BASE-modules-extra-$KERNEL_PKG_VRA
$KERNEL_PKG_BASE-devel-$KERNEL_PKG_VRA
"
else
rlLog "Detected non-RPM running kernel - no extra kernel packages will be installed"
KERNEL_PKGS=""
fi
# We need to install the kernel-* packages by ourselves, since we need
# the same versions as the running kernel. And since we already need a
# reliable package install function, let's just install all the
# dependencies here. Thus we don't need to maintain duplicate lists of
# package requirements in many places (RH repo, Fedora kernel dist-git,
# CKI).
PKG_SUFFIX=""
KERNEL_VERSION="$(uname -r)"
PKG_VERSION="${KERNEL_VERSION%+debug}"
if [ "$PKG_VERSION" != "$KERNEL_VERSION" ]; then
rlLog "Detected debug kernel running."
PKG_SUFFIX="-debug"
fi
REQUIRES="
kernel$PKG_SUFFIX-modules-extra-$PKG_VERSION
kernel-rt$PKG_SUFFIX-modules-extra-$PKG_VERSION
kernel$PKG_SUFFIX-devel-$PKG_VERSION
kernel-rt$PKG_SUFFIX-devel-$PKG_VERSION
$KERNEL_PKGS
/usr/bin/unbuffer
attr
audit
@ -180,13 +189,12 @@ rlJournalStart
rdma-core-devel
selinux-policy-devel
setools-console
which
xfsprogs-devel
"
rlRun "installDeps \$REQUIRES" 0 "Install requires"
# The CRB repo with libbpf-devel might not be enabled on RHEL
if rlIsRHEL '>=8'; then
if rlIsRHEL '>=8' && ! [ -e /run/ostree-booted ]; then
for repo in "rhel-CRB" "beaker-CRB"; do
rpm -q libbpf-devel &>/dev/null && break
rlRun "dnf install --enablerepo $repo -y libbpf-devel" 0-255
@ -198,18 +206,15 @@ rlJournalStart
rlAssertRpm ${PACKAGE}
rlAssertRpm audit
rlFileBackup /etc/selinux/semanage.conf
# running the testsuite in /tmp causes permission denied messages
# rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
# rlRun "pushd $TmpDir"
# run the testsuite in /root to avoid problems with other paths
rlRun "pushd /root"
if ! rlIsRHEL 5 ; then
# version_le() sanity check:
rlRun "version_le 4.10 4.10"
rlRun "version_le 4.10 4.10.0"
rlRun "version_le 4.10 4.10.1"
rlRun "! version_le 4.10 4.9"
rlRun "! version_le 4.10.0 4.10"
fi
# version_le() sanity check:
rlRun "version_le 4.10 4.10"
rlRun "version_le 4.10 4.10.0"
rlRun "version_le 4.10 4.10.1"
rlRun "! version_le 4.10 4.9"
rlRun "! version_le 4.10.0 4.10"
if [ -d /sys/fs/selinux ]; then
selinuxfs=/sys/fs/selinux
@ -258,24 +263,23 @@ rlJournalStart
for pull in $GIT_PULLS; do
ref="refs/pull/$pull/head"
if ! rlRun "git fetch origin $ref:$ref" 0; then
rlRun "git checkout $GIT_BRANCH" 0
rlLogWarning "PR merge failed, falling back to GIT_BRANCH"
break
rlLogFatal "PR merge failed!"
rlPhaseEnd
exit 127
fi
if ! rlRun "git merge --no-edit $ref" 0; then
rlRun "git merge --abort" 0
rlRun "git checkout $GIT_BRANCH" 0
rlLogWarning "PR merge failed, falling back to GIT_BRANCH"
break
rlLogFatal "PR merge failed!"
rlPhaseEnd
exit 127
fi
done
$PIPEFAIL_ENABLE
for pwseries in $GIT_PATCHES; do
url="https://patchwork.kernel.org/series/$pwseries/mbox/"
if ! rlRun "curl $url | git am -"; then
rlRun "git checkout $GIT_BRANCH" 0
rlLogWarning "Applying patch failed, falling back to GIT_BRANCH"
break
rlLogFatal "Applying patch failed!"
rlPhaseEnd
exit 127
fi
done
$PIPEFAIL_DISABLE
@ -305,34 +309,49 @@ rlJournalStart
} | rlRun "tee -a tests/tun_tap/tun_common.h" 0 \
"Harden tun_tap test against missing defs"
# needed to avoid a flood of AVCs when run via restraint
# (RHEL-6 doesn't have unconfined_service_t)
if ! rlIsRHEL '<7'; then
rlRun "sed -i 's/type unconfined_t;/type unconfined_t, unconfined_service_t;/' policy/test_policy.if" 0
rlRun "sed -i 's/\\(allow \\\$1 initrc_t:fd use;\\)/\\1 allow \$1 unconfined_service_t:fd use;/' policy/test_policy.if" 0
else
rlRun "sed -i '/install_t/d' policy/test_policy.if" 0
"RHEL 6 doesn't have install_t"
fi
exclude_tests=""
force_tests=""
for file in ./tests/nnp*/execnnp.c; do
rlRun "sed -i 's/3.18/3.9/' $file" 0 \
rlRun "sed -i 's/3\.18/3.9/' $file" 0 \
"Fix up kernel version in nnp test"
done
if rlIsRHEL 5 ; then
rlRun "sed -i '/unconfined_devpts_t/d' policy/test_policy.if" 0
rlRun "sed -i 's/read_file_perms/r_file_perms/' policy/*.te" 0
rlRun "sed -i 's/mmap_file_perms/rx_file_perms/' policy/*.te" 0
rlRun "sed -i 's/list_dir_perms/r_dir_perms/' policy/*.te" 0
rlRun "sed -i 's/ open / /' policy/*.te" 0
rlRun "sed -i 's/^sysadm_bin_spec_domtrans_to/userdom_sysadm_bin_spec_domtrans_to/' policy/*.te" 0
rlRun "sed -i 's/^corecmd_exec_bin(\(.*\))$/corecmd_exec_bin(\1)\ncorecmd_exec_sbin(\1)/' policy/*.te" 0
rlRun "sed -i 's/^corecmd_bin_entry_type(\(.*\))$/corecmd_bin_entry_type(\1)\ncorecmd_sbin_entry_type(\1)/' policy/*.te" 0
rlRun "sed -i 's/^userdom_search_user_home_dirs(\(.*\))$/userdom_search_user_home_dirs(user, \1)/' policy/*.te" 0
fi
if rlIsRHEL "<8.2"; then
rlRun "sed -i '/SUBDIRS += bpf/d;/export CFLAGS += -DHAVE_BPF/d' tests/Makefile" 0 \
"RHEL < 8.2 doesn't ship libbpf => disable BPF subtests"
fi
if rlIsRHEL "<9"; then
# CONFIG_KEY_DH_OPERATIONS not enabled on RHEL-8 :(
# on RHEL-7, KEYCTL_DH_COMPUTE is not defined in the header
exclude_tests+=" keys"
fi
rlRun "sed -i 's/tm\.tv_sec = [0-9]*;/tm.tv_sec = $NETWORK_TIMEOUT;/' ./tests/*/*.c" 0 \
"Tweak timeout in networking tests" # 2 secs is too little for SCTP test
if [ -e /run/ostree-booted ]; then
# Fixed by https://github.com/fedora-selinux/selinux-policy/pull/2029,
# but may not be in all distro streams.
rlRun "tee -a policy/test_global.te" 0 \
"Work around missing policy rules" <<EOF
gen_require(\`
attribute domain;
type install_t;
')
allow domain install_t:fd use;
EOF
fi
if rlIsRHEL; then
if kver_lt "3.10.0-349"; then
# c4684bbdac07 [security] selinux: Permit bounded transitions under NO_NEW_PRIVS or NOSUID
@ -343,7 +362,7 @@ rlJournalStart
if kver_lt "3.10.0-693"; then
# I don't know when exactly these tests start passing, so I'm just
# disabling them for anything below the RHEL-7.4 kernel...
exclude_tests+=" inet_socket"
exclude_tests+=" inet_socket/tcp inet_socket/udp"
exclude_tests+=" filesystem/ext4 filesystem/xfs filesystem/jfs filesystem/vfat"
fi
@ -362,6 +381,12 @@ rlJournalStart
rlRun "cat >>policy/test_mmap.te <<<'allow_map(test_no_execmem_t, tmpfs_t, file)'"
fi
# work around non-functional ext4 native quota support on
# RHEL-7
if kver_lt 4.18; then
rlRun "sed -i 's/3.6/4.18/g' tests/{fs_,}filesystem/test"
fi
if kver_ge 4.18; then
force_tests+=" sctp"
fi
@ -376,18 +401,61 @@ rlJournalStart
rlRun "sed -i 's/SCTP_SEND_FAILED_EVENT/SCTP_STREAM_CHANGE_EVENT + 1/g' tests/sctp/*.c" 0 \
"Fix SCTP test compilation on old RHEL kernels"
fi
# CONFIG_KEYS_DH_COMPUTE not enabled on RHEL-8 :(
exclude_tests+=" keys"
if kver_lt 4.18.0-252; then
# 8a4d5985551b [security] selinux: Add xfs quota command types
script1='s/\$test_count += 62;/$test_count = 55;/g'
script2='s/\$quota_checks += 1;/$quota_checks = 0;/g'
# for some reason this is needed for older RHEL 7 versions...
script3='s/\$test_count += 69;/$test_count = 55;/g'
rlRun "sed -i -E -e '$script1' -e '$script2' -e '$script3' tests/filesystem/test" 0 \
"Apply workaround for missing XFS quota checks"
fi
if kver_lt 4.18.0-314; then
# a17f0671017f selinux: vsock: Set SID for socket returned by accept()
exclude_tests+=" vsock_socket"
fi
# Needs:
# e4cfa05e9bfe ("selinux: Add xfs quota command types")
# (not backported to any RHEL at this point - TODO update the check once it is)
script1='s/\$test_count += 62;/$test_count = 55;/g'
script2='s/\$quota_checks += 1;/$quota_checks = 0;/g'
# for some reason this is needed for older RHEL 7 versions...
script3='s/\$test_count += 69;/$test_count = 55;/g'
rlRun "sed -i -E -e '$script1' -e '$script2' -e '$script3' tests/filesystem/test" 0 \
"Apply workaround for missing XFS quota checks"
sctp_client_peeloff=0
if kver_ge 4.18.0-305.39.1 && kver_lt 4.18.0-306; then
sctp_client_peeloff=1
fi
if kver_ge 4.18.0-348.19.1 && kver_lt 4.18.0-349; then
sctp_client_peeloff=1
fi
if kver_ge 4.18.0-372.1.1 && kver_lt 5.14; then
sctp_client_peeloff=1
fi
if kver_ge 5.14.0-70.15.1 && kver_lt 5.14.0-71; then
sctp_client_peeloff=1
fi
if kver_ge 5.14.0-84; then
sctp_client_peeloff=1
fi
if [ "$sctp_client_peeloff" -eq 1 ]; then
rlRun "sed -i 's/5\.18/4.18/g' tests/sctp/test" 0 \
"Fix up kernel version in sctp test"
fi
# TODO: wait for 786fc12457268cc9b555dde6c22ae7300d4b40e1
# to be backported
#if kver_ge 5.14.0-326; then
# force_tests+=" inet_socket/mptcp"
#fi
if ! grep -q 'CONFIG_SCSI_ISCSI_ATTRS=y' "/lib/modules/$(uname -r)/config"; then
rlRun "sed -i -e 's/runcon -t test_netlink_iscsi_socket_t/true/' \
-e 's/runcon -t test_no_netlink_iscsi_socket_t/false/' \
tests/netlink_socket/test" 0 \
"Apply workaround for disabled CONFIG_SCSI_ISCSI_ATTRS"
fi
if ! grep -q 'CONFIG_QFMT_V2=y' "/lib/modules/$(uname -r)/config"; then
# patch the filesystem tests to not do quota tests on ext4
rlRun "sed -i -e 's/\`uname -r\`/\"3.0\"/' \
-e 's/\\(elsif ( \$fs_type eq \"nfs4\" or \$fs_type eq \"nfs\"\\)/\\1 or \$fs_type eq \"ext4\"/' \
tests/filesystem/test tests/fs_filesystem/test" 0 \
"Apply workaround for disabled CONFIG_QFMT_V2"
fi
fi
# CKI mainline kernels don't ship with module build infrastructure
@ -415,24 +483,6 @@ rlJournalStart
"Force applicable tests: $force_tests"
fi
if ! modprobe sctp 2>/dev/null; then
script1='s/runcon -t test_sctp_socket_t/true/g'
script2='s/runcon -t test_no_sctp_socket_t/false/g'
rlRun "sed -i -e '$script1' -e '$script2' ./tests/extended_socket_class/test" 0 \
"No SCTP support => fix up extended_socket_class test"
fi
# on aarch64 and s390x the kernel support for Bluetooth is turned
# off so we disable the Bluetooth socket tests there
case "$(rlGetPrimaryArch)" in
aarch64|s390x)
script1='s/runcon -t test_bluetooth_socket_t/true/g'
script2='s/runcon -t test_no_bluetooth_socket_t/false/g'
rlRun "sed -i -e '$script1' -e '$script2' ./tests/extended_socket_class/test" 0 \
"No Bluetooth support => fix up extended_socket_class test"
;;
esac
# Initialize report.
rlRun "echo 'Remote: $GIT_URL' >results.log" 0
rlRun "echo 'Branch: $GIT_BRANCH' >>results.log" 0
@ -483,6 +533,8 @@ rlJournalStart
rlRun "sleep 5" 0
rlRun "dmesg | grep -i \"rcu_sched detected stalls\"" 1
rlRun "popd" 0 "Leave /root"
rlFileRestore
rlPhaseEnd
rlJournalPrintText

View file

@ -0,0 +1,18 @@
summary: Test soft lockup on selinuxfs dentry lookup
description: |
Verifies that traversing selinuxfs while policy is being reloaded doesn't
cause a deadlock in the kernel.
contact: Ondrej Mosnacek <omosnace@redhat.com>
component:
- kernel
framework: beakerlib
require:
- policycoreutils
- findutils
duration: 5m
tier: 2
enabled: true
link:
- verifies: https://bugzilla.redhat.com/show_bug.cgi?id=1510603
extra-hardware: |
keyvalue = PROCESSORS >= 2

View file

@ -0,0 +1,37 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# SPDX-License-Identifier: GPLv2
# Copyright (c) 2022 Red Hat, Inc.
# Author: Ondrej Mosnacek <omosnace@redhat.com>
# Include Beakerlib environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
rlJournalStart
rlPhaseStartSetup
rlRun "uname -r" 0 "Print running kernel version"
rlPhaseEnd
rlPhaseStartTest
rlAssertGreaterOrEqual "Ensure the machine has at least two cores" \
"$(nproc)" 2
rlRun "(cd /sys/fs/selinux; while true; do find >/dev/null 2>&1; done) &"
rlRun "while true; do load_policy; sleep 0.1; done &"
function check_soft_lockup() {
for (( i = 0; i < 60; i++ )); do
dmesg | grep 'BUG: soft lockup' && return 1
sleep 1
done
return 0
}
rlRun "check_soft_lockup" 0 "Wait and see if soft lockup appears in dmesg"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "kill \$(jobs -p)" 0 "Terminate background jobs"
rlRun "wait" 0 "Wait for background jobs to terminate"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -0,0 +1,7 @@
# Minimal Makefile for standard-test-roles-beakerlib
R="RhtsRequires: audit policycoreutils"
run:
chmod +x runtest.sh
TEST=/SELinux/kernel/setsebool-deadlock ./runtest.sh

View file

@ -0,0 +1,23 @@
summary: Regression test for deadlock when changing booleans
description: |
Verify that setting booleans with SELinux audit exclude rules present
doesn't deadlock itself.
WARNING: This test will lockup the machine if the bug is present!
https://bugzilla.redhat.com/show_bug.cgi?id=1924230
contact: Ondrej Mosnacek <omosnace@redhat.com>
component:
- kernel
framework: beakerlib
require:
- audit
- policycoreutils
duration: 5m
tier: 3
enabled: true
adjust+:
- enabled: false
when: distro < fedora-34
because: some kernels on Fedora 33 and below don't have the fix
- enabled: false
when: distro ~< rhel-8.4
because: not expected to be fixed in RHEL-8 below 8.4

View file

@ -0,0 +1,43 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# SPDX-License-Identifier: GPLv2
# Copyright (c) 2021 Red Hat, Inc.
# Author: Ondrej Mosnacek <omosnace@redhat.com>
# Include Beakerlib environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
function boolGet() {
getsebool "$1" | cut -d ' ' -f 3
}
function boolSet() {
getsebool "$1" &>/dev/null || return 0
setsebool "$1" "$2" || return 1
[ "$(boolGet "$1")" == "$2" ]
}
TEST_BOOLEAN="domain_can_mmap_files"
rlJournalStart
rlPhaseStartSetup
rlRun "bool_default=\$(boolGet domain_can_mmap_files)" 0 \
"Get the initial boolean value"
rlRun "auditctl -a exclude,never -F subj_user=sysadm_u" 0 \
"Add an audit rule that triggers the bug"
rlPhaseEnd
rlPhaseStartTest
rlRun "setsebool domain_can_mmap_files $(( 1 - $bool_default )) &" 0 \
"Start setsebool in the background (it may hang)"
rlRun "sleep 5s" 0 "Give it a grace period of 5 seconds"
rlRun "test \$(jobs -r | wc -l) -eq 0" 0 "Check that it has exited"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "auditctl -d exclude,never -F subj_user=sysadm_u" 0 \
"Remove the audit rule"
rlRun "boolSet domain_can_mmap_files $bool_default" 0 \
"Restore the boolean value"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -8,7 +8,9 @@ component:
- kernel
framework: beakerlib
require:
- library(distribution/epel)
- type: library
url: https://github.com/beakerlib/epel.git
name: /epel
- /usr/bin/nc
- perf
- git
@ -18,12 +20,16 @@ require:
recommend:
- /usr/sbin/hping3
duration: 1h
enabled: true
# currently disabled due to being unreliable
enabled: false
tier: 3
adjust:
enabled: false
adjust+:
- enabled: false
when: distro < rhel-8
because: The test doesn't work well on RHEL-7
- enabled: false
when: arch = s390x
because: No machines likely available with required HW configuration
extra-hardware: |
keyvalue = PROCESSORS >= 64
hostrequire = <system><numanodes op="&gt;" value="1"/></system>

View file

@ -7,6 +7,9 @@
# Include Beakerlib environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
# Set this parameter to 1 to also generate a flamegraph.
GENERATE_FLAMEGRAPH="${GENERATE_FLAMEGRAPH:-0}"
TEST_PORT=8080
FG_URL="https://github.com/brendangregg/FlameGraph"
@ -26,13 +29,15 @@ if [ $(nproc) -lt 64 ]; then
rlPhaseEnd
else
rlPhaseStartSetup
rlImport "distribution/epel"
rlImport "epel/epel"
rlRun "command -v hping3 || epelyum install -y hping3" 0 \
"Make sure hping3 is installed (EPEL-only on RHEL)"
rlRun "uname -r"
rlRun "git clone $FG_URL $FG_DIR"
if [ "$GENERATE_FLAMEGRAPH" != 0 ]; then
rlRun "git clone $FG_URL $FG_DIR"
fi
rlPhaseEnd
rlPhaseStartTest
@ -64,10 +69,14 @@ else
rlPhaseEnd
rlPhaseStartCleanup
rlRun "perf script -i perf.data | $FG_DIR/stackcollapse-perf.pl | $FG_DIR/flamegraph.pl > flamegraph.svg"
if [ "$GENERATE_FLAMEGRAPH" != 0 ]; then
rlRun "perf script -i perf.data | $FG_DIR/stackcollapse-perf.pl | $FG_DIR/flamegraph.pl > flamegraph.svg"
rlFileSubmit "flamegraph.svg"
rlRun "rm -f flamegraph.svg"
fi
rlRun "xz -T0 perf.data"
for file in "perf.data.xz" "flamegraph.svg" "perf-report.txt"; do
for file in "perf.data.xz" "perf-report.txt"; do
rlFileSubmit "$file"
rlRun "rm -f $file"
done

View file

@ -0,0 +1,22 @@
summary: Test for unexpected denials from sysctl -a
description: |
Verifes that running sysctl -a doesn't trigger unexpected capability
checks that would result in AVC denials even when access is allowed.
contact: Ondrej Mosnacek <omosnace@redhat.com>
component:
- kernel
framework: beakerlib
require:
- selinux-policy-devel
duration: 10m
tier: 2
check:
- avc
enabled: true
adjust+:
- enabled: false
when: distro < rhel-9
because: RHEL-8 and below are not worth supporting by this test
link:
- verifies: https://issues.redhat.com/browse/RHEL-135610
- verifies: https://issues.redhat.com/browse/RHEL-145590

32
kernel/sysctl-avcs/runtest.sh Executable file
View file

@ -0,0 +1,32 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# SPDX-License-Identifier: GPLv2
# Copyright (c) 2026 Red Hat, Inc.
# Author: Ondrej Mosnacek <omosnace@redhat.com>
# Include Beakerlib environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
rlJournalStart
rlPhaseStartSetup
rlRun "uname -r"
SE_ROLE="$(secon -r --pid $$)"
SE_TYPE="$(secon -t --pid $$)"
rlRun "make -f /usr/share/selinux/devel/Makefile test_policy.pp M4PARAM='-D TEST_ROLE=$SE_ROLE -D TEST_TYPE=$SE_TYPE'" 0 \
"Build the test policy"
rlRun "semodule -i test_policy.pp" 0 "Load test policy"
rlPhaseEnd
rlPhaseStartTest
rlRun "runcon -t test_domain_t sysctl -a"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "semodule -r test_policy" 0 "Unload test policy"
rlRun "make -f /usr/share/selinux/devel/Makefile clean" 0 \
"Clean the test policy"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -0,0 +1,37 @@
policy_module(test_policy,1.0.0)
type test_domain_t;
domain_type(test_domain_t)
corecmd_bin_entry_type(test_domain_t)
kernel_read_all_sysctls(test_domain_t)
kernel_read_security_state(test_domain_t)
fs_read_binfmt_misc(test_domain_t)
fs_search_auto_mountpoints(test_domain_t)
# No interface for this in policy:
require {
type binfmt_misc_fs_t;
}
list_dirs_pattern(test_domain_t, binfmt_misc_fs_t, binfmt_misc_fs_t)
# Some BPF sysctls can only be read with CAP_SYS_ADMIN, so we need to silence
# it.
dontaudit test_domain_t self:capability sys_admin;
require {
type TEST_TYPE;
role TEST_ROLE;
}
allow TEST_TYPE test_domain_t:process transition;
role TEST_ROLE types test_domain_t;
allow test_domain_t TEST_TYPE:fd use;
allow test_domain_t TEST_TYPE:fifo_file rw_inherited_fifo_file_perms;
allow test_domain_t TEST_TYPE:process { sigchld };
files_search_tmp(test_domain_t)
term_use_all_terms(test_domain_t)
userdom_search_user_tmp_dirs(test_domain_t)

View file

@ -0,0 +1,7 @@
# Minimal Makefile for standard-test-roles-beakerlib
R="RhtsRequires: policycoreutils setools-console"
run:
chmod +x runtest.sh
./runtest.sh

View file

@ -0,0 +1,20 @@
summary: Regression test for broken rules after setting booleans
description: |
Test that conditional rules are not broken after changing SELinux booleans.
Originally discovered in:
https://src.fedoraproject.org/tests/selinux/pull-request/203#comment-71053
contact: Ondrej Mosnacek <omosnace@redhat.com>
component:
- kernel
framework: beakerlib
require:
- policycoreutils
- setools-console
duration: 5m
tier: 2
enabled: true
adjust+:
- enabled: false
when: distro < rhel-7
because: RHEL-6 and below are not worth supporting by this test

View file

@ -0,0 +1,29 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# SPDX-License-Identifier: GPLv2
# Copyright (c) 2021 Red Hat, Inc.
# Author: Ondrej Mosnacek <omosnace@redhat.com>
# Include Beakerlib environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
rlJournalStart
rlPhaseStartSetup
rlRun "uname -r"
rlPhaseEnd
rlPhaseStartTest
rlRun "sesearch -s ftpd_t -t public_content_rw_t -c dir -p create -A | \
tee sesearch-before.txt"
rlRun "setsebool ftpd_anon_write=off ftpd_connect_all_unreserved=off \
ftpd_connect_db=off ftpd_full_access=off"
rlRun "sesearch -s ftpd_t -t public_content_rw_t -c dir -p create -A | \
tee sesearch-after.txt"
rlAssertNotDiffer "sesearch-before.txt" "sesearch-after.txt"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "rm -f sesearch-before.txt sesearch-after.txt"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -0,0 +1,22 @@
summary: XFRM refcount underflow test
description: |
Test that allocating and deallocating XFRM state and/or policy
structures doesn't lead to selinux_xfrm_refcount imbalance and
underflow.
contact: Ondrej Mosnacek <omosnace@redhat.com>
component:
- kernel
framework: beakerlib
recommend:
- systemtap
duration: 15m
tier: 2
enabled: true
adjust+:
- enabled: false
when: distro < rhel-7
because: RHEL-6 and below are not worth supporting by this test
link:
- verifies: https://issues.redhat.com/browse/RHEL-27751
extra-nitrate: TC#0617218
id: d2bfb49c-fe12-48b5-8f17-8edf6f93810a

Some files were not shown because too many files have changed in this diff Show more