Commit | Line | Data |
---|---|---|
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 | 18 | struct fs_pin; |
20fad13a | 19 | |
796f571b LW |
20 | enum { /* definitions for pid_namespace's hide_pid field */ |
21 | HIDEPID_OFF = 0, | |
22 | HIDEPID_NO_ACCESS = 1, | |
23 | HIDEPID_INVISIBLE = 2, | |
24 | }; | |
25 | ||
61a58c6c | 26 | struct 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 | 52 | extern struct pid_namespace init_pid_ns; |
3fbc9648 | 53 | |
e8cfbc24 | 54 | #define PIDNS_ADDING (1U << 31) |
c876ad76 | 55 | |
57d5f66b | 56 | #ifdef CONFIG_PID_NS |
a05f7b15 | 57 | static 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 |
64 | extern struct pid_namespace *copy_pid_ns(unsigned long flags, |
65 | struct user_namespace *user_ns, struct pid_namespace *ns); | |
74bd59bb | 66 | extern void zap_pid_ns_processes(struct pid_namespace *pid_ns); |
cf3f8921 | 67 | extern int reboot_pid_ns(struct pid_namespace *pid_ns, int cmd); |
bbc2e3ef | 68 | extern void put_pid_ns(struct pid_namespace *ns); |
9a575a92 | 69 | |
57d5f66b EB |
70 | #else /* !CONFIG_PID_NS */ |
71 | #include <linux/err.h> | |
72 | ||
73 | static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns) | |
74 | { | |
75 | return ns; | |
76 | } | |
77 | ||
49f4d8b9 EB |
78 | static 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 | ||
86 | static inline void put_pid_ns(struct pid_namespace *ns) | |
87 | { | |
88 | } | |
89 | ||
74bd59bb PE |
90 | static inline void zap_pid_ns_processes(struct pid_namespace *ns) |
91 | { | |
92 | BUG(); | |
93 | } | |
cf3f8921 DL |
94 | |
95 | static 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 | 101 | extern struct pid_namespace *task_active_pid_ns(struct task_struct *tsk); |
3ae4eed3 | 102 | void pidhash_init(void); |
95846ecf | 103 | void pid_idr_init(void); |
3ae4eed3 | 104 | |
61a58c6c | 105 | #endif /* _LINUX_PID_NS_H */ |