mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-16 14:18:27 +00:00
Delegate access to entrypoints via SCM rights
This patch eliminates the thread ID portion of the 'Native_capability' type. The access to entrypoints is now exclusively handled by passing socket descripts over Unix domain sockets and by inheriting the socket descriptor of the parent entrypoint at process-creation time. Each entrypoint creates a socket pair. The server-side socket is bound to a unique name defined by the server. The client-side socket is then connected to the same name. Whereas the server-side socket is meant to be exclusively used by the server to wait for incoming requests, the client-side socket can be delegated to other processes as payload of RPC messages (via SCM rights). Anyone who receives a capability over RPC receives the client-side socket of the entrypoint to which the capability refers. Given this socket descriptor, the unique name (as defined by the server) can be requested using 'getpeername'. Using this name, it is possible to compare socket descriptors, which is important to avoid duplicates from polluting the limited socket-descriptor name space. Wheras this patch introduces capability-based delegation of access rights to entrypoints, it does not cover the protection of the integrity of RPC objects. RPC objects are still referenced by a global ID passed as normal message payload.
This commit is contained in:
@ -16,50 +16,23 @@
|
||||
|
||||
#include <base/ipc_generic.h>
|
||||
|
||||
#include <base/snprintf.h>
|
||||
|
||||
extern "C" int raw_write_str(const char *str);
|
||||
extern "C" void wait_for_continue(void);
|
||||
|
||||
#define PRAWW(fmt, ...) \
|
||||
do { \
|
||||
char str[128]; \
|
||||
Genode::snprintf(str, sizeof(str), \
|
||||
ESC_ERR fmt ESC_END "\n", ##__VA_ARGS__); \
|
||||
raw_write_str(str); \
|
||||
} while (0)
|
||||
|
||||
|
||||
inline void Genode::Ipc_ostream::_marshal_capability(Genode::Native_capability const &cap)
|
||||
{
|
||||
|
||||
PRAWW("_marshal_capability called: local_name=%ld, tid=%ld, socket=%d",
|
||||
cap.local_name(), cap.dst().tid, cap.dst().socket);
|
||||
|
||||
_write_to_buf(cap.local_name());
|
||||
_write_to_buf(cap.dst().tid);
|
||||
|
||||
if (cap.valid()) {
|
||||
PRAWW("append_cap");
|
||||
if (cap.valid())
|
||||
_snd_msg->append_cap(cap.dst().socket);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void Genode::Ipc_istream::_unmarshal_capability(Genode::Native_capability &cap)
|
||||
{
|
||||
long local_name = 0;
|
||||
long tid = 0;
|
||||
int socket = -1;
|
||||
|
||||
_read_from_buf(local_name);
|
||||
_read_from_buf(tid);
|
||||
|
||||
bool const cap_valid = (tid != 0);
|
||||
if (cap_valid)
|
||||
socket = _rcv_msg->read_cap();
|
||||
|
||||
cap = Native_capability(Cap_dst_policy::Dst(tid, socket), local_name);
|
||||
int const socket = _rcv_msg->read_cap();
|
||||
cap = Native_capability(Cap_dst_policy::Dst(socket), local_name);
|
||||
}
|
||||
|
||||
#endif /* _INCLUDE__BASE__IPC_H_ */
|
||||
|
Reference in New Issue
Block a user