From: "Richard W.M. Jones" <rjones@redhat.com>
To: Jason Zaman <jason@perfinion.com>
Cc: selinux@tycho.nsa.gov
Subject: Re: [PATCH] libselinux: If autorelabel, force permissive mode.
Date: Wed, 6 Jul 2016 13:12:57 +0100 [thread overview]
Message-ID: <20160706121257.GS16797@redhat.com> (raw)
In-Reply-To: <20160706112942.GA21226@meriadoc.perfinion.com>
On Wed, Jul 06, 2016 at 07:29:42PM +0800, Jason Zaman wrote:
> On Wed, Jul 06, 2016 at 10:43:21AM +0100, Richard W.M. Jones wrote:
> > The autorelabel feature has been broken in Fedora for a while.
> > virt-builder relies on this feature to enable SELinux in guests since
> > we are unable to set filesystem labels when generating the image. So
> > it comes down to me to try to fix this. There was a discussion on the
> > Fedora development list which explains the background and the reasons
> > why autorelabel is broken:
> >
> > http://thread.gmane.org/gmane.linux.redhat.fedora.devel/220453
> >
> > The plan to fix autorelabel (also formulated in the above thread) is
> > in two parts:
> >
> > (1) [This patch] If the autorelabel condition is detected when loading
> > policy very early during boot, we set SELinux to permissive mode
> > (overriding the contents of /etc/selinux/config and the command line).
>
> Can't you just set enforcing=0 on the kernel commandline for the first
> boot?
For virt-builder, no. We create automated images that must
boot themselves without manual intervention.
However even ignoring my use case, I don't think it's a good idea
anyway. If /.autorelabel is set, then the labels on the filesystem
are known to be wrong. You shouldn't be making enforcement decisions
based on labels which you know are wrong.
> This patch sounds a bit dangerous. If anyone can touch /.autorelabel
> later on the machine will be in permissive mode on next reboot.
If someone can create files in / then I suspect you've got other
problems. In any case it will then immediately jump to the generator
and relabel in a (very) minimal environment and reboot. After this
second boot it'll be back to enforcing (or whatever is requested by
/etc/selinux/config).
> Also we dont use /.autorelabel in gentoo (not sure about arch or
> debian) so something like this would just make the machine always in
> permissive mode since there is no service to delete the file.
As I noted, I made this patch against the downstream fedora-selinux
git. That repository says to send patches here.
> There are also many times other than first install when you would want
> to relabel, if /home is moved to another HDD then you might want to
> relabel but the machine would be completely fine in enforcing mode.
>
> This sounds like you want permissive for *only* the very first boot and
> never again but the way of doing it leaves that open. At the very least
> I'd make it check for (/.autorelabel && (security.selinux xattr is
> completely missing on /))
The way autorelabel is documented to work, users can set it any time,
not just on first boot. The labels can be wrong, not unset.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages. http://libguestfs.org
next prev parent reply other threads:[~2016-07-06 12:13 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-06 9:43 [PATCH] libselinux: If autorelabel, force permissive mode Richard W.M. Jones
2016-07-06 9:43 ` Richard W.M. Jones
2016-07-06 11:29 ` Jason Zaman
2016-07-06 12:12 ` Richard W.M. Jones [this message]
2016-07-07 12:37 ` Sven Vermeulen
2016-07-07 12:43 ` William Roberts
2016-07-07 13:50 ` Jason Zaman
2016-07-07 13:52 ` William Roberts
2016-07-07 20:56 ` Richard W.M. Jones
2016-07-08 3:24 ` Russell Coker
2016-07-12 17:22 ` Stephen Smalley
2016-07-12 18:01 ` Richard W.M. Jones
2016-07-12 18:25 ` Stephen Smalley
2016-07-13 19:31 ` Richard W.M. Jones
2016-07-13 19:50 ` Stephen Smalley
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=20160706121257.GS16797@redhat.com \
--to=rjones@redhat.com \
--cc=jason@perfinion.com \
--cc=selinux@tycho.nsa.gov \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.