Skip to content
Commit 78db230a authored by Will Woods's avatar Will Woods Committed by Zbigniew Jędrzejewski-Szmek
Browse files

selinux: fix SEGV during switch-root if SELinux policy loaded

If you've got SELinux policy loaded, label_hnd is your labeling handle.
When systemd is shutting down, we free that handle via mac_selinux_finish().

But: switch_root() calls mkdir_p_label(), which tries to look up a label
using that freed handle, and so we get a bunch of garbage and eventually
SEGV in libselinux.

(This doesn't happen in the switch-root from initramfs to real root because
there's no SELinux policy loaded in initramfs, so label_hnd is NULL and we
never attempt any lookups.)

So: make sure that mac_selinux_finish() actually sets label_hnd to NULL, so
nobody tries to use it after it becomes invalid.

https://bugzilla.redhat.com/show_bug.cgi?id=1185604
(cherry picked from commit f5ce2b49)
(cherry picked from commit 19e98bf4)
parent 3e3ed4d0
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment