GNU Linux-libre 4.14.328-gnu1
[releases.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
8 struct key;
9
10 /*
11  * Some day this will be a full-fledged user tracking system..
12  */
13 struct user_struct {
14         atomic_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_FANOTIFY
18         atomic_t fanotify_listeners;
19 #endif
20 #ifdef CONFIG_EPOLL
21         atomic_long_t epoll_watches; /* The number of file descriptors currently watched */
22 #endif
23 #ifdef CONFIG_POSIX_MQUEUE
24         /* protected by mq_lock */
25         unsigned long mq_bytes; /* How many bytes can be allocated to mqueue? */
26 #endif
27         unsigned long locked_shm; /* How many pages of mlocked shm ? */
28         unsigned long unix_inflight;    /* How many files in flight in unix sockets */
29         atomic_long_t pipe_bufs;  /* how many pages are allocated in pipe buffers */
30
31 #ifdef CONFIG_KEYS
32         struct key *uid_keyring;        /* UID specific keyring */
33         struct key *session_keyring;    /* UID's default session keyring */
34 #endif
35
36         /* Hash table maintenance information */
37         struct hlist_node uidhash_node;
38         kuid_t uid;
39
40 #if defined(CONFIG_PERF_EVENTS) || defined(CONFIG_BPF_SYSCALL) || \
41     defined(CONFIG_NET)
42         atomic_long_t locked_vm;
43 #endif
44 };
45
46 extern int uids_sysfs_init(void);
47
48 extern struct user_struct *find_user(kuid_t);
49
50 extern struct user_struct root_user;
51 #define INIT_USER (&root_user)
52
53
54 /* per-UID process charging. */
55 extern struct user_struct * alloc_uid(kuid_t);
56 static inline struct user_struct *get_uid(struct user_struct *u)
57 {
58         atomic_inc(&u->__count);
59         return u;
60 }
61 extern void free_uid(struct user_struct *);
62
63 #endif /* _LINUX_SCHED_USER_H */