]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/linux/pid_namespace.h
net: rtnetlink: validate IFLA_MTU attribute in rtnl_create_link()
[mirror_ubuntu-bionic-kernel.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
aa5a6662 15
59eda0e0 16struct fs_pin;
20fad13a 17
796f571b
LW
18enum { /* definitions for pid_namespace's hide_pid field */
19 HIDEPID_OFF = 0,
20 HIDEPID_NO_ACCESS = 1,
21 HIDEPID_INVISIBLE = 2,
22};
23
61a58c6c 24struct pid_namespace {
9a575a92 25 struct kref kref;
95846ecf 26 struct idr idr;
1adfcb03 27 struct rcu_head rcu;
e8cfbc24 28 unsigned int pid_allocated;
84d73786 29 struct task_struct *child_reaper;
baf8f0f8 30 struct kmem_cache *pid_cachep;
caafa432 31 unsigned int level;
faacbfd3 32 struct pid_namespace *parent;
07543f5c
PE
33#ifdef CONFIG_PROC_FS
34 struct vfsmount *proc_mnt;
021ada7d 35 struct dentry *proc_self;
0097875b 36 struct dentry *proc_thread_self;
07543f5c 37#endif
20fad13a 38#ifdef CONFIG_BSD_PROCESS_ACCT
59eda0e0 39 struct fs_pin *bacct;
20fad13a 40#endif
49f4d8b9 41 struct user_namespace *user_ns;
f333c700 42 struct ucounts *ucounts;
0a01f2cc 43 struct work_struct proc_work;
dcb0f222 44 kgid_t pid_gid;
0499680a 45 int hide_pid;
cf3f8921 46 int reboot; /* group exit code if this pidns was rebooted */
435d5f4b 47 struct ns_common ns;
3859a271 48} __randomize_layout;
3fbc9648 49
61a58c6c 50extern struct pid_namespace init_pid_ns;
3fbc9648 51
e8cfbc24 52#define PIDNS_ADDING (1U << 31)
c876ad76 53
57d5f66b 54#ifdef CONFIG_PID_NS
a05f7b15 55static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns)
9a575a92 56{
b461cc03
PE
57 if (ns != &init_pid_ns)
58 kref_get(&ns->kref);
a05f7b15 59 return ns;
9a575a92
CLG
60}
61
49f4d8b9
EB
62extern struct pid_namespace *copy_pid_ns(unsigned long flags,
63 struct user_namespace *user_ns, struct pid_namespace *ns);
74bd59bb 64extern void zap_pid_ns_processes(struct pid_namespace *pid_ns);
cf3f8921 65extern int reboot_pid_ns(struct pid_namespace *pid_ns, int cmd);
bbc2e3ef 66extern void put_pid_ns(struct pid_namespace *ns);
9a575a92 67
57d5f66b
EB
68#else /* !CONFIG_PID_NS */
69#include <linux/err.h>
70
71static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns)
72{
73 return ns;
74}
75
49f4d8b9
EB
76static inline struct pid_namespace *copy_pid_ns(unsigned long flags,
77 struct user_namespace *user_ns, struct pid_namespace *ns)
57d5f66b
EB
78{
79 if (flags & CLONE_NEWPID)
80 ns = ERR_PTR(-EINVAL);
81 return ns;
82}
83
84static inline void put_pid_ns(struct pid_namespace *ns)
85{
86}
87
74bd59bb
PE
88static inline void zap_pid_ns_processes(struct pid_namespace *ns)
89{
90 BUG();
91}
cf3f8921
DL
92
93static inline int reboot_pid_ns(struct pid_namespace *pid_ns, int cmd)
94{
95 return 0;
96}
57d5f66b
EB
97#endif /* CONFIG_PID_NS */
98
61bce0f1 99extern struct pid_namespace *task_active_pid_ns(struct task_struct *tsk);
3ae4eed3 100void pidhash_init(void);
95846ecf 101void pid_idr_init(void);
3ae4eed3 102
61a58c6c 103#endif /* _LINUX_PID_NS_H */