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 /* 18bb22d80bSRandy Dunlap * The macro LSM_HOOK is used to define the data structures required by 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) 52b8bff599SEric W. Biederman LSM_HOOK(int, 0, bprm_creds_for_exec, struct linux_binprm *bprm) 5356305aa9SEric W. Biederman LSM_HOOK(int, 0, bprm_creds_from_file, struct linux_binprm *bprm, struct file *file) 5498e828a0SKP Singh LSM_HOOK(int, 0, bprm_check_security, struct linux_binprm *bprm) 5598e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, bprm_committing_creds, struct linux_binprm *bprm) 5698e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, bprm_committed_creds, struct linux_binprm *bprm) 5798e828a0SKP Singh LSM_HOOK(int, 0, fs_context_dup, struct fs_context *fc, 5898e828a0SKP Singh struct fs_context *src_sc) 5954261af4SKP Singh LSM_HOOK(int, -ENOPARAM, fs_context_parse_param, struct fs_context *fc, 6098e828a0SKP Singh struct fs_parameter *param) 6198e828a0SKP Singh LSM_HOOK(int, 0, sb_alloc_security, struct super_block *sb) 6298e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, sb_free_security, struct super_block *sb) 6398e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, sb_free_mnt_opts, void *mnt_opts) 6498e828a0SKP Singh LSM_HOOK(int, 0, sb_eat_lsm_opts, char *orig, void **mnt_opts) 6598e828a0SKP Singh LSM_HOOK(int, 0, sb_remount, struct super_block *sb, void *mnt_opts) 6698e828a0SKP Singh LSM_HOOK(int, 0, sb_kern_mount, struct super_block *sb) 6798e828a0SKP Singh LSM_HOOK(int, 0, sb_show_options, struct seq_file *m, struct super_block *sb) 6898e828a0SKP Singh LSM_HOOK(int, 0, sb_statfs, struct dentry *dentry) 6998e828a0SKP Singh LSM_HOOK(int, 0, sb_mount, const char *dev_name, const struct path *path, 7098e828a0SKP Singh const char *type, unsigned long flags, void *data) 7198e828a0SKP Singh LSM_HOOK(int, 0, sb_umount, struct vfsmount *mnt, int flags) 7298e828a0SKP Singh LSM_HOOK(int, 0, sb_pivotroot, const struct path *old_path, 7398e828a0SKP Singh const struct path *new_path) 7498e828a0SKP Singh LSM_HOOK(int, 0, sb_set_mnt_opts, struct super_block *sb, void *mnt_opts, 7598e828a0SKP Singh unsigned long kern_flags, unsigned long *set_kern_flags) 7698e828a0SKP Singh LSM_HOOK(int, 0, sb_clone_mnt_opts, const struct super_block *oldsb, 7798e828a0SKP Singh struct super_block *newsb, unsigned long kern_flags, 7898e828a0SKP Singh unsigned long *set_kern_flags) 7998e828a0SKP Singh LSM_HOOK(int, 0, sb_add_mnt_opt, const char *option, const char *val, 8098e828a0SKP Singh int len, void **mnt_opts) 8198e828a0SKP Singh LSM_HOOK(int, 0, move_mount, const struct path *from_path, 8298e828a0SKP Singh const struct path *to_path) 8398e828a0SKP Singh LSM_HOOK(int, 0, dentry_init_security, struct dentry *dentry, 8498e828a0SKP Singh int mode, const struct qstr *name, void **ctx, u32 *ctxlen) 8598e828a0SKP Singh LSM_HOOK(int, 0, dentry_create_files_as, struct dentry *dentry, int mode, 8698e828a0SKP Singh struct qstr *name, const struct cred *old, struct cred *new) 8798e828a0SKP Singh 8898e828a0SKP Singh #ifdef CONFIG_SECURITY_PATH 8998e828a0SKP Singh LSM_HOOK(int, 0, path_unlink, const struct path *dir, struct dentry *dentry) 9098e828a0SKP Singh LSM_HOOK(int, 0, path_mkdir, const struct path *dir, struct dentry *dentry, 9198e828a0SKP Singh umode_t mode) 9298e828a0SKP Singh LSM_HOOK(int, 0, path_rmdir, const struct path *dir, struct dentry *dentry) 9398e828a0SKP Singh LSM_HOOK(int, 0, path_mknod, const struct path *dir, struct dentry *dentry, 9498e828a0SKP Singh umode_t mode, unsigned int dev) 9598e828a0SKP Singh LSM_HOOK(int, 0, path_truncate, const struct path *path) 9698e828a0SKP Singh LSM_HOOK(int, 0, path_symlink, const struct path *dir, struct dentry *dentry, 9798e828a0SKP Singh const char *old_name) 9898e828a0SKP Singh LSM_HOOK(int, 0, path_link, struct dentry *old_dentry, 9998e828a0SKP Singh const struct path *new_dir, struct dentry *new_dentry) 10098e828a0SKP Singh LSM_HOOK(int, 0, path_rename, const struct path *old_dir, 10198e828a0SKP Singh struct dentry *old_dentry, const struct path *new_dir, 10298e828a0SKP Singh struct dentry *new_dentry) 10398e828a0SKP Singh LSM_HOOK(int, 0, path_chmod, const struct path *path, umode_t mode) 10498e828a0SKP Singh LSM_HOOK(int, 0, path_chown, const struct path *path, kuid_t uid, kgid_t gid) 10598e828a0SKP Singh LSM_HOOK(int, 0, path_chroot, const struct path *path) 10698e828a0SKP Singh #endif /* CONFIG_SECURITY_PATH */ 10798e828a0SKP Singh 10898e828a0SKP Singh /* Needed for inode based security check */ 10998e828a0SKP Singh LSM_HOOK(int, 0, path_notify, const struct path *path, u64 mask, 11098e828a0SKP Singh unsigned int obj_type) 11198e828a0SKP Singh LSM_HOOK(int, 0, inode_alloc_security, struct inode *inode) 11298e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, inode_free_security, struct inode *inode) 11398e828a0SKP Singh LSM_HOOK(int, 0, inode_init_security, struct inode *inode, 11498e828a0SKP Singh struct inode *dir, const struct qstr *qstr, const char **name, 11598e828a0SKP Singh void **value, size_t *len) 11698e828a0SKP Singh LSM_HOOK(int, 0, inode_create, struct inode *dir, struct dentry *dentry, 11798e828a0SKP Singh umode_t mode) 11898e828a0SKP Singh LSM_HOOK(int, 0, inode_link, struct dentry *old_dentry, struct inode *dir, 11998e828a0SKP Singh struct dentry *new_dentry) 12098e828a0SKP Singh LSM_HOOK(int, 0, inode_unlink, struct inode *dir, struct dentry *dentry) 12198e828a0SKP Singh LSM_HOOK(int, 0, inode_symlink, struct inode *dir, struct dentry *dentry, 12298e828a0SKP Singh const char *old_name) 12398e828a0SKP Singh LSM_HOOK(int, 0, inode_mkdir, struct inode *dir, struct dentry *dentry, 12498e828a0SKP Singh umode_t mode) 12598e828a0SKP Singh LSM_HOOK(int, 0, inode_rmdir, struct inode *dir, struct dentry *dentry) 12698e828a0SKP Singh LSM_HOOK(int, 0, inode_mknod, struct inode *dir, struct dentry *dentry, 12798e828a0SKP Singh umode_t mode, dev_t dev) 12898e828a0SKP Singh LSM_HOOK(int, 0, inode_rename, struct inode *old_dir, struct dentry *old_dentry, 12998e828a0SKP Singh struct inode *new_dir, struct dentry *new_dentry) 13098e828a0SKP Singh LSM_HOOK(int, 0, inode_readlink, struct dentry *dentry) 13198e828a0SKP Singh LSM_HOOK(int, 0, inode_follow_link, struct dentry *dentry, struct inode *inode, 13298e828a0SKP Singh bool rcu) 13398e828a0SKP Singh LSM_HOOK(int, 0, inode_permission, struct inode *inode, int mask) 13498e828a0SKP Singh LSM_HOOK(int, 0, inode_setattr, struct dentry *dentry, struct iattr *attr) 13598e828a0SKP Singh LSM_HOOK(int, 0, inode_getattr, const struct path *path) 13698e828a0SKP Singh LSM_HOOK(int, 0, inode_setxattr, struct dentry *dentry, const char *name, 13798e828a0SKP Singh const void *value, size_t size, int flags) 13898e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, inode_post_setxattr, struct dentry *dentry, 13998e828a0SKP Singh const char *name, const void *value, size_t size, int flags) 14098e828a0SKP Singh LSM_HOOK(int, 0, inode_getxattr, struct dentry *dentry, const char *name) 14198e828a0SKP Singh LSM_HOOK(int, 0, inode_listxattr, struct dentry *dentry) 14298e828a0SKP Singh LSM_HOOK(int, 0, inode_removexattr, struct dentry *dentry, const char *name) 14398e828a0SKP Singh LSM_HOOK(int, 0, inode_need_killpriv, struct dentry *dentry) 14498e828a0SKP Singh LSM_HOOK(int, 0, inode_killpriv, struct dentry *dentry) 14598e828a0SKP Singh LSM_HOOK(int, -EOPNOTSUPP, inode_getsecurity, struct inode *inode, 14698e828a0SKP Singh const char *name, void **buffer, bool alloc) 14798e828a0SKP Singh LSM_HOOK(int, -EOPNOTSUPP, inode_setsecurity, struct inode *inode, 14898e828a0SKP Singh const char *name, const void *value, size_t size, int flags) 14998e828a0SKP Singh LSM_HOOK(int, 0, inode_listsecurity, struct inode *inode, char *buffer, 15098e828a0SKP Singh size_t buffer_size) 15198e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, inode_getsecid, struct inode *inode, u32 *secid) 15298e828a0SKP Singh LSM_HOOK(int, 0, inode_copy_up, struct dentry *src, struct cred **new) 15323e390cdSKP Singh LSM_HOOK(int, -EOPNOTSUPP, inode_copy_up_xattr, const char *name) 15498e828a0SKP Singh LSM_HOOK(int, 0, kernfs_init_security, struct kernfs_node *kn_dir, 15598e828a0SKP Singh struct kernfs_node *kn) 15698e828a0SKP Singh LSM_HOOK(int, 0, file_permission, struct file *file, int mask) 15798e828a0SKP Singh LSM_HOOK(int, 0, file_alloc_security, struct file *file) 15898e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, file_free_security, struct file *file) 15998e828a0SKP Singh LSM_HOOK(int, 0, file_ioctl, struct file *file, unsigned int cmd, 16098e828a0SKP Singh unsigned long arg) 16198e828a0SKP Singh LSM_HOOK(int, 0, mmap_addr, unsigned long addr) 16298e828a0SKP Singh LSM_HOOK(int, 0, mmap_file, struct file *file, unsigned long reqprot, 16398e828a0SKP Singh unsigned long prot, unsigned long flags) 16498e828a0SKP Singh LSM_HOOK(int, 0, file_mprotect, struct vm_area_struct *vma, 16598e828a0SKP Singh unsigned long reqprot, unsigned long prot) 16698e828a0SKP Singh LSM_HOOK(int, 0, file_lock, struct file *file, unsigned int cmd) 16798e828a0SKP Singh LSM_HOOK(int, 0, file_fcntl, struct file *file, unsigned int cmd, 16898e828a0SKP Singh unsigned long arg) 16998e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, file_set_fowner, struct file *file) 17098e828a0SKP Singh LSM_HOOK(int, 0, file_send_sigiotask, struct task_struct *tsk, 17198e828a0SKP Singh struct fown_struct *fown, int sig) 17298e828a0SKP Singh LSM_HOOK(int, 0, file_receive, struct file *file) 17398e828a0SKP Singh LSM_HOOK(int, 0, file_open, struct file *file) 17498e828a0SKP Singh LSM_HOOK(int, 0, task_alloc, struct task_struct *task, 17598e828a0SKP Singh unsigned long clone_flags) 17698e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, task_free, struct task_struct *task) 17798e828a0SKP Singh LSM_HOOK(int, 0, cred_alloc_blank, struct cred *cred, gfp_t gfp) 17898e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, cred_free, struct cred *cred) 17998e828a0SKP Singh LSM_HOOK(int, 0, cred_prepare, struct cred *new, const struct cred *old, 18098e828a0SKP Singh gfp_t gfp) 18198e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, cred_transfer, struct cred *new, 18298e828a0SKP Singh const struct cred *old) 18398e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, cred_getsecid, const struct cred *c, u32 *secid) 18498e828a0SKP Singh LSM_HOOK(int, 0, kernel_act_as, struct cred *new, u32 secid) 18598e828a0SKP Singh LSM_HOOK(int, 0, kernel_create_files_as, struct cred *new, struct inode *inode) 18698e828a0SKP Singh LSM_HOOK(int, 0, kernel_module_request, char *kmod_name) 187b64fcae7SKees Cook LSM_HOOK(int, 0, kernel_load_data, enum kernel_load_data_id id, bool contents) 188b64fcae7SKees Cook LSM_HOOK(int, 0, kernel_post_load_data, char *buf, loff_t size, 189b64fcae7SKees Cook enum kernel_read_file_id id, char *description) 19098e828a0SKP Singh LSM_HOOK(int, 0, kernel_read_file, struct file *file, 191*2039bda1SKees Cook enum kernel_read_file_id id, bool contents) 19298e828a0SKP Singh LSM_HOOK(int, 0, kernel_post_read_file, struct file *file, char *buf, 19398e828a0SKP Singh loff_t size, enum kernel_read_file_id id) 19498e828a0SKP Singh LSM_HOOK(int, 0, task_fix_setuid, struct cred *new, const struct cred *old, 19598e828a0SKP Singh int flags) 19639030e13SThomas Cedeno LSM_HOOK(int, 0, task_fix_setgid, struct cred *new, const struct cred * old, 19739030e13SThomas Cedeno int flags) 19898e828a0SKP Singh LSM_HOOK(int, 0, task_setpgid, struct task_struct *p, pid_t pgid) 19998e828a0SKP Singh LSM_HOOK(int, 0, task_getpgid, struct task_struct *p) 20098e828a0SKP Singh LSM_HOOK(int, 0, task_getsid, struct task_struct *p) 20198e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, task_getsecid, struct task_struct *p, u32 *secid) 20298e828a0SKP Singh LSM_HOOK(int, 0, task_setnice, struct task_struct *p, int nice) 20398e828a0SKP Singh LSM_HOOK(int, 0, task_setioprio, struct task_struct *p, int ioprio) 20498e828a0SKP Singh LSM_HOOK(int, 0, task_getioprio, struct task_struct *p) 20598e828a0SKP Singh LSM_HOOK(int, 0, task_prlimit, const struct cred *cred, 20698e828a0SKP Singh const struct cred *tcred, unsigned int flags) 20798e828a0SKP Singh LSM_HOOK(int, 0, task_setrlimit, struct task_struct *p, unsigned int resource, 20898e828a0SKP Singh struct rlimit *new_rlim) 20998e828a0SKP Singh LSM_HOOK(int, 0, task_setscheduler, struct task_struct *p) 21098e828a0SKP Singh LSM_HOOK(int, 0, task_getscheduler, struct task_struct *p) 21198e828a0SKP Singh LSM_HOOK(int, 0, task_movememory, struct task_struct *p) 21298e828a0SKP Singh LSM_HOOK(int, 0, task_kill, struct task_struct *p, struct kernel_siginfo *info, 21398e828a0SKP Singh int sig, const struct cred *cred) 21498e828a0SKP Singh LSM_HOOK(int, -ENOSYS, task_prctl, int option, unsigned long arg2, 21598e828a0SKP Singh unsigned long arg3, unsigned long arg4, unsigned long arg5) 21698e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, task_to_inode, struct task_struct *p, 21798e828a0SKP Singh struct inode *inode) 21898e828a0SKP Singh LSM_HOOK(int, 0, ipc_permission, struct kern_ipc_perm *ipcp, short flag) 21998e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, ipc_getsecid, struct kern_ipc_perm *ipcp, 22098e828a0SKP Singh u32 *secid) 22198e828a0SKP Singh LSM_HOOK(int, 0, msg_msg_alloc_security, struct msg_msg *msg) 22298e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, msg_msg_free_security, struct msg_msg *msg) 22398e828a0SKP Singh LSM_HOOK(int, 0, msg_queue_alloc_security, struct kern_ipc_perm *perm) 22498e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, msg_queue_free_security, 22598e828a0SKP Singh struct kern_ipc_perm *perm) 22698e828a0SKP Singh LSM_HOOK(int, 0, msg_queue_associate, struct kern_ipc_perm *perm, int msqflg) 22798e828a0SKP Singh LSM_HOOK(int, 0, msg_queue_msgctl, struct kern_ipc_perm *perm, int cmd) 22898e828a0SKP Singh LSM_HOOK(int, 0, msg_queue_msgsnd, struct kern_ipc_perm *perm, 22998e828a0SKP Singh struct msg_msg *msg, int msqflg) 23098e828a0SKP Singh LSM_HOOK(int, 0, msg_queue_msgrcv, struct kern_ipc_perm *perm, 23198e828a0SKP Singh struct msg_msg *msg, struct task_struct *target, long type, int mode) 23298e828a0SKP Singh LSM_HOOK(int, 0, shm_alloc_security, struct kern_ipc_perm *perm) 23398e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, shm_free_security, struct kern_ipc_perm *perm) 23498e828a0SKP Singh LSM_HOOK(int, 0, shm_associate, struct kern_ipc_perm *perm, int shmflg) 23598e828a0SKP Singh LSM_HOOK(int, 0, shm_shmctl, struct kern_ipc_perm *perm, int cmd) 23698e828a0SKP Singh LSM_HOOK(int, 0, shm_shmat, struct kern_ipc_perm *perm, char __user *shmaddr, 23798e828a0SKP Singh int shmflg) 23898e828a0SKP Singh LSM_HOOK(int, 0, sem_alloc_security, struct kern_ipc_perm *perm) 23998e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, sem_free_security, struct kern_ipc_perm *perm) 24098e828a0SKP Singh LSM_HOOK(int, 0, sem_associate, struct kern_ipc_perm *perm, int semflg) 24198e828a0SKP Singh LSM_HOOK(int, 0, sem_semctl, struct kern_ipc_perm *perm, int cmd) 24298e828a0SKP Singh LSM_HOOK(int, 0, sem_semop, struct kern_ipc_perm *perm, struct sembuf *sops, 24398e828a0SKP Singh unsigned nsops, int alter) 24498e828a0SKP Singh LSM_HOOK(int, 0, netlink_send, struct sock *sk, struct sk_buff *skb) 24598e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, d_instantiate, struct dentry *dentry, 24698e828a0SKP Singh struct inode *inode) 24798e828a0SKP Singh LSM_HOOK(int, -EINVAL, getprocattr, struct task_struct *p, char *name, 24898e828a0SKP Singh char **value) 24998e828a0SKP Singh LSM_HOOK(int, -EINVAL, setprocattr, const char *name, void *value, size_t size) 25098e828a0SKP Singh LSM_HOOK(int, 0, ismaclabel, const char *name) 251625236baSAnders Roxell LSM_HOOK(int, -EOPNOTSUPP, secid_to_secctx, u32 secid, char **secdata, 25298e828a0SKP Singh u32 *seclen) 25398e828a0SKP Singh LSM_HOOK(int, 0, secctx_to_secid, const char *secdata, u32 seclen, u32 *secid) 25498e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, release_secctx, char *secdata, u32 seclen) 25598e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, inode_invalidate_secctx, struct inode *inode) 25698e828a0SKP Singh LSM_HOOK(int, 0, inode_notifysecctx, struct inode *inode, void *ctx, u32 ctxlen) 25798e828a0SKP Singh LSM_HOOK(int, 0, inode_setsecctx, struct dentry *dentry, void *ctx, u32 ctxlen) 25898e828a0SKP Singh LSM_HOOK(int, 0, inode_getsecctx, struct inode *inode, void **ctx, 25998e828a0SKP Singh u32 *ctxlen) 26098e828a0SKP Singh 261344fa64eSDavid Howells #if defined(CONFIG_SECURITY) && defined(CONFIG_WATCH_QUEUE) 262344fa64eSDavid Howells LSM_HOOK(int, 0, post_notification, const struct cred *w_cred, 263344fa64eSDavid Howells const struct cred *cred, struct watch_notification *n) 264998f5040SDavid Howells #endif /* CONFIG_SECURITY && CONFIG_WATCH_QUEUE */ 265998f5040SDavid Howells 266998f5040SDavid Howells #if defined(CONFIG_SECURITY) && defined(CONFIG_KEY_NOTIFICATIONS) 267998f5040SDavid Howells LSM_HOOK(int, 0, watch_key, struct key *key) 268344fa64eSDavid Howells #endif /* CONFIG_SECURITY && CONFIG_KEY_NOTIFICATIONS */ 269344fa64eSDavid Howells 27098e828a0SKP Singh #ifdef CONFIG_SECURITY_NETWORK 27198e828a0SKP Singh LSM_HOOK(int, 0, unix_stream_connect, struct sock *sock, struct sock *other, 27298e828a0SKP Singh struct sock *newsk) 27398e828a0SKP Singh LSM_HOOK(int, 0, unix_may_send, struct socket *sock, struct socket *other) 27498e828a0SKP Singh LSM_HOOK(int, 0, socket_create, int family, int type, int protocol, int kern) 27598e828a0SKP Singh LSM_HOOK(int, 0, socket_post_create, struct socket *sock, int family, int type, 27698e828a0SKP Singh int protocol, int kern) 27798e828a0SKP Singh LSM_HOOK(int, 0, socket_socketpair, struct socket *socka, struct socket *sockb) 27898e828a0SKP Singh LSM_HOOK(int, 0, socket_bind, struct socket *sock, struct sockaddr *address, 27998e828a0SKP Singh int addrlen) 28098e828a0SKP Singh LSM_HOOK(int, 0, socket_connect, struct socket *sock, struct sockaddr *address, 28198e828a0SKP Singh int addrlen) 28298e828a0SKP Singh LSM_HOOK(int, 0, socket_listen, struct socket *sock, int backlog) 28398e828a0SKP Singh LSM_HOOK(int, 0, socket_accept, struct socket *sock, struct socket *newsock) 28498e828a0SKP Singh LSM_HOOK(int, 0, socket_sendmsg, struct socket *sock, struct msghdr *msg, 28598e828a0SKP Singh int size) 28698e828a0SKP Singh LSM_HOOK(int, 0, socket_recvmsg, struct socket *sock, struct msghdr *msg, 28798e828a0SKP Singh int size, int flags) 28898e828a0SKP Singh LSM_HOOK(int, 0, socket_getsockname, struct socket *sock) 28998e828a0SKP Singh LSM_HOOK(int, 0, socket_getpeername, struct socket *sock) 29098e828a0SKP Singh LSM_HOOK(int, 0, socket_getsockopt, struct socket *sock, int level, int optname) 29198e828a0SKP Singh LSM_HOOK(int, 0, socket_setsockopt, struct socket *sock, int level, int optname) 29298e828a0SKP Singh LSM_HOOK(int, 0, socket_shutdown, struct socket *sock, int how) 29398e828a0SKP Singh LSM_HOOK(int, 0, socket_sock_rcv_skb, struct sock *sk, struct sk_buff *skb) 29498e828a0SKP Singh LSM_HOOK(int, 0, socket_getpeersec_stream, struct socket *sock, 29598e828a0SKP Singh char __user *optval, int __user *optlen, unsigned len) 29698e828a0SKP Singh LSM_HOOK(int, 0, socket_getpeersec_dgram, struct socket *sock, 29798e828a0SKP Singh struct sk_buff *skb, u32 *secid) 29898e828a0SKP Singh LSM_HOOK(int, 0, sk_alloc_security, struct sock *sk, int family, gfp_t priority) 29998e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, sk_free_security, struct sock *sk) 30098e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, sk_clone_security, const struct sock *sk, 30198e828a0SKP Singh struct sock *newsk) 30298e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, sk_getsecid, struct sock *sk, u32 *secid) 30398e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, sock_graft, struct sock *sk, struct socket *parent) 30498e828a0SKP Singh LSM_HOOK(int, 0, inet_conn_request, struct sock *sk, struct sk_buff *skb, 30598e828a0SKP Singh struct request_sock *req) 30698e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, inet_csk_clone, struct sock *newsk, 30798e828a0SKP Singh const struct request_sock *req) 30898e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, inet_conn_established, struct sock *sk, 30998e828a0SKP Singh struct sk_buff *skb) 31098e828a0SKP Singh LSM_HOOK(int, 0, secmark_relabel_packet, u32 secid) 31198e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, secmark_refcount_inc, void) 31298e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, secmark_refcount_dec, void) 31398e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, req_classify_flow, const struct request_sock *req, 31498e828a0SKP Singh struct flowi *fl) 31598e828a0SKP Singh LSM_HOOK(int, 0, tun_dev_alloc_security, void **security) 31698e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, tun_dev_free_security, void *security) 31798e828a0SKP Singh LSM_HOOK(int, 0, tun_dev_create, void) 31898e828a0SKP Singh LSM_HOOK(int, 0, tun_dev_attach_queue, void *security) 31998e828a0SKP Singh LSM_HOOK(int, 0, tun_dev_attach, struct sock *sk, void *security) 32098e828a0SKP Singh LSM_HOOK(int, 0, tun_dev_open, void *security) 32198e828a0SKP Singh LSM_HOOK(int, 0, sctp_assoc_request, struct sctp_endpoint *ep, 32298e828a0SKP Singh struct sk_buff *skb) 32398e828a0SKP Singh LSM_HOOK(int, 0, sctp_bind_connect, struct sock *sk, int optname, 32498e828a0SKP Singh struct sockaddr *address, int addrlen) 32598e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, sctp_sk_clone, struct sctp_endpoint *ep, 32698e828a0SKP Singh struct sock *sk, struct sock *newsk) 32798e828a0SKP Singh #endif /* CONFIG_SECURITY_NETWORK */ 32898e828a0SKP Singh 32998e828a0SKP Singh #ifdef CONFIG_SECURITY_INFINIBAND 33098e828a0SKP Singh LSM_HOOK(int, 0, ib_pkey_access, void *sec, u64 subnet_prefix, u16 pkey) 33198e828a0SKP Singh LSM_HOOK(int, 0, ib_endport_manage_subnet, void *sec, const char *dev_name, 33298e828a0SKP Singh u8 port_num) 33398e828a0SKP Singh LSM_HOOK(int, 0, ib_alloc_security, void **sec) 33498e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, ib_free_security, void *sec) 33598e828a0SKP Singh #endif /* CONFIG_SECURITY_INFINIBAND */ 33698e828a0SKP Singh 33798e828a0SKP Singh #ifdef CONFIG_SECURITY_NETWORK_XFRM 33898e828a0SKP Singh LSM_HOOK(int, 0, xfrm_policy_alloc_security, struct xfrm_sec_ctx **ctxp, 33998e828a0SKP Singh struct xfrm_user_sec_ctx *sec_ctx, gfp_t gfp) 34098e828a0SKP Singh LSM_HOOK(int, 0, xfrm_policy_clone_security, struct xfrm_sec_ctx *old_ctx, 34198e828a0SKP Singh struct xfrm_sec_ctx **new_ctx) 34298e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, xfrm_policy_free_security, 34398e828a0SKP Singh struct xfrm_sec_ctx *ctx) 34498e828a0SKP Singh LSM_HOOK(int, 0, xfrm_policy_delete_security, struct xfrm_sec_ctx *ctx) 34598e828a0SKP Singh LSM_HOOK(int, 0, xfrm_state_alloc, struct xfrm_state *x, 34698e828a0SKP Singh struct xfrm_user_sec_ctx *sec_ctx) 34798e828a0SKP Singh LSM_HOOK(int, 0, xfrm_state_alloc_acquire, struct xfrm_state *x, 34898e828a0SKP Singh struct xfrm_sec_ctx *polsec, u32 secid) 34998e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, xfrm_state_free_security, struct xfrm_state *x) 35098e828a0SKP Singh LSM_HOOK(int, 0, xfrm_state_delete_security, struct xfrm_state *x) 35198e828a0SKP Singh LSM_HOOK(int, 0, xfrm_policy_lookup, struct xfrm_sec_ctx *ctx, u32 fl_secid, 35298e828a0SKP Singh u8 dir) 35398e828a0SKP Singh LSM_HOOK(int, 1, xfrm_state_pol_flow_match, struct xfrm_state *x, 35498e828a0SKP Singh struct xfrm_policy *xp, const struct flowi *fl) 35598e828a0SKP Singh LSM_HOOK(int, 0, xfrm_decode_session, struct sk_buff *skb, u32 *secid, 35698e828a0SKP Singh int ckall) 35798e828a0SKP Singh #endif /* CONFIG_SECURITY_NETWORK_XFRM */ 35898e828a0SKP Singh 35998e828a0SKP Singh /* key management security hooks */ 36098e828a0SKP Singh #ifdef CONFIG_KEYS 36198e828a0SKP Singh LSM_HOOK(int, 0, key_alloc, struct key *key, const struct cred *cred, 36298e828a0SKP Singh unsigned long flags) 36398e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, key_free, struct key *key) 36498e828a0SKP Singh LSM_HOOK(int, 0, key_permission, key_ref_t key_ref, const struct cred *cred, 3654bc799dcSSami Tolvanen enum key_need_perm need_perm) 36698e828a0SKP Singh LSM_HOOK(int, 0, key_getsecurity, struct key *key, char **_buffer) 36798e828a0SKP Singh #endif /* CONFIG_KEYS */ 36898e828a0SKP Singh 36998e828a0SKP Singh #ifdef CONFIG_AUDIT 37098e828a0SKP Singh LSM_HOOK(int, 0, audit_rule_init, u32 field, u32 op, char *rulestr, 37198e828a0SKP Singh void **lsmrule) 37298e828a0SKP Singh LSM_HOOK(int, 0, audit_rule_known, struct audit_krule *krule) 37398e828a0SKP Singh LSM_HOOK(int, 0, audit_rule_match, u32 secid, u32 field, u32 op, void *lsmrule) 37498e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, audit_rule_free, void *lsmrule) 37598e828a0SKP Singh #endif /* CONFIG_AUDIT */ 37698e828a0SKP Singh 37798e828a0SKP Singh #ifdef CONFIG_BPF_SYSCALL 37898e828a0SKP Singh LSM_HOOK(int, 0, bpf, int cmd, union bpf_attr *attr, unsigned int size) 37998e828a0SKP Singh LSM_HOOK(int, 0, bpf_map, struct bpf_map *map, fmode_t fmode) 38098e828a0SKP Singh LSM_HOOK(int, 0, bpf_prog, struct bpf_prog *prog) 38198e828a0SKP Singh LSM_HOOK(int, 0, bpf_map_alloc_security, struct bpf_map *map) 38298e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, bpf_map_free_security, struct bpf_map *map) 38398e828a0SKP Singh LSM_HOOK(int, 0, bpf_prog_alloc_security, struct bpf_prog_aux *aux) 38498e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, bpf_prog_free_security, struct bpf_prog_aux *aux) 38598e828a0SKP Singh #endif /* CONFIG_BPF_SYSCALL */ 38698e828a0SKP Singh 38798e828a0SKP Singh LSM_HOOK(int, 0, locked_down, enum lockdown_reason what) 38898e828a0SKP Singh 38998e828a0SKP Singh #ifdef CONFIG_PERF_EVENTS 39098e828a0SKP Singh LSM_HOOK(int, 0, perf_event_open, struct perf_event_attr *attr, int type) 39198e828a0SKP Singh LSM_HOOK(int, 0, perf_event_alloc, struct perf_event *event) 39298e828a0SKP Singh LSM_HOOK(void, LSM_RET_VOID, perf_event_free, struct perf_event *event) 39398e828a0SKP Singh LSM_HOOK(int, 0, perf_event_read, struct perf_event *event) 39498e828a0SKP Singh LSM_HOOK(int, 0, perf_event_write, struct perf_event *event) 39598e828a0SKP Singh #endif /* CONFIG_PERF_EVENTS */ 396