Blame view

include/linux/pid_namespace.h 2.12 KB
b24413180   Greg Kroah-Hartman   License cleanup: ...
1
  /* SPDX-License-Identifier: GPL-2.0 */
61a58c6c2   Sukadev Bhattiprolu   [PATCH] rename st...
2
3
  #ifndef _LINUX_PID_NS_H
  #define _LINUX_PID_NS_H
aa5a6662f   Sukadev Bhattiprolu   [PATCH] Move pidm...
4
5
  
  #include <linux/sched.h>
187f1882b   Paul Gortmaker   BUG: headers with...
6
  #include <linux/bug.h>
aa5a6662f   Sukadev Bhattiprolu   [PATCH] Move pidm...
7
  #include <linux/mm.h>
a27bb332c   Kent Overstreet   aio: don't includ...
8
  #include <linux/workqueue.h>
aa5a6662f   Sukadev Bhattiprolu   [PATCH] Move pidm...
9
  #include <linux/threads.h>
9a575a92d   Cedric Le Goater   [PATCH] to nsproxy
10
11
  #include <linux/nsproxy.h>
  #include <linux/kref.h>
435d5f4bb   Al Viro   common object emb...
12
  #include <linux/ns_common.h>
95846ecf9   Gargi Sharma   pid: replace pid ...
13
  #include <linux/idr.h>
aa5a6662f   Sukadev Bhattiprolu   [PATCH] Move pidm...
14

49cb2fc42   Adrian Reber   fork: extend clon...
15
16
  /* MAX_PID_NS_LEVEL is needed for limiting size of 'struct pid' */
  #define MAX_PID_NS_LEVEL 32
aa5a6662f   Sukadev Bhattiprolu   [PATCH] Move pidm...
17

59eda0e07   Al Viro   new fs_pin killin...
18
  struct fs_pin;
20fad13ac   Pavel Emelyanov   pidns: add the st...
19

61a58c6c2   Sukadev Bhattiprolu   [PATCH] rename st...
20
  struct pid_namespace {
9a575a92d   Cedric Le Goater   [PATCH] to nsproxy
21
  	struct kref kref;
95846ecf9   Gargi Sharma   pid: replace pid ...
22
  	struct idr idr;
1adfcb03e   Al Viro   pid_namespace: ma...
23
  	struct rcu_head rcu;
e8cfbc245   Gargi Sharma   pid: remove pidhash
24
  	unsigned int pid_allocated;
84d737866   Sukadev Bhattiprolu   [PATCH] add child...
25
  	struct task_struct *child_reaper;
baf8f0f82   Pavel Emelianov   pid namespaces: d...
26
  	struct kmem_cache *pid_cachep;
caafa4324   Pavel Emelyanov   pidns: make pid->...
27
  	unsigned int level;
faacbfd3a   Pavel Emelyanov   pid namespaces: a...
28
  	struct pid_namespace *parent;
20fad13ac   Pavel Emelyanov   pidns: add the st...
29
  #ifdef CONFIG_BSD_PROCESS_ACCT
59eda0e07   Al Viro   new fs_pin killin...
30
  	struct fs_pin *bacct;
20fad13ac   Pavel Emelyanov   pidns: add the st...
31
  #endif
49f4d8b93   Eric W. Biederman   pidns: Capture th...
32
  	struct user_namespace *user_ns;
f333c700c   Eric W. Biederman   pidns: Add a limi...
33
  	struct ucounts *ucounts;
cf3f89214   Daniel Lezcano   pidns: add reboot...
34
  	int reboot;	/* group exit code if this pidns was rebooted */
435d5f4bb   Al Viro   common object emb...
35
  	struct ns_common ns;
3859a271a   Kees Cook   randstruct: Mark ...
36
  } __randomize_layout;
3fbc96486   Sukadev Bhattiprolu   [PATCH] Define st...
37

61a58c6c2   Sukadev Bhattiprolu   [PATCH] rename st...
38
  extern struct pid_namespace init_pid_ns;
3fbc96486   Sukadev Bhattiprolu   [PATCH] Define st...
39

e8cfbc245   Gargi Sharma   pid: remove pidhash
40
  #define PIDNS_ADDING (1U << 31)
c876ad768   Eric W. Biederman   pidns: Stop pid a...
41

57d5f66b8   Eric W. Biederman   pidns: Place unde...
42
  #ifdef CONFIG_PID_NS
a05f7b15d   Pavel Emelianov   pid namespaces: m...
43
  static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns)
9a575a92d   Cedric Le Goater   [PATCH] to nsproxy
44
  {
b461cc038   Pavel Emelyanov   pid namespaces: m...
45
46
  	if (ns != &init_pid_ns)
  		kref_get(&ns->kref);
a05f7b15d   Pavel Emelianov   pid namespaces: m...
47
  	return ns;
9a575a92d   Cedric Le Goater   [PATCH] to nsproxy
48
  }
49f4d8b93   Eric W. Biederman   pidns: Capture th...
49
50
  extern struct pid_namespace *copy_pid_ns(unsigned long flags,
  	struct user_namespace *user_ns, struct pid_namespace *ns);
74bd59bb3   Pavel Emelyanov   namespaces: clean...
51
  extern void zap_pid_ns_processes(struct pid_namespace *pid_ns);
cf3f89214   Daniel Lezcano   pidns: add reboot...
52
  extern int reboot_pid_ns(struct pid_namespace *pid_ns, int cmd);
bbc2e3ef8   Cyrill Gorcunov   pidns: remove rec...
53
  extern void put_pid_ns(struct pid_namespace *ns);
9a575a92d   Cedric Le Goater   [PATCH] to nsproxy
54

57d5f66b8   Eric W. Biederman   pidns: Place unde...
55
56
57
58
59
60
61
  #else /* !CONFIG_PID_NS */
  #include <linux/err.h>
  
  static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns)
  {
  	return ns;
  }
49f4d8b93   Eric W. Biederman   pidns: Capture th...
62
63
  static inline struct pid_namespace *copy_pid_ns(unsigned long flags,
  	struct user_namespace *user_ns, struct pid_namespace *ns)
57d5f66b8   Eric W. Biederman   pidns: Place unde...
64
65
66
67
68
69
70
71
72
  {
  	if (flags & CLONE_NEWPID)
  		ns = ERR_PTR(-EINVAL);
  	return ns;
  }
  
  static inline void put_pid_ns(struct pid_namespace *ns)
  {
  }
74bd59bb3   Pavel Emelyanov   namespaces: clean...
73
74
75
76
  static inline void zap_pid_ns_processes(struct pid_namespace *ns)
  {
  	BUG();
  }
cf3f89214   Daniel Lezcano   pidns: add reboot...
77
78
79
80
81
  
  static inline int reboot_pid_ns(struct pid_namespace *pid_ns, int cmd)
  {
  	return 0;
  }
57d5f66b8   Eric W. Biederman   pidns: Place unde...
82
  #endif /* CONFIG_PID_NS */
61bce0f13   Eric W. Biederman   pid: generalize t...
83
  extern struct pid_namespace *task_active_pid_ns(struct task_struct *tsk);
3ae4eed34   Adrian Bunk   proper pid{hash,m...
84
  void pidhash_init(void);
95846ecf9   Gargi Sharma   pid: replace pid ...
85
  void pid_idr_init(void);
3ae4eed34   Adrian Bunk   proper pid{hash,m...
86

61a58c6c2   Sukadev Bhattiprolu   [PATCH] rename st...
87
  #endif /* _LINUX_PID_NS_H */