Revert KDBUS_HELLO_ACCEPT_MEMFD support (ABI break)
authorKay Sievers <kay@vrfy.org>
Fri, 17 Oct 2014 08:00:35 +0000 (10:00 +0200)
committerKay Sievers <kay@vrfy.org>
Fri, 17 Oct 2014 08:08:42 +0000 (10:08 +0200)
Memfds are a basic exchange mechanism not supposed to be
optional per connection. A per-bus flag, instead of a
per-connection one, would probably be acceptable,
but its usefulness is questionable at this point.

Broadcasts can contain memfds and we would silently messages
for such connections, which is not the expected behavior.

Receivers just need to make sure to be able to receive messages
with memfd payload, otherwise they are just not fully supporting
the common kdbus interface.

Contracts of not supporting memfds on private buses are fine,
but the general purpose communication will always require
memfds to be supported by all clients.

connection.c
kdbus.h
kdbus.txt
test/kdbus-util.c
test/test-connection.c
tools/kdbus-monitor.c

index bbc87b1aa73478fd6e0ee217bbc0cf843177d71c..e4464cff84f329143402e0025e5153cffe51034f 100644 (file)
@@ -507,7 +507,7 @@ static int kdbus_conn_entry_insert(struct kdbus_conn *conn,
        }
 
        if ((kmsg->fds && !(conn->flags & KDBUS_HELLO_ACCEPT_FD)) ||
-           (kmsg->memfds_count && !(conn->flags & KDBUS_HELLO_ACCEPT_MEMFD))) {
+           (kmsg->memfds_count && !(conn->flags & KDBUS_HELLO_ACCEPT_FD))) {
                ret = -ECOMM;
                goto exit_unlock;
        }
