at v5.1 1.9 kB view raw
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 10struct key; 11 12/* 13 * Some day this will be a full-fledged user tracking system.. 14 */ 15struct user_struct { 16 refcount_t __count; /* reference count */ 17 atomic_t processes; /* How many processes does this user have? */ 18 atomic_t sigpending; /* How many pending signals does this user have? */ 19#ifdef CONFIG_FANOTIFY 20 atomic_t fanotify_listeners; 21#endif 22#ifdef CONFIG_EPOLL 23 atomic_long_t epoll_watches; /* The number of file descriptors currently watched */ 24#endif 25#ifdef CONFIG_POSIX_MQUEUE 26 /* protected by mq_lock */ 27 unsigned long mq_bytes; /* How many bytes can be allocated to mqueue? */ 28#endif 29 unsigned long locked_shm; /* How many pages of mlocked shm ? */ 30 unsigned long unix_inflight; /* How many files in flight in unix sockets */ 31 atomic_long_t pipe_bufs; /* how many pages are allocated in pipe buffers */ 32 33#ifdef CONFIG_KEYS 34 struct key *uid_keyring; /* UID specific keyring */ 35 struct key *session_keyring; /* UID's default session keyring */ 36#endif 37 38 /* Hash table maintenance information */ 39 struct hlist_node uidhash_node; 40 kuid_t uid; 41 42#if defined(CONFIG_PERF_EVENTS) || defined(CONFIG_BPF_SYSCALL) || \ 43 defined(CONFIG_NET) || defined(CONFIG_IO_URING) 44 atomic_long_t locked_vm; 45#endif 46 47 /* Miscellaneous per-user rate limit */ 48 struct ratelimit_state ratelimit; 49}; 50 51extern int uids_sysfs_init(void); 52 53extern struct user_struct *find_user(kuid_t); 54 55extern struct user_struct root_user; 56#define INIT_USER (&root_user) 57 58 59/* per-UID process charging. */ 60extern struct user_struct * alloc_uid(kuid_t); 61static inline struct user_struct *get_uid(struct user_struct *u) 62{ 63 refcount_inc(&u->__count); 64 return u; 65} 66extern void free_uid(struct user_struct *); 67 68#endif /* _LINUX_SCHED_USER_H */