blob: 6239a378c0ea8ba54efdb683e11651319ef58d33 [file] [log] [blame]
KP Singh98e828a2020-03-29 01:43:50 +01001/* SPDX-License-Identifier: GPL-2.0 */
2
3/*
4 * Linux Security Module Hook declarations.
5 *
6 * Copyright (C) 2001 WireX Communications, Inc <[email protected]>
7 * Copyright (C) 2001 Greg Kroah-Hartman <[email protected]>
8 * Copyright (C) 2001 Networks Associates Technology, Inc <[email protected]>
9 * Copyright (C) 2001 James Morris <[email protected]>
10 * Copyright (C) 2001 Silicon Graphics, Inc. (Trust Technology Group)
11 * Copyright (C) 2015 Intel Corporation.
12 * Copyright (C) 2015 Casey Schaufler <[email protected]>
13 * Copyright (C) 2016 Mellanox Techonologies
14 * Copyright (C) 2020 Google LLC.
15 */
16
17/*
Randy Dunlapbb22d802020-07-17 16:36:40 -070018 * The macro LSM_HOOK is used to define the data structures required by
KP Singh98e828a2020-03-29 01:43:50 +010019 * 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 */
Todd Kjos52f88692021-10-12 09:56:13 -070029LSM_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,
35 const struct cred *to, struct file *file)
KP Singh98e828a2020-03-29 01:43:50 +010036LSM_HOOK(int, 0, ptrace_access_check, struct task_struct *child,
37 unsigned int mode)
38LSM_HOOK(int, 0, ptrace_traceme, struct task_struct *parent)
39LSM_HOOK(int, 0, capget, struct task_struct *target, kernel_cap_t *effective,
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)
46LSM_HOOK(int, 0, quotactl, int cmds, int type, int id, struct super_block *sb)
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)
Ondrej Mosnacek7a048a92023-10-31 13:32:06 +010051LSM_HOOK(int, 1, vm_enough_memory, struct mm_struct *mm, long pages)
Eric W. Biedermanb8bff5992020-03-22 15:46:24 -050052LSM_HOOK(int, 0, bprm_creds_for_exec, struct linux_binprm *bprm)
Eric W. Biederman56305aa2020-05-29 22:00:54 -050053LSM_HOOK(int, 0, bprm_creds_from_file, struct linux_binprm *bprm, struct file *file)
KP Singh98e828a2020-03-29 01:43:50 +010054LSM_HOOK(int, 0, bprm_check_security, struct linux_binprm *bprm)
55LSM_HOOK(void, LSM_RET_VOID, bprm_committing_creds, struct linux_binprm *bprm)
56LSM_HOOK(void, LSM_RET_VOID, bprm_committed_creds, struct linux_binprm *bprm)
David Howellsed134f22023-08-08 07:34:20 -040057LSM_HOOK(int, 0, fs_context_submount, struct fs_context *fc, struct super_block *reference)
KP Singh98e828a2020-03-29 01:43:50 +010058LSM_HOOK(int, 0, fs_context_dup, struct fs_context *fc,
59 struct fs_context *src_sc)
KP Singh54261af2020-04-30 17:52:40 +020060LSM_HOOK(int, -ENOPARAM, fs_context_parse_param, struct fs_context *fc,
KP Singh98e828a2020-03-29 01:43:50 +010061 struct fs_parameter *param)
62LSM_HOOK(int, 0, sb_alloc_security, struct super_block *sb)
Mickaël Salaün83e804f2021-04-22 17:41:16 +020063LSM_HOOK(void, LSM_RET_VOID, sb_delete, struct super_block *sb)
KP Singh98e828a2020-03-29 01:43:50 +010064LSM_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)
Olga Kornievskaia69c4a422021-02-26 22:37:55 -050067LSM_HOOK(int, 0, sb_mnt_opts_compat, struct super_block *sb, void *mnt_opts)
KP Singh98e828a2020-03-29 01:43:50 +010068LSM_HOOK(int, 0, sb_remount, struct super_block *sb, void *mnt_opts)
69LSM_HOOK(int, 0, sb_kern_mount, struct super_block *sb)
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)
KP Singh98e828a2020-03-29 01:43:50 +010082LSM_HOOK(int, 0, move_mount, const struct path *from_path,
83 const struct path *to_path)
Vivek Goyal7f5056b2022-01-26 15:35:14 -050084LSM_HOOK(int, -EOPNOTSUPP, dentry_init_security, struct dentry *dentry,
Vivek Goyal15bf3232021-10-12 09:23:07 -040085 int mode, const struct qstr *name, const char **xattr_name,
86 void **ctx, u32 *ctxlen)
KP Singh98e828a2020-03-29 01:43:50 +010087LSM_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)
97LSM_HOOK(int, 0, path_truncate, const struct path *path)
98LSM_HOOK(int, 0, path_symlink, const struct path *dir, struct dentry *dentry,
99 const char *old_name)
100LSM_HOOK(int, 0, path_link, struct dentry *old_dentry,
101 const struct path *new_dir, struct dentry *new_dentry)
102LSM_HOOK(int, 0, path_rename, const struct path *old_dir,
103 struct dentry *old_dentry, const struct path *new_dir,
Mickaël Salaün100f59d2022-05-06 18:10:56 +0200104 struct dentry *new_dentry, unsigned int flags)
KP Singh98e828a2020-03-29 01:43:50 +0100105LSM_HOOK(int, 0, path_chmod, const struct path *path, umode_t mode)
106LSM_HOOK(int, 0, path_chown, const struct path *path, kuid_t uid, kgid_t gid)
107LSM_HOOK(int, 0, path_chroot, const struct path *path)
108#endif /* CONFIG_SECURITY_PATH */
109
110/* Needed for inode based security check */
111LSM_HOOK(int, 0, path_notify, const struct path *path, u64 mask,
112 unsigned int obj_type)
113LSM_HOOK(int, 0, inode_alloc_security, struct inode *inode)
114LSM_HOOK(void, LSM_RET_VOID, inode_free_security, struct inode *inode)
115LSM_HOOK(int, 0, inode_init_security, struct inode *inode,
116 struct inode *dir, const struct qstr *qstr, const char **name,
117 void **value, size_t *len)
Lokesh Gidra215b674b2021-01-08 14:22:20 -0800118LSM_HOOK(int, 0, inode_init_security_anon, struct inode *inode,
119 const struct qstr *name, const struct inode *context_inode)
KP Singh98e828a2020-03-29 01:43:50 +0100120LSM_HOOK(int, 0, inode_create, struct inode *dir, struct dentry *dentry,
121 umode_t mode)
122LSM_HOOK(int, 0, inode_link, struct dentry *old_dentry, struct inode *dir,
123 struct dentry *new_dentry)
124LSM_HOOK(int, 0, inode_unlink, struct inode *dir, struct dentry *dentry)
125LSM_HOOK(int, 0, inode_symlink, struct inode *dir, struct dentry *dentry,
126 const char *old_name)
127LSM_HOOK(int, 0, inode_mkdir, struct inode *dir, struct dentry *dentry,
128 umode_t mode)
129LSM_HOOK(int, 0, inode_rmdir, struct inode *dir, struct dentry *dentry)
130LSM_HOOK(int, 0, inode_mknod, struct inode *dir, struct dentry *dentry,
131 umode_t mode, dev_t dev)
132LSM_HOOK(int, 0, inode_rename, struct inode *old_dir, struct dentry *old_dentry,
133 struct inode *new_dir, struct dentry *new_dentry)
134LSM_HOOK(int, 0, inode_readlink, struct dentry *dentry)
135LSM_HOOK(int, 0, inode_follow_link, struct dentry *dentry, struct inode *inode,
136 bool rcu)
137LSM_HOOK(int, 0, inode_permission, struct inode *inode, int mask)
138LSM_HOOK(int, 0, inode_setattr, struct dentry *dentry, struct iattr *attr)
139LSM_HOOK(int, 0, inode_getattr, const struct path *path)
Christian Brauner71bc3562021-01-21 14:19:29 +0100140LSM_HOOK(int, 0, inode_setxattr, struct user_namespace *mnt_userns,
141 struct dentry *dentry, const char *name, const void *value,
142 size_t size, int flags)
KP Singh98e828a2020-03-29 01:43:50 +0100143LSM_HOOK(void, LSM_RET_VOID, inode_post_setxattr, struct dentry *dentry,
144 const char *name, const void *value, size_t size, int flags)
145LSM_HOOK(int, 0, inode_getxattr, struct dentry *dentry, const char *name)
146LSM_HOOK(int, 0, inode_listxattr, struct dentry *dentry)
Christian Brauner71bc3562021-01-21 14:19:29 +0100147LSM_HOOK(int, 0, inode_removexattr, struct user_namespace *mnt_userns,
148 struct dentry *dentry, const char *name)
KP Singh98e828a2020-03-29 01:43:50 +0100149LSM_HOOK(int, 0, inode_need_killpriv, struct dentry *dentry)
Christian Brauner71bc3562021-01-21 14:19:29 +0100150LSM_HOOK(int, 0, inode_killpriv, struct user_namespace *mnt_userns,
151 struct dentry *dentry)
152LSM_HOOK(int, -EOPNOTSUPP, inode_getsecurity, struct user_namespace *mnt_userns,
153 struct inode *inode, const char *name, void **buffer, bool alloc)
KP Singh98e828a2020-03-29 01:43:50 +0100154LSM_HOOK(int, -EOPNOTSUPP, inode_setsecurity, struct inode *inode,
155 const char *name, const void *value, size_t size, int flags)
156LSM_HOOK(int, 0, inode_listsecurity, struct inode *inode, char *buffer,
157 size_t buffer_size)
158LSM_HOOK(void, LSM_RET_VOID, inode_getsecid, struct inode *inode, u32 *secid)
159LSM_HOOK(int, 0, inode_copy_up, struct dentry *src, struct cred **new)
KP Singh23e390c2020-06-22 00:21:35 +0200160LSM_HOOK(int, -EOPNOTSUPP, inode_copy_up_xattr, const char *name)
KP Singh98e828a2020-03-29 01:43:50 +0100161LSM_HOOK(int, 0, kernfs_init_security, struct kernfs_node *kn_dir,
162 struct kernfs_node *kn)
163LSM_HOOK(int, 0, file_permission, struct file *file, int mask)
164LSM_HOOK(int, 0, file_alloc_security, struct file *file)
165LSM_HOOK(void, LSM_RET_VOID, file_free_security, struct file *file)
166LSM_HOOK(int, 0, file_ioctl, struct file *file, unsigned int cmd,
167 unsigned long arg)
Alfred Piccionic0144902023-12-19 10:09:09 +0100168LSM_HOOK(int, 0, file_ioctl_compat, struct file *file, unsigned int cmd,
169 unsigned long arg)
KP Singh98e828a2020-03-29 01:43:50 +0100170LSM_HOOK(int, 0, mmap_addr, unsigned long addr)
171LSM_HOOK(int, 0, mmap_file, struct file *file, unsigned long reqprot,
172 unsigned long prot, unsigned long flags)
173LSM_HOOK(int, 0, file_mprotect, struct vm_area_struct *vma,
174 unsigned long reqprot, unsigned long prot)
175LSM_HOOK(int, 0, file_lock, struct file *file, unsigned int cmd)
176LSM_HOOK(int, 0, file_fcntl, struct file *file, unsigned int cmd,
177 unsigned long arg)
178LSM_HOOK(void, LSM_RET_VOID, file_set_fowner, struct file *file)
179LSM_HOOK(int, 0, file_send_sigiotask, struct task_struct *tsk,
180 struct fown_struct *fown, int sig)
181LSM_HOOK(int, 0, file_receive, struct file *file)
182LSM_HOOK(int, 0, file_open, struct file *file)
183LSM_HOOK(int, 0, task_alloc, struct task_struct *task,
184 unsigned long clone_flags)
185LSM_HOOK(void, LSM_RET_VOID, task_free, struct task_struct *task)
186LSM_HOOK(int, 0, cred_alloc_blank, struct cred *cred, gfp_t gfp)
187LSM_HOOK(void, LSM_RET_VOID, cred_free, struct cred *cred)
188LSM_HOOK(int, 0, cred_prepare, struct cred *new, const struct cred *old,
189 gfp_t gfp)
190LSM_HOOK(void, LSM_RET_VOID, cred_transfer, struct cred *new,
191 const struct cred *old)
192LSM_HOOK(void, LSM_RET_VOID, cred_getsecid, const struct cred *c, u32 *secid)
193LSM_HOOK(int, 0, kernel_act_as, struct cred *new, u32 secid)
194LSM_HOOK(int, 0, kernel_create_files_as, struct cred *new, struct inode *inode)
195LSM_HOOK(int, 0, kernel_module_request, char *kmod_name)
Kees Cookb64fcae2020-10-02 10:38:20 -0700196LSM_HOOK(int, 0, kernel_load_data, enum kernel_load_data_id id, bool contents)
197LSM_HOOK(int, 0, kernel_post_load_data, char *buf, loff_t size,
Nathan Chancellor200da272020-10-06 13:11:15 -0700198 enum kernel_load_data_id id, char *description)
KP Singh98e828a2020-03-29 01:43:50 +0100199LSM_HOOK(int, 0, kernel_read_file, struct file *file,
Kees Cook2039bda2020-10-02 10:38:23 -0700200 enum kernel_read_file_id id, bool contents)
KP Singh98e828a2020-03-29 01:43:50 +0100201LSM_HOOK(int, 0, kernel_post_read_file, struct file *file, char *buf,
202 loff_t size, enum kernel_read_file_id id)
203LSM_HOOK(int, 0, task_fix_setuid, struct cred *new, const struct cred *old,
204 int flags)
Thomas Cedeno39030e12020-06-09 10:22:13 -0700205LSM_HOOK(int, 0, task_fix_setgid, struct cred *new, const struct cred * old,
206 int flags)
Micah Mortonfcfe0ac2022-06-08 20:57:11 +0000207LSM_HOOK(int, 0, task_fix_setgroups, struct cred *new, const struct cred * old)
KP Singh98e828a2020-03-29 01:43:50 +0100208LSM_HOOK(int, 0, task_setpgid, struct task_struct *p, pid_t pgid)
209LSM_HOOK(int, 0, task_getpgid, struct task_struct *p)
210LSM_HOOK(int, 0, task_getsid, struct task_struct *p)
Paul Moore63269482021-09-29 11:01:21 -0400211LSM_HOOK(void, LSM_RET_VOID, current_getsecid_subj, u32 *secid)
Paul Moore4ebd7652021-02-19 14:26:21 -0500212LSM_HOOK(void, LSM_RET_VOID, task_getsecid_obj,
213 struct task_struct *p, u32 *secid)
KP Singh98e828a2020-03-29 01:43:50 +0100214LSM_HOOK(int, 0, task_setnice, struct task_struct *p, int nice)
215LSM_HOOK(int, 0, task_setioprio, struct task_struct *p, int ioprio)
216LSM_HOOK(int, 0, task_getioprio, struct task_struct *p)
217LSM_HOOK(int, 0, task_prlimit, const struct cred *cred,
218 const struct cred *tcred, unsigned int flags)
219LSM_HOOK(int, 0, task_setrlimit, struct task_struct *p, unsigned int resource,
220 struct rlimit *new_rlim)
221LSM_HOOK(int, 0, task_setscheduler, struct task_struct *p)
222LSM_HOOK(int, 0, task_getscheduler, struct task_struct *p)
223LSM_HOOK(int, 0, task_movememory, struct task_struct *p)
224LSM_HOOK(int, 0, task_kill, struct task_struct *p, struct kernel_siginfo *info,
225 int sig, const struct cred *cred)
226LSM_HOOK(int, -ENOSYS, task_prctl, int option, unsigned long arg2,
227 unsigned long arg3, unsigned long arg4, unsigned long arg5)
228LSM_HOOK(void, LSM_RET_VOID, task_to_inode, struct task_struct *p,
229 struct inode *inode)
Frederick Lawler7cd4c5c2022-08-15 11:20:25 -0500230LSM_HOOK(int, 0, userns_create, const struct cred *cred)
KP Singh98e828a2020-03-29 01:43:50 +0100231LSM_HOOK(int, 0, ipc_permission, struct kern_ipc_perm *ipcp, short flag)
232LSM_HOOK(void, LSM_RET_VOID, ipc_getsecid, struct kern_ipc_perm *ipcp,
233 u32 *secid)
234LSM_HOOK(int, 0, msg_msg_alloc_security, struct msg_msg *msg)
235LSM_HOOK(void, LSM_RET_VOID, msg_msg_free_security, struct msg_msg *msg)
236LSM_HOOK(int, 0, msg_queue_alloc_security, struct kern_ipc_perm *perm)
237LSM_HOOK(void, LSM_RET_VOID, msg_queue_free_security,
238 struct kern_ipc_perm *perm)
239LSM_HOOK(int, 0, msg_queue_associate, struct kern_ipc_perm *perm, int msqflg)
240LSM_HOOK(int, 0, msg_queue_msgctl, struct kern_ipc_perm *perm, int cmd)
241LSM_HOOK(int, 0, msg_queue_msgsnd, struct kern_ipc_perm *perm,
242 struct msg_msg *msg, int msqflg)
243LSM_HOOK(int, 0, msg_queue_msgrcv, struct kern_ipc_perm *perm,
244 struct msg_msg *msg, struct task_struct *target, long type, int mode)
245LSM_HOOK(int, 0, shm_alloc_security, struct kern_ipc_perm *perm)
246LSM_HOOK(void, LSM_RET_VOID, shm_free_security, struct kern_ipc_perm *perm)
247LSM_HOOK(int, 0, shm_associate, struct kern_ipc_perm *perm, int shmflg)
248LSM_HOOK(int, 0, shm_shmctl, struct kern_ipc_perm *perm, int cmd)
249LSM_HOOK(int, 0, shm_shmat, struct kern_ipc_perm *perm, char __user *shmaddr,
250 int shmflg)
251LSM_HOOK(int, 0, sem_alloc_security, struct kern_ipc_perm *perm)
252LSM_HOOK(void, LSM_RET_VOID, sem_free_security, struct kern_ipc_perm *perm)
253LSM_HOOK(int, 0, sem_associate, struct kern_ipc_perm *perm, int semflg)
254LSM_HOOK(int, 0, sem_semctl, struct kern_ipc_perm *perm, int cmd)
255LSM_HOOK(int, 0, sem_semop, struct kern_ipc_perm *perm, struct sembuf *sops,
256 unsigned nsops, int alter)
257LSM_HOOK(int, 0, netlink_send, struct sock *sk, struct sk_buff *skb)
258LSM_HOOK(void, LSM_RET_VOID, d_instantiate, struct dentry *dentry,
259 struct inode *inode)
Al Viroc8e477c2022-01-30 19:57:52 -0500260LSM_HOOK(int, -EINVAL, getprocattr, struct task_struct *p, const char *name,
KP Singh98e828a2020-03-29 01:43:50 +0100261 char **value)
262LSM_HOOK(int, -EINVAL, setprocattr, const char *name, void *value, size_t size)
263LSM_HOOK(int, 0, ismaclabel, const char *name)
Anders Roxell625236b2020-05-12 19:46:07 +0200264LSM_HOOK(int, -EOPNOTSUPP, secid_to_secctx, u32 secid, char **secdata,
KP Singh98e828a2020-03-29 01:43:50 +0100265 u32 *seclen)
266LSM_HOOK(int, 0, secctx_to_secid, const char *secdata, u32 seclen, u32 *secid)
267LSM_HOOK(void, LSM_RET_VOID, release_secctx, char *secdata, u32 seclen)
268LSM_HOOK(void, LSM_RET_VOID, inode_invalidate_secctx, struct inode *inode)
269LSM_HOOK(int, 0, inode_notifysecctx, struct inode *inode, void *ctx, u32 ctxlen)
270LSM_HOOK(int, 0, inode_setsecctx, struct dentry *dentry, void *ctx, u32 ctxlen)
Ondrej Mosnacekcfcb1e72023-10-31 13:32:07 +0100271LSM_HOOK(int, -EOPNOTSUPP, inode_getsecctx, struct inode *inode, void **ctx,
KP Singh98e828a2020-03-29 01:43:50 +0100272 u32 *ctxlen)
273
David Howells344fa642020-02-12 13:58:35 +0000274#if defined(CONFIG_SECURITY) && defined(CONFIG_WATCH_QUEUE)
275LSM_HOOK(int, 0, post_notification, const struct cred *w_cred,
276 const struct cred *cred, struct watch_notification *n)
David Howells998f5042020-02-12 13:58:35 +0000277#endif /* CONFIG_SECURITY && CONFIG_WATCH_QUEUE */
278
279#if defined(CONFIG_SECURITY) && defined(CONFIG_KEY_NOTIFICATIONS)
280LSM_HOOK(int, 0, watch_key, struct key *key)
David Howells344fa642020-02-12 13:58:35 +0000281#endif /* CONFIG_SECURITY && CONFIG_KEY_NOTIFICATIONS */
282
KP Singh98e828a2020-03-29 01:43:50 +0100283#ifdef CONFIG_SECURITY_NETWORK
284LSM_HOOK(int, 0, unix_stream_connect, struct sock *sock, struct sock *other,
285 struct sock *newsk)
286LSM_HOOK(int, 0, unix_may_send, struct socket *sock, struct socket *other)
287LSM_HOOK(int, 0, socket_create, int family, int type, int protocol, int kern)
288LSM_HOOK(int, 0, socket_post_create, struct socket *sock, int family, int type,
289 int protocol, int kern)
290LSM_HOOK(int, 0, socket_socketpair, struct socket *socka, struct socket *sockb)
291LSM_HOOK(int, 0, socket_bind, struct socket *sock, struct sockaddr *address,
292 int addrlen)
293LSM_HOOK(int, 0, socket_connect, struct socket *sock, struct sockaddr *address,
294 int addrlen)
295LSM_HOOK(int, 0, socket_listen, struct socket *sock, int backlog)
296LSM_HOOK(int, 0, socket_accept, struct socket *sock, struct socket *newsock)
297LSM_HOOK(int, 0, socket_sendmsg, struct socket *sock, struct msghdr *msg,
298 int size)
299LSM_HOOK(int, 0, socket_recvmsg, struct socket *sock, struct msghdr *msg,
300 int size, int flags)
301LSM_HOOK(int, 0, socket_getsockname, struct socket *sock)
302LSM_HOOK(int, 0, socket_getpeername, struct socket *sock)
303LSM_HOOK(int, 0, socket_getsockopt, struct socket *sock, int level, int optname)
304LSM_HOOK(int, 0, socket_setsockopt, struct socket *sock, int level, int optname)
305LSM_HOOK(int, 0, socket_shutdown, struct socket *sock, int how)
306LSM_HOOK(int, 0, socket_sock_rcv_skb, struct sock *sk, struct sk_buff *skb)
307LSM_HOOK(int, 0, socket_getpeersec_stream, struct socket *sock,
308 char __user *optval, int __user *optlen, unsigned len)
309LSM_HOOK(int, 0, socket_getpeersec_dgram, struct socket *sock,
310 struct sk_buff *skb, u32 *secid)
311LSM_HOOK(int, 0, sk_alloc_security, struct sock *sk, int family, gfp_t priority)
312LSM_HOOK(void, LSM_RET_VOID, sk_free_security, struct sock *sk)
313LSM_HOOK(void, LSM_RET_VOID, sk_clone_security, const struct sock *sk,
314 struct sock *newsk)
315LSM_HOOK(void, LSM_RET_VOID, sk_getsecid, struct sock *sk, u32 *secid)
316LSM_HOOK(void, LSM_RET_VOID, sock_graft, struct sock *sk, struct socket *parent)
Florian Westphal41dd9592020-11-30 16:36:29 +0100317LSM_HOOK(int, 0, inet_conn_request, const struct sock *sk, struct sk_buff *skb,
KP Singh98e828a2020-03-29 01:43:50 +0100318 struct request_sock *req)
319LSM_HOOK(void, LSM_RET_VOID, inet_csk_clone, struct sock *newsk,
320 const struct request_sock *req)
321LSM_HOOK(void, LSM_RET_VOID, inet_conn_established, struct sock *sk,
322 struct sk_buff *skb)
323LSM_HOOK(int, 0, secmark_relabel_packet, u32 secid)
324LSM_HOOK(void, LSM_RET_VOID, secmark_refcount_inc, void)
325LSM_HOOK(void, LSM_RET_VOID, secmark_refcount_dec, void)
326LSM_HOOK(void, LSM_RET_VOID, req_classify_flow, const struct request_sock *req,
Paul Moore3df98d72020-09-27 22:38:26 -0400327 struct flowi_common *flic)
KP Singh98e828a2020-03-29 01:43:50 +0100328LSM_HOOK(int, 0, tun_dev_alloc_security, void **security)
329LSM_HOOK(void, LSM_RET_VOID, tun_dev_free_security, void *security)
330LSM_HOOK(int, 0, tun_dev_create, void)
331LSM_HOOK(int, 0, tun_dev_attach_queue, void *security)
332LSM_HOOK(int, 0, tun_dev_attach, struct sock *sk, void *security)
333LSM_HOOK(int, 0, tun_dev_open, void *security)
Xin Longc081d532021-11-02 08:02:47 -0400334LSM_HOOK(int, 0, sctp_assoc_request, struct sctp_association *asoc,
KP Singh98e828a2020-03-29 01:43:50 +0100335 struct sk_buff *skb)
336LSM_HOOK(int, 0, sctp_bind_connect, struct sock *sk, int optname,
337 struct sockaddr *address, int addrlen)
Xin Longc081d532021-11-02 08:02:47 -0400338LSM_HOOK(void, LSM_RET_VOID, sctp_sk_clone, struct sctp_association *asoc,
KP Singh98e828a2020-03-29 01:43:50 +0100339 struct sock *sk, struct sock *newsk)
Ondrej Mosnacek5e50f5d2022-02-12 18:59:21 +0100340LSM_HOOK(int, 0, sctp_assoc_established, struct sctp_association *asoc,
341 struct sk_buff *skb)
KP Singh98e828a2020-03-29 01:43:50 +0100342#endif /* CONFIG_SECURITY_NETWORK */
343
344#ifdef CONFIG_SECURITY_INFINIBAND
345LSM_HOOK(int, 0, ib_pkey_access, void *sec, u64 subnet_prefix, u16 pkey)
346LSM_HOOK(int, 0, ib_endport_manage_subnet, void *sec, const char *dev_name,
347 u8 port_num)
348LSM_HOOK(int, 0, ib_alloc_security, void **sec)
349LSM_HOOK(void, LSM_RET_VOID, ib_free_security, void *sec)
350#endif /* CONFIG_SECURITY_INFINIBAND */
351
352#ifdef CONFIG_SECURITY_NETWORK_XFRM
353LSM_HOOK(int, 0, xfrm_policy_alloc_security, struct xfrm_sec_ctx **ctxp,
354 struct xfrm_user_sec_ctx *sec_ctx, gfp_t gfp)
355LSM_HOOK(int, 0, xfrm_policy_clone_security, struct xfrm_sec_ctx *old_ctx,
356 struct xfrm_sec_ctx **new_ctx)
357LSM_HOOK(void, LSM_RET_VOID, xfrm_policy_free_security,
358 struct xfrm_sec_ctx *ctx)
359LSM_HOOK(int, 0, xfrm_policy_delete_security, struct xfrm_sec_ctx *ctx)
360LSM_HOOK(int, 0, xfrm_state_alloc, struct xfrm_state *x,
361 struct xfrm_user_sec_ctx *sec_ctx)
362LSM_HOOK(int, 0, xfrm_state_alloc_acquire, struct xfrm_state *x,
363 struct xfrm_sec_ctx *polsec, u32 secid)
364LSM_HOOK(void, LSM_RET_VOID, xfrm_state_free_security, struct xfrm_state *x)
365LSM_HOOK(int, 0, xfrm_state_delete_security, struct xfrm_state *x)
Zhongjun Tan8a922802021-04-09 13:48:41 +0800366LSM_HOOK(int, 0, xfrm_policy_lookup, struct xfrm_sec_ctx *ctx, u32 fl_secid)
KP Singh98e828a2020-03-29 01:43:50 +0100367LSM_HOOK(int, 1, xfrm_state_pol_flow_match, struct xfrm_state *x,
Paul Moore3df98d72020-09-27 22:38:26 -0400368 struct xfrm_policy *xp, const struct flowi_common *flic)
KP Singh98e828a2020-03-29 01:43:50 +0100369LSM_HOOK(int, 0, xfrm_decode_session, struct sk_buff *skb, u32 *secid,
370 int ckall)
371#endif /* CONFIG_SECURITY_NETWORK_XFRM */
372
373/* key management security hooks */
374#ifdef CONFIG_KEYS
375LSM_HOOK(int, 0, key_alloc, struct key *key, const struct cred *cred,
376 unsigned long flags)
377LSM_HOOK(void, LSM_RET_VOID, key_free, struct key *key)
378LSM_HOOK(int, 0, key_permission, key_ref_t key_ref, const struct cred *cred,
Sami Tolvanen4bc799d2020-06-15 11:12:32 -0700379 enum key_need_perm need_perm)
KP Singh98e828a2020-03-29 01:43:50 +0100380LSM_HOOK(int, 0, key_getsecurity, struct key *key, char **_buffer)
381#endif /* CONFIG_KEYS */
382
383#ifdef CONFIG_AUDIT
384LSM_HOOK(int, 0, audit_rule_init, u32 field, u32 op, char *rulestr,
385 void **lsmrule)
386LSM_HOOK(int, 0, audit_rule_known, struct audit_krule *krule)
387LSM_HOOK(int, 0, audit_rule_match, u32 secid, u32 field, u32 op, void *lsmrule)
388LSM_HOOK(void, LSM_RET_VOID, audit_rule_free, void *lsmrule)
389#endif /* CONFIG_AUDIT */
390
391#ifdef CONFIG_BPF_SYSCALL
392LSM_HOOK(int, 0, bpf, int cmd, union bpf_attr *attr, unsigned int size)
393LSM_HOOK(int, 0, bpf_map, struct bpf_map *map, fmode_t fmode)
394LSM_HOOK(int, 0, bpf_prog, struct bpf_prog *prog)
395LSM_HOOK(int, 0, bpf_map_alloc_security, struct bpf_map *map)
396LSM_HOOK(void, LSM_RET_VOID, bpf_map_free_security, struct bpf_map *map)
397LSM_HOOK(int, 0, bpf_prog_alloc_security, struct bpf_prog_aux *aux)
398LSM_HOOK(void, LSM_RET_VOID, bpf_prog_free_security, struct bpf_prog_aux *aux)
399#endif /* CONFIG_BPF_SYSCALL */
400
401LSM_HOOK(int, 0, locked_down, enum lockdown_reason what)
402
403#ifdef CONFIG_PERF_EVENTS
404LSM_HOOK(int, 0, perf_event_open, struct perf_event_attr *attr, int type)
405LSM_HOOK(int, 0, perf_event_alloc, struct perf_event *event)
406LSM_HOOK(void, LSM_RET_VOID, perf_event_free, struct perf_event *event)
407LSM_HOOK(int, 0, perf_event_read, struct perf_event *event)
408LSM_HOOK(int, 0, perf_event_write, struct perf_event *event)
409#endif /* CONFIG_PERF_EVENTS */
Paul Moorecdc14042021-02-01 19:56:49 -0500410
411#ifdef CONFIG_IO_URING
412LSM_HOOK(int, 0, uring_override_creds, const struct cred *new)
413LSM_HOOK(int, 0, uring_sqpoll, void)
Luis Chamberlain2a584012022-07-15 12:16:22 -0700414LSM_HOOK(int, 0, uring_cmd, struct io_uring_cmd *ioucmd)
Paul Moorecdc14042021-02-01 19:56:49 -0500415#endif /* CONFIG_IO_URING */