Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
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  * Some day this will be a full-fledged user tracking system..
0013  */
0014 struct user_struct {
0015     refcount_t __count; /* reference count */
0016 #ifdef CONFIG_EPOLL
0017     struct percpu_counter epoll_watches; /* The number of file descriptors currently watched */
0018 #endif
0019     unsigned long unix_inflight;    /* How many files in flight in unix sockets */
0020     atomic_long_t pipe_bufs;  /* how many pages are allocated in pipe buffers */
0021 
0022     /* Hash table maintenance information */
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;    /* The number of watches this user currently has */
0033 #endif
0034 
0035     /* Miscellaneous per-user rate limit */
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 /* per-UID process charging. */
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 /* _LINUX_SCHED_USER_H */