mirror of
https://github.com/drasko/codezero.git
synced 2026-10-24 11:47:27 +02:00
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.
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
#include <l4/macros.h>
|
#include <l4/macros.h>
|
||||||
#include <libposix.h>
|
#include <libposix.h>
|
||||||
|
|
||||||
static inline void __attribute__ ((noreturn)) l4_exit(int status)
|
static inline void __attribute__ ((noreturn)) l4_exit_ipc(int status)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -22,6 +22,6 @@ static inline void __attribute__ ((noreturn)) l4_exit(int status)
|
|||||||
|
|
||||||
void __attribute__ ((noreturn)) _exit(int status)
|
void __attribute__ ((noreturn)) _exit(int status)
|
||||||
{
|
{
|
||||||
l4_exit(status);
|
l4_exit_ipc(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,4 +20,8 @@
|
|||||||
#define CAP_SHARE_CHILD 0x08 /* All that we are pager of */
|
#define CAP_SHARE_CHILD 0x08 /* All that we are pager of */
|
||||||
#define CAP_SHARE_SIBLING 0x10 /* All that have a common pager */
|
#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__ */
|
#endif /* __API_CAPABILITY_H__ */
|
||||||
|
|||||||
+11
-7
@@ -14,6 +14,10 @@
|
|||||||
#include <l4/api/errno.h>
|
#include <l4/api/errno.h>
|
||||||
#include INC_API(syscall.h)
|
#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 read_task_capabilities(void *userbuf)
|
||||||
{
|
{
|
||||||
int copy_size, copy_offset = 0;
|
int copy_size, copy_offset = 0;
|
||||||
@@ -27,8 +31,8 @@ int read_task_capabilities(void *userbuf)
|
|||||||
if (current != current->pager->tcb)
|
if (current != current->pager->tcb)
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
/* Determine size of pager capabilities */
|
/* Determine size of pager capabilities (FIXME: partial!) */
|
||||||
copy_size = current->cap_list.ncaps * sizeof(*cap);
|
copy_size = TASK_CAP_LIST(current)->ncaps * sizeof(*cap);
|
||||||
|
|
||||||
/* Validate user buffer for this copy size */
|
/* Validate user buffer for this copy size */
|
||||||
if ((err = check_access((unsigned long)userbuf,
|
if ((err = check_access((unsigned long)userbuf,
|
||||||
@@ -37,7 +41,7 @@ int read_task_capabilities(void *userbuf)
|
|||||||
return err;
|
return err;
|
||||||
|
|
||||||
/* Copy capabilities from list to buffer */
|
/* Copy capabilities from list to buffer */
|
||||||
list_foreach_struct(cap, ¤t->cap_list.caps,
|
list_foreach_struct(cap, &TASK_CAP_LIST(current)->caps,
|
||||||
list) {
|
list) {
|
||||||
memcpy(userbuf + copy_offset,
|
memcpy(userbuf + copy_offset,
|
||||||
cap, sizeof(*cap));
|
cap, sizeof(*cap));
|
||||||
@@ -62,11 +66,11 @@ int capability_share(unsigned int share_flags)
|
|||||||
switch (share_flags) {
|
switch (share_flags) {
|
||||||
case CAP_SHARE_SPACE:
|
case CAP_SHARE_SPACE:
|
||||||
cap_list_move(¤t->space->cap_list,
|
cap_list_move(¤t->space->cap_list,
|
||||||
¤t->cap_list);
|
TASK_CAP_LIST(current));
|
||||||
break;
|
break;
|
||||||
case CAP_SHARE_CONTAINER:
|
case CAP_SHARE_CONTAINER:
|
||||||
cap_list_move(&curcont->cap_list,
|
cap_list_move(&curcont->cap_list,
|
||||||
¤t->cap_list);
|
TASK_CAP_LIST(current));
|
||||||
break;
|
break;
|
||||||
#if 0
|
#if 0
|
||||||
case CAP_SHARE_CHILD:
|
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)
|
MAP_USR_RW_FLAGS, 1)) < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
/* Copy ncaps value */
|
/* Copy ncaps value. FIXME: This is only a partial list */
|
||||||
*((int *)userbuf) = current->cap_list.ncaps;
|
*((int *)userbuf) = TASK_CAP_LIST(current)->ncaps;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Return all capabilities as an array of capabilities */
|
/* Return all capabilities as an array of capabilities */
|
||||||
|
|||||||
Reference in New Issue
Block a user