selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selinux-testsuite: ensure the cgroups_label tests works on old and new systems
@ 2019-08-26 21:40 Paul Moore
  2019-08-26 21:50 ` Paul Moore
  2019-09-04 12:48 ` Stephen Smalley
  0 siblings, 2 replies; 4+ messages in thread
From: Paul Moore @ 2019-08-26 21:40 UTC (permalink / raw)
  To: selinux

From: Paul Moore <paul@paul-moore.com>

Commit 697efc910393 ("selinux-testsuite: fix the cgroups_label test")
fixed the cgroups_label test on new systems, but it broke old systems.
Try to use /sys/fs/cgroup/unified first and if that doesn't exist go
with the new approach introduced in the commit above.

Signed-off-by: Paul Moore <paul@paul-moore.com>
---
 tests/cgroupfs_label/test |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tests/cgroupfs_label/test b/tests/cgroupfs_label/test
index 385b953..91517b4 100755
--- a/tests/cgroupfs_label/test
+++ b/tests/cgroupfs_label/test
@@ -5,7 +5,11 @@ BEGIN { plan tests => 2 }
 
 my $ret;
 
-my $dir = "/sys/fs/cgroup/selinuxtest";
+# Older systems use /sys/fs/cgroup/unified, newer use /sys/fs/cgroup.
+my $dir = "/sys/fs/cgroup/unified";
+if (! -d $dir) {
+	$dir = "/sys/fs/cgroup/selinuxtest";
+}
 
 # Create a new cgroupfs directory and relabel it.
 mkdir("$dir");


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] selinux-testsuite: ensure the cgroups_label tests works on old and new systems
  2019-08-26 21:40 [PATCH] selinux-testsuite: ensure the cgroups_label tests works on old and new systems Paul Moore
@ 2019-08-26 21:50 ` Paul Moore
  2019-09-04 12:48 ` Stephen Smalley
  1 sibling, 0 replies; 4+ messages in thread
From: Paul Moore @ 2019-08-26 21:50 UTC (permalink / raw)
  To: selinux

On Mon, Aug 26, 2019 at 5:40 PM Paul Moore <paul@paul-moore.com> wrote:
> From: Paul Moore <paul@paul-moore.com>
>
> Commit 697efc910393 ("selinux-testsuite: fix the cgroups_label test")
> fixed the cgroups_label test on new systems, but it broke old systems.
> Try to use /sys/fs/cgroup/unified first and if that doesn't exist go
> with the new approach introduced in the commit above.
>
> Signed-off-by: Paul Moore <paul@paul-moore.com>
> ---
>  tests/cgroupfs_label/test |    6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/tests/cgroupfs_label/test b/tests/cgroupfs_label/test
> index 385b953..91517b4 100755
> --- a/tests/cgroupfs_label/test
> +++ b/tests/cgroupfs_label/test
> @@ -5,7 +5,11 @@ BEGIN { plan tests => 2 }
>
>  my $ret;
>
> -my $dir = "/sys/fs/cgroup/selinuxtest";
> +# Older systems use /sys/fs/cgroup/unified, newer use /sys/fs/cgroup.
> +my $dir = "/sys/fs/cgroup/unified";
> +if (! -d $dir) {
> +       $dir = "/sys/fs/cgroup/selinuxtest";
> +}

Merged with the requisite style fixes (sorry about that, my mistake).

>  # Create a new cgroupfs directory and relabel it.
>  mkdir("$dir");

