| .. | .. |
|---|
| 5 | 5 | #ifndef _LINUX_PROC_FS_H |
|---|
| 6 | 6 | #define _LINUX_PROC_FS_H |
|---|
| 7 | 7 | |
|---|
| 8 | +#include <linux/compiler.h> |
|---|
| 8 | 9 | #include <linux/types.h> |
|---|
| 9 | 10 | #include <linux/fs.h> |
|---|
| 10 | 11 | |
|---|
| .. | .. |
|---|
| 12 | 13 | struct seq_file; |
|---|
| 13 | 14 | struct seq_operations; |
|---|
| 14 | 15 | |
|---|
| 16 | +enum { |
|---|
| 17 | + /* |
|---|
| 18 | + * All /proc entries using this ->proc_ops instance are never removed. |
|---|
| 19 | + * |
|---|
| 20 | + * If in doubt, ignore this flag. |
|---|
| 21 | + */ |
|---|
| 22 | +#ifdef MODULE |
|---|
| 23 | + PROC_ENTRY_PERMANENT = 0U, |
|---|
| 24 | +#else |
|---|
| 25 | + PROC_ENTRY_PERMANENT = 1U << 0, |
|---|
| 26 | +#endif |
|---|
| 27 | +}; |
|---|
| 28 | + |
|---|
| 29 | +struct proc_ops { |
|---|
| 30 | + unsigned int proc_flags; |
|---|
| 31 | + int (*proc_open)(struct inode *, struct file *); |
|---|
| 32 | + ssize_t (*proc_read)(struct file *, char __user *, size_t, loff_t *); |
|---|
| 33 | + ssize_t (*proc_read_iter)(struct kiocb *, struct iov_iter *); |
|---|
| 34 | + ssize_t (*proc_write)(struct file *, const char __user *, size_t, loff_t *); |
|---|
| 35 | + loff_t (*proc_lseek)(struct file *, loff_t, int); |
|---|
| 36 | + int (*proc_release)(struct inode *, struct file *); |
|---|
| 37 | + __poll_t (*proc_poll)(struct file *, struct poll_table_struct *); |
|---|
| 38 | + long (*proc_ioctl)(struct file *, unsigned int, unsigned long); |
|---|
| 39 | +#ifdef CONFIG_COMPAT |
|---|
| 40 | + long (*proc_compat_ioctl)(struct file *, unsigned int, unsigned long); |
|---|
| 41 | +#endif |
|---|
| 42 | + int (*proc_mmap)(struct file *, struct vm_area_struct *); |
|---|
| 43 | + unsigned long (*proc_get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); |
|---|
| 44 | +} __randomize_layout; |
|---|
| 45 | + |
|---|
| 46 | +/* definitions for hide_pid field */ |
|---|
| 47 | +enum proc_hidepid { |
|---|
| 48 | + HIDEPID_OFF = 0, |
|---|
| 49 | + HIDEPID_NO_ACCESS = 1, |
|---|
| 50 | + HIDEPID_INVISIBLE = 2, |
|---|
| 51 | + HIDEPID_NOT_PTRACEABLE = 4, /* Limit pids to only ptraceable pids */ |
|---|
| 52 | +}; |
|---|
| 53 | + |
|---|
| 54 | +/* definitions for proc mount option pidonly */ |
|---|
| 55 | +enum proc_pidonly { |
|---|
| 56 | + PROC_PIDONLY_OFF = 0, |
|---|
| 57 | + PROC_PIDONLY_ON = 1, |
|---|
| 58 | +}; |
|---|
| 59 | + |
|---|
| 60 | +struct proc_fs_info { |
|---|
| 61 | + struct pid_namespace *pid_ns; |
|---|
| 62 | + struct dentry *proc_self; /* For /proc/self */ |
|---|
| 63 | + struct dentry *proc_thread_self; /* For /proc/thread-self */ |
|---|
| 64 | + kgid_t pid_gid; |
|---|
| 65 | + enum proc_hidepid hide_pid; |
|---|
| 66 | + enum proc_pidonly pidonly; |
|---|
| 67 | +}; |
|---|
| 68 | + |
|---|
| 69 | +static inline struct proc_fs_info *proc_sb_info(struct super_block *sb) |
|---|
| 70 | +{ |
|---|
| 71 | + return sb->s_fs_info; |
|---|
| 72 | +} |
|---|
| 73 | + |
|---|
| 15 | 74 | #ifdef CONFIG_PROC_FS |
|---|
| 16 | 75 | |
|---|
| 17 | 76 | typedef int (*proc_write_t)(struct file *, char *, size_t); |
|---|
| 18 | 77 | |
|---|
| 19 | 78 | extern void proc_root_init(void); |
|---|
| 20 | | -extern void proc_flush_task(struct task_struct *); |
|---|
| 79 | +extern void proc_flush_pid(struct pid *); |
|---|
| 21 | 80 | |
|---|
| 22 | 81 | extern struct proc_dir_entry *proc_symlink(const char *, |
|---|
| 23 | 82 | struct proc_dir_entry *, const char *); |
|---|
| .. | .. |
|---|
| 44 | 103 | |
|---|
| 45 | 104 | extern struct proc_dir_entry *proc_create_data(const char *, umode_t, |
|---|
| 46 | 105 | struct proc_dir_entry *, |
|---|
| 47 | | - const struct file_operations *, |
|---|
| 106 | + const struct proc_ops *, |
|---|
| 48 | 107 | void *); |
|---|
| 49 | 108 | |
|---|
| 50 | | -struct proc_dir_entry *proc_create(const char *name, umode_t mode, struct proc_dir_entry *parent, const struct file_operations *proc_fops); |
|---|
| 109 | +struct proc_dir_entry *proc_create(const char *name, umode_t mode, struct proc_dir_entry *parent, const struct proc_ops *proc_ops); |
|---|
| 51 | 110 | extern void proc_set_size(struct proc_dir_entry *, loff_t); |
|---|
| 52 | 111 | extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t); |
|---|
| 53 | 112 | extern void *PDE_DATA(const struct inode *); |
|---|
| .. | .. |
|---|
| 59 | 118 | struct proc_dir_entry *proc_create_net_data(const char *name, umode_t mode, |
|---|
| 60 | 119 | struct proc_dir_entry *parent, const struct seq_operations *ops, |
|---|
| 61 | 120 | unsigned int state_size, void *data); |
|---|
| 62 | | -#define proc_create_net(name, mode, parent, state_size, ops) \ |
|---|
| 63 | | - proc_create_net_data(name, mode, parent, state_size, ops, NULL) |
|---|
| 121 | +#define proc_create_net(name, mode, parent, ops, state_size) \ |
|---|
| 122 | + proc_create_net_data(name, mode, parent, ops, state_size, NULL) |
|---|
| 64 | 123 | struct proc_dir_entry *proc_create_net_single(const char *name, umode_t mode, |
|---|
| 65 | 124 | struct proc_dir_entry *parent, |
|---|
| 66 | 125 | int (*show)(struct seq_file *, void *), void *data); |
|---|
| .. | .. |
|---|
| 76 | 135 | void *data); |
|---|
| 77 | 136 | extern struct pid *tgid_pidfd_to_pid(const struct file *file); |
|---|
| 78 | 137 | |
|---|
| 138 | +struct bpf_iter_aux_info; |
|---|
| 139 | +extern int bpf_iter_init_seq_net(void *priv_data, struct bpf_iter_aux_info *aux); |
|---|
| 140 | +extern void bpf_iter_fini_seq_net(void *priv_data); |
|---|
| 141 | + |
|---|
| 142 | +#ifdef CONFIG_PROC_PID_ARCH_STATUS |
|---|
| 143 | +/* |
|---|
| 144 | + * The architecture which selects CONFIG_PROC_PID_ARCH_STATUS must |
|---|
| 145 | + * provide proc_pid_arch_status() definition. |
|---|
| 146 | + */ |
|---|
| 147 | +int proc_pid_arch_status(struct seq_file *m, struct pid_namespace *ns, |
|---|
| 148 | + struct pid *pid, struct task_struct *task); |
|---|
| 149 | +#endif /* CONFIG_PROC_PID_ARCH_STATUS */ |
|---|
| 150 | + |
|---|
| 79 | 151 | #else /* CONFIG_PROC_FS */ |
|---|
| 80 | 152 | |
|---|
| 81 | 153 | static inline void proc_root_init(void) |
|---|
| 82 | 154 | { |
|---|
| 83 | 155 | } |
|---|
| 84 | 156 | |
|---|
| 85 | | -static inline void proc_flush_task(struct task_struct *task) |
|---|
| 157 | +static inline void proc_flush_pid(struct pid *pid) |
|---|
| 86 | 158 | { |
|---|
| 87 | 159 | } |
|---|
| 88 | 160 | |
|---|
| .. | .. |
|---|
| 105 | 177 | #define proc_create_seq(name, mode, parent, ops) ({NULL;}) |
|---|
| 106 | 178 | #define proc_create_single(name, mode, parent, show) ({NULL;}) |
|---|
| 107 | 179 | #define proc_create_single_data(name, mode, parent, show, data) ({NULL;}) |
|---|
| 108 | | -#define proc_create(name, mode, parent, proc_fops) ({NULL;}) |
|---|
| 109 | | -#define proc_create_data(name, mode, parent, proc_fops, data) ({NULL;}) |
|---|
| 180 | +#define proc_create(name, mode, parent, proc_ops) ({NULL;}) |
|---|
| 181 | +#define proc_create_data(name, mode, parent, proc_ops, data) ({NULL;}) |
|---|
| 110 | 182 | |
|---|
| 111 | 183 | static inline void proc_set_size(struct proc_dir_entry *de, loff_t size) {} |
|---|
| 112 | 184 | static inline void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid) {} |
|---|
| .. | .. |
|---|
| 118 | 190 | static inline int remove_proc_subtree(const char *name, struct proc_dir_entry *parent) { return 0; } |
|---|
| 119 | 191 | |
|---|
| 120 | 192 | #define proc_create_net_data(name, mode, parent, ops, state_size, data) ({NULL;}) |
|---|
| 193 | +#define proc_create_net_data_write(name, mode, parent, ops, write, state_size, data) ({NULL;}) |
|---|
| 121 | 194 | #define proc_create_net(name, mode, parent, state_size, ops) ({NULL;}) |
|---|
| 122 | 195 | #define proc_create_net_single(name, mode, parent, show, data) ({NULL;}) |
|---|
| 196 | +#define proc_create_net_single_write(name, mode, parent, show, write, data) ({NULL;}) |
|---|
| 123 | 197 | |
|---|
| 124 | 198 | static inline struct pid *tgid_pidfd_to_pid(const struct file *file) |
|---|
| 125 | 199 | { |
|---|
| .. | .. |
|---|
| 127 | 201 | } |
|---|
| 128 | 202 | |
|---|
| 129 | 203 | #endif /* CONFIG_PROC_FS */ |
|---|
| 130 | | - |
|---|
| 131 | | -#ifdef CONFIG_PROC_UID |
|---|
| 132 | | -extern void proc_register_uid(kuid_t uid); |
|---|
| 133 | | -#else |
|---|
| 134 | | -static inline void proc_register_uid(kuid_t uid) {} |
|---|
| 135 | | -#endif |
|---|
| 136 | 204 | |
|---|
| 137 | 205 | struct net; |
|---|
| 138 | 206 | |
|---|
| .. | .. |
|---|
| 147 | 215 | struct ns_common *(*get_ns)(struct ns_common *ns)); |
|---|
| 148 | 216 | |
|---|
| 149 | 217 | /* get the associated pid namespace for a file in procfs */ |
|---|
| 150 | | -static inline struct pid_namespace *proc_pid_ns(const struct inode *inode) |
|---|
| 218 | +static inline struct pid_namespace *proc_pid_ns(struct super_block *sb) |
|---|
| 151 | 219 | { |
|---|
| 152 | | - return inode->i_sb->s_fs_info; |
|---|
| 220 | + return proc_sb_info(sb)->pid_ns; |
|---|
| 153 | 221 | } |
|---|
| 154 | 222 | |
|---|
| 223 | +bool proc_ns_file(const struct file *file); |
|---|
| 224 | + |
|---|
| 155 | 225 | #endif /* _LINUX_PROC_FS_H */ |
|---|