user.h 1.8 KB

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