public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Vit Mojzis <vmojzis@redhat.com>
To: git-commits@fedoraproject.org
Subject: [tests/selinux] pr775-checkpolicy-revdeps: policycoreutils: Add test for restorecond "blob data"
Date: Fri, 11 Sep 2026 13:17:35 GMT	[thread overview]
Message-ID: <178913265544.1.237623335390039092.tests-selinux-56d49125a43e@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : tests/selinux
            Branch : pr775-checkpolicy-revdeps
            Commit : 56d49125a43eb0e368ec999c5df666f1a4dc4d66
            Author : Vit Mojzis <vmojzis@redhat.com>
            Date   : 2019-11-27T13:01:04+01:00
            Stats  : +101/-0 in 2 file(s)
            URL    : https://src.fedoraproject.org/tests/selinux/c/56d49125a43eb0e368ec999c5df666f1a4dc4d66?branch=pr775-checkpolicy-revdeps

            Log:
            policycoreutils: Add test for restorecond "blob data"

This test creates mislabeled files and runs restorecond repeatedly to test
for an issue caused by overwriting program variable with memory address.
The issue caused restorecond to write status messages (that appeared
as "blob data" because of \r character) to journal.

Since the memory address mentioned above is effectively random data,
this test may result in SUCESS even if the issue being tested is present!

---
diff --git a/policycoreutils/restorecond_pointer_abuse/main.fmf b/policycoreutils/restorecond_pointer_abuse/main.fmf
new file mode 100644
index 0000000..f7d412a
--- /dev/null
+++ b/policycoreutils/restorecond_pointer_abuse/main.fmf
@@ -0,0 +1,16 @@
+path: /policycoreutils/restorecond_pointer_abuse
+summary: Does restorecond flood journal with "blob data" messages?
+description: |
+    This test creates mislabeled files and runs restorecond repeatedly to test
+    for an issue caused by overwriting program variable with memory address.
+    The issue caused restorecond to write status messages (that appeared
+    as "blob data" because of \r character) to journal.
+
+    Since the memory address mentioned above is effectively random data,
+    this test may result in SUCESS even if the issue being tested is present!
+
+    Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1626468
+relevancy:
+    - "distro = rhel-4, rhel-5, rhel-6: False"
+component: [ policycoreutils ]
+#requires: [/usr/sbin/restorecond, /usr/bin/chcon, /usr/sbin/sestatus, /usr/bin/systemctl, /usr/bin/journalctl]

diff --git a/policycoreutils/restorecond_pointer_abuse/runtest.sh b/policycoreutils/restorecond_pointer_abuse/runtest.sh
new file mode 100755
index 0000000..465b1f2
--- /dev/null
+++ b/policycoreutils/restorecond_pointer_abuse/runtest.sh
@@ -0,0 +1,85 @@
+#!/bin/bash
+# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#   runtest.sh of /selinux/policycoreutils/restorecond_pointer_abuse
+#   Description:
+#      This test creates mislabeled files and runs restorecond repeatedly to test
+#      for an issue caused by overwriting program variable with memory address.
+#      The issue caused restorecond to write status messages (that appeared
+#      as "blob data" because of \r character) to journal.
+#
+#      Since the memory address mentioned above is effectively random data,
+#      this test may result in SUCESS even if the issue being tested is present!
+#
+#   Author: vmojzis <vmojzis@redhat.com>
+#   Bug summary: restorecond flooding logs with blob data messages
+#   Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1626468
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#   Copyright (c) 2019 Red Hat, Inc.
+#
+#   This program is free software: you can redistribute it and/or
+#   modify it under the terms of the GNU General Public License as
+#   published by the Free Software Foundation, either version 2 of
+#   the License, or (at your option) any later version.
+#
+#   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, see http://www.gnu.org/licenses/.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+# Include Beaker environment
+. /usr/bin/rhts-environment.sh || exit 1
+. /usr/share/beakerlib/beakerlib.sh || exit 1
+
+PACKAGE="policycoreutils"
+
+# Requires /usr/sbin/restorecond, /usr/bin/chcon, /usr/sbin/sestatus, /usr/bin/systemctl, /usr/bin/journalctl
+rlJournalStart
+    rlPhaseStartSetup
+        rlAssertRpm $PACKAGE
+        # backup restorecond configuration file
+        rlRun "rlFileBackup /etc/selinux/restorecond.conf" 0
+        rlRun "echo '/usr/*' > /etc/selinux/restorecond.conf" 0-255
+        OUTPUT_FILE=`mktemp`
+        rlRun "setenforce 1"
+        rlRun "sestatus"
+        START_DATE_TIME=`date "+%Y-%m-%d %T"`
+    rlPhaseEnd
+
+    rlPhaseStartTest
+        # 
+        for i in {1..15}
+        do
+            # create misslabeled files
+            for folder in  share games tmp
+            do
+                rlRun "touch /usr/$folder/$i"
+                rlRun "chcon -t unlabeled_t /usr/$folder/$i"
+            done
+            rlRun "systemctl restart restorecond" 0
+            rlRun "systemctl status restorecond" 0
+            rlRun "journalctl -S '$START_DATE_TIME' -u restorecond 2>&1 > ${OUTPUT_FILE}" 0
+            rlRun "grep -E \"blob data\" ${OUTPUT_FILE}" 1
+            if [ $? -ne 1 ]; then cat ${OUTPUT_FILE}; fi
+            sleep 3
+            # cleanup
+            for folder in share games tmp
+            do
+                rlRun "rm -f /usr/$folder/$i"
+            done
+        done
+    rlPhaseEnd
+
+    rlPhaseStartCleanup
+        rlRun "rlFileRestore" 0
+    rlPhaseEnd
+rlJournalPrintText
+rlJournalEnd

                 reply	other threads:[~2026-09-11 13:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178913265544.1.237623335390039092.tests-selinux-56d49125a43e@fedoraproject.org \
    --to=vmojzis@redhat.com \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox