Introduce struct task_exec_state, a per-task RCU-protected structure that holds the dumpable mode and the user namespace and stays attached to the task for its full lifetime. task_exec_state_rcu() is the canonical reader: asserts RCU or task_lock is held, WARNs on a NULL state, returns the rcu_dereference()'d pointer. Reviewed-by: Jann Horn <jannh@google.com> Link: https://patch.msgid.link/20260520-work-task_exec_state-v3-2-69f895bc1385@kernel.org Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
32 lines
1.1 KiB
C
32 lines
1.1 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/* Copyright (c) 2026 Christian Brauner <brauner@kernel.org> */
|
|
#ifndef _LINUX_SCHED_EXEC_STATE_H
|
|
#define _LINUX_SCHED_EXEC_STATE_H
|
|
|
|
#include <linux/init.h>
|
|
#include <linux/rcupdate.h>
|
|
#include <linux/refcount.h>
|
|
#include <linux/sched/coredump.h>
|
|
#include <linux/user_namespace.h>
|
|
|
|
struct task_exec_state {
|
|
refcount_t count;
|
|
enum task_dumpable dumpable;
|
|
struct user_namespace *user_ns;
|
|
struct rcu_head rcu;
|
|
};
|
|
|
|
struct task_exec_state *alloc_task_exec_state(struct user_namespace *user_ns);
|
|
void put_task_exec_state(struct task_exec_state *exec_state);
|
|
struct task_exec_state *task_exec_state_rcu(const struct task_struct *tsk);
|
|
struct task_exec_state *task_exec_state_replace(struct task_struct *tsk,
|
|
struct task_exec_state *exec_state);
|
|
void task_exec_state_set_dumpable(enum task_dumpable value);
|
|
enum task_dumpable task_exec_state_get_dumpable(struct task_struct *task);
|
|
int task_exec_state_copy(struct task_struct *tsk);
|
|
void __init exec_state_init(void);
|
|
|
|
DEFINE_FREE(put_task_exec_state, struct task_exec_state *, put_task_exec_state(_T))
|
|
|
|
#endif /* _LINUX_SCHED_EXEC_STATE_H */
|