^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /* Internal procfs definitions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Written by David Howells (dhowells@redhat.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/proc_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/proc_ns.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/refcount.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/atomic.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/binfmts.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/sched/coredump.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/sched/task.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) struct ctl_table_header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) struct mempolicy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * This is not completely implemented yet. The idea is to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * create an in-memory tree (like the actual /proc filesystem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * tree) of these proc_dir_entries, so that we can dynamically
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * add new files to /proc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * parent/subdir are used for the directory structure (every /proc file has a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * parent, but "subdir" is empty for all non-directory entries).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * subdir_node is used to build the rb tree "subdir" of the parent.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) struct proc_dir_entry {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * number of callers into module in progress;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * negative -> it's going away RSN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) atomic_t in_use;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) refcount_t refcnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) struct list_head pde_openers; /* who did ->open, but not ->release */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) /* protects ->pde_openers and all struct pde_opener instances */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) spinlock_t pde_unload_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) struct completion *pde_unload_completion;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) const struct inode_operations *proc_iops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) const struct proc_ops *proc_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) const struct file_operations *proc_dir_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) const struct dentry_operations *proc_dops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) const struct seq_operations *seq_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) int (*single_show)(struct seq_file *, void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) proc_write_t write;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) void *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) unsigned int state_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) unsigned int low_ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) nlink_t nlink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) kuid_t uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) kgid_t gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) loff_t size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) struct proc_dir_entry *parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) struct rb_root subdir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) struct rb_node subdir_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) umode_t mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) u8 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) u8 namelen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) char inline_name[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) } __randomize_layout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) #define SIZEOF_PDE ( \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) sizeof(struct proc_dir_entry) < 128 ? 128 : \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) sizeof(struct proc_dir_entry) < 192 ? 192 : \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) sizeof(struct proc_dir_entry) < 256 ? 256 : \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) sizeof(struct proc_dir_entry) < 512 ? 512 : \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) #define SIZEOF_PDE_INLINE_NAME (SIZEOF_PDE - sizeof(struct proc_dir_entry))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) static inline bool pde_is_permanent(const struct proc_dir_entry *pde)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) return pde->flags & PROC_ENTRY_PERMANENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) extern struct kmem_cache *proc_dir_entry_cache;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) void pde_free(struct proc_dir_entry *pde);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) union proc_op {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) int (*proc_get_link)(struct dentry *, struct path *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) int (*proc_show)(struct seq_file *m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) struct pid_namespace *ns, struct pid *pid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) struct task_struct *task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) const char *lsm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) struct proc_inode {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) struct pid *pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) unsigned int fd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) union proc_op op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) struct proc_dir_entry *pde;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) struct ctl_table_header *sysctl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) struct ctl_table *sysctl_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) struct hlist_node sibling_inodes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) const struct proc_ns_operations *ns_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) struct inode vfs_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) } __randomize_layout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) * General functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) static inline struct proc_inode *PROC_I(const struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) return container_of(inode, struct proc_inode, vfs_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) static inline struct proc_dir_entry *PDE(const struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) return PROC_I(inode)->pde;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) static inline void *__PDE_DATA(const struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) return PDE(inode)->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) static inline struct pid *proc_pid(const struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) return PROC_I(inode)->pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) static inline struct task_struct *get_proc_task(const struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) return get_pid_task(proc_pid(inode), PIDTYPE_PID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) void task_dump_owner(struct task_struct *task, umode_t mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) kuid_t *ruid, kgid_t *rgid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) unsigned name_to_int(const struct qstr *qstr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) * Offset of the first process in the /proc root directory..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) #define FIRST_PROCESS_ENTRY 256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) /* Worst case buffer size needed for holding an integer. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) #define PROC_NUMBUF 13
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) * array.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) extern const struct file_operations proc_tid_children_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) extern void proc_task_name(struct seq_file *m, struct task_struct *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) bool escape);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) extern int proc_tid_stat(struct seq_file *, struct pid_namespace *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) struct pid *, struct task_struct *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) extern int proc_tgid_stat(struct seq_file *, struct pid_namespace *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) struct pid *, struct task_struct *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) struct pid *, struct task_struct *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) struct pid *, struct task_struct *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) * base.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) extern const struct dentry_operations pid_dentry_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) extern int pid_getattr(const struct path *, struct kstat *, u32, unsigned int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) extern int proc_setattr(struct dentry *, struct iattr *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) extern void proc_pid_evict_inode(struct proc_inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) extern struct inode *proc_pid_make_inode(struct super_block *, struct task_struct *, umode_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) extern void pid_update_inode(struct task_struct *, struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) extern int pid_delete_dentry(const struct dentry *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) extern int proc_pid_readdir(struct file *, struct dir_context *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) struct dentry *proc_pid_lookup(struct dentry *, unsigned int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) extern loff_t mem_lseek(struct file *, loff_t, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) /* Lookups */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) typedef struct dentry *instantiate_t(struct dentry *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) struct task_struct *, const void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) bool proc_fill_cache(struct file *, struct dir_context *, const char *, unsigned int,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) instantiate_t, struct task_struct *, const void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) * generic.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) struct proc_dir_entry *proc_create_reg(const char *name, umode_t mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) struct proc_dir_entry **parent, void *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) struct proc_dir_entry *proc_register(struct proc_dir_entry *dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) struct proc_dir_entry *dp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) extern struct dentry *proc_lookup(struct inode *, struct dentry *, unsigned int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) struct dentry *proc_lookup_de(struct inode *, struct dentry *, struct proc_dir_entry *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) extern int proc_readdir(struct file *, struct dir_context *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) int proc_readdir_de(struct file *, struct dir_context *, struct proc_dir_entry *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) static inline struct proc_dir_entry *pde_get(struct proc_dir_entry *pde)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) refcount_inc(&pde->refcnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) return pde;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) extern void pde_put(struct proc_dir_entry *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) static inline bool is_empty_pde(const struct proc_dir_entry *pde)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) return S_ISDIR(pde->mode) && !pde->proc_iops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) extern ssize_t proc_simple_write(struct file *, const char __user *, size_t, loff_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) * inode.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) struct pde_opener {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) struct list_head lh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) struct file *file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) bool closing;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) struct completion *c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) } __randomize_layout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) extern const struct inode_operations proc_link_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) extern const struct inode_operations proc_pid_link_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) extern const struct super_operations proc_sops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) void proc_init_kmemcache(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) void proc_invalidate_siblings_dcache(struct hlist_head *inodes, spinlock_t *lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) void set_proc_pid_nlink(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) extern struct inode *proc_get_inode(struct super_block *, struct proc_dir_entry *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) extern void proc_entry_rundown(struct proc_dir_entry *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) * proc_namespaces.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) extern const struct inode_operations proc_ns_dir_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) extern const struct file_operations proc_ns_dir_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) * proc_net.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) extern const struct file_operations proc_net_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) extern const struct inode_operations proc_net_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) #ifdef CONFIG_NET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) extern int proc_net_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) static inline int proc_net_init(void) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) * proc_self.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) extern int proc_setup_self(struct super_block *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) * proc_thread_self.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) extern int proc_setup_thread_self(struct super_block *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) extern void proc_thread_self_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) * proc_sysctl.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) #ifdef CONFIG_PROC_SYSCTL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) extern int proc_sys_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) extern void proc_sys_evict_inode(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) struct ctl_table_header *head);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) static inline void proc_sys_init(void) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) static inline void proc_sys_evict_inode(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) struct ctl_table_header *head) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) * proc_tty.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) #ifdef CONFIG_TTY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) extern void proc_tty_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) static inline void proc_tty_init(void) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) * root.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) extern struct proc_dir_entry proc_root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) extern void proc_self_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) * task_[no]mmu.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) struct mem_size_stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) struct proc_maps_private {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) struct inode *inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) struct task_struct *task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) struct mm_struct *mm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) #ifdef CONFIG_MMU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) struct vm_area_struct *tail_vma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) #ifdef CONFIG_NUMA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) struct mempolicy *task_mempolicy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) } __randomize_layout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) struct mm_struct *proc_mem_open(struct inode *inode, unsigned int mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) extern const struct file_operations proc_pid_maps_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) extern const struct file_operations proc_pid_numa_maps_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) extern const struct file_operations proc_pid_smaps_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) extern const struct file_operations proc_pid_smaps_rollup_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) extern const struct file_operations proc_clear_refs_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) extern const struct file_operations proc_pagemap_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) extern unsigned long task_vsize(struct mm_struct *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) extern unsigned long task_statm(struct mm_struct *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) unsigned long *, unsigned long *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) unsigned long *, unsigned long *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) extern void task_mem(struct seq_file *, struct mm_struct *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) extern const struct dentry_operations proc_net_dentry_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) static inline void pde_force_lookup(struct proc_dir_entry *pde)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) /* /proc/net/ entries can be changed under us by setns(CLONE_NEWNET) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) pde->proc_dops = &proc_net_dentry_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) }