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