Commit graph

233 commits

Author SHA1 Message Date
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
Milos Malik
7420494018 test if rtkit-daemon can do sys_nice in user namespaces
SELinux prevents the rtkit-daemon process from setting nice value.
I believe this access is harmless from security point-of-view and
should be allowed. The TC is not able to reproduce the issue, but it
looks for an appropriate SELinux policy rule.

The TC covers BZ#1750024, BZ#1910507 and other duplicates.
2021-01-29 13:50:37 +00:00
Milos Malik
145822c1d2 enable the logging_syslogd_append_public_content boolean
The test reproduces scenarios described in 2 different bugs. One of
them is BZ#1823672. If this scenario should succeed, a newly introduced
boolean called logging_syslogd_append_public_content needs to be enabled.
The scenario also requires that the target log file exists before
the rsyslogd process tries to append to it.
2021-01-29 13:22:20 +00:00
Milos Malik
2132272e29 search for AVCs only, ignore USER_AVCs
Because the test uses a custom policy module, there will always
be at least 2 USER_AVC messages reported (received policyload notice
caused by insertion and removal of the policy module). The ausearch
calls should only care about AVC messages.
The test also uses the semanage command, which is not required in Makefile.
Both issues are now fixed.
2021-01-29 13:22:20 +00:00
Ondrej Mosnacek
cf69ccdee8 kernel/selinux-testsuite: ensure test policy is fully unloaded
Since the testsuite now loads more policy modules, the `semodule -r
test_policy` command is not enough for a full cleanup. Do `make -C
policy unload instead`.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-01-25 13:21:39 +01:00
Ondrej Mosnacek
602c2e9fe6 kernel/selinux-testsuite: clean up make_vars usage
Define it in a more suitable place and use it also for `make clean`.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-01-25 13:21:39 +01:00
Amith Kumar
4ccfd53121 pcp-daemons: Move pcp tests to upstream
Migrate cases from downstream test suite pcp-deamons-and-similar to
upstream.

Signed-off-by: Amith Kumar <apeetham@redhat.com>
2021-01-20 14:50:18 +00:00
Ondrej Mosnacek
893ed4c898 selinux-testsuite: Bump to latest upstream commit
Brings in two bugfixes to adapt to changes in Fedora policy.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-01-19 18:07:52 +01:00
Ondrej Mosnacek
5e0275eb2f kernel/synflood: require at least 64 cores and 2 NUMA nodes
Based on several runs in Beaker, these seem to be the best conditions
for distinguishing the bug. Currently, legacy Beaker HW filters are used
in the metadata. Once TMT introduces support for generic HW
requirements, they will need to be converted to the new format.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-01-19 14:04:27 +01:00
Ondrej Mosnacek
a358f02d2f kernel/synflood: reduce sampling time and increase duration
On fast systems with a lot of cores the 10s synflood run produces too
large perf.data (> 1 GiB), so reduce it to 5s and also increase the
test's time limit to 1h to make sure that it has enough time to process
such a large file.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-01-19 14:04:27 +01:00
Ondrej Mosnacek
e38ed68c9f kernel/synflood: refactor main test condition
It turns out there is too much variability in the percent values across
arches/machines, so give up on the general approach (checking that all
SELinux functions are below some hard limit) and instead focus only on
selinux_peerlbl_enabled() and compare its position with other functions.

In case selinux_peerlbl_enabled() is not found in /proc/kallsyms, it is
inlined into other functions, so we need to check selinux_ip_postroute()
instead of selinux_peerlbl_enabled().

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-01-19 14:04:27 +01:00
Ondrej Mosnacek
7ee186fe44 kernel/synflood: compress perf.data before uploading
The file can get really huge and it compresses well, so it's better to
compress it with xz before doing rlFileSubmit.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-01-19 13:20:40 +01:00
Ondrej Mosnacek
08a3ab17fb Add 'framework: beakerlib' to global metadata
This is needed for running tests using TMT. Since all tests here use
beakerlib, let's just make it a global default.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-01-18 22:53:50 +01:00
Ondrej Mosnacek
513ab703c5 kernel/synflood: raise maximum test duration
The generated perf.data can be quite big and uploading it takes a long
time in some cases, so raise the time to 20 minutes.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-01-14 10:29:44 +01:00
Ondrej Mosnacek
a6425dda5c kernel/synflood: add HW requirements to metadata
Needed to schedule correctly via bkr workflow-tomorrow.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-01-14 10:29:14 +01:00
Ondrej Mosnacek
419529ad63 Add test for TCP synflood performance
Verify that SELinux functions do not take up more time during a TCP SYN
flood than expected.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-01-13 18:05:48 +01:00
Milos Malik
5ff9ff4d44 delete the test user and the base.cil file
Repeated run of the TC in the same location revealed 2 issues:
the test user (toor) and the base.cil (modified policy module) file
were not deleted, which lead to unnecessary failures.
Both issues should be fixed now.
2021-01-08 10:44:56 +01:00
Petr Lautrbach
2cb83d9acd Rework "usepasswd in semanage.conf" test
- use spaces instead of tabs
- update copyright date
- cover more cases with correct behavior

  usepasswd=False
    - Standard users should not trigger a policy change
    - SELinux users with home in / shoud not trigger a policy change
    - Other SELinux users should trigger a policy change

  usepasswd=True
    - Standard users with home in /home should not trigger a policy change
    - Standard users with home in directory like /var/home should trigger a policy change
    - Standard users with home in / shoud not trigger a policy change
    - SELinux users with home in / shoud not trigger a policy change
    - Other SELinux users should trigger a policy change
2020-12-21 14:15:57 +01:00
Milos Malik
22a4a27b2f improve the main.fmf file
Name of the TC is correct now.
Relevancy of the TC is present now.
2020-12-15 18:42:59 +01:00
Milos Malik
ca5dfafc7f add the getrlimit test to upstream repo
There are no changes in the TC functionality.
Moving the downstream TC to upstream repo.
2020-12-15 12:52:18 +00:00