Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Ingo Molnar | 8703e8a | 2017-02-08 18:51:30 +0100 | [diff] [blame] | 2 | #ifndef _LINUX_SCHED_USER_H |
| 3 | #define _LINUX_SCHED_USER_H |
| 4 | |
Ingo Molnar | de8deb0 | 2017-02-08 18:51:55 +0100 | [diff] [blame] | 5 | #include <linux/uidgid.h> |
| 6 | #include <linux/atomic.h> |
Luck, Tony | bef3efb | 2018-02-22 09:15:06 -0800 | [diff] [blame] | 7 | #include <linux/ratelimit.h> |
Ingo Molnar | 8703e8a | 2017-02-08 18:51:30 +0100 | [diff] [blame] | 8 | |
Ingo Molnar | bcbb6a5 | 2017-02-02 10:22:42 +0100 | [diff] [blame] | 9 | struct key; |
| 10 | |
| 11 | /* |
| 12 | * Some day this will be a full-fledged user tracking system.. |
| 13 | */ |
| 14 | struct user_struct { |
| 15 | atomic_t __count; /* reference count */ |
| 16 | atomic_t processes; /* How many processes does this user have? */ |
| 17 | atomic_t sigpending; /* How many pending signals does this user have? */ |
| 18 | #ifdef CONFIG_FANOTIFY |
| 19 | atomic_t fanotify_listeners; |
| 20 | #endif |
| 21 | #ifdef CONFIG_EPOLL |
| 22 | atomic_long_t epoll_watches; /* The number of file descriptors currently watched */ |
| 23 | #endif |
| 24 | #ifdef CONFIG_POSIX_MQUEUE |
| 25 | /* protected by mq_lock */ |
| 26 | unsigned long mq_bytes; /* How many bytes can be allocated to mqueue? */ |
| 27 | #endif |
| 28 | unsigned long locked_shm; /* How many pages of mlocked shm ? */ |
| 29 | unsigned long unix_inflight; /* How many files in flight in unix sockets */ |
| 30 | atomic_long_t pipe_bufs; /* how many pages are allocated in pipe buffers */ |
| 31 | |
| 32 | #ifdef CONFIG_KEYS |
| 33 | struct key *uid_keyring; /* UID specific keyring */ |
| 34 | struct key *session_keyring; /* UID's default session keyring */ |
| 35 | #endif |
| 36 | |
| 37 | /* Hash table maintenance information */ |
| 38 | struct hlist_node uidhash_node; |
| 39 | kuid_t uid; |
| 40 | |
Willem de Bruijn | a91dbff | 2017-08-03 16:29:43 -0400 | [diff] [blame] | 41 | #if defined(CONFIG_PERF_EVENTS) || defined(CONFIG_BPF_SYSCALL) || \ |
| 42 | defined(CONFIG_NET) |
Ingo Molnar | bcbb6a5 | 2017-02-02 10:22:42 +0100 | [diff] [blame] | 43 | atomic_long_t locked_vm; |
| 44 | #endif |
Luck, Tony | bef3efb | 2018-02-22 09:15:06 -0800 | [diff] [blame] | 45 | |
| 46 | /* Miscellaneous per-user rate limit */ |
| 47 | struct ratelimit_state ratelimit; |
Ingo Molnar | bcbb6a5 | 2017-02-02 10:22:42 +0100 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | extern int uids_sysfs_init(void); |
| 51 | |
| 52 | extern struct user_struct *find_user(kuid_t); |
| 53 | |
| 54 | extern struct user_struct root_user; |
| 55 | #define INIT_USER (&root_user) |
| 56 | |
| 57 | |
| 58 | /* per-UID process charging. */ |
| 59 | extern struct user_struct * alloc_uid(kuid_t); |
| 60 | static inline struct user_struct *get_uid(struct user_struct *u) |
| 61 | { |
| 62 | atomic_inc(&u->__count); |
| 63 | return u; |
| 64 | } |
| 65 | extern void free_uid(struct user_struct *); |
| 66 | |
Ingo Molnar | 8703e8a | 2017-02-08 18:51:30 +0100 | [diff] [blame] | 67 | #endif /* _LINUX_SCHED_USER_H */ |