[RFC][PATCH 18/24] kernel/task: Add a helper to get the thread_union
From: Dave Hansen
Date: Wed Oct 21 2026 - 15:53:39 EST
There's currently no helper that, given a task, can work back to the
"outer" thread_union. Add one to help locating the shadow stack
mapping location.
---
b/include/linux/sched/task_stack.h | 5 +++++
1 file changed, 5 insertions(+)
diff -puN include/linux/sched/task_stack.h~generic-task_thread_union include/linux/sched/task_stack.h
--- a/include/linux/sched/task_stack.h~generic-task_thread_union 2026-10-21 12:36:41.575888044 -0700
+++ b/include/linux/sched/task_stack.h 2026-10-21 12:36:41.577888048 -0700
@@ -23,6 +23,11 @@ static __always_inline void *task_stack_
return task->stack;
}
+static inline union thread_union *task_thread_union(struct task_struct *tsk)
+{
+ return (union thread_union *)task_stack_page(tsk);
+}
+
#define setup_thread_stack(new,old) do { } while(0)
static __always_inline unsigned long *end_of_stack(const struct task_struct *task)
_