Minor fixes and improvements for sys_call().
This commit is contained in:
27
kernel/ipc.h
27
kernel/ipc.h
@@ -14,26 +14,25 @@
|
||||
* numbers are carefully defined so that it can easily be seen (based on
|
||||
* the bits that are on) which checks should be done in sys_call().
|
||||
*/
|
||||
#define ECHO 0 /* 0 0 0 0 1 (01) : echo a message */
|
||||
#define SEND 1 /* 0 0 0 1 1 (03) : blocking send */
|
||||
#define RECEIVE 2 /* 0 0 1 0 1 (05) : blocking receive */
|
||||
#define SENDREC 3 /* 0 0 1 1 1 (07) : SEND + RECEIVE */
|
||||
#define NOTIFY 4 /* temp */
|
||||
#define ALERT 5 /* 0 1 0 1 0 (10) : nonblocking notify */
|
||||
#define SEND 1 /* 0 0 0 1 : blocking send */
|
||||
#define RECEIVE 2 /* 0 0 1 0 : blocking receive */
|
||||
#define SENDREC 3 /* 0 0 1 1 : SEND + RECEIVE */
|
||||
#define ALERT 4 /* 0 1 0 0 : nonblocking notify */
|
||||
#define ECHO 8 /* 1 0 0 0 : echo a message */
|
||||
|
||||
/* The following definitions determine whether a calls message buffer and/
|
||||
* or destination processes should be validated.
|
||||
*/
|
||||
#define CHECK_PTR 0x01 /* 0 0 0 0 1 : validate message buffer */
|
||||
#define CHECK_DST 0x02 /* 0 0 0 1 0 : validate message destination */
|
||||
#define CHECK_SRC 0x04 /* 0 0 1 0 0 : validate message source */
|
||||
#define NOTIFY 16 /* 1 0 0 0 0 : temp */
|
||||
|
||||
/* The following bit masks determine what checks that should be done. */
|
||||
#define CHECK_PTR 0x0B /* 1 0 1 1 : validate message buffer */
|
||||
#define CHECK_DST 0x05 /* 0 1 0 1 : validate message destination */
|
||||
#define CHECK_SRC 0x02 /* 0 0 1 0 : validate message source */
|
||||
|
||||
/* Call masks indicating which system calls (traps) a process can make.
|
||||
* The values here are used for the processes in the boot image.
|
||||
* System processes can do anything; user processes are highly restricted.
|
||||
*/
|
||||
#define EMPTY_MASK (0)
|
||||
#define FILLED_MASK (~0)
|
||||
#define USER_CALL_MASK (1 << SENDREC)
|
||||
#define USER_CALL_MASK ((1 << SENDREC) | (1 << ECHO))
|
||||
|
||||
/* Send masks determine to whom processes can send messages or notifications.
|
||||
* The values here are used for the processes in the boot image. We rely on
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
struct priv {
|
||||
proc_nr_t s_proc_nr; /* number of associated process */
|
||||
sys_id_t s_id; /* index of this system structure */
|
||||
char s_flags; /* PREEMTIBLE, BILLABLE, etc. */
|
||||
short s_flags; /* PREEMTIBLE, BILLABLE, etc. */
|
||||
|
||||
char s_call_mask; /* allowed system call traps */
|
||||
short s_call_mask; /* allowed system call traps */
|
||||
sys_map_t s_send_mask; /* allowed send destinations */
|
||||
long s_sys_mask; /* allowed kernel calls */
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ message *m_ptr; /* pointer to message in the caller's space */
|
||||
* anywhere in data or stack or gap. It will have to be made more elaborate
|
||||
* for machines which don't have the gap mapped.
|
||||
*/
|
||||
if (function & SENDREC) {
|
||||
if (function & CHECK_PTR) {
|
||||
vb = (vir_bytes) m_ptr; /* virtual clicks */
|
||||
vlo = vb >> CLICK_SHIFT; /* bottom of message */
|
||||
vhi = (vb + MESS_SIZE - 1) >> CLICK_SHIFT; /* top of message */
|
||||
@@ -148,7 +148,7 @@ message *m_ptr; /* pointer to message in the caller's space */
|
||||
* verify that the caller is allowed to send to the given destination and
|
||||
* that the destination is still alive.
|
||||
*/
|
||||
if (function & SEND) {
|
||||
if (function & CHECK_DST) {
|
||||
if (! get_sys_bit(priv(caller_ptr)->s_send_mask, nr_to_id(src_dst))) {
|
||||
kprintf("Warning, send_mask denied %d sending to %d\n",
|
||||
proc_nr(caller_ptr), src_dst);
|
||||
|
||||
@@ -71,7 +71,7 @@ PUBLIC char *t_stack[TOT_STACK_SPACE / sizeof(char *)];
|
||||
PUBLIC struct system_image image[] = {
|
||||
{ IDLE, idle_task, IDLE_F, IDLE_T, IDLE_Q, IDLE_S, EMPTY_MASK, EMPTY_MASK, "IDLE" },
|
||||
{ CLOCK, clock_task, TASK_F, SYS_T, TASK_Q, CLOCK_S, FILLED_MASK, SYSTEM_SEND_MASK, "CLOCK" },
|
||||
{ SYSTEM, sys_task, TASK_F, SYS_T, TASK_Q, SYSTEM_S, FILLED_MASK, SYSTEM_SEND_MASK, "SYS" },
|
||||
{ SYSTEM, sys_task, TASK_F, SYS_T, TASK_Q, SYSTEM_S, FILLED_MASK, SYSTEM_SEND_MASK, "SYSTEM" },
|
||||
{ HARDWARE, 0, TASK_F, SYS_T, TASK_Q, HARDWARE_S, EMPTY_MASK, SYSTEM_SEND_MASK, "KERNEL" },
|
||||
{ PM_PROC_NR, 0, SYS_F, SYS_T, 3, 0, FILLED_MASK, SERVER_SEND_MASK, "PM" },
|
||||
{ FS_PROC_NR, 0, SYS_F, SYS_T, 3, 0, FILLED_MASK, SERVER_SEND_MASK, "FS" },
|
||||
|
||||
@@ -17,7 +17,7 @@ struct system_image {
|
||||
char quantum; /* quantum (tick count) */
|
||||
int priority; /* scheduling priority */
|
||||
int stksize; /* stack size for tasks */
|
||||
char call_mask; /* allowed system calls */
|
||||
short call_mask; /* allowed system calls */
|
||||
bitchunk_t send_mask; /* send mask protection */
|
||||
char proc_name[P_NAME_LEN]; /* name in process table */
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user