-- 
paul moore
www.paul-moore.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] selinux-testsuite: ensure the cgroups_label tests works on old and new systems
  2019-08-26 21:40 [PATCH] selinux-testsuite: ensure the cgroups_label tests works on old and new systems Paul Moore
  2019-08-26 21:50 ` Paul Moore
@ 2019-09-04 12:48 ` Stephen Smalley
  2019-09-04 21:51   ` Paul Moore
  1 sibling, 1 reply; 4+ messages in thread
From: Stephen Smalley @ 2019-09-04 12:48 UTC (permalink / raw)
  To: Paul Moore, selinux

On 8/26/19 5:40 PM, Paul Moore wrote:
> From: Paul Moore <paul@paul-moore.com>
> 
> Commit 697efc910393 ("selinux-testsuite: fix the cgroups_label test")
> fixed the cgroups_label test on new systems, but it broke old systems.
> Try to use /sys/fs/cgroup/unified first and if that doesn't exist go
> with the new approach introduced in the commit above.
> 
> Signed-off-by: Paul Moore <paul@paul-moore.com>

This leaves the test system in a broken state, with all of 
/sys/fs/cgroup/unified getting relabeled to test_cgroup_t during the 
test and then switching to unlabeled_t upon the unloading of the test 
policy.  I get a bajillion denials after the testsuite completes from 
anything trying to access /sys/fs/cgroup/unified, and ls -Z 
/sys/fs/cgroup/unified shows it as being unlabeled_t throughout.

> ---
>   tests/cgroupfs_label/test |    6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/cgroupfs_label/test b/tests/cgroupfs_label/test
> index 385b953..91517b4 100755
> --- a/tests/cgroupfs_label/test
> +++ b/tests/cgroupfs_label/test
> @@ -5,7 +5,11 @@ BEGIN { plan tests => 2 }
>   
>   my $ret;
>   
> -my $dir = "/sys/fs/cgroup/selinuxtest";
> +# Older systems use /sys/fs/cgroup/unified, newer use /sys/fs/cgroup.
> +my $dir = "/sys/fs/cgroup/unified";
> +if (! -d $dir) {
> +	$dir = "/sys/fs/cgroup/selinuxtest";
> +}
>   
>   # Create a new cgroupfs directory and relabel it.
>   mkdir("$dir");
> 
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] selinux-testsuite: ensure the cgroups_label tests works on old and new systems
  2019-09-04 12:48 ` Stephen Smalley
@ 2019-09-04 21:51   ` Paul Moore
  0 siblings, 0 replies; 4+ messages in thread
From: Paul Moore @ 2019-09-04 21:51 UTC (permalink / raw)
  To: Stephen Smalley; +Cc: selinux

On Wed, Sep 4, 2019 at 8:48 AM Stephen Smalley <sds@tycho.nsa.gov> wrote:
> On 8/26/19 5:40 PM, Paul Moore wrote:
> > From: Paul Moore <paul@paul-moore.com>
> >
> > Commit 697efc910393 ("selinux-testsuite: fix the cgroups_label test")
> > fixed the cgroups_label test on new systems, but it broke old systems.
> > Try to use /sys/fs/cgroup/unified first and if that doesn't exist go
> > with the new approach introduced in the commit above.
> >
> > Signed-off-by: Paul Moore <paul@paul-moore.com>
>
> This leaves the test system in a broken state, with all of
> /sys/fs/cgroup/unified getting relabeled to test_cgroup_t during the
> test and then switching to unlabeled_t upon the unloading of the test
> policy.  I get a bajillion denials after the testsuite completes from
> anything trying to access /sys/fs/cgroup/unified, and ls -Z
> /sys/fs/cgroup/unified shows it as being unlabeled_t throughout.

A bajillion, that sounds serious! ;)

Anyway, my apologies for breaking things after the test runs.  My test
systems pretty much just run the tests (over and over and over) so I
didn't notice the breakage.  I'll post a patch for this right now ...

> > ---
> >   tests/cgroupfs_label/test |    6 +++++-
> >   1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/tests/cgroupfs_label/test b/tests/cgroupfs_label/test
> > index 385b953..91517b4 100755
> > --- a/tests/cgroupfs_label/test
> > +++ b/tests/cgroupfs_label/test
> > @@ -5,7 +5,11 @@ BEGIN { plan tests => 2 }
> >
> >   my $ret;
> >
> > -my $dir = "/sys/fs/cgroup/selinuxtest";
> > +# Older systems use /sys/fs/cgroup/unified, newer use /sys/fs/cgroup.
> > +my $dir = "/sys/fs/cgroup/unified";
> > +if (! -d $dir) {
> > +     $dir = "/sys/fs/cgroup/selinuxtest";
> > +}
> >
> >   # Create a new cgroupfs directory and relabel it.
> >   mkdir("$dir");
> >

-- 
paul moore
www.paul-moore.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-09-04 21:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-26 21:40 [PATCH] selinux-testsuite: ensure the cgroups_label tests works on old and new systems Paul Moore
2019-08-26 21:50 ` Paul Moore
2019-09-04 12:48 ` Stephen Smalley
2019-09-04 21:51   ` Paul Moore

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).