Capability replicate/split/destroy/grant working for test0 ipc.

Implemented a protocol between a client and its pager to
request and get a capability to ipc to another client of the pager.

Pager first ensures the request is valid from its client.
It then tries to use a greater capability that it possesses, to
produce a new capability that the client requested. Once the kernel
validates the correct one and replicates/reduces it to client's
need, it grants it to the client.
This commit is contained in:
Bahadir Balban
2009-11-09 00:40:07 +02:00
parent 1bb2c05c9b
commit b24c8eb89d
7 changed files with 195 additions and 78 deletions

View File

@@ -154,6 +154,43 @@ struct capability *cap_find_byid(l4id_t capid)
return 0;
}
/*
* TODO: Instead of destroying, use cap_find_byid match function's
* match_args to pass a pointer to the capability list, so the
* caller may destroy it
*/
int cap_find_destroy(l4id_t capid)
{
struct capability *cap;
struct ktcb *task = current;
/* Search task's own list */
list_foreach_struct(cap, &task->cap_list.caps, list)
if (cap->capid == capid) {
cap_list_remove(cap, &task->cap_list);
free_capability(cap);
return 0;
}
/* Search space list */
list_foreach_struct(cap, &task->space->cap_list.caps, list)
if (cap->capid == capid) {
cap_list_remove(cap, &task->space->cap_list);
free_capability(cap);
return 0;
}
/* Search container list */
list_foreach_struct(cap, &task->container->cap_list.caps, list)
if (cap->capid == capid) {
cap_list_remove(cap, &task->container->cap_list);
free_capability(cap);
return 0;
}
return -EEXIST;
}
typedef struct capability *(*cap_match_func_t) \
(struct capability *cap, void *match_args);
@@ -273,6 +310,9 @@ cap_match_capctrl(struct capability *cap, void *args_ptr)
if (req == CAP_CONTROL_DEDUCE)
if (!(cap->access & CAP_CAP_DEDUCE))
return 0;
if (req == CAP_CONTROL_DESTROY)
if (!(cap->access & CAP_CAP_DESTROY))
return 0;
/* Now check the usual restype/resid pair */
switch (cap_rtype(cap)) {