From 1006038cf103f11ce50fe27ae8f7ee2a3badb05b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Christian=20G=C3=B6ttsche?= Date: Sat, 5 Sep 2020 17:49:48 +0200 Subject: [PATCH] selinux: early exit in mac_selinux_maybe_reload if not initialized Binaries might not initialize SELinux, e.g. when they normally do not create files with the SELinux default context. If they, via an internal libary function, call a _label() function, mac_selinux_maybe_reload() gets called. Since the SELinux status page has not been opened, selinux_status_updated() will fail with EINVAL. This affects particularly test binaries. Just exit early and avoid confusing debug logs. --- src/basic/selinux-util.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/basic/selinux-util.c b/src/basic/selinux-util.c index 2876b718bf8..9b3b15d387d 100644 --- a/src/basic/selinux-util.c +++ b/src/basic/selinux-util.c @@ -153,6 +153,9 @@ void mac_selinux_maybe_reload(void) { #if HAVE_SELINUX int r; + if (!initialized) + return; + r = selinux_status_updated(); if (r < 0) log_debug_errno(errno, "Failed to update SELinux from status page: %m"); -- 2.47.3