Commit graph

204 commits

Author SHA1 Message Date
Milos Malik
918af6a3fc 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 09:32:11 +01:00
Amith Kumar
63bf841c3e 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-10 02:25:05 +05:30
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
Ondrej Mosnacek
596ec7fafe Make all relevancy expressions use comparison operators
Rather than enumerating RHEL versions, use comparison against
"known-good" version to make the expressions easier to read and
understand.

Also convert users of '~<' to '<', as '~<' compares only minor versions
within the same major.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2020-12-15 12:38:32 +01:00
Milos Malik
15f6d6c612 update test relevancy based on packages availability
Relevancy changes are made based on recommendations from:
  tmt test lint --fix

Some packages are available for Fedoras only and are not available
for RHELs at all.
Some packages are available for latest RHEL major versions only.
2020-12-15 11:53:28 +01:00
Amith Kumar
5be146b085 selinux-policy: Move rtkit daemon tests to upstream
Migrate cases from downstream test suite rtkit-deamon-and-similar to
upstream.

Signed-off-by: Amith Kumar <apeetham@redhat.com>
2020-12-15 09:47:38 +00:00
Amith Kumar
6ad739ab7e selinux-policy: Move kerberos tests to upstream
Migrate cases from downstream test suite kerberos-and-similar to
upstream.

Signed-off-by: Amith Kumar <apeetham@redhat.com>
2020-12-15 09:43:39 +00:00
Milos Malik
37878fa9cc test if dhclient-script can execute chronyc
When the root user runs dhclient, SELinux denials related to chronyc
are triggered, because SELinux policy does not allow dhclient-script
to find and execute chronyc.

I believe that SELinux policy should define a transition from dhcpc_t
to chronyc_t, which allows the chronyc program to run under the correct
context and do actions which are expected.

The TC covers BZ#1897388. The TC reproduces the issue described above
and it also looks for appropriate policy rules.
2020-12-14 11:17:12 +00:00
Milos Malik
565cbef141 add new test which covers the dhclient program
Basic automated test which runs the dhclient program and looks for
any SELinux denials which appear during the run. The dhclient tool
is known to run other network related programs, which can trigger
various SELinux denials.
2020-12-14 11:17:12 +00:00
Milos Malik
303a35cafd look for policy rules allowing sysadm_t to do perf_event actions
The TC also covers BZ#1901958.
2020-12-14 11:14:32 +00:00
Milos Malik
12ca54c409 enable the root user to log in via SSH
If the scenario, where confined root user tries to run the perf tool,
should work, the root user must be able to log in via SSH. This
access is disabled by default. The TC will temporarily enable it.
2020-12-14 11:14:32 +00:00
Milos Malik
47a88659d2 correct the description and add main.fmf file
There were incorrect descriptions in some files. Now, they are fixed.

I forgot to add the main.fmf file. Now, it is present.
2020-12-14 11:14:32 +00:00
Milos Malik
2d3332a5e1 test if confined root is allowed to use perf_event
Not only unconfined root (unconfined_t) should be able to run the
perf tool, but also the confined root (sysadm_t) should be able to
do that.
The TC now contains a new test phase which tests the scenario.
2020-12-14 11:14:32 +00:00
Milos Malik
95855db588 add new test which covers perf_event class+permissions
The kernel already recognizes the perf_event class and its permissions.
Current SELinux policy does not, but it will.
To avoid possible issues, we need to test some basic scenarios which
take advantage of the perf_event class. For example: the perf tool
executed by root/unconfined_t user.

The TC covers BZ#1901957.
2020-12-14 11:14:32 +00:00
Zdenek Pytela
9caf81bf10 selinux-policy: Adjust fapolicyd test for /etc/resolv.conf symlink
Adjust the fapolicyd test to branch conditionally if /etc/resolv.conf
is a symlink labeled etc_t or a plain file labeled net_conf_t.
2020-12-09 09:01:28 +00:00
Milos Malik
1572bc3434 skip some checks if /sys/fs/selinux cannot be unmounted
Some checks in the automated tests require an unmounted SELinux
file-system. This way is used to pretend that SELinux is disabled.
Sometimes the file-system cannot be unmounted because of

  umount: /sys/fs/selinux: target is busy.

To work around this issue, umount with --lazy option will be used.
If umount --lazy still complains, the problematic checks will be
skipped, because it still make sense to run the other parts of the
automated tests.
2020-12-08 08:18:30 +00:00
Milos Malik
59f9aeedbf look for additional systemd-sleep rules
Additional SELinux denials were found during systemd-sleep testing
process. Unfortunately, SELinux policy rules which fix these denials
were not tested in this TC. Now, they are.
2020-12-03 16:29:23 +01:00
Milos Malik
c1aeb02be4 skip the BZ#1845594 test phase on RHEL
It seems that BZ#1845594 cannot be reproduced on RHEL-8. From now
on, the test phase will be executed in Fedora environments only.
2020-12-01 18:36:45 +00:00
Milos Malik
f0693a3d13 introduce a variable which skips systemd-sleep services
The automated TC contains a phase where services systemd-hybrid-sleep
and systemd-hibernate are started for testing purposes. Unfortunately,
running these services had real consequences on machines in certain
environments where the TC was executed (for example: machines became
unresponsive).
To have some control of the situation, a new environment variable was
introduced. It is called REAL_SCENARIOS and it can avoid the situation
when set to false. Default value of the variable is true which means
that above-mentioned services will be executed.
2020-12-01 18:36:45 +00:00
Milos Malik
d0c19396bd test if systemd-sleep can sys_ptrace and write to sysfs_t
Recent testing of the new policy for the system-sleep program revealed,
that the program wants the sys_ptrace capability and it also wants to
write to /sys/power directory. Unfortunately, these actions are prevented
by SELinux because SELinux policy does not contain appropriate allow
rules.

