From fa29c349957eb7260f759515a8335d28f4c5fa95 Mon Sep 17 00:00:00 2001 From: NAKAMURA Gou Date: Thu, 5 Mar 2015 14:09:39 +0900 Subject: [PATCH] expand the size of kstack 12 KiB When a procfs file belonging to a process which was in PS_TRACED status was accessed, calling kprintf() from process_procfs_request() caused stack overrun, and x86_cpu_local_variables was destroyed. --- arch/x86/kernel/local.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/local.c b/arch/x86/kernel/local.c index 16e83995..ea980e65 100644 --- a/arch/x86/kernel/local.c +++ b/arch/x86/kernel/local.c @@ -19,13 +19,19 @@ #include #include +#define LOCALS_SPAN (4 * PAGE_SIZE) + struct x86_cpu_local_variables *locals; +size_t x86_cpu_local_variables_span = LOCALS_SPAN; /* for debugger */ void init_processors_local(int max_id) { + size_t size; + + size = LOCALS_SPAN * max_id; /* Is contiguous allocating adequate?? */ - locals = ihk_mc_alloc_pages(max_id, IHK_MC_AP_CRITICAL); - memset(locals, 0, PAGE_SIZE * max_id); + locals = ihk_mc_alloc_pages(size/PAGE_SIZE, IHK_MC_AP_CRITICAL); + memset(locals, 0, size); kprintf("locals = %p\n", locals); } @@ -33,12 +39,12 @@ void init_processors_local(int max_id) struct x86_cpu_local_variables *get_x86_cpu_local_variable(int id) { return (struct x86_cpu_local_variables *) - ((char *)locals + (id << PAGE_SHIFT)); + ((char *)locals + (LOCALS_SPAN * id)); } static void *get_x86_cpu_local_kstack(int id) { - return ((char *)locals + ((id + 1) << PAGE_SHIFT)); + return ((char *)locals + (LOCALS_SPAN * (id + 1))); } struct x86_cpu_local_variables *get_x86_this_cpu_local(void)