From 244f7f873471949216072a8d11544900bfe15456 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Tue, 5 Feb 2019 07:23:19 +0100 Subject: [PATCH] namespace: remove stack allocations Switch to a static stack instead of allocating a new one. There's really no point in doing all of the dance to get the current pagesize. Signed-off-by: Christian Brauner --- src/lxc/namespace.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/lxc/namespace.c b/src/lxc/namespace.c index b6eab04e6..e22d9a4bf 100644 --- a/src/lxc/namespace.c +++ b/src/lxc/namespace.c @@ -24,7 +24,6 @@ #ifndef _GNU_SOURCE #define _GNU_SOURCE 1 #endif -#include #include #include #include @@ -37,6 +36,7 @@ #include "config.h" #include "log.h" +#include "memory_utils.h" #include "namespace.h" #include "utils.h" @@ -53,16 +53,17 @@ static int do_clone(void *arg) return clone_arg->fn(clone_arg->arg); } +#define __LXC_STACK_SIZE 4096 pid_t lxc_clone(int (*fn)(void *), void *arg, int flags) { + size_t stack_size; + pid_t ret; struct clone_arg clone_arg = { - .fn = fn, - .arg = arg, + .fn = fn, + .arg = arg, }; - - size_t stack_size = lxc_getpagesize(); - void *stack = alloca(stack_size); - pid_t ret; + char *stack[__LXC_STACK_SIZE] = {0}; + stack_size = __LXC_STACK_SIZE; #ifdef __ia64__ ret = __clone2(do_clone, stack, stack_size, flags | SIGCHLD, &clone_arg); -- 2.39.2