This automated TC checks for appropriate SELinux policy rules and it
also reproduces the issue.

This TC covers BZ#1850177.
2020-12-01 18:36:45 +00:00
Amith Kumar
5e5913141f selinux-policy: Move tlp tests to upstream
Migrate cases from downstream test suite tlp-and-similar to upstream.

Signed-off-by: Amith Kumar <apeetham@redhat.com>
2020-12-01 14:00:21 +00:00
Milos Malik
430d838dd5 test if rpmdb can talk to D-bus and SSSD processes
When 'rpmdb --help' is executed in console, there is no output
displayed because of SELinux denials. This issue should be fixed
in SELinux policy via appropriate allow rules.

When 'rpmdb --exportdb' is executed, SELinux denials appear again,
but this time they are related to communication with SSSD and D-bus
daemon. This issue should be fixed in SELinux policy via dontaudit
rules because the access to D-bus and SSSD processes is not necessary
for successful run of rpmdb.

The TC covers BZ#1899548 and its duplicates.
2020-12-01 13:03:32 +00:00
Vit Mojzis
119be88601 libsemanage: Make sure usepassd in semanage.conf works 2020-11-30 15:56:18 +00:00
Ondrej Mosnacek
f7449e5226 kernel: Add test for netlabel failure to remove all rules
Add coverage for:
https://bugzilla.redhat.com/show_bug.cgi?id=1901174

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2020-11-26 11:40:43 +01:00
Amith Kumar
6bfc47d553 rsyslog : Add test coverage for rsyslog issues
The rsyslog test suite, at present provides coverage for bugs 1823669
and 1823672. Later more cases will be added from downstream. Bz1823669
highlights the avc issues related rsyslog "imfile" module, which cannot
read parent directories of the file to process. Bz1823672 is also about
AVCs related to browsing the parent directories when rsyslog is
configured to write logs to a custom file.

Signed-off-by: Amith Kumar <apeetham@redhat.com>
2020-11-25 12:06:54 +00:00
Milos Malik
72f35b9876 test if root user can run rpmdb successfully
Based on SELinux policy rules, the root/unconfined_t user is expected
to run the rpmdb program. A new test phase tests if such a scenario
works successfully or not. Of course, the rpmdb program recognizes
a lot of options, only the basic ones will be tested here.
2020-11-25 08:37:47 +00:00
Milos Malik
90f769d4b4 test if rpmdb can read /etc/resolv.conf symlink
The rpmdb process executed by the rpmdb-rebuild service wants to
read the /etc/resolv.conf symlink, but SELinux denies that access,
because SELinux policy does not allow that. This TC is able to
reproduce the issue.

I believe this issue should be fixed in selinux-policy component
via appropriate allow rule.

The TC covers BZ#1898298.
2020-11-25 08:37:47 +00:00
Milos Malik
b48b557e16 add new test which covers rpmdb program
Recent SELinux policy brought new types like rpmdb_exec_t and rpmdb_t,
which are assigned to the rpmdb program and to the rpmdb process.
Because we don't have any test coverage for these types, I wrote a basic
test which runs the rpmdb-rebuild service in default configuration and
looks for any SELinux denials.
2020-11-25 08:37:47 +00:00
Zdenek Pytela
8f14cccbfc selinux-policy: Limit the cups-pdf test to F32+
The cups-pdf issue is expected to be fixed in Fedora 32 and newer.
The cups-pdf package is not present in RHEL.
2020-11-24 20:12:19 +00:00
Ondrej Mosnacek
8c8e512138 selinux-testsuite: Bump to latest upstream commit
The main highlight is that filesystems tests are now run for all
supported filesystems, instead of just the one that is native to the
platform.

Also, the testsuite no longer (directly) requires Python, so drop the
dependency and a related workaround.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2020-11-09 16:49:29 +01:00
Richard Filo
9b92d7be6d selinux-policy: Checks if dbus daemon is able to send message to hal daemon and vice versa
Original author: Milos Malik <mmalik@redhat.com>
2020-11-09 09:04:15 +00:00
Milos Malik
06c47e669e skip systemd-userdbd test on RHEL-8
It makes no sense to run this TC on RHEL-8.x or lower RHELs, because
the systemd-userdbd service is not available there. As soon as the
service becomes available in these environments, the TC can be enabled.
2020-11-02 08:22:58 +00:00