|
|
803fb7 |
From 3a82f8be03b07b84fa470c6e42cd87865aeaf701 Mon Sep 17 00:00:00 2001
|
|
|
803fb7 |
From: Will Woods <wwoods@redhat.com>
|
|
|
803fb7 |
Date: Fri, 13 Mar 2015 17:24:46 -0400
|
|
|
803fb7 |
Subject: [PATCH] selinux: fix SEGV during switch-root if SELinux policy loaded
|
|
|
803fb7 |
|
|
|
803fb7 |
If you've got SELinux policy loaded, label_hnd is your labeling handle.
|
|
|
803fb7 |
When systemd is shutting down, we free that handle via mac_selinux_finish().
|
|
|
803fb7 |
|
|
|
803fb7 |
But: switch_root() calls mkdir_p_label(), which tries to look up a label
|
|
|
803fb7 |
using that freed handle, and so we get a bunch of garbage and eventually
|
|
|
803fb7 |
SEGV in libselinux.
|
|
|
803fb7 |
|
|
|
803fb7 |
(This doesn't happen in the switch-root from initramfs to real root because
|
|
|
803fb7 |
there's no SELinux policy loaded in initramfs, so label_hnd is NULL and we
|
|
|
803fb7 |
never attempt any lookups.)
|
|
|
803fb7 |
|
|
|
803fb7 |
So: make sure that mac_selinux_finish() actually sets label_hnd to NULL, so
|
|
|
803fb7 |
nobody tries to use it after it becomes invalid.
|
|
|
803fb7 |
|
|
|
803fb7 |
https://bugzilla.redhat.com/show_bug.cgi?id=1185604
|
|
|
803fb7 |
(cherry picked from commit f5ce2b49585a14cefb6d02f61c8dcdf7628a8605)
|
|
|
803fb7 |
---
|
|
|
803fb7 |
src/shared/selinux-util.c | 1 +
|
|
|
803fb7 |
1 file changed, 1 insertion(+)
|
|
|
803fb7 |
|
|
|
803fb7 |
diff --git a/src/shared/selinux-util.c b/src/shared/selinux-util.c
|
|
|
803fb7 |
index a2233e0cf..a46ddf849 100644
|
|
|
803fb7 |
--- a/src/shared/selinux-util.c
|
|
|
803fb7 |
+++ b/src/shared/selinux-util.c
|
|
|
803fb7 |
@@ -117,6 +117,7 @@ void mac_selinux_finish(void) {
|
|
|
803fb7 |
return;
|
|
|
803fb7 |
|
|
|
803fb7 |
selabel_close(label_hnd);
|
|
|
803fb7 |
+ label_hnd = NULL;
|
|
|
803fb7 |
#endif
|
|
|
803fb7 |
}
|
|
|
803fb7 |
|