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