]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
namespace: remove stack allocations
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 5 Feb 2019 06:23:19 +0000 (07:23 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 6 Feb 2019 10:47:57 +0000 (11:47 +0100)
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 <christian.brauner@ubuntu.com>
src/lxc/namespace.c

index b6eab04e677bfa677c83cc66cae7ff96acbd5c4b..e22d9a4bf01f3537ceb89a3773a8a274c9c54616 100644 (file)
@@ -24,7 +24,6 @@
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE 1
 #endif
-#include <alloca.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <sched.h>
@@ -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);