aboutsummaryrefslogtreecommitdiff
path: root/kernel/features
diff options
context:
space:
mode:
authorMarvin Borner2021-04-02 13:55:25 +0200
committerMarvin Borner2021-04-02 13:55:25 +0200
commitd055495f3dbb62f74809d31a84621d6e86d61d0a (patch)
tree38d39fd8ae20cec29221264e8394586cc509547c /kernel/features
parent3e81b8a254485de532d46c9a0710be97879d0605 (diff)
Fixed serious race condition exploits
Diffstat (limited to 'kernel/features')
-rw-r--r--kernel/features/proc.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/kernel/features/proc.c b/kernel/features/proc.c
index 52627ed..2b2d2d2 100644
--- a/kernel/features/proc.c
+++ b/kernel/features/proc.c
@@ -16,7 +16,7 @@
#define PROC(node) ((struct proc *)node->data)
-static u8 locked = 0;
+static u32 locked = 0;
static u32 current_pid = 0;
static struct node *idle_proc = NULL;
static struct node *current = NULL;
@@ -132,6 +132,8 @@ void proc_state(struct proc *proc, enum proc_state state)
void proc_exit(struct proc *proc, struct regs *r, s32 status)
{
+ assert(proc != idle_proc->data);
+
struct node *running = list_first_data(proc_list_running, proc);
if (!running || !list_remove(proc_list_running, running)) {
struct node *blocked = list_first_data(proc_list_blocked, proc);
@@ -156,6 +158,8 @@ void proc_exit(struct proc *proc, struct regs *r, s32 status)
printf("\t-> 0x%x: %dB\n", link->vrange.base, link->vrange.size);
iterator = iterator->next;
}
+ } else {
+ printf("Process didn't leak memory!\n");
}
stack_destroy(proc->messages);
@@ -164,8 +168,7 @@ void proc_exit(struct proc *proc, struct regs *r, s32 status)
free(proc);
- if (current->data == proc)
- proc_yield(r);
+ proc_yield(r);
}
void proc_yield(struct regs *r)