@@ -1415,10 +1415,9 @@ int kdbus_conn_new(struct kdbus_ep *ep,
        BUG_ON(*c);
 
        /* Reject unknown flags */
-       if (hello->conn_flags & ~(KDBUS_HELLO_ACCEPT_FD         |
-                                 KDBUS_HELLO_ACCEPT_MEMFD      |
-                                 KDBUS_HELLO_ACTIVATOR         |
-                                 KDBUS_HELLO_POLICY_HOLDER     |
+       if (hello->conn_flags & ~(KDBUS_HELLO_ACCEPT_FD |
+                                 KDBUS_HELLO_ACTIVATOR |
+                                 KDBUS_HELLO_POLICY_HOLDER |
                                  KDBUS_HELLO_MONITOR))
                return -EOPNOTSUPP;
 
diff --git a/kdbus.h b/kdbus.h
index 1ea4329ea2642bbd572c5937624f389028ed169b..79a17f3449a55cd9ce36019f1a90e0e99c85a4eb 100644 (file)
--- a/kdbus.h
+++ b/kdbus.h
@@ -500,8 +500,6 @@ enum kdbus_policy_type {
  * enum kdbus_hello_flags - flags for struct kdbus_cmd_hello
  * @KDBUS_HELLO_ACCEPT_FD:     The connection allows the reception of
  *                             any passed file descriptors
- * @KDBUS_HELLO_ACCEPT_MEMFD:  The connection allows the reception of
- *                             any passed memfd file descriptors
  * @KDBUS_HELLO_ACTIVATOR:     Special-purpose connection which registers
  *                             a well-know name for a process to be started
  *                             when traffic arrives
@@ -516,10 +514,9 @@ enum kdbus_policy_type {
  */
 enum kdbus_hello_flags {
        KDBUS_HELLO_ACCEPT_FD           =  1ULL <<  0,
-       KDBUS_HELLO_ACCEPT_MEMFD        =  1ULL <<  1,
-       KDBUS_HELLO_ACTIVATOR           =  1ULL <<  2,
-       KDBUS_HELLO_POLICY_HOLDER       =  1ULL <<  3,
-       KDBUS_HELLO_MONITOR             =  1ULL <<  4,
+       KDBUS_HELLO_ACTIVATOR           =  1ULL <<  1,
+       KDBUS_HELLO_POLICY_HOLDER       =  1ULL <<  2,
+       KDBUS_HELLO_MONITOR             =  1ULL <<  3,
 };
 
 /**
index 6e8b0901ae91bf51f02baa0610b1a86ee758ac88..3a219be698c5650e9a44d9fb19be399f287e2ef1 100644 (file)
--- a/kdbus.txt
+++ b/kdbus.txt
@@ -442,11 +442,6 @@ struct kdbus_cmd_hello {
       as message payload. If it's not set, any attempt of doing so will
       result in -ECOMM on the sender's side.
 
-    KDBUS_HELLO_ACCEPT_MEMFD
-      When this flag is set, the connection can be sent memfd file
-      descriptors as message payload. If it's not set, any attempt of
-      doing so will result in -ECOMM on the sender's side.
-
     KDBUS_HELLO_ACTIVATOR
       Make this connection an activator (see below). With this bit set,
       an item of type KDBUS_ITEM_NAME has to be attached which describes
@@ -876,10 +871,9 @@ pool. The message is stored as struct kdbus_msg at this offset, and can be
 interpreted with the semantics described above.
 
 Also, if the connection allowed for file descriptor to be passed
-(KDBUS_HELLO_ACCEPT_FD or KDBUS_HELLO_ACCEPT_MEMFD), and if the message
-contained any, they will be installed into the receiving process after the
-KDBUS_CMD_MSG_RECV ioctl returns. The receiving task is obliged to close all
-of them appropriately.
+(KDBUS_HELLO_ACCEPT_FD), and if the message contained any, they will be
+installed into the receiving process after the KDBUS_CMD_MSG_RECV ioctl
+returns. The receiving task is obliged to close all of them appropriately.
 
 The caller is obliged to call KDBUS_CMD_FREE with the returned offset when
 the memory is no longer needed.
index 90e9e47e4c6e65f1f2e6fb450e1eba1b650df2e3..52b4c47d81ce2c209ca2b25ba9f51c5e73108f0f 100644 (file)
@@ -139,8 +139,7 @@ kdbus_hello(const char *path, uint64_t flags,
                return NULL;
        }
 
-       h.hello.conn_flags = flags | KDBUS_HELLO_ACCEPT_FD |
-                            KDBUS_HELLO_ACCEPT_MEMFD;
+       h.hello.conn_flags = flags | KDBUS_HELLO_ACCEPT_FD;
        h.hello.attach_flags = _KDBUS_ATTACH_ALL;
        h.conn_name.type = KDBUS_ITEM_CONN_NAME;
        strcpy(h.conn_name.str, "this-is-my-name");
index 7d51b4d025f56d975145de40878665c9785080b7..bc397d9b6df3be526b8c165341df8261f578507e 100644 (file)
@@ -104,7 +104,7 @@ int kdbus_test_hello(struct kdbus_test_env *env)
        if (fd < 0)
                return TEST_ERR;
 
-       hello.conn_flags = KDBUS_HELLO_ACCEPT_FD | KDBUS_HELLO_ACCEPT_MEMFD;
+       hello.conn_flags = KDBUS_HELLO_ACCEPT_FD;
        hello.attach_flags = _KDBUS_ATTACH_ALL;
        hello.size = sizeof(struct kdbus_cmd_hello);
        hello.pool_size = POOL_SIZE;
@@ -125,6 +125,8 @@ int kdbus_test_hello(struct kdbus_test_env *env)
        ret = ioctl(fd, KDBUS_CMD_HELLO, &hello);
        ASSERT_RETURN(ret == -1 && errno == EOPNOTSUPP);
 
+       hello.conn_flags = KDBUS_HELLO_ACCEPT_FD;
+
        /* check for faulty pool sizes */
        hello.pool_size = 0;
        ret = ioctl(fd, KDBUS_CMD_HELLO, &hello);
@@ -134,9 +136,9 @@ int kdbus_test_hello(struct kdbus_test_env *env)
        ret = ioctl(fd, KDBUS_CMD_HELLO, &hello);
        ASSERT_RETURN(ret == -1 && errno == EFAULT);
 
-       /* success test */
        hello.pool_size = POOL_SIZE;
-       hello.conn_flags = KDBUS_HELLO_ACCEPT_FD | KDBUS_HELLO_ACCEPT_MEMFD;
+
+       /* success test */
        ret = ioctl(fd, KDBUS_CMD_HELLO, &hello);
        ASSERT_RETURN(ret == 0);
 
@@ -302,7 +304,7 @@ int kdbus_test_writable_pool(struct kdbus_test_env *env)
        ASSERT_RETURN(fd >= 0);
 
        memset(&hello, 0, sizeof(hello));
-       hello.conn_flags = KDBUS_HELLO_ACCEPT_FD | KDBUS_HELLO_ACCEPT_MEMFD;
+       hello.conn_flags = KDBUS_HELLO_ACCEPT_FD;
        hello.attach_flags = _KDBUS_ATTACH_ALL;
        hello.size = sizeof(struct kdbus_cmd_hello);
        hello.pool_size = POOL_SIZE;
index ef7381e76ab3de82803fd9421f861b1a91e9531b..4bb61b70f869c99bf67c367eb9a4a037c0e02482 100644 (file)
@@ -81,8 +81,7 @@ static struct conn *kdbus_hello(const char *path, uint64_t flags)
                return NULL;
        }
 
-       h.hello.conn_flags = flags | KDBUS_HELLO_ACCEPT_FD |
-                            KDBUS_HELLO_ACCEPT_MEMFD;
+       h.hello.conn_flags = flags | KDBUS_HELLO_ACCEPT_FD;
        h.hello.attach_flags = _KDBUS_ATTACH_ALL;
        h.type = KDBUS_ITEM_CONN_NAME;
        strncpy(h.comm, "monitor", sizeof(h.comm) - 1);