lsm_hook_defs.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Linux Security Module Hook declarations.
  4. *
  5. * Copyright (C) 2001 WireX Communications, Inc <[email protected]>
  6. * Copyright (C) 2001 Greg Kroah-Hartman <[email protected]>
  7. * Copyright (C) 2001 Networks Associates Technology, Inc <[email protected]>
  8. * Copyright (C) 2001 James Morris <[email protected]>
  9. * Copyright (C) 2001 Silicon Graphics, Inc. (Trust Technology Group)
  10. * Copyright (C) 2015 Intel Corporation.
  11. * Copyright (C) 2015 Casey Schaufler <[email protected]>
  12. * Copyright (C) 2016 Mellanox Techonologies
  13. * Copyright (C) 2020 Google LLC.
  14. */
  15. /*
  16. * The macro LSM_HOOK is used to define the data structures required by
  17. * the LSM framework using the pattern:
  18. *
  19. * LSM_HOOK(<return_type>, <default_value>, <hook_name>, args...)
  20. *
  21. * struct security_hook_heads {
  22. * #define LSM_HOOK(RET, DEFAULT, NAME, ...) struct hlist_head NAME;
  23. * #include <linux/lsm_hook_defs.h>
  24. * #undef LSM_HOOK
  25. * };
  26. */
  27. LSM_HOOK(int, 0, binder_set_context_mgr, const struct cred *mgr)
  28. LSM_HOOK(int, 0, binder_transaction, const struct cred *from,
  29. const struct cred *to)
  30. LSM_HOOK(int, 0, binder_transfer_binder, const struct cred *from,
  31. const struct cred *to)
  32. LSM_HOOK(int, 0, binder_transfer_file, const struct cred *from,
  33. const struct cred *to, struct file *file)
  34. LSM_HOOK(int, 0, ptrace_access_check, struct task_struct *child,
  35. unsigned int mode)
  36. LSM_HOOK(int, 0, ptrace_traceme, struct task_struct *parent)
  37. LSM_HOOK(int, 0, capget, struct task_struct *target, kernel_cap_t *effective,
  38. kernel_cap_t *inheritable, kernel_cap_t *permitted)
  39. LSM_HOOK(int, 0, capset, struct cred *new, const struct cred *old,
  40. const kernel_cap_t *effective, const kernel_cap_t *inheritable,
  41. const kernel_cap_t *permitted)
  42. LSM_HOOK(int, 0, capable, const struct cred *cred, struct user_namespace *ns,
  43. int cap, unsigned int opts)
  44. LSM_HOOK(int, 0, quotactl, int cmds, int type, int id, struct super_block *sb)
  45. LSM_HOOK(int, 0, quota_on, struct dentry *dentry)
  46. LSM_HOOK(int, 0, syslog, int type)
  47. LSM_HOOK(int, 0, settime, const struct timespec64 *ts,
  48. const struct timezone *tz)
  49. LSM_HOOK(int, 1, vm_enough_memory, struct mm_struct *mm, long pages)
  50. LSM_HOOK(int, 0, bprm_creds_for_exec, struct linux_binprm *bprm)
  51. LSM_HOOK(int, 0, bprm_creds_from_file, struct linux_binprm *bprm, struct file *file)
  52. LSM_HOOK(int, 0, bprm_check_security, struct linux_binprm *bprm)
  53. LSM_HOOK(void, LSM_RET_VOID, bprm_committing_creds, struct linux_binprm *bprm)
  54. LSM_HOOK(void, LSM_RET_VOID, bprm_committed_creds, struct linux_binprm *bprm)
  55. LSM_HOOK(int, 0, fs_context_submount, struct fs_context *fc, struct super_block *reference)
  56. LSM_HOOK(int, 0, fs_context_dup, struct fs_context *fc,
  57. struct fs_context *src_sc)
  58. LSM_HOOK(int, -ENOPARAM, fs_context_parse_param, struct fs_context *fc,
  59. struct fs_parameter *param)
  60. LSM_HOOK(int, 0, sb_alloc_security, struct super_block *sb)
  61. LSM_HOOK(void, LSM_RET_VOID, sb_delete, struct super_block *sb)
  62. LSM_HOOK(void, LSM_RET_VOID, sb_free_security, struct super_block *sb)
  63. LSM_HOOK(void, LSM_RET_VOID, sb_free_mnt_opts, void *mnt_opts)
  64. LSM_HOOK(int, 0, sb_eat_lsm_opts, char *orig, void **mnt_opts)
  65. LSM_HOOK(int, 0, sb_mnt_opts_compat, struct super_block *sb, void *mnt_opts)
  66. LSM_HOOK(int, 0, sb_remount, struct super_block *sb, void *mnt_opts)
  67. LSM_HOOK(int, 0, sb_kern_mount, struct super_block *sb)
  68. LSM_HOOK(int, 0, sb_show_options, struct seq_file *m, struct super_block *sb)
  69. LSM_HOOK(int, 0, sb_statfs, struct dentry *dentry)
  70. LSM_HOOK(int, 0, sb_mount, const char *dev_name, const struct path *path,
  71. const char *type, unsigned long flags, void *data)
  72. LSM_HOOK(int, 0, sb_umount, struct vfsmount *mnt, int flags)
  73. LSM_HOOK(int, 0, sb_pivotroot, const struct path *old_path,
  74. const struct path *new_path)
  75. LSM_HOOK(int, 0, sb_set_mnt_opts, struct super_block *sb, void *mnt_opts,
  76. unsigned long kern_flags, unsigned long *set_kern_flags)
  77. LSM_HOOK(int, 0, sb_clone_mnt_opts, const struct super_block *oldsb,
  78. struct super_block *newsb, unsigned long kern_flags,
  79. unsigned long *set_kern_flags)
  80. LSM_HOOK(int, 0, move_mount, const struct path *from_path,
  81. const struct path *to_path)
  82. LSM_HOOK(int, -EOPNOTSUPP, dentry_init_security, struct dentry *dentry,
  83. int mode, const struct qstr *name, const char **xattr_name,
  84. void **ctx, u32 *ctxlen)
  85. LSM_HOOK(int, 0, dentry_create_files_as, struct dentry *dentry, int mode,
  86. struct qstr *name, const struct cred *old, struct cred *new)
  87. #ifdef CONFIG_SECURITY_PATH
  88. LSM_HOOK(int, 0, path_unlink, const struct path *dir, struct dentry *dentry)
  89. LSM_HOOK(int, 0, path_mkdir, const struct path *dir, struct dentry *dentry,
  90. umode_t mode)
  91. LSM_HOOK(int, 0, path_rmdir, const struct path *dir, struct dentry *dentry)
  92. LSM_HOOK(int, 0, path_mknod, const struct path *dir, struct dentry *dentry,
  93. umode_t mode, unsigned int dev)
  94. LSM_HOOK(int, 0, path_truncate, const struct path *path)
  95. LSM_HOOK(int, 0, path_symlink, const struct path *dir, struct dentry *dentry,
  96. const char *old_name)
  97. LSM_HOOK(int, 0, path_link, struct dentry *old_dentry,
  98. const struct path *new_dir, struct dentry *new_dentry)
  99. LSM_HOOK(int, 0, path_rename, const struct path *old_dir,
  100. struct dentry *old_dentry, const struct path *new_dir,
  101. struct dentry *new_dentry, unsigned int flags)
  102. LSM_HOOK(int, 0, path_chmod, const struct path *path, umode_t mode)
  103. LSM_HOOK(int, 0, path_chown, const struct path *path, kuid_t uid, kgid_t gid)
  104. LSM_HOOK(int, 0, path_chroot, const struct path *path)
  105. #endif /* CONFIG_SECURITY_PATH */
  106. /* Needed for inode based security check */
  107. LSM_HOOK(int, 0, path_notify, const struct path *path, u64 mask,
  108. unsigned int obj_type)
  109. LSM_HOOK(int, 0, inode_alloc_security, struct inode *inode)
  110. LSM_HOOK(void, LSM_RET_VOID, inode_free_security, struct inode *inode)
  111. LSM_HOOK(int, 0, inode_init_security, struct inode *inode,
  112. struct inode *dir, const struct qstr *qstr, const char **name,
  113. void **value, size_t *len)
  114. LSM_HOOK(int, 0, inode_init_security_anon, struct inode *inode,
  115. const struct qstr *name, const struct inode *context_inode)
  116. LSM_HOOK(int, 0, inode_create, struct inode *dir, struct dentry *dentry,
  117. umode_t mode)
  118. LSM_HOOK(int, 0, inode_link, struct dentry *old_dentry, struct inode *dir,
  119. struct dentry *new_dentry)
  120. LSM_HOOK(int, 0, inode_unlink, struct inode *dir, struct dentry *dentry)
  121. LSM_HOOK(int, 0, inode_symlink, struct inode *dir, struct dentry *dentry,
  122. const char *old_name)
  123. LSM_HOOK(int, 0, inode_mkdir, struct inode *dir, struct dentry *dentry,
  124. umode_t mode)
  125. LSM_HOOK(int, 0, inode_rmdir, struct inode *dir, struct dentry *dentry)
  126. LSM_HOOK(int, 0, inode_mknod, struct inode *dir, struct dentry *dentry,
  127. umode_t mode, dev_t dev)
  128. LSM_HOOK(int, 0, inode_rename, struct inode *old_dir, struct dentry *old_dentry,
  129. struct inode *new_dir, struct dentry *new_dentry)
  130. LSM_HOOK(int, 0, inode_readlink, struct dentry *dentry)
  131. LSM_HOOK(int, 0, inode_follow_link, struct dentry *dentry, struct inode *inode,
  132. bool rcu)
  133. LSM_HOOK(int, 0, inode_permission, struct inode *inode, int mask)
  134. LSM_HOOK(int, 0, inode_setattr, struct dentry *dentry, struct iattr *attr)
  135. LSM_HOOK(int, 0, inode_getattr, const struct path *path)
  136. LSM_HOOK(int, 0, inode_setxattr, struct user_namespace *mnt_userns,
  137. struct dentry *dentry, const char *name, const void *value,
  138. size_t size, int flags)
  139. LSM_HOOK(void, LSM_RET_VOID, inode_post_setxattr, struct dentry *dentry,
  140. const char *name, const void *value, size_t size, int flags)
  141. LSM_HOOK(int, 0, inode_getxattr, struct dentry *dentry, const char *name)
  142. LSM_HOOK(int, 0, inode_listxattr, struct dentry *dentry)
  143. LSM_HOOK(int, 0, inode_removexattr, struct user_namespace *mnt_userns,
  144. struct dentry *dentry, const char *name)
  145. LSM_HOOK(int, 0, inode_need_killpriv, struct dentry *dentry)
  146. LSM_HOOK(int, 0, inode_killpriv, struct user_namespace *mnt_userns,
  147. struct dentry *dentry)
  148. LSM_HOOK(int, -EOPNOTSUPP, inode_getsecurity, struct user_namespace *mnt_userns,
  149. struct inode *inode, const char *name, void **buffer, bool alloc)
  150. LSM_HOOK(int, -EOPNOTSUPP, inode_setsecurity, struct inode *inode,
  151. const char *name, const void *value, size_t size, int flags)
  152. LSM_HOOK(int, 0, inode_listsecurity, struct inode *inode, char *buffer,
  153. size_t buffer_size)
  154. LSM_HOOK(void, LSM_RET_VOID, inode_getsecid, struct inode *inode, u32 *secid)
  155. LSM_HOOK(int, 0, inode_copy_up, struct dentry *src, struct cred **new)
  156. LSM_HOOK(int, -EOPNOTSUPP, inode_copy_up_xattr, const char *name)
  157. LSM_HOOK(int, 0, kernfs_init_security, struct kernfs_node *kn_dir,
  158. struct kernfs_node *kn)
  159. LSM_HOOK(int, 0, file_permission, struct file *file, int mask)
  160. LSM_HOOK(int, 0, file_alloc_security, struct file *file)
  161. LSM_HOOK(void, LSM_RET_VOID, file_free_security, struct file *file)
  162. LSM_HOOK(int, 0, file_ioctl, struct file *file, unsigned int cmd,
  163. unsigned long arg)
  164. LSM_HOOK(int, 0, mmap_addr, unsigned long addr)
  165. LSM_HOOK(int, 0, mmap_file, struct file *file, unsigned long reqprot,
  166. unsigned long prot, unsigned long flags)
  167. LSM_HOOK(int, 0, file_mprotect, struct vm_area_struct *vma,
  168. unsigned long reqprot, unsigned long prot)
  169. LSM_HOOK(int, 0, file_lock, struct file *file, unsigned int cmd)
  170. LSM_HOOK(int, 0, file_fcntl, struct file *file, unsigned int cmd,
  171. unsigned long arg)
  172. LSM_HOOK(void, LSM_RET_VOID, file_set_fowner, struct file *file)
  173. LSM_HOOK(int, 0, file_send_sigiotask, struct task_struct *tsk,
  174. struct fown_struct *fown, int sig)
  175. LSM_HOOK(int, 0, file_receive, struct file *file)
  176. LSM_HOOK(int, 0, file_open, struct file *file)
  177. LSM_HOOK(int, 0, task_alloc, struct task_struct *task,
  178. unsigned long clone_flags)
  179. LSM_HOOK(void, LSM_RET_VOID, task_free, struct task_struct *task)
  180. LSM_HOOK(int, 0, cred_alloc_blank, struct cred *cred, gfp_t gfp)
  181. LSM_HOOK(void, LSM_RET_VOID, cred_free, struct cred *cred)
  182. LSM_HOOK(int, 0, cred_prepare, struct cred *new, const struct cred *old,
  183. gfp_t gfp)
  184. LSM_HOOK(void, LSM_RET_VOID, cred_transfer, struct cred *new,
  185. const struct cred *old)
  186. LSM_HOOK(void, LSM_RET_VOID, cred_getsecid, const struct cred *c, u32 *secid)
  187. LSM_HOOK(int, 0, kernel_act_as, struct cred *new, u32 secid)
  188. LSM_HOOK(int, 0, kernel_create_files_as, struct cred *new, struct inode *inode)
  189. LSM_HOOK(int, 0, kernel_module_request, char *kmod_name)
  190. LSM_HOOK(int, 0, kernel_load_data, enum kernel_load_data_id id, bool contents)
  191. LSM_HOOK(int, 0, kernel_post_load_data, char *buf, loff_t size,
  192. enum kernel_load_data_id id, char *description)
  193. LSM_HOOK(int, 0, kernel_read_file, struct file *file,
  194. enum kernel_read_file_id id, bool contents)
  195. LSM_HOOK(int, 0, kernel_post_read_file, struct file *file, char *buf,
  196. loff_t size, enum kernel_read_file_id id)
  197. LSM_HOOK(int, 0, task_fix_setuid, struct cred *new, const struct cred *old,
  198. int flags)
  199. LSM_HOOK(int, 0, task_fix_setgid, struct cred *new, const struct cred * old,
  200. int flags)
  201. LSM_HOOK(int, 0, task_fix_setgroups, struct cred *new, const struct cred * old)
  202. LSM_HOOK(int, 0, task_setpgid, struct task_struct *p, pid_t pgid)
  203. LSM_HOOK(int, 0, task_getpgid, struct task_struct *p)
  204. LSM_HOOK(int, 0, task_getsid, struct task_struct *p)
  205. LSM_HOOK(void, LSM_RET_VOID, current_getsecid_subj, u32 *secid)
  206. LSM_HOOK(void, LSM_RET_VOID, task_getsecid_obj,
  207. struct task_struct *p, u32 *secid)
  208. LSM_HOOK(int, 0, task_setnice, struct task_struct *p, int nice)
  209. LSM_HOOK(int, 0, task_setioprio, struct task_struct *p, int ioprio)
  210. LSM_HOOK(int, 0, task_getioprio, struct task_struct *p)
  211. LSM_HOOK(int, 0, task_prlimit, const struct cred *cred,
  212. const struct cred *tcred, unsigned int flags)
  213. LSM_HOOK(int, 0, task_setrlimit, struct task_struct *p, unsigned int resource,
  214. struct rlimit *new_rlim)
  215. LSM_HOOK(int, 0, task_setscheduler, struct task_struct *p)
  216. LSM_HOOK(int, 0, task_getscheduler, struct task_struct *p)
  217. LSM_HOOK(int, 0, task_movememory, struct task_struct *p)
  218. LSM_HOOK(int, 0, task_kill, struct task_struct *p, struct kernel_siginfo *info,
  219. int sig, const struct cred *cred)
  220. LSM_HOOK(int, -ENOSYS, task_prctl, int option, unsigned long arg2,
  221. unsigned long arg3, unsigned long arg4, unsigned long arg5)
  222. LSM_HOOK(void, LSM_RET_VOID, task_to_inode, struct task_struct *p,
  223. struct inode *inode)
  224. LSM_HOOK(int, 0, userns_create, const struct cred *cred)
  225. LSM_HOOK(int, 0, ipc_permission, struct kern_ipc_perm *ipcp, short flag)
  226. LSM_HOOK(void, LSM_RET_VOID, ipc_getsecid, struct kern_ipc_perm *ipcp,
  227. u32 *secid)
  228. LSM_HOOK(int, 0, msg_msg_alloc_security, struct msg_msg *msg)
  229. LSM_HOOK(void, LSM_RET_VOID, msg_msg_free_security, struct msg_msg *msg)
  230. LSM_HOOK(int, 0, msg_queue_alloc_security, struct kern_ipc_perm *perm)
  231. LSM_HOOK(void, LSM_RET_VOID, msg_queue_free_security,
  232. struct kern_ipc_perm *perm)
  233. LSM_HOOK(int, 0, msg_queue_associate, struct kern_ipc_perm *perm, int msqflg)
  234. LSM_HOOK(int, 0, msg_queue_msgctl, struct kern_ipc_perm *perm, int cmd)
  235. LSM_HOOK(int, 0, msg_queue_msgsnd, struct kern_ipc_perm *perm,
  236. struct msg_msg *msg, int msqflg)
  237. LSM_HOOK(int, 0, msg_queue_msgrcv, struct kern_ipc_perm *perm,
  238. struct msg_msg *msg, struct task_struct *target, long type, int mode)
  239. LSM_HOOK(int, 0, shm_alloc_security, struct kern_ipc_perm *perm)
  240. LSM_HOOK(void, LSM_RET_VOID, shm_free_security, struct kern_ipc_perm *perm)
  241. LSM_HOOK(int, 0, shm_associate, struct kern_ipc_perm *perm, int shmflg)
  242. LSM_HOOK(int, 0, shm_shmctl, struct kern_ipc_perm *perm, int cmd)
  243. LSM_HOOK(int, 0, shm_shmat, struct kern_ipc_perm *perm, char __user *shmaddr,
  244. int shmflg)
  245. LSM_HOOK(int, 0, sem_alloc_security, struct kern_ipc_perm *perm)
  246. LSM_HOOK(void, LSM_RET_VOID, sem_free_security, struct kern_ipc_perm *perm)
  247. LSM_HOOK(int, 0, sem_associate, struct kern_ipc_perm *perm, int semflg)
  248. LSM_HOOK(int, 0, sem_semctl, struct kern_ipc_perm *perm, int cmd)
  249. LSM_HOOK(int, 0, sem_semop, struct kern_ipc_perm *perm, struct sembuf *sops,
  250. unsigned nsops, int alter)
  251. LSM_HOOK(int, 0, netlink_send, struct sock *sk, struct sk_buff *skb)
  252. LSM_HOOK(void, LSM_RET_VOID, d_instantiate, struct dentry *dentry,
  253. struct inode *inode)
  254. LSM_HOOK(int, -EINVAL, getprocattr, struct task_struct *p, const char *name,
  255. char **value)
  256. LSM_HOOK(int, -EINVAL, setprocattr, const char *name, void *value, size_t size)
  257. LSM_HOOK(int, 0, ismaclabel, const char *name)
  258. LSM_HOOK(int, -EOPNOTSUPP, secid_to_secctx, u32 secid, char **secdata,
  259. u32 *seclen)
  260. LSM_HOOK(int, 0, secctx_to_secid, const char *secdata, u32 seclen, u32 *secid)
  261. LSM_HOOK(void, LSM_RET_VOID, release_secctx, char *secdata, u32 seclen)
  262. LSM_HOOK(void, LSM_RET_VOID, inode_invalidate_secctx, struct inode *inode)
  263. LSM_HOOK(int, 0, inode_notifysecctx, struct inode *inode, void *ctx, u32 ctxlen)
  264. LSM_HOOK(int, 0, inode_setsecctx, struct dentry *dentry, void *ctx, u32 ctxlen)
  265. LSM_HOOK(int, -EOPNOTSUPP, inode_getsecctx, struct inode *inode, void **ctx,
  266. u32 *ctxlen)
  267. #if defined(CONFIG_SECURITY) && defined(CONFIG_WATCH_QUEUE)
  268. LSM_HOOK(int, 0, post_notification, const struct cred *w_cred,
  269. const struct cred *cred, struct watch_notification *n)
  270. #endif /* CONFIG_SECURITY && CONFIG_WATCH_QUEUE */
  271. #if defined(CONFIG_SECURITY) && defined(CONFIG_KEY_NOTIFICATIONS)
  272. LSM_HOOK(int, 0, watch_key, struct key *key)
  273. #endif /* CONFIG_SECURITY && CONFIG_KEY_NOTIFICATIONS */
  274. #ifdef CONFIG_SECURITY_NETWORK
  275. LSM_HOOK(int, 0, unix_stream_connect, struct sock *sock, struct sock *other,
  276. struct sock *newsk)
  277. LSM_HOOK(int, 0, unix_may_send, struct socket *sock, struct socket *other)
  278. LSM_HOOK(int, 0, socket_create, int family, int type, int protocol, int kern)
  279. LSM_HOOK(int, 0, socket_post_create, struct socket *sock, int family, int type,
  280. int protocol, int kern)
  281. LSM_HOOK(int, 0, socket_socketpair, struct socket *socka, struct socket *sockb)
  282. LSM_HOOK(int, 0, socket_bind, struct socket *sock, struct sockaddr *address,
  283. int addrlen)
  284. LSM_HOOK(int, 0, socket_connect, struct socket *sock, struct sockaddr *address,
  285. int addrlen)
  286. LSM_HOOK(int, 0, socket_listen, struct socket *sock, int backlog)
  287. LSM_HOOK(int, 0, socket_accept, struct socket *sock, struct socket *newsock)
  288. LSM_HOOK(int, 0, socket_sendmsg, struct socket *sock, struct msghdr *msg,
  289. int size)
  290. LSM_HOOK(int, 0, socket_recvmsg, struct socket *sock, struct msghdr *msg,
  291. int size, int flags)
  292. LSM_HOOK(int, 0, socket_getsockname, struct socket *sock)
  293. LSM_HOOK(int, 0, socket_getpeername, struct socket *sock)
  294. LSM_HOOK(int, 0, socket_getsockopt, struct socket *sock, int level, int optname)
  295. LSM_HOOK(int, 0, socket_setsockopt, struct socket *sock, int level, int optname)
  296. LSM_HOOK(int, 0, socket_shutdown, struct socket *sock, int how)
  297. LSM_HOOK(int, 0, socket_sock_rcv_skb, struct sock *sk, struct sk_buff *skb)
  298. LSM_HOOK(int, 0, socket_getpeersec_stream, struct socket *sock,
  299. char __user *optval, int __user *optlen, unsigned len)
  300. LSM_HOOK(int, 0, socket_getpeersec_dgram, struct socket *sock,
  301. struct sk_buff *skb, u32 *secid)
  302. LSM_HOOK(int, 0, sk_alloc_security, struct sock *sk, int family, gfp_t priority)
  303. LSM_HOOK(void, LSM_RET_VOID, sk_free_security, struct sock *sk)
  304. LSM_HOOK(void, LSM_RET_VOID, sk_clone_security, const struct sock *sk,
  305. struct sock *newsk)
  306. LSM_HOOK(void, LSM_RET_VOID, sk_getsecid, struct sock *sk, u32 *secid)
  307. LSM_HOOK(void, LSM_RET_VOID, sock_graft, struct sock *sk, struct socket *parent)
  308. LSM_HOOK(int, 0, inet_conn_request, const struct sock *sk, struct sk_buff *skb,
  309. struct request_sock *req)
  310. LSM_HOOK(void, LSM_RET_VOID, inet_csk_clone, struct sock *newsk,
  311. const struct request_sock *req)
  312. LSM_HOOK(void, LSM_RET_VOID, inet_conn_established, struct sock *sk,
  313. struct sk_buff *skb)
  314. LSM_HOOK(int, 0, secmark_relabel_packet, u32 secid)
  315. LSM_HOOK(void, LSM_RET_VOID, secmark_refcount_inc, void)
  316. LSM_HOOK(void, LSM_RET_VOID, secmark_refcount_dec, void)
  317. LSM_HOOK(void, LSM_RET_VOID, req_classify_flow, const struct request_sock *req,
  318. struct flowi_common *flic)
  319. LSM_HOOK(int, 0, tun_dev_alloc_security, void **security)
  320. LSM_HOOK(void, LSM_RET_VOID, tun_dev_free_security, void *security)
  321. LSM_HOOK(int, 0, tun_dev_create, void)
  322. LSM_HOOK(int, 0, tun_dev_attach_queue, void *security)
  323. LSM_HOOK(int, 0, tun_dev_attach, struct sock *sk, void *security)
  324. LSM_HOOK(int, 0, tun_dev_open, void *security)
  325. LSM_HOOK(int, 0, sctp_assoc_request, struct sctp_association *asoc,
  326. struct sk_buff *skb)
  327. LSM_HOOK(int, 0, sctp_bind_connect, struct sock *sk, int optname,
  328. struct sockaddr *address, int addrlen)
  329. LSM_HOOK(void, LSM_RET_VOID, sctp_sk_clone, struct sctp_association *asoc,
  330. struct sock *sk, struct sock *newsk)
  331. LSM_HOOK(int, 0, sctp_assoc_established, struct sctp_association *asoc,
  332. struct sk_buff *skb)
  333. #endif /* CONFIG_SECURITY_NETWORK */
  334. #ifdef CONFIG_SECURITY_INFINIBAND
  335. LSM_HOOK(int, 0, ib_pkey_access, void *sec, u64 subnet_prefix, u16 pkey)
  336. LSM_HOOK(int, 0, ib_endport_manage_subnet, void *sec, const char *dev_name,
  337. u8 port_num)
  338. LSM_HOOK(int, 0, ib_alloc_security, void **sec)
  339. LSM_HOOK(void, LSM_RET_VOID, ib_free_security, void *sec)
  340. #endif /* CONFIG_SECURITY_INFINIBAND */
  341. #ifdef CONFIG_SECURITY_NETWORK_XFRM
  342. LSM_HOOK(int, 0, xfrm_policy_alloc_security, struct xfrm_sec_ctx **ctxp,
  343. struct xfrm_user_sec_ctx *sec_ctx, gfp_t gfp)
  344. LSM_HOOK(int, 0, xfrm_policy_clone_security, struct xfrm_sec_ctx *old_ctx,
  345. struct xfrm_sec_ctx **new_ctx)
  346. LSM_HOOK(void, LSM_RET_VOID, xfrm_policy_free_security,
  347. struct xfrm_sec_ctx *ctx)
  348. LSM_HOOK(int, 0, xfrm_policy_delete_security, struct xfrm_sec_ctx *ctx)
  349. LSM_HOOK(int, 0, xfrm_state_alloc, struct xfrm_state *x,
  350. struct xfrm_user_sec_ctx *sec_ctx)
  351. LSM_HOOK(int, 0, xfrm_state_alloc_acquire, struct xfrm_state *x,
  352. struct xfrm_sec_ctx *polsec, u32 secid)
  353. LSM_HOOK(void, LSM_RET_VOID, xfrm_state_free_security, struct xfrm_state *x)
  354. LSM_HOOK(int, 0, xfrm_state_delete_security, struct xfrm_state *x)
  355. LSM_HOOK(int, 0, xfrm_policy_lookup, struct xfrm_sec_ctx *ctx, u32 fl_secid)
  356. LSM_HOOK(int, 1, xfrm_state_pol_flow_match, struct xfrm_state *x,
  357. struct xfrm_policy *xp, const struct flowi_common *flic)
  358. LSM_HOOK(int, 0, xfrm_decode_session, struct sk_buff *skb, u32 *secid,
  359. int ckall)
  360. #endif /* CONFIG_SECURITY_NETWORK_XFRM */
  361. /* key management security hooks */
  362. #ifdef CONFIG_KEYS
  363. LSM_HOOK(int, 0, key_alloc, struct key *key, const struct cred *cred,
  364. unsigned long flags)
  365. LSM_HOOK(void, LSM_RET_VOID, key_free, struct key *key)
  366. LSM_HOOK(int, 0, key_permission, key_ref_t key_ref, const struct cred *cred,
  367. enum key_need_perm need_perm)
  368. LSM_HOOK(int, 0, key_getsecurity, struct key *key, char **_buffer)
  369. #endif /* CONFIG_KEYS */
  370. #ifdef CONFIG_AUDIT
  371. LSM_HOOK(int, 0, audit_rule_init, u32 field, u32 op, char *rulestr,
  372. void **lsmrule)
  373. LSM_HOOK(int, 0, audit_rule_known, struct audit_krule *krule)
  374. LSM_HOOK(int, 0, audit_rule_match, u32 secid, u32 field, u32 op, void *lsmrule)
  375. LSM_HOOK(void, LSM_RET_VOID, audit_rule_free, void *lsmrule)
  376. #endif /* CONFIG_AUDIT */
  377. #ifdef CONFIG_BPF_SYSCALL
  378. LSM_HOOK(int, 0, bpf, int cmd, union bpf_attr *attr, unsigned int size)
  379. LSM_HOOK(int, 0, bpf_map, struct bpf_map *map, fmode_t fmode)
  380. LSM_HOOK(int, 0, bpf_prog, struct bpf_prog *prog)
  381. LSM_HOOK(int, 0, bpf_map_alloc_security, struct bpf_map *map)
  382. LSM_HOOK(void, LSM_RET_VOID, bpf_map_free_security, struct bpf_map *map)
  383. LSM_HOOK(int, 0, bpf_prog_alloc_security, struct bpf_prog_aux *aux)
  384. LSM_HOOK(void, LSM_RET_VOID, bpf_prog_free_security, struct bpf_prog_aux *aux)
  385. #endif /* CONFIG_BPF_SYSCALL */
  386. LSM_HOOK(int, 0, locked_down, enum lockdown_reason what)
  387. #ifdef CONFIG_PERF_EVENTS
  388. LSM_HOOK(int, 0, perf_event_open, struct perf_event_attr *attr, int type)
  389. LSM_HOOK(int, 0, perf_event_alloc, struct perf_event *event)
  390. LSM_HOOK(void, LSM_RET_VOID, perf_event_free, struct perf_event *event)
  391. LSM_HOOK(int, 0, perf_event_read, struct perf_event *event)
  392. LSM_HOOK(int, 0, perf_event_write, struct perf_event *event)
  393. #endif /* CONFIG_PERF_EVENTS */
  394. #ifdef CONFIG_IO_URING
  395. LSM_HOOK(int, 0, uring_override_creds, const struct cred *new)
  396. LSM_HOOK(int, 0, uring_sqpoll, void)
  397. LSM_HOOK(int, 0, uring_cmd, struct io_uring_cmd *ioucmd)
  398. #endif /* CONFIG_IO_URING */