0001
0002 #ifndef _LINUX_SCHED_USER_H
0003 #define _LINUX_SCHED_USER_H
0004
0005 #include <linux/uidgid.h>
0006 #include <linux/atomic.h>
0007 #include <linux/percpu_counter.h>
0008 #include <linux/refcount.h>
0009 #include <linux/ratelimit.h>
0010
0011
0012
0013
0014 struct user_struct {
0015 refcount_t __count;
0016 #ifdef CONFIG_EPOLL
0017 struct percpu_counter epoll_watches;
0018 #endif
0019 unsigned long unix_inflight;
0020 atomic_long_t pipe_bufs;
0021
0022
0023 struct hlist_node uidhash_node;
0024 kuid_t uid;
0025
0026 #if defined(CONFIG_PERF_EVENTS) || defined(CONFIG_BPF_SYSCALL) || \
0027 defined(CONFIG_NET) || defined(CONFIG_IO_URING) || \
0028 defined(CONFIG_VFIO_PCI_ZDEV_KVM)
0029 atomic_long_t locked_vm;
0030 #endif
0031 #ifdef CONFIG_WATCH_QUEUE
0032 atomic_t nr_watches;
0033 #endif
0034
0035
0036 struct ratelimit_state ratelimit;
0037 };
0038
0039 extern int uids_sysfs_init(void);
0040
0041 extern struct user_struct *find_user(kuid_t);
0042
0043 extern struct user_struct root_user;
0044 #define INIT_USER (&root_user)
0045
0046
0047
0048 extern struct user_struct * alloc_uid(kuid_t);
0049 static inline struct user_struct *get_uid(struct user_struct *u)
0050 {
0051 refcount_inc(&u->__count);
0052 return u;
0053 }
0054 extern void free_uid(struct user_struct *);
0055
0056 #endif