LCOV - code coverage report
Current view: top level - include/linux - pid_namespace.h (source / functions) Hit Total Coverage
Test: landlock.info Lines: 9 12 75.0 %
Date: 2021-04-22 12:43:58 Functions: 0 1 0.0 %

          Line data    Source code
       1             : /* SPDX-License-Identifier: GPL-2.0 */
       2             : #ifndef _LINUX_PID_NS_H
       3             : #define _LINUX_PID_NS_H
       4             : 
       5             : #include <linux/sched.h>
       6             : #include <linux/bug.h>
       7             : #include <linux/mm.h>
       8             : #include <linux/workqueue.h>
       9             : #include <linux/threads.h>
      10             : #include <linux/nsproxy.h>
      11             : #include <linux/ns_common.h>
      12             : #include <linux/idr.h>
      13             : 
      14             : /* MAX_PID_NS_LEVEL is needed for limiting size of 'struct pid' */
      15             : #define MAX_PID_NS_LEVEL 32
      16             : 
      17             : struct fs_pin;
      18             : 
      19             : struct pid_namespace {
      20             :         struct idr idr;
      21             :         struct rcu_head rcu;
      22             :         unsigned int pid_allocated;
      23             :         struct task_struct *child_reaper;
      24             :         struct kmem_cache *pid_cachep;
      25             :         unsigned int level;
      26             :         struct pid_namespace *parent;
      27             : #ifdef CONFIG_BSD_PROCESS_ACCT
      28             :         struct fs_pin *bacct;
      29             : #endif
      30             :         struct user_namespace *user_ns;
      31             :         struct ucounts *ucounts;
      32             :         int reboot;     /* group exit code if this pidns was rebooted */
      33             :         struct ns_common ns;
      34             : } __randomize_layout;
      35             : 
      36             : extern struct pid_namespace init_pid_ns;
      37             : 
      38             : #define PIDNS_ADDING (1U << 31)
      39             : 
      40             : #ifdef CONFIG_PID_NS
      41             : static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns)
      42             : {
      43             :         if (ns != &init_pid_ns)
      44             :                 refcount_inc(&ns->ns.count);
      45             :         return ns;
      46             : }
      47             : 
      48             : extern struct pid_namespace *copy_pid_ns(unsigned long flags,
      49             :         struct user_namespace *user_ns, struct pid_namespace *ns);
      50             : extern void zap_pid_ns_processes(struct pid_namespace *pid_ns);
      51             : extern int reboot_pid_ns(struct pid_namespace *pid_ns, int cmd);
      52             : extern void put_pid_ns(struct pid_namespace *ns);
      53             : 
      54             : #else /* !CONFIG_PID_NS */
      55             : #include <linux/err.h>
      56             : 
      57         947 : static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns)
      58             : {
      59         947 :         return ns;
      60             : }
      61             : 
      62          50 : static inline struct pid_namespace *copy_pid_ns(unsigned long flags,
      63             :         struct user_namespace *user_ns, struct pid_namespace *ns)
      64             : {
      65          50 :         if (flags & CLONE_NEWPID)
      66           0 :                 ns = ERR_PTR(-EINVAL);
      67          50 :         return ns;
      68             : }
      69             : 
      70         867 : static inline void put_pid_ns(struct pid_namespace *ns)
      71             : {
      72         867 : }
      73             : 
      74           0 : static inline void zap_pid_ns_processes(struct pid_namespace *ns)
      75             : {
      76           0 :         BUG();
      77             : }
      78             : 
      79           1 : static inline int reboot_pid_ns(struct pid_namespace *pid_ns, int cmd)
      80             : {
      81           1 :         return 0;
      82             : }
      83             : #endif /* CONFIG_PID_NS */
      84             : 
      85             : extern struct pid_namespace *task_active_pid_ns(struct task_struct *tsk);
      86             : void pidhash_init(void);
      87             : void pid_idr_init(void);
      88             : 
      89             : #endif /* _LINUX_PID_NS_H */

Generated by: LCOV version 1.14