chiark / gitweb /
core: dont't remount /sys/fs/cgroup for relabel if not needed (#8595)
authorKrzysztof Nowicki <krzysztof.a.nowicki+github@gmail.com>
Wed, 28 Mar 2018 11:36:33 +0000 (13:36 +0200)
committerSven Eden <yamakuzure@gmx.net>
Thu, 28 Jun 2018 07:24:07 +0000 (09:24 +0200)
commit705723a2a6177b50d561aab451133beab6f31efa
tree559f4ca2cfe012b394dc39fb6d52bfe5d50bf0a9
parent996045a96a16b35cb4eff859ed69d12464f95797
core: dont't remount /sys/fs/cgroup for relabel if not needed (#8595)

The initial fix for relabelling the cgroup filesystem for
SELinux delivered in commit 8739f23e3 was based on the assumption that
the cgroup filesystem is already populated once mount_setup() is
executed, which was true for my system. What I wasn't aware is that this
is the case only when another instance of systemd was running before
this one, which can happen if systemd is used in the initrd (for ex. by
dracut).

In case of a clean systemd start-up the cgroup filesystem is actually
being populated after mount_setup() and does not need relabelling as at
that moment the SELinux policy is already loaded. Since however the root
cgroup filesystem was remounted read-only in the meantime this operation
will now fail.

To fix this check for the filesystem mount flags before relabelling and
only remount ro->rw->ro if necessary and leave the filesystem read-write
otherwise.

Fixes #7901.

(cherry picked from commit 6f7729c1767998110c4460c85c94435c5782a613)

Also https://bugzilla.redhat.com/show_bug.cgi?id=1576240.
src/core/mount-setup.c