]> git.ipfire.org Git - thirdparty/kernel/linux.git/blob - include/linux/sched/user.h
Merge tag 'array-bounds-fixes-5.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel...
[thirdparty/kernel/linux.git] / include / linux / sched / user.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_SCHED_USER_H
3 #define _LINUX_SCHED_USER_H
4
5 #include <linux/uidgid.h>
6 #include <linux/atomic.h>
7 #include <linux/refcount.h>
8 #include <linux/ratelimit.h>
9
10 /*
11 * Some day this will be a full-fledged user tracking system..
12 */
13 struct user_struct {
14 refcount_t __count; /* reference count */
15 atomic_t processes; /* How many processes does this user have? */
16 atomic_t sigpending; /* How many pending signals does this user have? */
17 #ifdef CONFIG_EPOLL
18 atomic_long_t epoll_watches; /* The number of file descriptors currently watched */
19 #endif
20 #ifdef CONFIG_POSIX_MQUEUE
21 /* protected by mq_lock */
22 unsigned long mq_bytes; /* How many bytes can be allocated to mqueue? */
23 #endif
24 unsigned long locked_shm; /* How many pages of mlocked shm ? */
25 unsigned long unix_inflight; /* How many files in flight in unix sockets */
26 atomic_long_t pipe_bufs; /* how many pages are allocated in pipe buffers */
27
28 /* Hash table maintenance information */
29 struct hlist_node uidhash_node;
30 kuid_t uid;
31
32 #if defined(CONFIG_PERF_EVENTS) || defined(CONFIG_BPF_SYSCALL) || \
33 defined(CONFIG_NET) || defined(CONFIG_IO_URING)
34 atomic_long_t locked_vm;
35 #endif
36 #ifdef CONFIG_WATCH_QUEUE
37 atomic_t nr_watches; /* The number of watches this user currently has */
38 #endif
39
40 /* Miscellaneous per-user rate limit */
41 struct ratelimit_state ratelimit;
42 };
43
44 extern int uids_sysfs_init(void);
45
46 extern struct user_struct *find_user(kuid_t);
47
48 extern struct user_struct root_user;
49 #define INIT_USER (&root_user)
50
51
52 /* per-UID process charging. */
53 extern struct user_struct * alloc_uid(kuid_t);
54 static inline struct user_struct *get_uid(struct user_struct *u)
55 {
56 refcount_inc(&u->__count);
57 return u;
58 }
59 extern void free_uid(struct user_struct *);
60
61 #endif /* _LINUX_SCHED_USER_H */