Blame SOURCES/0107-Refuse-dbus-message-paths-longer-than-BUS_PATH_SIZE_.patch

a3e2b5
From ac9c51b72213bcea3dc9cea330d4c5fce9c4470e Mon Sep 17 00:00:00 2001
a3e2b5
From: Riccardo Schirone <rschiron@redhat.com>
a3e2b5
Date: Mon, 4 Feb 2019 14:29:09 +0100
a3e2b5
Subject: [PATCH] Refuse dbus message paths longer than BUS_PATH_SIZE_MAX
a3e2b5
 limit.
a3e2b5
a3e2b5
Even though the dbus specification does not enforce any length limit on the
a3e2b5
path of a dbus message, having to analyze too long strings in PID1 may be
a3e2b5
time-consuming and it may have security impacts.
a3e2b5
a3e2b5
In any case, the limit is set so high that real-life applications should not
a3e2b5
have a problem with it.
a3e2b5
a3e2b5
(cherry-picked from commit 61397a60d98e368a5720b37e83f3169e3eb511c4)
a3e2b5
a3e2b5
Related: #1678641
a3e2b5
---
a3e2b5
 src/libsystemd/sd-bus/bus-internal.c | 2 +-
a3e2b5
 src/libsystemd/sd-bus/bus-internal.h | 4 ++++
a3e2b5
 2 files changed, 5 insertions(+), 1 deletion(-)
a3e2b5
a3e2b5
diff --git a/src/libsystemd/sd-bus/bus-internal.c b/src/libsystemd/sd-bus/bus-internal.c
a3e2b5
index 7bb653338d..35e0b668ee 100644
a3e2b5
--- a/src/libsystemd/sd-bus/bus-internal.c
a3e2b5
+++ b/src/libsystemd/sd-bus/bus-internal.c
a3e2b5
@@ -45,7 +45,7 @@ bool object_path_is_valid(const char *p) {
a3e2b5
         if (slash)
a3e2b5
                 return false;
a3e2b5
 
a3e2b5
-        return true;
a3e2b5
+        return (q - p) <= BUS_PATH_SIZE_MAX;
a3e2b5
 }
a3e2b5
 
a3e2b5
 char* object_path_startswith(const char *a, const char *b) {
a3e2b5
diff --git a/src/libsystemd/sd-bus/bus-internal.h b/src/libsystemd/sd-bus/bus-internal.h
a3e2b5
index 2087ef8eeb..90e6028983 100644
a3e2b5
--- a/src/libsystemd/sd-bus/bus-internal.h
a3e2b5
+++ b/src/libsystemd/sd-bus/bus-internal.h
a3e2b5
@@ -333,6 +333,10 @@ struct sd_bus {
a3e2b5
 
a3e2b5
 #define BUS_MESSAGE_SIZE_MAX (128*1024*1024)
a3e2b5
 #define BUS_AUTH_SIZE_MAX (64*1024)
a3e2b5
+/* Note that the D-Bus specification states that bus paths shall have no size limit. We enforce here one
a3e2b5
+ * anyway, since truly unbounded strings are a security problem. The limit we pick is relatively large however,
a3e2b5
+ * to not clash unnecessarily with real-life applications. */
a3e2b5
+#define BUS_PATH_SIZE_MAX (64*1024)
a3e2b5
 
a3e2b5
 #define BUS_CONTAINER_DEPTH 128
a3e2b5