/* * Linux Security plug * * Copyright (C) 2001 WireX Communications, Inc <chris@wirex.com> * Copyright (C) 2001 Greg Kroah-Hartman <greg@kroah.com> * Copyright (C) 2001 Networks Associates Technology, Inc <ssmalley@nai.com> * Copyright (C) 2001 James Morris <jmorris@intercode.com.au> * Copyright (C) 2001 Silicon Graphics, Inc. (Trust Technology Group) * Copyright (C) 2016 Mellanox Techonologies * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Due to this file being licensed under the GPL there is controversy over * whether this permits you to write a module that #includes this file * without placing your module under the GPL. Please consult a lawyer for * advice before doing this. *
*/
/* Default (no) options for the capable function */ #define CAP_OPT_NONE 0x0 /* If capable should audit the security request */ #define CAP_OPT_NOAUDIT BIT(1) /* If capable is being called by a setid function */ #define CAP_OPT_INSETID BIT(2)
/* * These are reasons that can be passed to the security_locked_down() * LSM hook. Lockdown reasons that protect kernel integrity (ie, the * ability for userland to modify kernel code) are placed before * LOCKDOWN_INTEGRITY_MAX. Lockdown reasons that protect kernel * confidentiality (ie, the ability for userland to extract * information from the running kernel that would otherwise be * restricted) are placed before LOCKDOWN_CONFIDENTIALITY_MAX. * * LSM authors should note that the semantics of any given lockdown * reason are not guaranteed to be stable - the same reason may block * one set of features in one kernel release, and a slightly different * set of features in a later kernel release. LSMs that seek to expose * lockdown policy at any level of granularity other than "none", * "integrity" or "confidentiality" are responsible for either * ensuring that they expose a consistent level of functionality to * userland, or ensuring that userland is aware that this is * potentially a moving target. It is easy to misuse this information * in a way that could break userspace. Please be careful not to do * so. * * If you add to this, remember to extend lockdown_reasons in * security/lockdown/lockdown.c.
*/ enum lockdown_reason {
LOCKDOWN_NONE,
LOCKDOWN_MODULE_SIGNATURE,
LOCKDOWN_DEV_MEM,
LOCKDOWN_EFI_TEST,
LOCKDOWN_KEXEC,
LOCKDOWN_HIBERNATION,
LOCKDOWN_PCI_ACCESS,
LOCKDOWN_IOPORT,
LOCKDOWN_MSR,
LOCKDOWN_ACPI_TABLES,
LOCKDOWN_DEVICE_TREE,
LOCKDOWN_PCMCIA_CIS,
LOCKDOWN_TIOCSSERIAL,
LOCKDOWN_MODULE_PARAMETERS,
LOCKDOWN_MMIOTRACE,
LOCKDOWN_DEBUGFS,
LOCKDOWN_XMON_WR,
LOCKDOWN_BPF_WRITE_USER,
LOCKDOWN_DBG_WRITE_KERNEL,
LOCKDOWN_RTAS_ERROR_INJECTION,
LOCKDOWN_INTEGRITY_MAX,
LOCKDOWN_KCORE,
LOCKDOWN_KPROBES,
LOCKDOWN_BPF_READ_KERNEL,
LOCKDOWN_DBG_READ_KERNEL,
LOCKDOWN_PERF,
LOCKDOWN_TRACEFS,
LOCKDOWN_XMON_RW,
LOCKDOWN_XFRM_SECRET,
LOCKDOWN_CONFIDENTIALITY_MAX,
};
/* * Data exported by the security modules
*/ struct lsm_prop { struct lsm_prop_selinux selinux; struct lsm_prop_smack smack; struct lsm_prop_apparmor apparmor; struct lsm_prop_bpf bpf;
};
/* * A "security context" is the text representation of * the information used by LSMs. * This structure contains the string, its length, and which LSM * it is useful for.
*/ struct lsm_context { char *context; /* Provided by the module */
u32 len; int id; /* Identifies the module */
};
/* * Values used in the task_security_ops calls
*/ /* setuid or setgid, id0 == uid or gid */ #define LSM_SETID_ID 1
/** * lsmprop_init - initialize a lsm_prop structure * @prop: Pointer to the data to initialize * * Set all secid for all modules to the specified value.
*/ staticinlinevoid lsmprop_init(struct lsm_prop *prop)
{
memset(prop, 0, sizeof(*prop));
}
#ifdef CONFIG_SECURITY
/** * lsmprop_is_set - report if there is a value in the lsm_prop * @prop: Pointer to the exported LSM data * * Returns true if there is a value set, false otherwise
*/ staticinlinebool lsmprop_is_set(struct lsm_prop *prop)
{ conststruct lsm_prop empty = {};
return !!memcmp(prop, &empty, sizeof(*prop));
}
int call_blocking_lsm_notifier(enum lsm_event event, void *data); int register_blocking_lsm_notifier(struct notifier_block *nb); int unregister_blocking_lsm_notifier(struct notifier_block *nb);
/* Security operations */ int security_binder_set_context_mgr(conststruct cred *mgr); int security_binder_transaction(conststruct cred *from, conststruct cred *to); int security_binder_transfer_binder(conststruct cred *from, conststruct cred *to); int security_binder_transfer_file(conststruct cred *from, conststruct cred *to, conststruct file *file); int security_ptrace_access_check(struct task_struct *child, unsignedint mode); int security_ptrace_traceme(struct task_struct *parent); int security_capget(conststruct task_struct *target,
kernel_cap_t *effective,
kernel_cap_t *inheritable,
kernel_cap_t *permitted); int security_capset(struct cred *new, conststruct cred *old, const kernel_cap_t *effective, const kernel_cap_t *inheritable, const kernel_cap_t *permitted); int security_capable(conststruct cred *cred, struct user_namespace *ns, int cap, unsignedint opts); int security_quotactl(int cmds, int type, int id, conststruct super_block *sb); int security_quota_on(struct dentry *dentry); int security_syslog(int type); int security_settime64(conststruct timespec64 *ts, conststruct timezone *tz); int security_vm_enough_memory_mm(struct mm_struct *mm, long pages); int security_bprm_creds_for_exec(struct linux_binprm *bprm); int security_bprm_creds_from_file(struct linux_binprm *bprm, conststruct file *file); int security_bprm_check(struct linux_binprm *bprm); void security_bprm_committing_creds(conststruct linux_binprm *bprm); void security_bprm_committed_creds(conststruct linux_binprm *bprm); int security_fs_context_submount(struct fs_context *fc, struct super_block *reference); int security_fs_context_dup(struct fs_context *fc, struct fs_context *src_fc); int security_fs_context_parse_param(struct fs_context *fc, struct fs_parameter *param); int security_sb_alloc(struct super_block *sb); void security_sb_delete(struct super_block *sb); void security_sb_free(struct super_block *sb); void security_free_mnt_opts(void **mnt_opts); int security_sb_eat_lsm_opts(char *options, void **mnt_opts); int security_sb_mnt_opts_compat(struct super_block *sb, void *mnt_opts); int security_sb_remount(struct super_block *sb, void *mnt_opts); int security_sb_kern_mount(conststruct super_block *sb); int security_sb_show_options(struct seq_file *m, struct super_block *sb); int security_sb_statfs(struct dentry *dentry); int security_sb_mount(constchar *dev_name, conststruct path *path, constchar *type, unsignedlong flags, void *data); int security_sb_umount(struct vfsmount *mnt, int flags); int security_sb_pivotroot(conststruct path *old_path, conststruct path *new_path); int security_sb_set_mnt_opts(struct super_block *sb, void *mnt_opts, unsignedlong kern_flags, unsignedlong *set_kern_flags); int security_sb_clone_mnt_opts(conststruct super_block *oldsb, struct super_block *newsb, unsignedlong kern_flags, unsignedlong *set_kern_flags); int security_move_mount(conststruct path *from_path, conststruct path *to_path); int security_dentry_init_security(struct dentry *dentry, int mode, conststruct qstr *name, constchar **xattr_name, struct lsm_context *lsmcxt); int security_dentry_create_files_as(struct dentry *dentry, int mode, struct qstr *name, conststruct cred *old, struct cred *new); int security_path_notify(conststruct path *path, u64 mask, unsignedint obj_type); int security_inode_alloc(struct inode *inode, gfp_t gfp); void security_inode_free(struct inode *inode); int security_inode_init_security(struct inode *inode, struct inode *dir, conststruct qstr *qstr,
initxattrs initxattrs, void *fs_data); int security_inode_init_security_anon(struct inode *inode, conststruct qstr *name, conststruct inode *context_inode); int security_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode); void security_inode_post_create_tmpfile(struct mnt_idmap *idmap, struct inode *inode); int security_inode_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry); int security_inode_unlink(struct inode *dir, struct dentry *dentry); int security_inode_symlink(struct inode *dir, struct dentry *dentry, constchar *old_name); int security_inode_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode); int security_inode_rmdir(struct inode *dir, struct dentry *dentry); int security_inode_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev); int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry, unsignedint flags); int security_inode_readlink(struct dentry *dentry); int security_inode_follow_link(struct dentry *dentry, struct inode *inode, bool rcu); int security_inode_permission(struct inode *inode, int mask); int security_inode_setattr(struct mnt_idmap *idmap, struct dentry *dentry, struct iattr *attr); void security_inode_post_setattr(struct mnt_idmap *idmap, struct dentry *dentry, int ia_valid); int security_inode_getattr(conststruct path *path); int security_inode_setxattr(struct mnt_idmap *idmap, struct dentry *dentry, constchar *name, constvoid *value, size_t size, int flags); int security_inode_set_acl(struct mnt_idmap *idmap, struct dentry *dentry, constchar *acl_name, struct posix_acl *kacl); void security_inode_post_set_acl(struct dentry *dentry, constchar *acl_name, struct posix_acl *kacl); int security_inode_get_acl(struct mnt_idmap *idmap, struct dentry *dentry, constchar *acl_name); int security_inode_remove_acl(struct mnt_idmap *idmap, struct dentry *dentry, constchar *acl_name); void security_inode_post_remove_acl(struct mnt_idmap *idmap, struct dentry *dentry, constchar *acl_name); void security_inode_post_setxattr(struct dentry *dentry, constchar *name, constvoid *value, size_t size, int flags); int security_inode_getxattr(struct dentry *dentry, constchar *name); int security_inode_listxattr(struct dentry *dentry); int security_inode_removexattr(struct mnt_idmap *idmap, struct dentry *dentry, constchar *name); void security_inode_post_removexattr(struct dentry *dentry, constchar *name); int security_inode_file_setattr(struct dentry *dentry, struct file_kattr *fa); int security_inode_file_getattr(struct dentry *dentry, struct file_kattr *fa); int security_inode_need_killpriv(struct dentry *dentry); int security_inode_killpriv(struct mnt_idmap *idmap, struct dentry *dentry); int security_inode_getsecurity(struct mnt_idmap *idmap, struct inode *inode, constchar *name, void **buffer, bool alloc); int security_inode_setsecurity(struct inode *inode, constchar *name, constvoid *value, size_t size, int flags); int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size); void security_inode_getlsmprop(struct inode *inode, struct lsm_prop *prop); int security_inode_copy_up(struct dentry *src, struct cred **new); int security_inode_copy_up_xattr(struct dentry *src, constchar *name); int security_inode_setintegrity(conststruct inode *inode, enum lsm_integrity_type type, constvoid *value,
size_t size); int security_kernfs_init_security(struct kernfs_node *kn_dir, struct kernfs_node *kn); int security_file_permission(struct file *file, int mask); int security_file_alloc(struct file *file); void security_file_release(struct file *file); void security_file_free(struct file *file); int security_file_ioctl(struct file *file, unsignedint cmd, unsignedlong arg); int security_file_ioctl_compat(struct file *file, unsignedint cmd, unsignedlong arg); int security_mmap_file(struct file *file, unsignedlong prot, unsignedlong flags); int security_mmap_addr(unsignedlong addr); int security_file_mprotect(struct vm_area_struct *vma, unsignedlong reqprot, unsignedlong prot); int security_file_lock(struct file *file, unsignedint cmd); int security_file_fcntl(struct file *file, unsignedint cmd, unsignedlong arg); void security_file_set_fowner(struct file *file); int security_file_send_sigiotask(struct task_struct *tsk, struct fown_struct *fown, int sig); int security_file_receive(struct file *file); int security_file_open(struct file *file); int security_file_post_open(struct file *file, int mask); int security_file_truncate(struct file *file); int security_task_alloc(struct task_struct *task, unsignedlong clone_flags); void security_task_free(struct task_struct *task); int security_cred_alloc_blank(struct cred *cred, gfp_t gfp); void security_cred_free(struct cred *cred); int security_prepare_creds(struct cred *new, conststruct cred *old, gfp_t gfp); void security_transfer_creds(struct cred *new, conststruct cred *old); void security_cred_getsecid(conststruct cred *c, u32 *secid); void security_cred_getlsmprop(conststruct cred *c, struct lsm_prop *prop); int security_kernel_act_as(struct cred *new, u32 secid); int security_kernel_create_files_as(struct cred *new, struct inode *inode); int security_kernel_module_request(char *kmod_name); int security_kernel_load_data(enum kernel_load_data_id id, bool contents); int security_kernel_post_load_data(char *buf, loff_t size, enum kernel_load_data_id id, char *description); int security_kernel_read_file(struct file *file, enum kernel_read_file_id id, bool contents); int security_kernel_post_read_file(struct file *file, char *buf, loff_t size, enum kernel_read_file_id id); int security_task_fix_setuid(struct cred *new, conststruct cred *old, int flags); int security_task_fix_setgid(struct cred *new, conststruct cred *old, int flags); int security_task_fix_setgroups(struct cred *new, conststruct cred *old); int security_task_setpgid(struct task_struct *p, pid_t pgid); int security_task_getpgid(struct task_struct *p); int security_task_getsid(struct task_struct *p); void security_current_getlsmprop_subj(struct lsm_prop *prop); void security_task_getlsmprop_obj(struct task_struct *p, struct lsm_prop *prop); int security_task_setnice(struct task_struct *p, int nice); int security_task_setioprio(struct task_struct *p, int ioprio); int security_task_getioprio(struct task_struct *p); int security_task_prlimit(conststruct cred *cred, conststruct cred *tcred, unsignedint flags); int security_task_setrlimit(struct task_struct *p, unsignedint resource, struct rlimit *new_rlim); int security_task_setscheduler(struct task_struct *p); int security_task_getscheduler(struct task_struct *p); int security_task_movememory(struct task_struct *p); int security_task_kill(struct task_struct *p, struct kernel_siginfo *info, int sig, conststruct cred *cred); int security_task_prctl(int option, unsignedlong arg2, unsignedlong arg3, unsignedlong arg4, unsignedlong arg5); void security_task_to_inode(struct task_struct *p, struct inode *inode); int security_create_user_ns(conststruct cred *cred); int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag); void security_ipc_getlsmprop(struct kern_ipc_perm *ipcp, struct lsm_prop *prop); int security_msg_msg_alloc(struct msg_msg *msg); void security_msg_msg_free(struct msg_msg *msg); int security_msg_queue_alloc(struct kern_ipc_perm *msq); void security_msg_queue_free(struct kern_ipc_perm *msq); int security_msg_queue_associate(struct kern_ipc_perm *msq, int msqflg); int security_msg_queue_msgctl(struct kern_ipc_perm *msq, int cmd); int security_msg_queue_msgsnd(struct kern_ipc_perm *msq, struct msg_msg *msg, int msqflg); int security_msg_queue_msgrcv(struct kern_ipc_perm *msq, struct msg_msg *msg, struct task_struct *target, long type, int mode); int security_shm_alloc(struct kern_ipc_perm *shp); void security_shm_free(struct kern_ipc_perm *shp); int security_shm_associate(struct kern_ipc_perm *shp, int shmflg); int security_shm_shmctl(struct kern_ipc_perm *shp, int cmd); int security_shm_shmat(struct kern_ipc_perm *shp, char __user *shmaddr, int shmflg); int security_sem_alloc(struct kern_ipc_perm *sma); void security_sem_free(struct kern_ipc_perm *sma); int security_sem_associate(struct kern_ipc_perm *sma, int semflg); int security_sem_semctl(struct kern_ipc_perm *sma, int cmd); int security_sem_semop(struct kern_ipc_perm *sma, struct sembuf *sops, unsigned nsops, int alter); void security_d_instantiate(struct dentry *dentry, struct inode *inode); int security_getselfattr(unsignedint attr, struct lsm_ctx __user *ctx,
u32 __user *size, u32 flags); int security_setselfattr(unsignedint attr, struct lsm_ctx __user *ctx,
u32 size, u32 flags); int security_getprocattr(struct task_struct *p, int lsmid, constchar *name, char **value); int security_setprocattr(int lsmid, constchar *name, void *value, size_t size); int security_ismaclabel(constchar *name); int security_secid_to_secctx(u32 secid, struct lsm_context *cp); int security_lsmprop_to_secctx(struct lsm_prop *prop, struct lsm_context *cp); int security_secctx_to_secid(constchar *secdata, u32 seclen, u32 *secid); void security_release_secctx(struct lsm_context *cp); void security_inode_invalidate_secctx(struct inode *inode); int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen); int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen); int security_inode_getsecctx(struct inode *inode, struct lsm_context *cp); int security_locked_down(enum lockdown_reason what); int lsm_fill_user_ctx(struct lsm_ctx __user *uctx, u32 *uctx_len, void *val, size_t val_len, u64 id, u64 flags); int security_bdev_alloc(struct block_device *bdev); void security_bdev_free(struct block_device *bdev); int security_bdev_setintegrity(struct block_device *bdev, enum lsm_integrity_type type, constvoid *value,
size_t size); #else/* CONFIG_SECURITY */
/** * lsmprop_is_set - report if there is a value in the lsm_prop * @prop: Pointer to the exported LSM data * * Returns true if there is a value set, false otherwise
*/ staticinlinebool lsmprop_is_set(struct lsm_prop *prop)
{ returnfalse;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.