Blame SOURCES/dbus-1.6.12-avoid-hardcoded-selinux-constants.patch

6c002b
From 4b4747fe3533a6a34a901ec6cf1a99cef9f1dd2b Mon Sep 17 00:00:00 2001
6c002b
From: osmond sun <osmond.sun@gmail.com>
6c002b
Date: Wed, 6 Nov 2013 00:53:18 +0800
6c002b
Subject: [PATCH 1/2] selinux: Use selinux_set_mapping() to avoid hardcoded
6c002b
 constants for policy
6c002b
6c002b
Previous to the introduction of selinux_set_mapping(), DBus pulled
6c002b
constants generated from the system's policy at build time.  But this
6c002b
means it's impossible to replace the system policy without rebuilding
6c002b
userspace components.
6c002b
6c002b
This patch maps from arbitrary class/perm indices used by D-Bus and
6c002b
the policy values and handles all the translation at runtime on
6c002b
avc_has_perm() calls.
6c002b
6c002b
Bug: https://bugs.freedesktop.org/attachment.cgi?id=88719
6c002b
Reviewed-By: Colin Walters <walters@verbum.org>
6c002b
Tested-By: Colin Walters <walters@verbum.org>
6c002b
---
6c002b
 bus/bus.c     |  2 +-
6c002b
 bus/selinux.c | 30 +++++++++++++++++++++++++++---
6c002b
 2 files changed, 28 insertions(+), 4 deletions(-)
6c002b
6c002b
diff --git a/bus/bus.c b/bus/bus.c
6c002b
index 59274ee..f4fad5b 100644
6c002b
--- a/bus/bus.c
6c002b
+++ b/bus/bus.c
6c002b
@@ -902,7 +902,7 @@ bus_context_new (const DBusString *config_file,
6c002b
 
6c002b
   if (!bus_selinux_full_init ())
6c002b
     {
6c002b
-      bus_context_log (context, DBUS_SYSTEM_LOG_FATAL, "SELinux enabled but AVC initialization failed; check system log\n");
6c002b
+      bus_context_log (context, DBUS_SYSTEM_LOG_FATAL, "SELinux enabled but D-Bus initialization failed; check system log\n");
6c002b
     }
6c002b
 
6c002b
   if (!process_config_postinit (context, parser, error))
6c002b
diff --git a/bus/selinux.c b/bus/selinux.c
6c002b
index 6442b79..9a1d4b4 100644
6c002b
--- a/bus/selinux.c
6c002b
+++ b/bus/selinux.c
6c002b
@@ -44,8 +44,6 @@
6c002b
 #include <syslog.h>
6c002b
 #include <selinux/selinux.h>
6c002b
 #include <selinux/avc.h>
6c002b
-#include <selinux/av_permissions.h>
6c002b
-#include <selinux/flask.h>
6c002b
 #include <signal.h>
6c002b
 #include <stdarg.h>
6c002b
 #include <stdio.h>
6c002b
@@ -341,8 +339,27 @@ bus_selinux_pre_init (void)
6c002b
 #endif
6c002b
 }
6c002b
 
6c002b
+/*
6c002b
+ * Private Flask definitions; the order of these constants must
6c002b
+ * exactly match that of the structure array below!
6c002b
+ */
6c002b
+/* security dbus class constants */
6c002b
+#define SECCLASS_DBUS       1
6c002b
+
6c002b
+/* dbus's per access vector constants */
6c002b
+#define DBUS__ACQUIRE_SVC   1
6c002b
+#define DBUS__SEND_MSG      2
6c002b
+
6c002b
+#ifdef HAVE_SELINUX
6c002b
+static struct security_class_mapping dbus_map[] = {
6c002b
+  { "dbus", { "acquire_svc", "send_msg", NULL } },
6c002b
+  { NULL }
6c002b
+};
6c002b
+#endif /* HAVE_SELINUX */
6c002b
+
6c002b
 /**
6c002b
- * Initialize the user space access vector cache (AVC) for D-Bus and set up
6c002b
+ * Establish dynamic object class and permission mapping and
6c002b
+ * initialize the user space access vector cache (AVC) for D-Bus and set up
6c002b
  * logging callbacks.
6c002b
  */
6c002b
 dbus_bool_t
6c002b
@@ -361,6 +378,13 @@ bus_selinux_full_init (void)
6c002b
 
6c002b
   _dbus_verbose ("SELinux is enabled in this kernel.\n");
6c002b
 
6c002b
+  if (selinux_set_mapping (dbus_map) < 0)
6c002b
+    {
6c002b
+      _dbus_warn ("Failed to set up security class mapping (selinux_set_mapping():%s).\n",
6c002b
+                   strerror (errno));
6c002b
+      return FALSE; 
6c002b
+    }
6c002b
+
6c002b
   avc_entry_ref_init (&aeref);
6c002b
   if (avc_init ("avc", &mem_cb, &log_cb, &thread_cb, &lock_cb) < 0)
6c002b
     {
6c002b
-- 
6c002b
2.7.4
6c002b
6c002b
6c002b
From 1859b1e672ca2cbcc05b43cf20aba3df2ca48317 Mon Sep 17 00:00:00 2001
6c002b
From: David King <dking@redhat.com>
6c002b
Date: Mon, 8 Aug 2016 13:25:14 +0200
6c002b
Subject: [PATCH 2/2] Rebase MLS change against new SELinux checks
6c002b
6c002b
https://bugzilla.redhat.com/show_bug.cgi?id=1364485
6c002b
---
6c002b
 bus/selinux.c | 4 ++++
6c002b
 1 file changed, 4 insertions(+)
6c002b
6c002b
diff --git a/bus/selinux.c b/bus/selinux.c
6c002b
index 9a1d4b4..2fb4a8b 100644
6c002b
--- a/bus/selinux.c
6c002b
+++ b/bus/selinux.c
6c002b
@@ -345,14 +345,18 @@ bus_selinux_pre_init (void)
6c002b
  */
6c002b
 /* security dbus class constants */
6c002b
 #define SECCLASS_DBUS       1
6c002b
+#define SECCLASS_CONTEXT    2
6c002b
 
6c002b
 /* dbus's per access vector constants */
6c002b
 #define DBUS__ACQUIRE_SVC   1
6c002b
 #define DBUS__SEND_MSG      2
6c002b
 
6c002b
+#define CONTEXT__CONTAINS   1
6c002b
+
6c002b
 #ifdef HAVE_SELINUX
6c002b
 static struct security_class_mapping dbus_map[] = {
6c002b
   { "dbus", { "acquire_svc", "send_msg", NULL } },
6c002b
+  { "context", { "contains", NULL } },
6c002b
   { NULL }
6c002b
 };
6c002b
 #endif /* HAVE_SELINUX */
6c002b
-- 
6c002b
2.7.4
6c002b