summaryrefslogtreecommitdiffstats
path: root/kdbus-make-metadata-on-broadcasts-reliable.patch
blob: e76f429c586d325394ef61c90595b7bb0020603e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
From: David Herrmann <dh.herrmann@gmail.com>
Date: Tue, 26 May 2015 10:01:37 +0200
Subject: [PATCH] kdbus: make metadata on broadcasts reliable

If we cannot collect metadata, this is a serious error. Don't try to
continue sending a message, but immediately bail out and tell the receiver
that we dropped it. Otherwise, the receiver cannot rely on metadata to be
present and might assume it's a faked connection.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Acked-by: Daniel Mack <daniel@zonque.org>
---
 ipc/kdbus/bus.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/ipc/kdbus/bus.c b/ipc/kdbus/bus.c
index 9a0ecbc9df2f..d5475961b896 100644
--- a/ipc/kdbus/bus.c
+++ b/ipc/kdbus/bus.c
@@ -293,12 +293,12 @@ void kdbus_bus_broadcast(struct kdbus_bus *bus,
 			if (!kdbus_conn_policy_talk(conn_dst, NULL, conn_src))
 				continue;
 
-			/*
-			 * Keep sending messages even if we cannot acquire the
-			 * requested metadata. It's up to the receiver to drop
-			 * messages that lack expected metadata.
-			 */
-			kdbus_kmsg_collect_metadata(kmsg, conn_src, conn_dst);
+			ret = kdbus_kmsg_collect_metadata(kmsg, conn_src,
+							  conn_dst);
+			if (ret < 0) {
+				kdbus_conn_lost_message(conn_dst);
+				continue;
+			}
 		} else {
 			/*
 			 * Check if there is a policy db that prevents the
@@ -344,14 +344,14 @@ void kdbus_bus_eavesdrop(struct kdbus_bus *bus,
 
 	down_read(&bus->conn_rwlock);
 	list_for_each_entry(conn_dst, &bus->monitors_list, monitor_entry) {
-		/*
-		 * Collect metadata requested by the destination connection.
-		 * Ignore errors, as receivers need to check metadata
-		 * availability, anyway. So it's still better to send messages
-		 * that lack data, than to skip it entirely.
-		 */
-		if (conn_src)
-			kdbus_kmsg_collect_metadata(kmsg, conn_src, conn_dst);
+		if (conn_src) {
+			ret = kdbus_kmsg_collect_metadata(kmsg, conn_src,
+							  conn_dst);
+			if (ret < 0) {
+				kdbus_conn_lost_message(conn_dst);
+				continue;
+			}
+		}
 
 		ret = kdbus_conn_entry_insert(conn_src, conn_dst, kmsg, NULL);
 		if (ret < 0)