blob: 3c07e4135127915b75f916fa12e99f077889a141 [file] [log] [blame]
Ingo Molnar8703e8a2017-02-08 18:51:30 +01001#ifndef _LINUX_SCHED_USER_H
2#define _LINUX_SCHED_USER_H
3
Ingo Molnarde8deb02017-02-08 18:51:55 +01004#include <linux/uidgid.h>
5#include <linux/atomic.h>
Ingo Molnar8703e8a2017-02-08 18:51:30 +01006
Ingo Molnarbcbb6a52017-02-02 10:22:42 +01007struct key;
8
9/*
10 * Some day this will be a full-fledged user tracking system..
11 */
12struct user_struct {
13 atomic_t __count; /* reference count */
14 atomic_t processes; /* How many processes does this user have? */
15 atomic_t sigpending; /* How many pending signals does this user have? */
16#ifdef CONFIG_FANOTIFY
17 atomic_t fanotify_listeners;
18#endif
19#ifdef CONFIG_EPOLL
20 atomic_long_t epoll_watches; /* The number of file descriptors currently watched */
21#endif
22#ifdef CONFIG_POSIX_MQUEUE
23 /* protected by mq_lock */
24 unsigned long mq_bytes; /* How many bytes can be allocated to mqueue? */
25#endif
26 unsigned long locked_shm; /* How many pages of mlocked shm ? */
27 unsigned long unix_inflight; /* How many files in flight in unix sockets */
28 atomic_long_t pipe_bufs; /* how many pages are allocated in pipe buffers */
29
30#ifdef CONFIG_KEYS
31 struct key *uid_keyring; /* UID specific keyring */
32 struct key *session_keyring; /* UID's default session keyring */
33#endif
34
35 /* Hash table maintenance information */
36 struct hlist_node uidhash_node;
37 kuid_t uid;
38
Willem de Bruijna91dbff2017-08-03 16:29:43 -040039#if defined(CONFIG_PERF_EVENTS) || defined(CONFIG_BPF_SYSCALL) || \
40 defined(CONFIG_NET)
Ingo Molnarbcbb6a52017-02-02 10:22:42 +010041 atomic_long_t locked_vm;
42#endif
43};
44
45extern int uids_sysfs_init(void);
46
47extern struct user_struct *find_user(kuid_t);
48
49extern struct user_struct root_user;
50#define INIT_USER (&root_user)
51
52
53/* per-UID process charging. */
54extern struct user_struct * alloc_uid(kuid_t);
55static inline struct user_struct *get_uid(struct user_struct *u)
56{
57 atomic_inc(&u->__count);
58 return u;
59}
60extern void free_uid(struct user_struct *);
61
Ingo Molnar8703e8a2017-02-08 18:51:30 +010062#endif /* _LINUX_SCHED_USER_H */