From cabbf335824db0df835e4c541c19d3803ce38454 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Wed, 14 Sep 2022 21:30:11 +0300 Subject: add canary to kernel stack --- common/tcb.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'common/tcb.c') diff --git a/common/tcb.c b/common/tcb.c index 1e25f47..9768eb0 100644 --- a/common/tcb.c +++ b/common/tcb.c @@ -7,7 +7,6 @@ */ #include -#include #include #include #include @@ -16,6 +15,9 @@ #include #include #include +#include + +#include #include /* arguably exessively many globals... */ @@ -137,7 +139,7 @@ struct tcb *create_thread(struct tcb *p) { hard_assert(tcbs, 0); - vm_t bottom = alloc_page(MM_O0, 0); + vm_t bottom = alloc_page(KERNEL_STACK_PAGE_ORDER, 0); /* move tcb to top of kernel stack, keeping alignment in check * (hopefully) */ /** \todo check alignment */ @@ -163,6 +165,7 @@ struct tcb *create_thread(struct tcb *p) t->rid = p->rid; t->rpc.vmem = create_vmem(); + set_canary(t); return t; } @@ -303,8 +306,9 @@ struct tcb *cur_proc() void use_tcb(struct tcb *t) { - t->cpu_id = cpu_id(); - cpu_tcb[cpu_id()] = t; + id_t cpu = cpu_id(); + t->cpu_id = cpu; + cpu_tcb[cpu] = t; } struct tcb *get_tcb(id_t tid) -- cgit v1.3