connection: check policy for reply-awaiting messages as well
authorDaniel Mack <daniel@zonque.org>
Fri, 5 Sep 2014 16:39:57 +0000 (18:39 +0200)
committerDaniel Mack <daniel@zonque.org>
Fri, 5 Sep 2014 16:39:57 +0000 (18:39 +0200)
The current logic in bogus. We need to call kdbus_conn_check_access()
for messages that require a message as well. Also, teach
kdbus_conn_check_access() a mode in which not to look up expected
replies of a connection.

connection.c

index 1620f1e19f43586c182cf00e8d06e7d58f3a0309..ba47a1de16343db141c3cb3746eff5dd37e8592b 100644 (file)
@@ -1266,7 +1266,7 @@ static int kdbus_conn_check_access(struct kdbus_ep *ep,
         * If there's any matching entry, allow the message to
         * be sent, and remove the entry.
         */
-       if (msg->cookie_reply > 0) {
+       if (reply_wake && msg->cookie_reply > 0) {
                struct kdbus_conn_reply *r, *r_tmp;
                LIST_HEAD(reply_list);
 
@@ -1279,8 +1279,7 @@ static int kdbus_conn_check_access(struct kdbus_ep *ep,
                                if (r->sync)
                                        *reply_wake = r;
                                else
-                                       list_move_tail(&r->entry,
-                                                      &reply_list);
+                                       list_move_tail(&r->entry, &reply_list);
 
                                allowed = true;
                                break;
@@ -1500,15 +1499,22 @@ int kdbus_conn_kmsg_send(struct kdbus_ep *ep,
                kmsg->dst_name_id = entry->name_id;
 
        if (conn_src) {
-               if (msg->flags & KDBUS_MSG_FLAGS_EXPECT_REPLY)
+               if (msg->flags & KDBUS_MSG_FLAGS_EXPECT_REPLY) {
+                       ret = kdbus_conn_check_access(ep, msg, conn_src,
+                                                     conn_dst, NULL);
+                       if (ret < 0)
+                               goto exit_unref;
+
                        ret = kdbus_conn_add_expected_reply(conn_src, conn_dst,
                                                            msg, &reply_wait);
-               else
+                       if (ret < 0)
+                               goto exit_unref;
+               } else {
                        ret = kdbus_conn_check_access(ep, msg, conn_src,
                                                      conn_dst, &reply_wake);
-
-               if (ret < 0)
-                       goto exit_unref;
+                       if (ret < 0)
+                               goto exit_unref;
+               }
 
                ret = kdbus_meta_append(kmsg->meta, conn_src, kmsg->seq,
                                        conn_dst->attach_flags);