goto exit_unlock;
}
- if (kmsg->fds && !(conn->flags & KDBUS_HELLO_ACCEPT_FD)) {
+ if ((kmsg->fds && !(conn->flags & KDBUS_HELLO_ACCEPT_FD)) ||
+ (kmsg->memfds_count && !(conn->flags & KDBUS_HELLO_ACCEPT_FD))) {
ret = -ECOMM;
goto exit_unlock;
}
BUG_ON(*c);
/* Reject unknown flags */
- if (hello->conn_flags & ~(KDBUS_HELLO_ACCEPT_FD |
- KDBUS_HELLO_ACTIVATOR |
- KDBUS_HELLO_POLICY_HOLDER |
+ if (hello->conn_flags & ~(KDBUS_HELLO_ACCEPT_FD |
+ KDBUS_HELLO_ACCEPT_MEMFD |
+ KDBUS_HELLO_ACTIVATOR |
+ KDBUS_HELLO_POLICY_HOLDER |
KDBUS_HELLO_MONITOR))
return -EOPNOTSUPP;
* 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
*/
enum kdbus_hello_flags {
KDBUS_HELLO_ACCEPT_FD = 1ULL << 0,
- KDBUS_HELLO_ACTIVATOR = 1ULL << 1,
- KDBUS_HELLO_POLICY_HOLDER = 1ULL << 2,
- KDBUS_HELLO_MONITOR = 1ULL << 3,
+ KDBUS_HELLO_ACCEPT_MEMFD = 1ULL << 1,
+ KDBUS_HELLO_ACTIVATOR = 1ULL << 2,
+ KDBUS_HELLO_POLICY_HOLDER = 1ULL << 3,
+ KDBUS_HELLO_MONITOR = 1ULL << 4,
};
/**
return NULL;
}
- h.hello.conn_flags = flags | KDBUS_HELLO_ACCEPT_FD;
+ h.hello.conn_flags = flags | KDBUS_HELLO_ACCEPT_FD |
+ KDBUS_HELLO_ACCEPT_MEMFD;
h.hello.attach_flags = _KDBUS_ATTACH_ALL;
h.conn_name.type = KDBUS_ITEM_CONN_NAME;
strcpy(h.conn_name.str, "this-is-my-name");
if (fd < 0)
return TEST_ERR;
- hello.conn_flags = KDBUS_HELLO_ACCEPT_FD;
+ hello.conn_flags = KDBUS_HELLO_ACCEPT_FD | KDBUS_HELLO_ACCEPT_MEMFD;
hello.attach_flags = _KDBUS_ATTACH_ALL;
hello.size = sizeof(struct kdbus_cmd_hello);
hello.pool_size = POOL_SIZE;
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);
ret = ioctl(fd, KDBUS_CMD_HELLO, &hello);
ASSERT_RETURN(ret == -1 && errno == EFAULT);
- hello.pool_size = POOL_SIZE;
-
/* success test */
+ hello.pool_size = POOL_SIZE;
+ hello.conn_flags = KDBUS_HELLO_ACCEPT_FD | KDBUS_HELLO_ACCEPT_MEMFD;
ret = ioctl(fd, KDBUS_CMD_HELLO, &hello);
ASSERT_RETURN(ret == 0);
ASSERT_RETURN(fd >= 0);
memset(&hello, 0, sizeof(hello));
- hello.conn_flags = KDBUS_HELLO_ACCEPT_FD;
+ hello.conn_flags = KDBUS_HELLO_ACCEPT_FD | KDBUS_HELLO_ACCEPT_MEMFD;
hello.attach_flags = _KDBUS_ATTACH_ALL;
hello.size = sizeof(struct kdbus_cmd_hello);
hello.pool_size = POOL_SIZE;
return NULL;
}
- h.hello.conn_flags = flags | KDBUS_HELLO_ACCEPT_FD;
+ h.hello.conn_flags = flags | KDBUS_HELLO_ACCEPT_FD |
+ KDBUS_HELLO_ACCEPT_MEMFD;
h.hello.attach_flags = _KDBUS_ATTACH_ALL;
h.type = KDBUS_ITEM_CONN_NAME;
strncpy(h.comm, "monitor", sizeof(h.comm) - 1);