198e828a0SKP Singh /* SPDX-License-Identifier: GPL-2.0 */ 298e828a0SKP Singh 398e828a0SKP Singh /* 498e828a0SKP Singh * Linux Security Module Hook declarations. 598e828a0SKP Singh * 698e828a0SKP Singh * Copyright (C) 2001 WireX Communications, Inc <chris@wirex.com> 798e828a0SKP Singh * Copyright (C) 2001 Greg Kroah-Hartman <greg@kroah.com> 898e828a0SKP Singh * Copyright (C) 2001 Networks Associates Technology, Inc <ssmalley@nai.com> 998e828a0SKP Singh * Copyright (C) 2001 James Morris <jmorris@intercode.com.au> 1098e828a0SKP Singh * Copyright (C) 2001 Silicon Graphics, Inc. (Trust Technology Group) 1198e828a0SKP Singh * Copyright (C) 2015 Intel Corporation. 1298e828a0SKP Singh * Copyright (C) 2015 Casey Schaufler <casey@schaufler-ca.com> 1398e828a0SKP Singh * Copyright (C) 2016 Mellanox Techonologies 1498e828a0SKP Singh * Copyright (C) 2020 Google LLC. 1598e828a0SKP Singh */ 1698e828a0SKP Singh 1798e828a0SKP Singh /* 1898e828a0SKP Singh * The macro LSM_HOOK is used to define the data structures required by the 1998e828a0SKP Singh * the LSM framework using the pattern: 2098e828a0SKP Singh * 2198e828a0SKP Singh * LSM_HOOK(<return_type>, <default_value>, <hook_name>, args...) 2298e828a0SKP Singh * 2398e828a0SKP Singh * struct security_hook_heads { 2498e828a0SKP Singh * #define LSM_HOOK(RET, DEFAULT, NAME, ...) struct hlist_head NAME; 2598e828a0SKP Singh * #include <linux/lsm_hook_defs.h> 2698e828a0SKP Singh * #undef LSM_HOOK 2798e828a0SKP Singh * }; 2898e828a0SKP Singh */ 2998e828a0SKP Singh LSM_HOOK(int, 0, binder_set_context_mgr, struct task_struct *mgr) 3098e828a0SKP Singh LSM_HOOK(int, 0, binder_transaction, struct task_struct *from, 3198e828a0SKP Singh struct task_struct *to) 3298e828a0SKP Singh LSM_HOOK(int, 0, binder_transfer_binder, struct task_struct *from, 3398e828a0SKP Singh struct task_struct *to) 3498e828a0SKP Singh LSM_HOOK(int, 0, binder_transfer_file, struct task_struct *from, 3598e828a0SKP Singh struct task_struct *to, struct file *file) 3698e828a0SKP Singh LSM_HOOK(int, 0, ptrace_access_check, struct task_struct *child, 3798e828a0SKP Singh unsigned int mode) 3898e828a0SKP Singh LSM_HOOK(int, 0, ptrace_traceme, struct task_struct *parent) 3998e828a0SKP Singh LSM_HOOK(int, 0, capget, struct task_struct *target, kernel_cap_t *effective, 4098e828a0SKP Singh kernel_cap_t *inheritable, kernel_cap_t *permitted) 4198e828a0SKP Singh LSM_HOOK(int, 0, capset, struct cred *new, const struct cred *old, 4298e828a0SKP Singh const kernel_cap_t *effective, const kernel_cap_t *inheritable, 4398e828a0SKP Singh const kernel_cap_t *permitted) 4498e828a0SKP Singh LSM_HOOK(int, 0, capable, const struct cred *cred, struct user_namespace *ns, 4598e828a0SKP Singh int cap, unsigned int opts) 4698e828a0SKP Singh LSM_HOOK(int, 0, quotactl, int cmds, int type, int id, struct super_block *sb) 4798e828a0SKP Singh LSM_HOOK(int, 0, quota_on, struct dentry *dentry) 4898e828a0SKP Singh LSM_HOOK(int, 0, syslog, int type) 4998e828a0SKP Singh LSM_HOOK(int, 0, settime, const struct timespec64 *ts, 5098e828a0SKP Singh const struct timezone *tz) 5198e828a0SKP Singh LSM_HOOK(int, 0, vm_enough_memory, struct mm_struct *mm, long pages) 5298e828a0SKP Singh LSM_HOOK(int, 0, bprm_set_creds, struct linux_binprm *bprm) 5398e828a0SKP Singh LSM_HOOK(int, 0, bprm_check_security, struct linux_binprm *bprm) 5498e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, bprm_committing_creds, struct linux_binprm *bprm) 5598e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, bprm_committed_creds, struct linux_binprm *bprm) 5698e828a0SKP Singh LSM_HOOK(int, 0, fs_context_dup, struct fs_context *fc, 5798e828a0SKP Singh struct fs_context *src_sc) 58*54261af4SKP Singh LSM_HOOK(int, -ENOPARAM, fs_context_parse_param, struct fs_context *fc, 5998e828a0SKP Singh struct fs_parameter *param) 6098e828a0SKP Singh LSM_HOOK(int, 0, sb_alloc_security, struct super_block *sb) 6198e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, sb_free_security, struct super_block *sb) 6298e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, sb_free_mnt_opts, void *mnt_opts) 6398e828a0SKP Singh LSM_HOOK(int, 0, sb_eat_lsm_opts, char *orig, void **mnt_opts) 6498e828a0SKP Singh LSM_HOOK(int, 0, sb_remount, struct super_block *sb, void *mnt_opts) 6598e828a0SKP Singh LSM_HOOK(int, 0, sb_kern_mount, struct super_block *sb) 6698e828a0SKP Singh LSM_HOOK(int, 0, sb_show_options, struct seq_file *m, struct super_block *sb) 6798e828a0SKP Singh LSM_HOOK(int, 0, sb_statfs, struct dentry *dentry) 6898e828a0SKP Singh LSM_HOOK(int, 0, sb_mount, const char *dev_name, const struct path *path, 6998e828a0SKP Singh const char *type, unsigned long flags, void *data) 7098e828a0SKP Singh LSM_HOOK(int, 0, sb_umount, struct vfsmount *mnt, int flags) 7198e828a0SKP Singh LSM_HOOK(int, 0, sb_pivotroot, const struct path *old_path, 7298e828a0SKP Singh const struct path *new_path) 7398e828a0SKP Singh LSM_HOOK(int, 0, sb_set_mnt_opts, struct super_block *sb, void *mnt_opts, 7498e828a0SKP Singh unsigned long kern_flags, unsigned long *set_kern_flags) 7598e828a0SKP Singh LSM_HOOK(int, 0, sb_clone_mnt_opts, const struct super_block *oldsb, 7698e828a0SKP Singh struct super_block *newsb, unsigned long kern_flags, 7798e828a0SKP Singh unsigned long *set_kern_flags) 7898e828a0SKP Singh LSM_HOOK(int, 0, sb_add_mnt_opt, const char *option, const char *val, 7998e828a0SKP Singh int len, void **mnt_opts) 8098e828a0SKP Singh LSM_HOOK(int, 0, move_mount, const struct path *from_path, 8198e828a0SKP Singh const struct path *to_path) 8298e828a0SKP Singh LSM_HOOK(int, 0, dentry_init_security, struct dentry *dentry, 8398e828a0SKP Singh int mode, const struct qstr *name, void **ctx, u32 *ctxlen) 8498e828a0SKP Singh LSM_HOOK(int, 0, dentry_create_files_as, struct dentry *dentry, int mode, 8598e828a0SKP Singh struct qstr *name, const struct cred *old, struct cred *new) 8698e828a0SKP Singh 8798e828a0SKP Singh #ifdef CONFIG_SECURITY_PATH 8898e828a0SKP Singh LSM_HOOK(int, 0, path_unlink, const struct path *dir, struct dentry *dentry) 8998e828a0SKP Singh LSM_HOOK(int, 0, path_mkdir, const struct path *dir, struct dentry *dentry, 9098e828a0SKP Singh umode_t mode) 9198e828a0SKP Singh LSM_HOOK(int, 0, path_rmdir, const struct path *dir, struct dentry *dentry) 9298e828a0SKP Singh LSM_HOOK(int, 0, path_mknod, const struct path *dir, struct dentry *dentry, 9398e828a0SKP Singh umode_t mode, unsigned int dev) 9498e828a0SKP Singh LSM_HOOK(int, 0, path_truncate, const struct path *path) 9598e828a0SKP Singh LSM_HOOK(int, 0, path_symlink, const struct path *dir, struct dentry *dentry, 9698e828a0SKP Singh const char *old_name) 9798e828a0SKP Singh LSM_HOOK(int, 0, path_link, struct dentry *old_dentry, 9898e828a0SKP Singh const struct path *new_dir, struct dentry *new_dentry) 9998e828a0SKP Singh LSM_HOOK(int, 0, path_rename, const struct path *old_dir, 10098e828a0SKP Singh struct dentry *old_dentry, const struct path *new_dir, 10198e828a0SKP Singh struct dentry *new_dentry) 10298e828a0SKP Singh LSM_HOOK(int, 0, path_chmod, const struct path *path, umode_t mode) 10398e828a0SKP Singh LSM_HOOK(int, 0, path_chown, const struct path *path, kuid_t uid, kgid_t gid) 10498e828a0SKP Singh LSM_HOOK(int, 0, path_chroot, const struct path *path) 10598e828a0SKP Singh #endif /* CONFIG_SECURITY_PATH */ 10698e828a0SKP Singh 10798e828a0SKP Singh /* Needed for inode based security check */ 10898e828a0SKP Singh LSM_HOOK(int, 0, path_notify, const struct path *path, u64 mask, 10998e828a0SKP Singh unsigned int obj_type) 11098e828a0SKP Singh LSM_HOOK(int, 0, inode_alloc_security, struct inode *inode) 11198e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, inode_free_security, struct inode *inode) 11298e828a0SKP Singh LSM_HOOK(int, 0, inode_init_security, struct inode *inode, 11398e828a0SKP Singh struct inode *dir, const struct qstr *qstr, const char **name, 11498e828a0SKP Singh void **value, size_t *len) 11598e828a0SKP Singh LSM_HOOK(int, 0, inode_create, struct inode *dir, struct dentry *dentry, 11698e828a0SKP Singh umode_t mode) 11798e828a0SKP Singh LSM_HOOK(int, 0, inode_link, struct dentry *old_dentry, struct inode *dir, 11898e828a0SKP Singh struct dentry *new_dentry) 11998e828a0SKP Singh LSM_HOOK(int, 0, inode_unlink, struct inode *dir, struct dentry *dentry) 12098e828a0SKP Singh LSM_HOOK(int, 0, inode_symlink, struct inode *dir, struct dentry *dentry, 12198e828a0SKP Singh const char *old_name) 12298e828a0SKP Singh LSM_HOOK(int, 0, inode_mkdir, struct inode *dir, struct dentry *dentry, 12398e828a0SKP Singh umode_t mode) 12498e828a0SKP Singh LSM_HOOK(int, 0, inode_rmdir, struct inode *dir, struct dentry *dentry) 12598e828a0SKP Singh LSM_HOOK(int, 0, inode_mknod, struct inode *dir, struct dentry *dentry, 12698e828a0SKP Singh umode_t mode, dev_t dev) 12798e828a0SKP Singh LSM_HOOK(int, 0, inode_rename, struct inode *old_dir, struct dentry *old_dentry, 12898e828a0SKP Singh struct inode *new_dir, struct dentry *new_dentry) 12998e828a0SKP Singh LSM_HOOK(int, 0, inode_readlink, struct dentry *dentry) 13098e828a0SKP Singh LSM_HOOK(int, 0, inode_follow_link, struct dentry *dentry, struct inode *inode, 13198e828a0SKP Singh bool rcu) 13298e828a0SKP Singh LSM_HOOK(int, 0, inode_permission, struct inode *inode, int mask) 13398e828a0SKP Singh LSM_HOOK(int, 0, inode_setattr, struct dentry *dentry, struct iattr *attr) 13498e828a0SKP Singh LSM_HOOK(int, 0, inode_getattr, const struct path *path) 13598e828a0SKP Singh LSM_HOOK(int, 0, inode_setxattr, struct dentry *dentry, const char *name, 13698e828a0SKP Singh const void *value, size_t size, int flags) 13798e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, inode_post_setxattr, struct dentry *dentry, 13898e828a0SKP Singh const char *name, const void *value, size_t size, int flags) 13998e828a0SKP Singh LSM_HOOK(int, 0, inode_getxattr, struct dentry *dentry, const char *name) 14098e828a0SKP Singh LSM_HOOK(int, 0, inode_listxattr, struct dentry *dentry) 14198e828a0SKP Singh LSM_HOOK(int, 0, inode_removexattr, struct dentry *dentry, const char *name) 14298e828a0SKP Singh LSM_HOOK(int, 0, inode_need_killpriv, struct dentry *dentry) 14398e828a0SKP Singh LSM_HOOK(int, 0, inode_killpriv, struct dentry *dentry) 14498e828a0SKP Singh LSM_HOOK(int, -EOPNOTSUPP, inode_getsecurity, struct inode *inode, 14598e828a0SKP Singh const char *name, void **buffer, bool alloc) 14698e828a0SKP Singh LSM_HOOK(int, -EOPNOTSUPP, inode_setsecurity, struct inode *inode, 14798e828a0SKP Singh const char *name, const void *value, size_t size, int flags) 14898e828a0SKP Singh LSM_HOOK(int, 0, inode_listsecurity, struct inode *inode, char *buffer, 14998e828a0SKP Singh size_t buffer_size) 15098e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, inode_getsecid, struct inode *inode, u32 *secid) 15198e828a0SKP Singh LSM_HOOK(int, 0, inode_copy_up, struct dentry *src, struct cred **new) 15298e828a0SKP Singh LSM_HOOK(int, 0, inode_copy_up_xattr, const char *name) 15398e828a0SKP Singh LSM_HOOK(int, 0, kernfs_init_security, struct kernfs_node *kn_dir, 15498e828a0SKP Singh struct kernfs_node *kn) 15598e828a0SKP Singh LSM_HOOK(int, 0, file_permission, struct file *file, int mask) 15698e828a0SKP Singh LSM_HOOK(int, 0, file_alloc_security, struct file *file) 15798e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, file_free_security, struct file *file) 15898e828a0SKP Singh LSM_HOOK(int, 0, file_ioctl, struct file *file, unsigned int cmd, 15998e828a0SKP Singh unsigned long arg) 16098e828a0SKP Singh LSM_HOOK(int, 0, mmap_addr, unsigned long addr) 16198e828a0SKP Singh LSM_HOOK(int, 0, mmap_file, struct file *file, unsigned long reqprot, 16298e828a0SKP Singh unsigned long prot, unsigned long flags) 16398e828a0SKP Singh LSM_HOOK(int, 0, file_mprotect, struct vm_area_struct *vma, 16498e828a0SKP Singh unsigned long reqprot, unsigned long prot) 16598e828a0SKP Singh LSM_HOOK(int, 0, file_lock, struct file *file, unsigned int cmd) 16698e828a0SKP Singh LSM_HOOK(int, 0, file_fcntl, struct file *file, unsigned int cmd, 16798e828a0SKP Singh unsigned long arg) 16898e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, file_set_fowner, struct file *file) 16998e828a0SKP Singh LSM_HOOK(int, 0, file_send_sigiotask, struct task_struct *tsk, 17098e828a0SKP Singh struct fown_struct *fown, int sig) 17198e828a0SKP Singh LSM_HOOK(int, 0, file_receive, struct file *file) 17298e828a0SKP Singh LSM_HOOK(int, 0, file_open, struct file *file) 17398e828a0SKP Singh LSM_HOOK(int, 0, task_alloc, struct task_struct *task, 17498e828a0SKP Singh unsigned long clone_flags) 17598e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, task_free, struct task_struct *task) 17698e828a0SKP Singh LSM_HOOK(int, 0, cred_alloc_blank, struct cred *cred, gfp_t gfp) 17798e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, cred_free, struct cred *cred) 17898e828a0SKP Singh LSM_HOOK(int, 0, cred_prepare, struct cred *new, const struct cred *old, 17998e828a0SKP Singh gfp_t gfp) 18098e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, cred_transfer, struct cred *new, 18198e828a0SKP Singh const struct cred *old) 18298e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, cred_getsecid, const struct cred *c, u32 *secid) 18398e828a0SKP Singh LSM_HOOK(int, 0, kernel_act_as, struct cred *new, u32 secid) 18498e828a0SKP Singh LSM_HOOK(int, 0, kernel_create_files_as, struct cred *new, struct inode *inode) 18598e828a0SKP Singh LSM_HOOK(int, 0, kernel_module_request, char *kmod_name) 18698e828a0SKP Singh LSM_HOOK(int, 0, kernel_load_data, enum kernel_load_data_id id) 18798e828a0SKP Singh LSM_HOOK(int, 0, kernel_read_file, struct file *file, 18898e828a0SKP Singh enum kernel_read_file_id id) 18998e828a0SKP Singh LSM_HOOK(int, 0, kernel_post_read_file, struct file *file, char *buf, 19098e828a0SKP Singh loff_t size, enum kernel_read_file_id id) 19198e828a0SKP Singh LSM_HOOK(int, 0, task_fix_setuid, struct cred *new, const struct cred *old, 19298e828a0SKP Singh int flags) 19398e828a0SKP Singh LSM_HOOK(int, 0, task_setpgid, struct task_struct *p, pid_t pgid) 19498e828a0SKP Singh LSM_HOOK(int, 0, task_getpgid, struct task_struct *p) 19598e828a0SKP Singh LSM_HOOK(int, 0, task_getsid, struct task_struct *p) 19698e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, task_getsecid, struct task_struct *p, u32 *secid) 19798e828a0SKP Singh LSM_HOOK(int, 0, task_setnice, struct task_struct *p, int nice) 19898e828a0SKP Singh LSM_HOOK(int, 0, task_setioprio, struct task_struct *p, int ioprio) 19998e828a0SKP Singh LSM_HOOK(int, 0, task_getioprio, struct task_struct *p) 20098e828a0SKP Singh LSM_HOOK(int, 0, task_prlimit, const struct cred *cred, 20198e828a0SKP Singh const struct cred *tcred, unsigned int flags) 20298e828a0SKP Singh LSM_HOOK(int, 0, task_setrlimit, struct task_struct *p, unsigned int resource, 20398e828a0SKP Singh struct rlimit *new_rlim) 20498e828a0SKP Singh LSM_HOOK(int, 0, task_setscheduler, struct task_struct *p) 20598e828a0SKP Singh LSM_HOOK(int, 0, task_getscheduler, struct task_struct *p) 20698e828a0SKP Singh LSM_HOOK(int, 0, task_movememory, struct task_struct *p) 20798e828a0SKP Singh LSM_HOOK(int, 0, task_kill, struct task_struct *p, struct kernel_siginfo *info, 20898e828a0SKP Singh int sig, const struct cred *cred) 20998e828a0SKP Singh LSM_HOOK(int, -ENOSYS, task_prctl, int option, unsigned long arg2, 21098e828a0SKP Singh unsigned long arg3, unsigned long arg4, unsigned long arg5) 21198e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, task_to_inode, struct task_struct *p, 21298e828a0SKP Singh struct inode *inode) 21398e828a0SKP Singh LSM_HOOK(int, 0, ipc_permission, struct kern_ipc_perm *ipcp, short flag) 21498e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, ipc_getsecid, struct kern_ipc_perm *ipcp, 21598e828a0SKP Singh u32 *secid) 21698e828a0SKP Singh LSM_HOOK(int, 0, msg_msg_alloc_security, struct msg_msg *msg) 21798e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, msg_msg_free_security, struct msg_msg *msg) 21898e828a0SKP Singh LSM_HOOK(int, 0, msg_queue_alloc_security, struct kern_ipc_perm *perm) 21998e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, msg_queue_free_security, 22098e828a0SKP Singh struct kern_ipc_perm *perm) 22198e828a0SKP Singh LSM_HOOK(int, 0, msg_queue_associate, struct kern_ipc_perm *perm, int msqflg) 22298e828a0SKP Singh LSM_HOOK(int, 0, msg_queue_msgctl, struct kern_ipc_perm *perm, int cmd) 22398e828a0SKP Singh LSM_HOOK(int, 0, msg_queue_msgsnd, struct kern_ipc_perm *perm, 22498e828a0SKP Singh struct msg_msg *msg, int msqflg) 22598e828a0SKP Singh LSM_HOOK(int, 0, msg_queue_msgrcv, struct kern_ipc_perm *perm, 22698e828a0SKP Singh struct msg_msg *msg, struct task_struct *target, long type, int mode) 22798e828a0SKP Singh LSM_HOOK(int, 0, shm_alloc_security, struct kern_ipc_perm *perm) 22898e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, shm_free_security, struct kern_ipc_perm *perm) 22998e828a0SKP Singh LSM_HOOK(int, 0, shm_associate, struct kern_ipc_perm *perm, int shmflg) 23098e828a0SKP Singh LSM_HOOK(int, 0, shm_shmctl, struct kern_ipc_perm *perm, int cmd) 23198e828a0SKP Singh LSM_HOOK(int, 0, shm_shmat, struct kern_ipc_perm *perm, char __user *shmaddr, 23298e828a0SKP Singh int shmflg) 23398e828a0SKP Singh LSM_HOOK(int, 0, sem_alloc_security, struct kern_ipc_perm *perm) 23498e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, sem_free_security, struct kern_ipc_perm *perm) 23598e828a0SKP Singh LSM_HOOK(int, 0, sem_associate, struct kern_ipc_perm *perm, int semflg) 23698e828a0SKP Singh LSM_HOOK(int, 0, sem_semctl, struct kern_ipc_perm *perm, int cmd) 23798e828a0SKP Singh LSM_HOOK(int, 0, sem_semop, struct kern_ipc_perm *perm, struct sembuf *sops, 23898e828a0SKP Singh unsigned nsops, int alter) 23998e828a0SKP Singh LSM_HOOK(int, 0, netlink_send, struct sock *sk, struct sk_buff *skb) 24098e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, d_instantiate, struct dentry *dentry, 24198e828a0SKP Singh struct inode *inode) 24298e828a0SKP Singh LSM_HOOK(int, -EINVAL, getprocattr, struct task_struct *p, char *name, 24398e828a0SKP Singh char **value) 24498e828a0SKP Singh LSM_HOOK(int, -EINVAL, setprocattr, const char *name, void *value, size_t size) 24598e828a0SKP Singh LSM_HOOK(int, 0, ismaclabel, const char *name) 24698e828a0SKP Singh LSM_HOOK(int, 0, secid_to_secctx, u32 secid, char **secdata, 24798e828a0SKP Singh u32 *seclen) 24898e828a0SKP Singh LSM_HOOK(int, 0, secctx_to_secid, const char *secdata, u32 seclen, u32 *secid) 24998e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, release_secctx, char *secdata, u32 seclen) 25098e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, inode_invalidate_secctx, struct inode *inode) 25198e828a0SKP Singh LSM_HOOK(int, 0, inode_notifysecctx, struct inode *inode, void *ctx, u32 ctxlen) 25298e828a0SKP Singh LSM_HOOK(int, 0, inode_setsecctx, struct dentry *dentry, void *ctx, u32 ctxlen) 25398e828a0SKP Singh LSM_HOOK(int, 0, inode_getsecctx, struct inode *inode, void **ctx, 25498e828a0SKP Singh u32 *ctxlen) 25598e828a0SKP Singh 25698e828a0SKP Singh #ifdef CONFIG_SECURITY_NETWORK 25798e828a0SKP Singh LSM_HOOK(int, 0, unix_stream_connect, struct sock *sock, struct sock *other, 25898e828a0SKP Singh struct sock *newsk) 25998e828a0SKP Singh LSM_HOOK(int, 0, unix_may_send, struct socket *sock, struct socket *other) 26098e828a0SKP Singh LSM_HOOK(int, 0, socket_create, int family, int type, int protocol, int kern) 26198e828a0SKP Singh LSM_HOOK(int, 0, socket_post_create, struct socket *sock, int family, int type, 26298e828a0SKP Singh int protocol, int kern) 26398e828a0SKP Singh LSM_HOOK(int, 0, socket_socketpair, struct socket *socka, struct socket *sockb) 26498e828a0SKP Singh LSM_HOOK(int, 0, socket_bind, struct socket *sock, struct sockaddr *address, 26598e828a0SKP Singh int addrlen) 26698e828a0SKP Singh LSM_HOOK(int, 0, socket_connect, struct socket *sock, struct sockaddr *address, 26798e828a0SKP Singh int addrlen) 26898e828a0SKP Singh LSM_HOOK(int, 0, socket_listen, struct socket *sock, int backlog) 26998e828a0SKP Singh LSM_HOOK(int, 0, socket_accept, struct socket *sock, struct socket *newsock) 27098e828a0SKP Singh LSM_HOOK(int, 0, socket_sendmsg, struct socket *sock, struct msghdr *msg, 27198e828a0SKP Singh int size) 27298e828a0SKP Singh LSM_HOOK(int, 0, socket_recvmsg, struct socket *sock, struct msghdr *msg, 27398e828a0SKP Singh int size, int flags) 27498e828a0SKP Singh LSM_HOOK(int, 0, socket_getsockname, struct socket *sock) 27598e828a0SKP Singh LSM_HOOK(int, 0, socket_getpeername, struct socket *sock) 27698e828a0SKP Singh LSM_HOOK(int, 0, socket_getsockopt, struct socket *sock, int level, int optname) 27798e828a0SKP Singh LSM_HOOK(int, 0, socket_setsockopt, struct socket *sock, int level, int optname) 27898e828a0SKP Singh LSM_HOOK(int, 0, socket_shutdown, struct socket *sock, int how) 27998e828a0SKP Singh LSM_HOOK(int, 0, socket_sock_rcv_skb, struct sock *sk, struct sk_buff *skb) 28098e828a0SKP Singh LSM_HOOK(int, 0, socket_getpeersec_stream, struct socket *sock, 28198e828a0SKP Singh char __user *optval, int __user *optlen, unsigned len) 28298e828a0SKP Singh LSM_HOOK(int, 0, socket_getpeersec_dgram, struct socket *sock, 28398e828a0SKP Singh struct sk_buff *skb, u32 *secid) 28498e828a0SKP Singh LSM_HOOK(int, 0, sk_alloc_security, struct sock *sk, int family, gfp_t priority) 28598e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, sk_free_security, struct sock *sk) 28698e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, sk_clone_security, const struct sock *sk, 28798e828a0SKP Singh struct sock *newsk) 28898e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, sk_getsecid, struct sock *sk, u32 *secid) 28998e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, sock_graft, struct sock *sk, struct socket *parent) 29098e828a0SKP Singh LSM_HOOK(int, 0, inet_conn_request, struct sock *sk, struct sk_buff *skb, 29198e828a0SKP Singh struct request_sock *req) 29298e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, inet_csk_clone, struct sock *newsk, 29398e828a0SKP Singh const struct request_sock *req) 29498e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, inet_conn_established, struct sock *sk, 29598e828a0SKP Singh struct sk_buff *skb) 29698e828a0SKP Singh LSM_HOOK(int, 0, secmark_relabel_packet, u32 secid) 29798e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, secmark_refcount_inc, void) 29898e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, secmark_refcount_dec, void) 29998e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, req_classify_flow, const struct request_sock *req, 30098e828a0SKP Singh struct flowi *fl) 30198e828a0SKP Singh LSM_HOOK(int, 0, tun_dev_alloc_security, void **security) 30298e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, tun_dev_free_security, void *security) 30398e828a0SKP Singh LSM_HOOK(int, 0, tun_dev_create, void) 30498e828a0SKP Singh LSM_HOOK(int, 0, tun_dev_attach_queue, void *security) 30598e828a0SKP Singh LSM_HOOK(int, 0, tun_dev_attach, struct sock *sk, void *security) 30698e828a0SKP Singh LSM_HOOK(int, 0, tun_dev_open, void *security) 30798e828a0SKP Singh LSM_HOOK(int, 0, sctp_assoc_request, struct sctp_endpoint *ep, 30898e828a0SKP Singh struct sk_buff *skb) 30998e828a0SKP Singh LSM_HOOK(int, 0, sctp_bind_connect, struct sock *sk, int optname, 31098e828a0SKP Singh struct sockaddr *address, int addrlen) 31198e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, sctp_sk_clone, struct sctp_endpoint *ep, 31298e828a0SKP Singh struct sock *sk, struct sock *newsk) 31398e828a0SKP Singh #endif /* CONFIG_SECURITY_NETWORK */ 31498e828a0SKP Singh 31598e828a0SKP Singh #ifdef CONFIG_SECURITY_INFINIBAND 31698e828a0SKP Singh LSM_HOOK(int, 0, ib_pkey_access, void *sec, u64 subnet_prefix, u16 pkey) 31798e828a0SKP Singh LSM_HOOK(int, 0, ib_endport_manage_subnet, void *sec, const char *dev_name, 31898e828a0SKP Singh u8 port_num) 31998e828a0SKP Singh LSM_HOOK(int, 0, ib_alloc_security, void **sec) 32098e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, ib_free_security, void *sec) 32198e828a0SKP Singh #endif /* CONFIG_SECURITY_INFINIBAND */ 32298e828a0SKP Singh 32398e828a0SKP Singh #ifdef CONFIG_SECURITY_NETWORK_XFRM 32498e828a0SKP Singh LSM_HOOK(int, 0, xfrm_policy_alloc_security, struct xfrm_sec_ctx **ctxp, 32598e828a0SKP Singh struct xfrm_user_sec_ctx *sec_ctx, gfp_t gfp) 32698e828a0SKP Singh LSM_HOOK(int, 0, xfrm_policy_clone_security, struct xfrm_sec_ctx *old_ctx, 32798e828a0SKP Singh struct xfrm_sec_ctx **new_ctx) 32898e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, xfrm_policy_free_security, 32998e828a0SKP Singh struct xfrm_sec_ctx *ctx) 33098e828a0SKP Singh LSM_HOOK(int, 0, xfrm_policy_delete_security, struct xfrm_sec_ctx *ctx) 33198e828a0SKP Singh LSM_HOOK(int, 0, xfrm_state_alloc, struct xfrm_state *x, 33298e828a0SKP Singh struct xfrm_user_sec_ctx *sec_ctx) 33398e828a0SKP Singh LSM_HOOK(int, 0, xfrm_state_alloc_acquire, struct xfrm_state *x, 33498e828a0SKP Singh struct xfrm_sec_ctx *polsec, u32 secid) 33598e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, xfrm_state_free_security, struct xfrm_state *x) 33698e828a0SKP Singh LSM_HOOK(int, 0, xfrm_state_delete_security, struct xfrm_state *x) 33798e828a0SKP Singh LSM_HOOK(int, 0, xfrm_policy_lookup, struct xfrm_sec_ctx *ctx, u32 fl_secid, 33898e828a0SKP Singh u8 dir) 33998e828a0SKP Singh LSM_HOOK(int, 1, xfrm_state_pol_flow_match, struct xfrm_state *x, 34098e828a0SKP Singh struct xfrm_policy *xp, const struct flowi *fl) 34198e828a0SKP Singh LSM_HOOK(int, 0, xfrm_decode_session, struct sk_buff *skb, u32 *secid, 34298e828a0SKP Singh int ckall) 34398e828a0SKP Singh #endif /* CONFIG_SECURITY_NETWORK_XFRM */ 34498e828a0SKP Singh 34598e828a0SKP Singh /* key management security hooks */ 34698e828a0SKP Singh #ifdef CONFIG_KEYS 34798e828a0SKP Singh LSM_HOOK(int, 0, key_alloc, struct key *key, const struct cred *cred, 34898e828a0SKP Singh unsigned long flags) 34998e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, key_free, struct key *key) 35098e828a0SKP Singh LSM_HOOK(int, 0, key_permission, key_ref_t key_ref, const struct cred *cred, 35198e828a0SKP Singh unsigned perm) 35298e828a0SKP Singh LSM_HOOK(int, 0, key_getsecurity, struct key *key, char **_buffer) 35398e828a0SKP Singh #endif /* CONFIG_KEYS */ 35498e828a0SKP Singh 35598e828a0SKP Singh #ifdef CONFIG_AUDIT 35698e828a0SKP Singh LSM_HOOK(int, 0, audit_rule_init, u32 field, u32 op, char *rulestr, 35798e828a0SKP Singh void **lsmrule) 35898e828a0SKP Singh LSM_HOOK(int, 0, audit_rule_known, struct audit_krule *krule) 35998e828a0SKP Singh LSM_HOOK(int, 0, audit_rule_match, u32 secid, u32 field, u32 op, void *lsmrule) 36098e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, audit_rule_free, void *lsmrule) 36198e828a0SKP Singh #endif /* CONFIG_AUDIT */ 36298e828a0SKP Singh 36398e828a0SKP Singh #ifdef CONFIG_BPF_SYSCALL 36498e828a0SKP Singh LSM_HOOK(int, 0, bpf, int cmd, union bpf_attr *attr, unsigned int size) 36598e828a0SKP Singh LSM_HOOK(int, 0, bpf_map, struct bpf_map *map, fmode_t fmode) 36698e828a0SKP Singh LSM_HOOK(int, 0, bpf_prog, struct bpf_prog *prog) 36798e828a0SKP Singh LSM_HOOK(int, 0, bpf_map_alloc_security, struct bpf_map *map) 36898e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, bpf_map_free_security, struct bpf_map *map) 36998e828a0SKP Singh LSM_HOOK(int, 0, bpf_prog_alloc_security, struct bpf_prog_aux *aux) 37098e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, bpf_prog_free_security, struct bpf_prog_aux *aux) 37198e828a0SKP Singh #endif /* CONFIG_BPF_SYSCALL */ 37298e828a0SKP Singh 37398e828a0SKP Singh LSM_HOOK(int, 0, locked_down, enum lockdown_reason what) 37498e828a0SKP Singh 37598e828a0SKP Singh #ifdef CONFIG_PERF_EVENTS 37698e828a0SKP Singh LSM_HOOK(int, 0, perf_event_open, struct perf_event_attr *attr, int type) 37798e828a0SKP Singh LSM_HOOK(int, 0, perf_event_alloc, struct perf_event *event) 37898e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, perf_event_free, struct perf_event *event) 37998e828a0SKP Singh LSM_HOOK(int, 0, perf_event_read, struct perf_event *event) 38098e828a0SKP Singh LSM_HOOK(int, 0, perf_event_write, struct perf_event *event) 38198e828a0SKP Singh #endif /* CONFIG_PERF_EVENTS */ 382