[RFC][PATCH 01/24] kernel/fork: Break out vmap task allocation into helper
From: Dave Hansen
Date: Wed Oct 21 2026 - 15:51:34 EST
Prepare for kernel shadow stacks. Move the low-level vmalloc call
into its own helper. This will soon have to deal with more things
like appending the shadow stack allocation and setting up the
different permissions for shadow stack pages.
---
b/kernel/fork.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff -puN kernel/fork.c~alloc_thread_stack_node-perms kernel/fork.c
--- a/kernel/fork.c~alloc_thread_stack_node-perms 2026-10-21 12:36:32.589870843 -0700
+++ b/kernel/fork.c 2026-10-21 12:36:32.592870848 -0700
@@ -330,6 +330,13 @@ err:
return ret;
}
+static void *__vmalloc_thread_stack_node(int node)
+{
+ return __vmalloc_node(THREAD_SIZE, THREAD_ALIGN,
+ GFP_VMAP_STACK,
+ node, __builtin_return_address(0));
+}
+
static int alloc_thread_stack_node(struct task_struct *tsk, int node)
{
struct vm_struct *vm_area;
@@ -356,9 +363,7 @@ static int alloc_thread_stack_node(struc
return 0;
}
- stack = __vmalloc_node(THREAD_SIZE, THREAD_ALIGN,
- GFP_VMAP_STACK,
- node, __builtin_return_address(0));
+ stack = __vmalloc_thread_stack_node(node);
if (!stack)
return -ENOMEM;
_