Merge branch 'x86-pti-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-block.git] / include / linux / pid_namespace.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
61a58c6c
SB
2#ifndef _LINUX_PID_NS_H
3#define _LINUX_PID_NS_H
aa5a6662
SB
4
5#include <linux/sched.h>
187f1882 6#include <linux/bug.h>
aa5a6662 7#include <linux/mm.h>
a27bb332 8#include <linux/workqueue.h>
aa5a6662 9#include <linux/threads.h>
9a575a92
CLG
10#include <linux/nsproxy.h>
11#include <linux/kref.h>
435d5f4b 12#include <linux/ns_common.h>
95846ecf 13#include <linux/idr.h>
aa5a6662 14
49cb2fc4
AR
15/* MAX_PID_NS_LEVEL is needed for limiting size of 'struct pid' */
16#define MAX_PID_NS_LEVEL 32
aa5a6662 17
59eda0e0 18struct fs_pin;
20fad13a 19
796f571b
LW
20enum { /* definitions for pid_namespace's hide_pid field */
21 HIDEPID_OFF = 0,
22 HIDEPID_NO_ACCESS = 1,
23 HIDEPID_INVISIBLE = 2,
24};
25
61a58c6c 26struct pid_namespace {
9a575a92 27 struct kref kref;
95846ecf 28 struct idr idr;
1adfcb03 29 struct rcu_head rcu;
e8cfbc24 30 unsigned int pid_allocated;
84d73786 31 struct task_struct *child_reaper;
baf8f0f8 32 struct kmem_cache *pid_cachep;
caafa432 33 unsigned int level;
faacbfd3 34 struct pid_namespace *parent;
07543f5c
PE
35#ifdef CONFIG_PROC_FS
36 struct vfsmount *proc_mnt;
021ada7d 37 struct dentry *proc_self;
0097875b 38 struct dentry *proc_thread_self;
07543f5c 39#endif
20fad13a 40#ifdef CONFIG_BSD_PROCESS_ACCT
59eda0e0 41 struct fs_pin *bacct;
20fad13a 42#endif
49f4d8b9 43 struct user_namespace *user_ns;
f333c700 44 struct ucounts *ucounts;
0a01f2cc 45 struct work_struct proc_work;
dcb0f222 46 kgid_t pid_gid;
0499680a 47 int hide_pid;
cf3f8921 48 int reboot; /* group exit code if this pidns was rebooted */
435d5f4b 49 struct ns_common ns;
3859a271 50} __randomize_layout;
3fbc9648 51
61a58c6c 52extern struct pid_namespace init_pid_ns;
3fbc9648 53
e8cfbc24 54#define PIDNS_ADDING (1U << 31)
c876ad76 55
57d5f66b 56#ifdef CONFIG_PID_NS
a05f7b15 57static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns)
9a575a92 58{
b461cc03
PE
59 if (ns != &init_pid_ns)
60 kref_get(&ns->kref);
a05f7b15 61 return ns;
9a575a92
CLG
62}
63
49f4d8b9
EB
64extern struct pid_namespace *copy_pid_ns(unsigned long flags,
65 struct user_namespace *user_ns, struct pid_namespace *ns);
74bd59bb 66extern void zap_pid_ns_processes(struct pid_namespace *pid_ns);
cf3f8921 67extern int reboot_pid_ns(struct pid_namespace *pid_ns, int cmd);
bbc2e3ef 68extern void put_pid_ns(struct pid_namespace *ns);
9a575a92 69
57d5f66b
EB
70#else /* !CONFIG_PID_NS */
71#include <linux/err.h>
72
73static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns)
74{
75 return ns;
76}
77
49f4d8b9
EB
78static inline struct pid_namespace *copy_pid_ns(unsigned long flags,
79 struct user_namespace *user_ns, struct pid_namespace *ns)
57d5f66b
EB
80{
81 if (flags & CLONE_NEWPID)
82 ns = ERR_PTR(-EINVAL);
83 return ns;
84}
85
86static inline void put_pid_ns(struct pid_namespace *ns)
87{
88}
89
74bd59bb
PE
90static inline void zap_pid_ns_processes(struct pid_namespace *ns)
91{
92 BUG();
93}
cf3f8921
DL
94
95static inline int reboot_pid_ns(struct pid_namespace *pid_ns, int cmd)
96{
97 return 0;
98}
57d5f66b
EB
99#endif /* CONFIG_PID_NS */
100
61bce0f1 101extern struct pid_namespace *task_active_pid_ns(struct task_struct *tsk);
3ae4eed3 102void pidhash_init(void);
95846ecf 103void pid_idr_init(void);
3ae4eed3 104
61a58c6c 105#endif /* _LINUX_PID_NS_H */