public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [tests/selinux] pr775-checkpolicy-revdeps: Add a test for memory leak when SELinux mount options are used
@ 2026-09-11 13:20 Ondrej Mosnacek
0 siblings, 0 replies; only message in thread
From: Ondrej Mosnacek @ 2026-09-11 13:20 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : tests/selinux
Branch : pr775-checkpolicy-revdeps
Commit : 7ce3757ef627376006115f0c6fdb972fcf86af4a
Author : Ondrej Mosnacek <omosnace@redhat.com>
Date : 2023-05-16T13:54:25+00:00
Stats : +123/-0 in 2 file(s)
URL : https://src.fedoraproject.org/tests/selinux/c/7ce3757ef627376006115f0c6fdb972fcf86af4a?branch=pr775-checkpolicy-revdeps
Log:
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>
---
diff --git a/kernel/mount-options-memleak/main.fmf b/kernel/mount-options-memleak/main.fmf
new file mode 100644
index 0000000..e54f7b6
--- /dev/null
+++ b/kernel/mount-options-memleak/main.fmf
@@ -0,0 +1,17 @@
+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
diff --git a/kernel/mount-options-memleak/runtest.sh b/kernel/mount-options-memleak/runtest.sh
new file mode 100755
index 0000000..c5e86e2
--- /dev/null
+++ b/kernel/mount-options-memleak/runtest.sh
@@ -0,0 +1,106 @@
+#!/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="$REBOOT_COUNT"
+fi
+
+function installDepsYum() {
+ local yum="$1"; shift
+
+ if "$yum" --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"
+ tmt-reboot
+fi
+if [ $TMT_REBOOT_COUNT -lt 2 ]; then
+ rlRun "uname -r" 0 "Print running kernel version 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"
+ tmt-reboot
+fi
+ rlRun "uname -r" 0 \
+ "Print running kernel version after cleanup reboot"
+ rlPhaseEnd
+rlJournalPrintText
+rlJournalEnd
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-09-11 13:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-11 13:20 [tests/selinux] pr775-checkpolicy-revdeps: Add a test for memory leak when SELinux mount options are used Ondrej Mosnacek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox