From 18ffa0b4d126f3e81418f522ab92a7d6400767d9 Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Fri, 30 Oct 2009 13:46:47 +0200 Subject: [PATCH] Added a TASK_CAP_LIST macro that abstracts away the primary cap list We moved initial list of a pager's caps from ktcb to task's space since the task is expected to trust its space. Most references to task->cap_list had to change. Although a single cap list only tells part of the story about the task's caps, the TASK_CAP_LIST macro works for us to get the first private set of caps that a task has. --- conts/posix/libposix/exit.c | 4 ++-- include/l4/api/capability.h | 4 ++++ src/api/cap.c | 18 +++++++++++------- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/conts/posix/libposix/exit.c b/conts/posix/libposix/exit.c index 904aabe..b396eba 100644 --- a/conts/posix/libposix/exit.c +++ b/conts/posix/libposix/exit.c @@ -6,7 +6,7 @@ #include #include -static inline void __attribute__ ((noreturn)) l4_exit(int status) +static inline void __attribute__ ((noreturn)) l4_exit_ipc(int status) { int ret; @@ -22,6 +22,6 @@ static inline void __attribute__ ((noreturn)) l4_exit(int status) void __attribute__ ((noreturn)) _exit(int status) { - l4_exit(status); + l4_exit_ipc(status); } diff --git a/include/l4/api/capability.h b/include/l4/api/capability.h index 2e0f7d1..8b53411 100644 --- a/include/l4/api/capability.h +++ b/include/l4/api/capability.h @@ -20,4 +20,8 @@ #define CAP_SHARE_CHILD 0x08 /* All that we are pager of */ #define CAP_SHARE_SIBLING 0x10 /* All that have a common pager */ +/* Task's primary capability list */ +#define TASK_CAP_LIST(task) \ + (&((task)->space->cap_list)) + #endif /* __API_CAPABILITY_H__ */ diff --git a/src/api/cap.c b/src/api/cap.c index 61fa89a..56306a2 100644 --- a/src/api/cap.c +++ b/src/api/cap.c @@ -14,6 +14,10 @@ #include #include INC_API(syscall.h) +/* + * FIXME: This is reading only a single list + * there may be more than one + */ int read_task_capabilities(void *userbuf) { int copy_size, copy_offset = 0; @@ -27,8 +31,8 @@ int read_task_capabilities(void *userbuf) if (current != current->pager->tcb) return -EPERM; - /* Determine size of pager capabilities */ - copy_size = current->cap_list.ncaps * sizeof(*cap); + /* Determine size of pager capabilities (FIXME: partial!) */ + copy_size = TASK_CAP_LIST(current)->ncaps * sizeof(*cap); /* Validate user buffer for this copy size */ if ((err = check_access((unsigned long)userbuf, @@ -37,7 +41,7 @@ int read_task_capabilities(void *userbuf) return err; /* Copy capabilities from list to buffer */ - list_foreach_struct(cap, ¤t->cap_list.caps, + list_foreach_struct(cap, &TASK_CAP_LIST(current)->caps, list) { memcpy(userbuf + copy_offset, cap, sizeof(*cap)); @@ -62,11 +66,11 @@ int capability_share(unsigned int share_flags) switch (share_flags) { case CAP_SHARE_SPACE: cap_list_move(¤t->space->cap_list, - ¤t->cap_list); + TASK_CAP_LIST(current)); break; case CAP_SHARE_CONTAINER: cap_list_move(&curcont->cap_list, - ¤t->cap_list); + TASK_CAP_LIST(current)); break; #if 0 case CAP_SHARE_CHILD: @@ -130,8 +134,8 @@ int sys_capability_control(unsigned int req, unsigned int flags, void *userbuf) MAP_USR_RW_FLAGS, 1)) < 0) return err; - /* Copy ncaps value */ - *((int *)userbuf) = current->cap_list.ncaps; + /* Copy ncaps value. FIXME: This is only a partial list */ + *((int *)userbuf) = TASK_CAP_LIST(current)->ncaps; break; /* Return all capabilities as an array of capabilities */