Commit graph

134 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
bgrech
4119cf83ed Add support for rpm-ostree as a package manager for installDeps 2024-02-07 16:01:30 +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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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