From: Christian Brauner Date: Tue, 5 Feb 2019 06:23:19 +0000 (+0100) Subject: namespace: remove stack allocations X-Git-Tag: lxc-3.2.0~164^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=244f7f873471949216072a8d11544900bfe15456;p=thirdparty%2Flxc.git 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 --- 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);