selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ondrej Mosnacek <omosnace@redhat.com>
To: selinux@vger.kernel.org
Subject: [PATCH testsuite 1/2] tests/task_setscheduler: fix for old kernels
Date: Fri, 20 Sep 2019 12:15:09 +0200	[thread overview]
Message-ID: <20190920101510.13907-2-omosnace@redhat.com> (raw)
In-Reply-To: <20190920101510.13907-1-omosnace@redhat.com>

On some old kernels (e.g. RHEL-5) the setscheduler test hangs the system
after commit 26a3b59d5f5a ("selinux-testsuite: fix potential races when
starting bg programs"). The issue seems to be that the new 'target'
program does a busy loop, whereas the old one did sleep() in a loop.

Fix this by sleeping inside the loop as before. Note that the policy
needs to be updated to allow running the sleep command from
a test_setsched_target_t process.

Fixes: 26a3b59d5f5a ("selinux-testsuite: fix potential races when starting bg programs")
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
---
 policy/test_task_setsched.te | 1 +
 tests/task_setscheduler/test | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/policy/test_task_setsched.te b/policy/test_task_setsched.te
index 32569b7..794de65 100644
--- a/policy/test_task_setsched.te
+++ b/policy/test_task_setsched.te
@@ -11,6 +11,7 @@ type test_setsched_target_t;
 domain_type(test_setsched_target_t)
 unconfined_runs_test(test_setsched_target_t)
 corecmd_shell_entry_type(test_setsched_target_t)
+corecmd_exec_bin(test_setsched_target_t)
 typeattribute test_setsched_target_t test_setsched_d;
 typeattribute test_setsched_target_t testdomain;
 
diff --git a/tests/task_setscheduler/test b/tests/task_setscheduler/test
index 9e712a8..fa7d9cb 100755
--- a/tests/task_setscheduler/test
+++ b/tests/task_setscheduler/test
@@ -10,7 +10,7 @@ $basedir =~ s|(.*)/[^/]*|$1|;
 system("mkfifo $basedir/flag");
 if ( ( $pid = fork() ) == 0 ) {
     exec
-"runcon -t test_setsched_target_t sh -c 'echo >$basedir/flag; while :; do :; done'";
+"runcon -t test_setsched_target_t sh -c 'echo >$basedir/flag; while :; do sleep 1; done'";
 }
 
 # Wait for it to start.
-- 
2.21.0


  reply	other threads:[~2019-09-20 10:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-20 10:15 [PATCH testsuite 0/2] RFE: remove special RHEL-5 and -4 policies Ondrej Mosnacek
2019-09-20 10:15 ` Ondrej Mosnacek [this message]
2019-09-20 12:26 ` Ondrej Mosnacek

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=20190920101510.13907-2-omosnace@redhat.com \
    --to=omosnace@redhat.com \
    --cc=selinux@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).