at v6.2-rc6 58 kB view raw
1/* 2 * Linux Security plug 3 * 4 * Copyright (C) 2001 WireX Communications, Inc <chris@wirex.com> 5 * Copyright (C) 2001 Greg Kroah-Hartman <greg@kroah.com> 6 * Copyright (C) 2001 Networks Associates Technology, Inc <ssmalley@nai.com> 7 * Copyright (C) 2001 James Morris <jmorris@intercode.com.au> 8 * Copyright (C) 2001 Silicon Graphics, Inc. (Trust Technology Group) 9 * Copyright (C) 2016 Mellanox Techonologies 10 * 11 * This program is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * Due to this file being licensed under the GPL there is controversy over 17 * whether this permits you to write a module that #includes this file 18 * without placing your module under the GPL. Please consult a lawyer for 19 * advice before doing this. 20 * 21 */ 22 23#ifndef __LINUX_SECURITY_H 24#define __LINUX_SECURITY_H 25 26#include <linux/kernel_read_file.h> 27#include <linux/key.h> 28#include <linux/capability.h> 29#include <linux/fs.h> 30#include <linux/slab.h> 31#include <linux/err.h> 32#include <linux/string.h> 33#include <linux/mm.h> 34#include <linux/sockptr.h> 35 36struct linux_binprm; 37struct cred; 38struct rlimit; 39struct kernel_siginfo; 40struct sembuf; 41struct kern_ipc_perm; 42struct audit_context; 43struct super_block; 44struct inode; 45struct dentry; 46struct file; 47struct vfsmount; 48struct path; 49struct qstr; 50struct iattr; 51struct fown_struct; 52struct file_operations; 53struct msg_msg; 54struct xattr; 55struct kernfs_node; 56struct xfrm_sec_ctx; 57struct mm_struct; 58struct fs_context; 59struct fs_parameter; 60enum fs_value_type; 61struct watch; 62struct watch_notification; 63 64/* Default (no) options for the capable function */ 65#define CAP_OPT_NONE 0x0 66/* If capable should audit the security request */ 67#define CAP_OPT_NOAUDIT BIT(1) 68/* If capable is being called by a setid function */ 69#define CAP_OPT_INSETID BIT(2) 70 71/* LSM Agnostic defines for fs_context::lsm_flags */ 72#define SECURITY_LSM_NATIVE_LABELS 1 73 74struct ctl_table; 75struct audit_krule; 76struct user_namespace; 77struct timezone; 78 79enum lsm_event { 80 LSM_POLICY_CHANGE, 81}; 82 83/* 84 * These are reasons that can be passed to the security_locked_down() 85 * LSM hook. Lockdown reasons that protect kernel integrity (ie, the 86 * ability for userland to modify kernel code) are placed before 87 * LOCKDOWN_INTEGRITY_MAX. Lockdown reasons that protect kernel 88 * confidentiality (ie, the ability for userland to extract 89 * information from the running kernel that would otherwise be 90 * restricted) are placed before LOCKDOWN_CONFIDENTIALITY_MAX. 91 * 92 * LSM authors should note that the semantics of any given lockdown 93 * reason are not guaranteed to be stable - the same reason may block 94 * one set of features in one kernel release, and a slightly different 95 * set of features in a later kernel release. LSMs that seek to expose 96 * lockdown policy at any level of granularity other than "none", 97 * "integrity" or "confidentiality" are responsible for either 98 * ensuring that they expose a consistent level of functionality to 99 * userland, or ensuring that userland is aware that this is 100 * potentially a moving target. It is easy to misuse this information 101 * in a way that could break userspace. Please be careful not to do 102 * so. 103 * 104 * If you add to this, remember to extend lockdown_reasons in 105 * security/lockdown/lockdown.c. 106 */ 107enum lockdown_reason { 108 LOCKDOWN_NONE, 109 LOCKDOWN_MODULE_SIGNATURE, 110 LOCKDOWN_DEV_MEM, 111 LOCKDOWN_EFI_TEST, 112 LOCKDOWN_KEXEC, 113 LOCKDOWN_HIBERNATION, 114 LOCKDOWN_PCI_ACCESS, 115 LOCKDOWN_IOPORT, 116 LOCKDOWN_MSR, 117 LOCKDOWN_ACPI_TABLES, 118 LOCKDOWN_DEVICE_TREE, 119 LOCKDOWN_PCMCIA_CIS, 120 LOCKDOWN_TIOCSSERIAL, 121 LOCKDOWN_MODULE_PARAMETERS, 122 LOCKDOWN_MMIOTRACE, 123 LOCKDOWN_DEBUGFS, 124 LOCKDOWN_XMON_WR, 125 LOCKDOWN_BPF_WRITE_USER, 126 LOCKDOWN_DBG_WRITE_KERNEL, 127 LOCKDOWN_RTAS_ERROR_INJECTION, 128 LOCKDOWN_INTEGRITY_MAX, 129 LOCKDOWN_KCORE, 130 LOCKDOWN_KPROBES, 131 LOCKDOWN_BPF_READ_KERNEL, 132 LOCKDOWN_DBG_READ_KERNEL, 133 LOCKDOWN_PERF, 134 LOCKDOWN_TRACEFS, 135 LOCKDOWN_XMON_RW, 136 LOCKDOWN_XFRM_SECRET, 137 LOCKDOWN_CONFIDENTIALITY_MAX, 138}; 139 140extern const char *const lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX+1]; 141 142/* These functions are in security/commoncap.c */ 143extern int cap_capable(const struct cred *cred, struct user_namespace *ns, 144 int cap, unsigned int opts); 145extern int cap_settime(const struct timespec64 *ts, const struct timezone *tz); 146extern int cap_ptrace_access_check(struct task_struct *child, unsigned int mode); 147extern int cap_ptrace_traceme(struct task_struct *parent); 148extern int cap_capget(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted); 149extern int cap_capset(struct cred *new, const struct cred *old, 150 const kernel_cap_t *effective, 151 const kernel_cap_t *inheritable, 152 const kernel_cap_t *permitted); 153extern int cap_bprm_creds_from_file(struct linux_binprm *bprm, struct file *file); 154int cap_inode_setxattr(struct dentry *dentry, const char *name, 155 const void *value, size_t size, int flags); 156int cap_inode_removexattr(struct user_namespace *mnt_userns, 157 struct dentry *dentry, const char *name); 158int cap_inode_need_killpriv(struct dentry *dentry); 159int cap_inode_killpriv(struct user_namespace *mnt_userns, 160 struct dentry *dentry); 161int cap_inode_getsecurity(struct user_namespace *mnt_userns, 162 struct inode *inode, const char *name, void **buffer, 163 bool alloc); 164extern int cap_mmap_addr(unsigned long addr); 165extern int cap_mmap_file(struct file *file, unsigned long reqprot, 166 unsigned long prot, unsigned long flags); 167extern int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags); 168extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3, 169 unsigned long arg4, unsigned long arg5); 170extern int cap_task_setscheduler(struct task_struct *p); 171extern int cap_task_setioprio(struct task_struct *p, int ioprio); 172extern int cap_task_setnice(struct task_struct *p, int nice); 173extern int cap_vm_enough_memory(struct mm_struct *mm, long pages); 174 175struct msghdr; 176struct sk_buff; 177struct sock; 178struct sockaddr; 179struct socket; 180struct flowi_common; 181struct dst_entry; 182struct xfrm_selector; 183struct xfrm_policy; 184struct xfrm_state; 185struct xfrm_user_sec_ctx; 186struct seq_file; 187struct sctp_association; 188 189#ifdef CONFIG_MMU 190extern unsigned long mmap_min_addr; 191extern unsigned long dac_mmap_min_addr; 192#else 193#define mmap_min_addr 0UL 194#define dac_mmap_min_addr 0UL 195#endif 196 197/* 198 * Values used in the task_security_ops calls 199 */ 200/* setuid or setgid, id0 == uid or gid */ 201#define LSM_SETID_ID 1 202 203/* setreuid or setregid, id0 == real, id1 == eff */ 204#define LSM_SETID_RE 2 205 206/* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */ 207#define LSM_SETID_RES 4 208 209/* setfsuid or setfsgid, id0 == fsuid or fsgid */ 210#define LSM_SETID_FS 8 211 212/* Flags for security_task_prlimit(). */ 213#define LSM_PRLIMIT_READ 1 214#define LSM_PRLIMIT_WRITE 2 215 216/* forward declares to avoid warnings */ 217struct sched_param; 218struct request_sock; 219 220/* bprm->unsafe reasons */ 221#define LSM_UNSAFE_SHARE 1 222#define LSM_UNSAFE_PTRACE 2 223#define LSM_UNSAFE_NO_NEW_PRIVS 4 224 225#ifdef CONFIG_MMU 226extern int mmap_min_addr_handler(struct ctl_table *table, int write, 227 void *buffer, size_t *lenp, loff_t *ppos); 228#endif 229 230/* security_inode_init_security callback function to write xattrs */ 231typedef int (*initxattrs) (struct inode *inode, 232 const struct xattr *xattr_array, void *fs_data); 233 234 235/* Keep the kernel_load_data_id enum in sync with kernel_read_file_id */ 236#define __data_id_enumify(ENUM, dummy) LOADING_ ## ENUM, 237#define __data_id_stringify(dummy, str) #str, 238 239enum kernel_load_data_id { 240 __kernel_read_file_id(__data_id_enumify) 241}; 242 243static const char * const kernel_load_data_str[] = { 244 __kernel_read_file_id(__data_id_stringify) 245}; 246 247static inline const char *kernel_load_data_id_str(enum kernel_load_data_id id) 248{ 249 if ((unsigned)id >= LOADING_MAX_ID) 250 return kernel_load_data_str[LOADING_UNKNOWN]; 251 252 return kernel_load_data_str[id]; 253} 254 255#ifdef CONFIG_SECURITY 256 257int call_blocking_lsm_notifier(enum lsm_event event, void *data); 258int register_blocking_lsm_notifier(struct notifier_block *nb); 259int unregister_blocking_lsm_notifier(struct notifier_block *nb); 260 261/* prototypes */ 262extern int security_init(void); 263extern int early_security_init(void); 264 265/* Security operations */ 266int security_binder_set_context_mgr(const struct cred *mgr); 267int security_binder_transaction(const struct cred *from, 268 const struct cred *to); 269int security_binder_transfer_binder(const struct cred *from, 270 const struct cred *to); 271int security_binder_transfer_file(const struct cred *from, 272 const struct cred *to, struct file *file); 273int security_ptrace_access_check(struct task_struct *child, unsigned int mode); 274int security_ptrace_traceme(struct task_struct *parent); 275int security_capget(struct task_struct *target, 276 kernel_cap_t *effective, 277 kernel_cap_t *inheritable, 278 kernel_cap_t *permitted); 279int security_capset(struct cred *new, const struct cred *old, 280 const kernel_cap_t *effective, 281 const kernel_cap_t *inheritable, 282 const kernel_cap_t *permitted); 283int security_capable(const struct cred *cred, 284 struct user_namespace *ns, 285 int cap, 286 unsigned int opts); 287int security_quotactl(int cmds, int type, int id, struct super_block *sb); 288int security_quota_on(struct dentry *dentry); 289int security_syslog(int type); 290int security_settime64(const struct timespec64 *ts, const struct timezone *tz); 291int security_vm_enough_memory_mm(struct mm_struct *mm, long pages); 292int security_bprm_creds_for_exec(struct linux_binprm *bprm); 293int security_bprm_creds_from_file(struct linux_binprm *bprm, struct file *file); 294int security_bprm_check(struct linux_binprm *bprm); 295void security_bprm_committing_creds(struct linux_binprm *bprm); 296void security_bprm_committed_creds(struct linux_binprm *bprm); 297int security_fs_context_dup(struct fs_context *fc, struct fs_context *src_fc); 298int security_fs_context_parse_param(struct fs_context *fc, struct fs_parameter *param); 299int security_sb_alloc(struct super_block *sb); 300void security_sb_delete(struct super_block *sb); 301void security_sb_free(struct super_block *sb); 302void security_free_mnt_opts(void **mnt_opts); 303int security_sb_eat_lsm_opts(char *options, void **mnt_opts); 304int security_sb_mnt_opts_compat(struct super_block *sb, void *mnt_opts); 305int security_sb_remount(struct super_block *sb, void *mnt_opts); 306int security_sb_kern_mount(struct super_block *sb); 307int security_sb_show_options(struct seq_file *m, struct super_block *sb); 308int security_sb_statfs(struct dentry *dentry); 309int security_sb_mount(const char *dev_name, const struct path *path, 310 const char *type, unsigned long flags, void *data); 311int security_sb_umount(struct vfsmount *mnt, int flags); 312int security_sb_pivotroot(const struct path *old_path, const struct path *new_path); 313int security_sb_set_mnt_opts(struct super_block *sb, 314 void *mnt_opts, 315 unsigned long kern_flags, 316 unsigned long *set_kern_flags); 317int security_sb_clone_mnt_opts(const struct super_block *oldsb, 318 struct super_block *newsb, 319 unsigned long kern_flags, 320 unsigned long *set_kern_flags); 321int security_move_mount(const struct path *from_path, const struct path *to_path); 322int security_dentry_init_security(struct dentry *dentry, int mode, 323 const struct qstr *name, 324 const char **xattr_name, void **ctx, 325 u32 *ctxlen); 326int security_dentry_create_files_as(struct dentry *dentry, int mode, 327 struct qstr *name, 328 const struct cred *old, 329 struct cred *new); 330int security_path_notify(const struct path *path, u64 mask, 331 unsigned int obj_type); 332int security_inode_alloc(struct inode *inode); 333void security_inode_free(struct inode *inode); 334int security_inode_init_security(struct inode *inode, struct inode *dir, 335 const struct qstr *qstr, 336 initxattrs initxattrs, void *fs_data); 337int security_inode_init_security_anon(struct inode *inode, 338 const struct qstr *name, 339 const struct inode *context_inode); 340int security_old_inode_init_security(struct inode *inode, struct inode *dir, 341 const struct qstr *qstr, const char **name, 342 void **value, size_t *len); 343int security_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode); 344int security_inode_link(struct dentry *old_dentry, struct inode *dir, 345 struct dentry *new_dentry); 346int security_inode_unlink(struct inode *dir, struct dentry *dentry); 347int security_inode_symlink(struct inode *dir, struct dentry *dentry, 348 const char *old_name); 349int security_inode_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode); 350int security_inode_rmdir(struct inode *dir, struct dentry *dentry); 351int security_inode_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev); 352int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry, 353 struct inode *new_dir, struct dentry *new_dentry, 354 unsigned int flags); 355int security_inode_readlink(struct dentry *dentry); 356int security_inode_follow_link(struct dentry *dentry, struct inode *inode, 357 bool rcu); 358int security_inode_permission(struct inode *inode, int mask); 359int security_inode_setattr(struct user_namespace *mnt_userns, 360 struct dentry *dentry, struct iattr *attr); 361int security_inode_getattr(const struct path *path); 362int security_inode_setxattr(struct user_namespace *mnt_userns, 363 struct dentry *dentry, const char *name, 364 const void *value, size_t size, int flags); 365int security_inode_set_acl(struct user_namespace *mnt_userns, 366 struct dentry *dentry, const char *acl_name, 367 struct posix_acl *kacl); 368int security_inode_get_acl(struct user_namespace *mnt_userns, 369 struct dentry *dentry, const char *acl_name); 370int security_inode_remove_acl(struct user_namespace *mnt_userns, 371 struct dentry *dentry, const char *acl_name); 372void security_inode_post_setxattr(struct dentry *dentry, const char *name, 373 const void *value, size_t size, int flags); 374int security_inode_getxattr(struct dentry *dentry, const char *name); 375int security_inode_listxattr(struct dentry *dentry); 376int security_inode_removexattr(struct user_namespace *mnt_userns, 377 struct dentry *dentry, const char *name); 378int security_inode_need_killpriv(struct dentry *dentry); 379int security_inode_killpriv(struct user_namespace *mnt_userns, 380 struct dentry *dentry); 381int security_inode_getsecurity(struct user_namespace *mnt_userns, 382 struct inode *inode, const char *name, 383 void **buffer, bool alloc); 384int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags); 385int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size); 386void security_inode_getsecid(struct inode *inode, u32 *secid); 387int security_inode_copy_up(struct dentry *src, struct cred **new); 388int security_inode_copy_up_xattr(const char *name); 389int security_kernfs_init_security(struct kernfs_node *kn_dir, 390 struct kernfs_node *kn); 391int security_file_permission(struct file *file, int mask); 392int security_file_alloc(struct file *file); 393void security_file_free(struct file *file); 394int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg); 395int security_mmap_file(struct file *file, unsigned long prot, 396 unsigned long flags); 397int security_mmap_addr(unsigned long addr); 398int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot, 399 unsigned long prot); 400int security_file_lock(struct file *file, unsigned int cmd); 401int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg); 402void security_file_set_fowner(struct file *file); 403int security_file_send_sigiotask(struct task_struct *tsk, 404 struct fown_struct *fown, int sig); 405int security_file_receive(struct file *file); 406int security_file_open(struct file *file); 407int security_file_truncate(struct file *file); 408int security_task_alloc(struct task_struct *task, unsigned long clone_flags); 409void security_task_free(struct task_struct *task); 410int security_cred_alloc_blank(struct cred *cred, gfp_t gfp); 411void security_cred_free(struct cred *cred); 412int security_prepare_creds(struct cred *new, const struct cred *old, gfp_t gfp); 413void security_transfer_creds(struct cred *new, const struct cred *old); 414void security_cred_getsecid(const struct cred *c, u32 *secid); 415int security_kernel_act_as(struct cred *new, u32 secid); 416int security_kernel_create_files_as(struct cred *new, struct inode *inode); 417int security_kernel_module_request(char *kmod_name); 418int security_kernel_load_data(enum kernel_load_data_id id, bool contents); 419int security_kernel_post_load_data(char *buf, loff_t size, 420 enum kernel_load_data_id id, 421 char *description); 422int security_kernel_read_file(struct file *file, enum kernel_read_file_id id, 423 bool contents); 424int security_kernel_post_read_file(struct file *file, char *buf, loff_t size, 425 enum kernel_read_file_id id); 426int security_task_fix_setuid(struct cred *new, const struct cred *old, 427 int flags); 428int security_task_fix_setgid(struct cred *new, const struct cred *old, 429 int flags); 430int security_task_fix_setgroups(struct cred *new, const struct cred *old); 431int security_task_setpgid(struct task_struct *p, pid_t pgid); 432int security_task_getpgid(struct task_struct *p); 433int security_task_getsid(struct task_struct *p); 434void security_current_getsecid_subj(u32 *secid); 435void security_task_getsecid_obj(struct task_struct *p, u32 *secid); 436int security_task_setnice(struct task_struct *p, int nice); 437int security_task_setioprio(struct task_struct *p, int ioprio); 438int security_task_getioprio(struct task_struct *p); 439int security_task_prlimit(const struct cred *cred, const struct cred *tcred, 440 unsigned int flags); 441int security_task_setrlimit(struct task_struct *p, unsigned int resource, 442 struct rlimit *new_rlim); 443int security_task_setscheduler(struct task_struct *p); 444int security_task_getscheduler(struct task_struct *p); 445int security_task_movememory(struct task_struct *p); 446int security_task_kill(struct task_struct *p, struct kernel_siginfo *info, 447 int sig, const struct cred *cred); 448int security_task_prctl(int option, unsigned long arg2, unsigned long arg3, 449 unsigned long arg4, unsigned long arg5); 450void security_task_to_inode(struct task_struct *p, struct inode *inode); 451int security_create_user_ns(const struct cred *cred); 452int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag); 453void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid); 454int security_msg_msg_alloc(struct msg_msg *msg); 455void security_msg_msg_free(struct msg_msg *msg); 456int security_msg_queue_alloc(struct kern_ipc_perm *msq); 457void security_msg_queue_free(struct kern_ipc_perm *msq); 458int security_msg_queue_associate(struct kern_ipc_perm *msq, int msqflg); 459int security_msg_queue_msgctl(struct kern_ipc_perm *msq, int cmd); 460int security_msg_queue_msgsnd(struct kern_ipc_perm *msq, 461 struct msg_msg *msg, int msqflg); 462int security_msg_queue_msgrcv(struct kern_ipc_perm *msq, struct msg_msg *msg, 463 struct task_struct *target, long type, int mode); 464int security_shm_alloc(struct kern_ipc_perm *shp); 465void security_shm_free(struct kern_ipc_perm *shp); 466int security_shm_associate(struct kern_ipc_perm *shp, int shmflg); 467int security_shm_shmctl(struct kern_ipc_perm *shp, int cmd); 468int security_shm_shmat(struct kern_ipc_perm *shp, char __user *shmaddr, int shmflg); 469int security_sem_alloc(struct kern_ipc_perm *sma); 470void security_sem_free(struct kern_ipc_perm *sma); 471int security_sem_associate(struct kern_ipc_perm *sma, int semflg); 472int security_sem_semctl(struct kern_ipc_perm *sma, int cmd); 473int security_sem_semop(struct kern_ipc_perm *sma, struct sembuf *sops, 474 unsigned nsops, int alter); 475void security_d_instantiate(struct dentry *dentry, struct inode *inode); 476int security_getprocattr(struct task_struct *p, const char *lsm, const char *name, 477 char **value); 478int security_setprocattr(const char *lsm, const char *name, void *value, 479 size_t size); 480int security_netlink_send(struct sock *sk, struct sk_buff *skb); 481int security_ismaclabel(const char *name); 482int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen); 483int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid); 484void security_release_secctx(char *secdata, u32 seclen); 485void security_inode_invalidate_secctx(struct inode *inode); 486int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen); 487int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen); 488int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen); 489int security_locked_down(enum lockdown_reason what); 490#else /* CONFIG_SECURITY */ 491 492static inline int call_blocking_lsm_notifier(enum lsm_event event, void *data) 493{ 494 return 0; 495} 496 497static inline int register_blocking_lsm_notifier(struct notifier_block *nb) 498{ 499 return 0; 500} 501 502static inline int unregister_blocking_lsm_notifier(struct notifier_block *nb) 503{ 504 return 0; 505} 506 507static inline void security_free_mnt_opts(void **mnt_opts) 508{ 509} 510 511/* 512 * This is the default capabilities functionality. Most of these functions 513 * are just stubbed out, but a few must call the proper capable code. 514 */ 515 516static inline int security_init(void) 517{ 518 return 0; 519} 520 521static inline int early_security_init(void) 522{ 523 return 0; 524} 525 526static inline int security_binder_set_context_mgr(const struct cred *mgr) 527{ 528 return 0; 529} 530 531static inline int security_binder_transaction(const struct cred *from, 532 const struct cred *to) 533{ 534 return 0; 535} 536 537static inline int security_binder_transfer_binder(const struct cred *from, 538 const struct cred *to) 539{ 540 return 0; 541} 542 543static inline int security_binder_transfer_file(const struct cred *from, 544 const struct cred *to, 545 struct file *file) 546{ 547 return 0; 548} 549 550static inline int security_ptrace_access_check(struct task_struct *child, 551 unsigned int mode) 552{ 553 return cap_ptrace_access_check(child, mode); 554} 555 556static inline int security_ptrace_traceme(struct task_struct *parent) 557{ 558 return cap_ptrace_traceme(parent); 559} 560 561static inline int security_capget(struct task_struct *target, 562 kernel_cap_t *effective, 563 kernel_cap_t *inheritable, 564 kernel_cap_t *permitted) 565{ 566 return cap_capget(target, effective, inheritable, permitted); 567} 568 569static inline int security_capset(struct cred *new, 570 const struct cred *old, 571 const kernel_cap_t *effective, 572 const kernel_cap_t *inheritable, 573 const kernel_cap_t *permitted) 574{ 575 return cap_capset(new, old, effective, inheritable, permitted); 576} 577 578static inline int security_capable(const struct cred *cred, 579 struct user_namespace *ns, 580 int cap, 581 unsigned int opts) 582{ 583 return cap_capable(cred, ns, cap, opts); 584} 585 586static inline int security_quotactl(int cmds, int type, int id, 587 struct super_block *sb) 588{ 589 return 0; 590} 591 592static inline int security_quota_on(struct dentry *dentry) 593{ 594 return 0; 595} 596 597static inline int security_syslog(int type) 598{ 599 return 0; 600} 601 602static inline int security_settime64(const struct timespec64 *ts, 603 const struct timezone *tz) 604{ 605 return cap_settime(ts, tz); 606} 607 608static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages) 609{ 610 return __vm_enough_memory(mm, pages, cap_vm_enough_memory(mm, pages)); 611} 612 613static inline int security_bprm_creds_for_exec(struct linux_binprm *bprm) 614{ 615 return 0; 616} 617 618static inline int security_bprm_creds_from_file(struct linux_binprm *bprm, 619 struct file *file) 620{ 621 return cap_bprm_creds_from_file(bprm, file); 622} 623 624static inline int security_bprm_check(struct linux_binprm *bprm) 625{ 626 return 0; 627} 628 629static inline void security_bprm_committing_creds(struct linux_binprm *bprm) 630{ 631} 632 633static inline void security_bprm_committed_creds(struct linux_binprm *bprm) 634{ 635} 636 637static inline int security_fs_context_dup(struct fs_context *fc, 638 struct fs_context *src_fc) 639{ 640 return 0; 641} 642static inline int security_fs_context_parse_param(struct fs_context *fc, 643 struct fs_parameter *param) 644{ 645 return -ENOPARAM; 646} 647 648static inline int security_sb_alloc(struct super_block *sb) 649{ 650 return 0; 651} 652 653static inline void security_sb_delete(struct super_block *sb) 654{ } 655 656static inline void security_sb_free(struct super_block *sb) 657{ } 658 659static inline int security_sb_eat_lsm_opts(char *options, 660 void **mnt_opts) 661{ 662 return 0; 663} 664 665static inline int security_sb_remount(struct super_block *sb, 666 void *mnt_opts) 667{ 668 return 0; 669} 670 671static inline int security_sb_mnt_opts_compat(struct super_block *sb, 672 void *mnt_opts) 673{ 674 return 0; 675} 676 677 678static inline int security_sb_kern_mount(struct super_block *sb) 679{ 680 return 0; 681} 682 683static inline int security_sb_show_options(struct seq_file *m, 684 struct super_block *sb) 685{ 686 return 0; 687} 688 689static inline int security_sb_statfs(struct dentry *dentry) 690{ 691 return 0; 692} 693 694static inline int security_sb_mount(const char *dev_name, const struct path *path, 695 const char *type, unsigned long flags, 696 void *data) 697{ 698 return 0; 699} 700 701static inline int security_sb_umount(struct vfsmount *mnt, int flags) 702{ 703 return 0; 704} 705 706static inline int security_sb_pivotroot(const struct path *old_path, 707 const struct path *new_path) 708{ 709 return 0; 710} 711 712static inline int security_sb_set_mnt_opts(struct super_block *sb, 713 void *mnt_opts, 714 unsigned long kern_flags, 715 unsigned long *set_kern_flags) 716{ 717 return 0; 718} 719 720static inline int security_sb_clone_mnt_opts(const struct super_block *oldsb, 721 struct super_block *newsb, 722 unsigned long kern_flags, 723 unsigned long *set_kern_flags) 724{ 725 return 0; 726} 727 728static inline int security_move_mount(const struct path *from_path, 729 const struct path *to_path) 730{ 731 return 0; 732} 733 734static inline int security_path_notify(const struct path *path, u64 mask, 735 unsigned int obj_type) 736{ 737 return 0; 738} 739 740static inline int security_inode_alloc(struct inode *inode) 741{ 742 return 0; 743} 744 745static inline void security_inode_free(struct inode *inode) 746{ } 747 748static inline int security_dentry_init_security(struct dentry *dentry, 749 int mode, 750 const struct qstr *name, 751 const char **xattr_name, 752 void **ctx, 753 u32 *ctxlen) 754{ 755 return -EOPNOTSUPP; 756} 757 758static inline int security_dentry_create_files_as(struct dentry *dentry, 759 int mode, struct qstr *name, 760 const struct cred *old, 761 struct cred *new) 762{ 763 return 0; 764} 765 766 767static inline int security_inode_init_security(struct inode *inode, 768 struct inode *dir, 769 const struct qstr *qstr, 770 const initxattrs xattrs, 771 void *fs_data) 772{ 773 return 0; 774} 775 776static inline int security_inode_init_security_anon(struct inode *inode, 777 const struct qstr *name, 778 const struct inode *context_inode) 779{ 780 return 0; 781} 782 783static inline int security_old_inode_init_security(struct inode *inode, 784 struct inode *dir, 785 const struct qstr *qstr, 786 const char **name, 787 void **value, size_t *len) 788{ 789 return -EOPNOTSUPP; 790} 791 792static inline int security_inode_create(struct inode *dir, 793 struct dentry *dentry, 794 umode_t mode) 795{ 796 return 0; 797} 798 799static inline int security_inode_link(struct dentry *old_dentry, 800 struct inode *dir, 801 struct dentry *new_dentry) 802{ 803 return 0; 804} 805 806static inline int security_inode_unlink(struct inode *dir, 807 struct dentry *dentry) 808{ 809 return 0; 810} 811 812static inline int security_inode_symlink(struct inode *dir, 813 struct dentry *dentry, 814 const char *old_name) 815{ 816 return 0; 817} 818 819static inline int security_inode_mkdir(struct inode *dir, 820 struct dentry *dentry, 821 int mode) 822{ 823 return 0; 824} 825 826static inline int security_inode_rmdir(struct inode *dir, 827 struct dentry *dentry) 828{ 829 return 0; 830} 831 832static inline int security_inode_mknod(struct inode *dir, 833 struct dentry *dentry, 834 int mode, dev_t dev) 835{ 836 return 0; 837} 838 839static inline int security_inode_rename(struct inode *old_dir, 840 struct dentry *old_dentry, 841 struct inode *new_dir, 842 struct dentry *new_dentry, 843 unsigned int flags) 844{ 845 return 0; 846} 847 848static inline int security_inode_readlink(struct dentry *dentry) 849{ 850 return 0; 851} 852 853static inline int security_inode_follow_link(struct dentry *dentry, 854 struct inode *inode, 855 bool rcu) 856{ 857 return 0; 858} 859 860static inline int security_inode_permission(struct inode *inode, int mask) 861{ 862 return 0; 863} 864 865static inline int security_inode_setattr(struct user_namespace *mnt_userns, 866 struct dentry *dentry, 867 struct iattr *attr) 868{ 869 return 0; 870} 871 872static inline int security_inode_getattr(const struct path *path) 873{ 874 return 0; 875} 876 877static inline int security_inode_setxattr(struct user_namespace *mnt_userns, 878 struct dentry *dentry, const char *name, const void *value, 879 size_t size, int flags) 880{ 881 return cap_inode_setxattr(dentry, name, value, size, flags); 882} 883 884static inline int security_inode_set_acl(struct user_namespace *mnt_userns, 885 struct dentry *dentry, 886 const char *acl_name, 887 struct posix_acl *kacl) 888{ 889 return 0; 890} 891 892static inline int security_inode_get_acl(struct user_namespace *mnt_userns, 893 struct dentry *dentry, 894 const char *acl_name) 895{ 896 return 0; 897} 898 899static inline int security_inode_remove_acl(struct user_namespace *mnt_userns, 900 struct dentry *dentry, 901 const char *acl_name) 902{ 903 return 0; 904} 905 906static inline void security_inode_post_setxattr(struct dentry *dentry, 907 const char *name, const void *value, size_t size, int flags) 908{ } 909 910static inline int security_inode_getxattr(struct dentry *dentry, 911 const char *name) 912{ 913 return 0; 914} 915 916static inline int security_inode_listxattr(struct dentry *dentry) 917{ 918 return 0; 919} 920 921static inline int security_inode_removexattr(struct user_namespace *mnt_userns, 922 struct dentry *dentry, 923 const char *name) 924{ 925 return cap_inode_removexattr(mnt_userns, dentry, name); 926} 927 928static inline int security_inode_need_killpriv(struct dentry *dentry) 929{ 930 return cap_inode_need_killpriv(dentry); 931} 932 933static inline int security_inode_killpriv(struct user_namespace *mnt_userns, 934 struct dentry *dentry) 935{ 936 return cap_inode_killpriv(mnt_userns, dentry); 937} 938 939static inline int security_inode_getsecurity(struct user_namespace *mnt_userns, 940 struct inode *inode, 941 const char *name, void **buffer, 942 bool alloc) 943{ 944 return cap_inode_getsecurity(mnt_userns, inode, name, buffer, alloc); 945} 946 947static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags) 948{ 949 return -EOPNOTSUPP; 950} 951 952static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size) 953{ 954 return 0; 955} 956 957static inline void security_inode_getsecid(struct inode *inode, u32 *secid) 958{ 959 *secid = 0; 960} 961 962static inline int security_inode_copy_up(struct dentry *src, struct cred **new) 963{ 964 return 0; 965} 966 967static inline int security_kernfs_init_security(struct kernfs_node *kn_dir, 968 struct kernfs_node *kn) 969{ 970 return 0; 971} 972 973static inline int security_inode_copy_up_xattr(const char *name) 974{ 975 return -EOPNOTSUPP; 976} 977 978static inline int security_file_permission(struct file *file, int mask) 979{ 980 return 0; 981} 982 983static inline int security_file_alloc(struct file *file) 984{ 985 return 0; 986} 987 988static inline void security_file_free(struct file *file) 989{ } 990 991static inline int security_file_ioctl(struct file *file, unsigned int cmd, 992 unsigned long arg) 993{ 994 return 0; 995} 996 997static inline int security_mmap_file(struct file *file, unsigned long prot, 998 unsigned long flags) 999{ 1000 return 0; 1001} 1002 1003static inline int security_mmap_addr(unsigned long addr) 1004{ 1005 return cap_mmap_addr(addr); 1006} 1007 1008static inline int security_file_mprotect(struct vm_area_struct *vma, 1009 unsigned long reqprot, 1010 unsigned long prot) 1011{ 1012 return 0; 1013} 1014 1015static inline int security_file_lock(struct file *file, unsigned int cmd) 1016{ 1017 return 0; 1018} 1019 1020static inline int security_file_fcntl(struct file *file, unsigned int cmd, 1021 unsigned long arg) 1022{ 1023 return 0; 1024} 1025 1026static inline void security_file_set_fowner(struct file *file) 1027{ 1028 return; 1029} 1030 1031static inline int security_file_send_sigiotask(struct task_struct *tsk, 1032 struct fown_struct *fown, 1033 int sig) 1034{ 1035 return 0; 1036} 1037 1038static inline int security_file_receive(struct file *file) 1039{ 1040 return 0; 1041} 1042 1043static inline int security_file_open(struct file *file) 1044{ 1045 return 0; 1046} 1047 1048static inline int security_file_truncate(struct file *file) 1049{ 1050 return 0; 1051} 1052 1053static inline int security_task_alloc(struct task_struct *task, 1054 unsigned long clone_flags) 1055{ 1056 return 0; 1057} 1058 1059static inline void security_task_free(struct task_struct *task) 1060{ } 1061 1062static inline int security_cred_alloc_blank(struct cred *cred, gfp_t gfp) 1063{ 1064 return 0; 1065} 1066 1067static inline void security_cred_free(struct cred *cred) 1068{ } 1069 1070static inline int security_prepare_creds(struct cred *new, 1071 const struct cred *old, 1072 gfp_t gfp) 1073{ 1074 return 0; 1075} 1076 1077static inline void security_transfer_creds(struct cred *new, 1078 const struct cred *old) 1079{ 1080} 1081 1082static inline void security_cred_getsecid(const struct cred *c, u32 *secid) 1083{ 1084 *secid = 0; 1085} 1086 1087static inline int security_kernel_act_as(struct cred *cred, u32 secid) 1088{ 1089 return 0; 1090} 1091 1092static inline int security_kernel_create_files_as(struct cred *cred, 1093 struct inode *inode) 1094{ 1095 return 0; 1096} 1097 1098static inline int security_kernel_module_request(char *kmod_name) 1099{ 1100 return 0; 1101} 1102 1103static inline int security_kernel_load_data(enum kernel_load_data_id id, bool contents) 1104{ 1105 return 0; 1106} 1107 1108static inline int security_kernel_post_load_data(char *buf, loff_t size, 1109 enum kernel_load_data_id id, 1110 char *description) 1111{ 1112 return 0; 1113} 1114 1115static inline int security_kernel_read_file(struct file *file, 1116 enum kernel_read_file_id id, 1117 bool contents) 1118{ 1119 return 0; 1120} 1121 1122static inline int security_kernel_post_read_file(struct file *file, 1123 char *buf, loff_t size, 1124 enum kernel_read_file_id id) 1125{ 1126 return 0; 1127} 1128 1129static inline int security_task_fix_setuid(struct cred *new, 1130 const struct cred *old, 1131 int flags) 1132{ 1133 return cap_task_fix_setuid(new, old, flags); 1134} 1135 1136static inline int security_task_fix_setgid(struct cred *new, 1137 const struct cred *old, 1138 int flags) 1139{ 1140 return 0; 1141} 1142 1143static inline int security_task_fix_setgroups(struct cred *new, 1144 const struct cred *old) 1145{ 1146 return 0; 1147} 1148 1149static inline int security_task_setpgid(struct task_struct *p, pid_t pgid) 1150{ 1151 return 0; 1152} 1153 1154static inline int security_task_getpgid(struct task_struct *p) 1155{ 1156 return 0; 1157} 1158 1159static inline int security_task_getsid(struct task_struct *p) 1160{ 1161 return 0; 1162} 1163 1164static inline void security_current_getsecid_subj(u32 *secid) 1165{ 1166 *secid = 0; 1167} 1168 1169static inline void security_task_getsecid_obj(struct task_struct *p, u32 *secid) 1170{ 1171 *secid = 0; 1172} 1173 1174static inline int security_task_setnice(struct task_struct *p, int nice) 1175{ 1176 return cap_task_setnice(p, nice); 1177} 1178 1179static inline int security_task_setioprio(struct task_struct *p, int ioprio) 1180{ 1181 return cap_task_setioprio(p, ioprio); 1182} 1183 1184static inline int security_task_getioprio(struct task_struct *p) 1185{ 1186 return 0; 1187} 1188 1189static inline int security_task_prlimit(const struct cred *cred, 1190 const struct cred *tcred, 1191 unsigned int flags) 1192{ 1193 return 0; 1194} 1195 1196static inline int security_task_setrlimit(struct task_struct *p, 1197 unsigned int resource, 1198 struct rlimit *new_rlim) 1199{ 1200 return 0; 1201} 1202 1203static inline int security_task_setscheduler(struct task_struct *p) 1204{ 1205 return cap_task_setscheduler(p); 1206} 1207 1208static inline int security_task_getscheduler(struct task_struct *p) 1209{ 1210 return 0; 1211} 1212 1213static inline int security_task_movememory(struct task_struct *p) 1214{ 1215 return 0; 1216} 1217 1218static inline int security_task_kill(struct task_struct *p, 1219 struct kernel_siginfo *info, int sig, 1220 const struct cred *cred) 1221{ 1222 return 0; 1223} 1224 1225static inline int security_task_prctl(int option, unsigned long arg2, 1226 unsigned long arg3, 1227 unsigned long arg4, 1228 unsigned long arg5) 1229{ 1230 return cap_task_prctl(option, arg2, arg3, arg4, arg5); 1231} 1232 1233static inline void security_task_to_inode(struct task_struct *p, struct inode *inode) 1234{ } 1235 1236static inline int security_create_user_ns(const struct cred *cred) 1237{ 1238 return 0; 1239} 1240 1241static inline int security_ipc_permission(struct kern_ipc_perm *ipcp, 1242 short flag) 1243{ 1244 return 0; 1245} 1246 1247static inline void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid) 1248{ 1249 *secid = 0; 1250} 1251 1252static inline int security_msg_msg_alloc(struct msg_msg *msg) 1253{ 1254 return 0; 1255} 1256 1257static inline void security_msg_msg_free(struct msg_msg *msg) 1258{ } 1259 1260static inline int security_msg_queue_alloc(struct kern_ipc_perm *msq) 1261{ 1262 return 0; 1263} 1264 1265static inline void security_msg_queue_free(struct kern_ipc_perm *msq) 1266{ } 1267 1268static inline int security_msg_queue_associate(struct kern_ipc_perm *msq, 1269 int msqflg) 1270{ 1271 return 0; 1272} 1273 1274static inline int security_msg_queue_msgctl(struct kern_ipc_perm *msq, int cmd) 1275{ 1276 return 0; 1277} 1278 1279static inline int security_msg_queue_msgsnd(struct kern_ipc_perm *msq, 1280 struct msg_msg *msg, int msqflg) 1281{ 1282 return 0; 1283} 1284 1285static inline int security_msg_queue_msgrcv(struct kern_ipc_perm *msq, 1286 struct msg_msg *msg, 1287 struct task_struct *target, 1288 long type, int mode) 1289{ 1290 return 0; 1291} 1292 1293static inline int security_shm_alloc(struct kern_ipc_perm *shp) 1294{ 1295 return 0; 1296} 1297 1298static inline void security_shm_free(struct kern_ipc_perm *shp) 1299{ } 1300 1301static inline int security_shm_associate(struct kern_ipc_perm *shp, 1302 int shmflg) 1303{ 1304 return 0; 1305} 1306 1307static inline int security_shm_shmctl(struct kern_ipc_perm *shp, int cmd) 1308{ 1309 return 0; 1310} 1311 1312static inline int security_shm_shmat(struct kern_ipc_perm *shp, 1313 char __user *shmaddr, int shmflg) 1314{ 1315 return 0; 1316} 1317 1318static inline int security_sem_alloc(struct kern_ipc_perm *sma) 1319{ 1320 return 0; 1321} 1322 1323static inline void security_sem_free(struct kern_ipc_perm *sma) 1324{ } 1325 1326static inline int security_sem_associate(struct kern_ipc_perm *sma, int semflg) 1327{ 1328 return 0; 1329} 1330 1331static inline int security_sem_semctl(struct kern_ipc_perm *sma, int cmd) 1332{ 1333 return 0; 1334} 1335 1336static inline int security_sem_semop(struct kern_ipc_perm *sma, 1337 struct sembuf *sops, unsigned nsops, 1338 int alter) 1339{ 1340 return 0; 1341} 1342 1343static inline void security_d_instantiate(struct dentry *dentry, 1344 struct inode *inode) 1345{ } 1346 1347static inline int security_getprocattr(struct task_struct *p, const char *lsm, 1348 const char *name, char **value) 1349{ 1350 return -EINVAL; 1351} 1352 1353static inline int security_setprocattr(const char *lsm, char *name, 1354 void *value, size_t size) 1355{ 1356 return -EINVAL; 1357} 1358 1359static inline int security_netlink_send(struct sock *sk, struct sk_buff *skb) 1360{ 1361 return 0; 1362} 1363 1364static inline int security_ismaclabel(const char *name) 1365{ 1366 return 0; 1367} 1368 1369static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen) 1370{ 1371 return -EOPNOTSUPP; 1372} 1373 1374static inline int security_secctx_to_secid(const char *secdata, 1375 u32 seclen, 1376 u32 *secid) 1377{ 1378 return -EOPNOTSUPP; 1379} 1380 1381static inline void security_release_secctx(char *secdata, u32 seclen) 1382{ 1383} 1384 1385static inline void security_inode_invalidate_secctx(struct inode *inode) 1386{ 1387} 1388 1389static inline int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen) 1390{ 1391 return -EOPNOTSUPP; 1392} 1393static inline int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen) 1394{ 1395 return -EOPNOTSUPP; 1396} 1397static inline int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen) 1398{ 1399 return -EOPNOTSUPP; 1400} 1401static inline int security_locked_down(enum lockdown_reason what) 1402{ 1403 return 0; 1404} 1405#endif /* CONFIG_SECURITY */ 1406 1407#if defined(CONFIG_SECURITY) && defined(CONFIG_WATCH_QUEUE) 1408int security_post_notification(const struct cred *w_cred, 1409 const struct cred *cred, 1410 struct watch_notification *n); 1411#else 1412static inline int security_post_notification(const struct cred *w_cred, 1413 const struct cred *cred, 1414 struct watch_notification *n) 1415{ 1416 return 0; 1417} 1418#endif 1419 1420#if defined(CONFIG_SECURITY) && defined(CONFIG_KEY_NOTIFICATIONS) 1421int security_watch_key(struct key *key); 1422#else 1423static inline int security_watch_key(struct key *key) 1424{ 1425 return 0; 1426} 1427#endif 1428 1429#ifdef CONFIG_SECURITY_NETWORK 1430 1431int security_unix_stream_connect(struct sock *sock, struct sock *other, struct sock *newsk); 1432int security_unix_may_send(struct socket *sock, struct socket *other); 1433int security_socket_create(int family, int type, int protocol, int kern); 1434int security_socket_post_create(struct socket *sock, int family, 1435 int type, int protocol, int kern); 1436int security_socket_socketpair(struct socket *socka, struct socket *sockb); 1437int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen); 1438int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen); 1439int security_socket_listen(struct socket *sock, int backlog); 1440int security_socket_accept(struct socket *sock, struct socket *newsock); 1441int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size); 1442int security_socket_recvmsg(struct socket *sock, struct msghdr *msg, 1443 int size, int flags); 1444int security_socket_getsockname(struct socket *sock); 1445int security_socket_getpeername(struct socket *sock); 1446int security_socket_getsockopt(struct socket *sock, int level, int optname); 1447int security_socket_setsockopt(struct socket *sock, int level, int optname); 1448int security_socket_shutdown(struct socket *sock, int how); 1449int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb); 1450int security_socket_getpeersec_stream(struct socket *sock, sockptr_t optval, 1451 sockptr_t optlen, unsigned int len); 1452int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid); 1453int security_sk_alloc(struct sock *sk, int family, gfp_t priority); 1454void security_sk_free(struct sock *sk); 1455void security_sk_clone(const struct sock *sk, struct sock *newsk); 1456void security_sk_classify_flow(struct sock *sk, struct flowi_common *flic); 1457void security_req_classify_flow(const struct request_sock *req, 1458 struct flowi_common *flic); 1459void security_sock_graft(struct sock*sk, struct socket *parent); 1460int security_inet_conn_request(const struct sock *sk, 1461 struct sk_buff *skb, struct request_sock *req); 1462void security_inet_csk_clone(struct sock *newsk, 1463 const struct request_sock *req); 1464void security_inet_conn_established(struct sock *sk, 1465 struct sk_buff *skb); 1466int security_secmark_relabel_packet(u32 secid); 1467void security_secmark_refcount_inc(void); 1468void security_secmark_refcount_dec(void); 1469int security_tun_dev_alloc_security(void **security); 1470void security_tun_dev_free_security(void *security); 1471int security_tun_dev_create(void); 1472int security_tun_dev_attach_queue(void *security); 1473int security_tun_dev_attach(struct sock *sk, void *security); 1474int security_tun_dev_open(void *security); 1475int security_sctp_assoc_request(struct sctp_association *asoc, struct sk_buff *skb); 1476int security_sctp_bind_connect(struct sock *sk, int optname, 1477 struct sockaddr *address, int addrlen); 1478void security_sctp_sk_clone(struct sctp_association *asoc, struct sock *sk, 1479 struct sock *newsk); 1480int security_sctp_assoc_established(struct sctp_association *asoc, 1481 struct sk_buff *skb); 1482 1483#else /* CONFIG_SECURITY_NETWORK */ 1484static inline int security_unix_stream_connect(struct sock *sock, 1485 struct sock *other, 1486 struct sock *newsk) 1487{ 1488 return 0; 1489} 1490 1491static inline int security_unix_may_send(struct socket *sock, 1492 struct socket *other) 1493{ 1494 return 0; 1495} 1496 1497static inline int security_socket_create(int family, int type, 1498 int protocol, int kern) 1499{ 1500 return 0; 1501} 1502 1503static inline int security_socket_post_create(struct socket *sock, 1504 int family, 1505 int type, 1506 int protocol, int kern) 1507{ 1508 return 0; 1509} 1510 1511static inline int security_socket_socketpair(struct socket *socka, 1512 struct socket *sockb) 1513{ 1514 return 0; 1515} 1516 1517static inline int security_socket_bind(struct socket *sock, 1518 struct sockaddr *address, 1519 int addrlen) 1520{ 1521 return 0; 1522} 1523 1524static inline int security_socket_connect(struct socket *sock, 1525 struct sockaddr *address, 1526 int addrlen) 1527{ 1528 return 0; 1529} 1530 1531static inline int security_socket_listen(struct socket *sock, int backlog) 1532{ 1533 return 0; 1534} 1535 1536static inline int security_socket_accept(struct socket *sock, 1537 struct socket *newsock) 1538{ 1539 return 0; 1540} 1541 1542static inline int security_socket_sendmsg(struct socket *sock, 1543 struct msghdr *msg, int size) 1544{ 1545 return 0; 1546} 1547 1548static inline int security_socket_recvmsg(struct socket *sock, 1549 struct msghdr *msg, int size, 1550 int flags) 1551{ 1552 return 0; 1553} 1554 1555static inline int security_socket_getsockname(struct socket *sock) 1556{ 1557 return 0; 1558} 1559 1560static inline int security_socket_getpeername(struct socket *sock) 1561{ 1562 return 0; 1563} 1564 1565static inline int security_socket_getsockopt(struct socket *sock, 1566 int level, int optname) 1567{ 1568 return 0; 1569} 1570 1571static inline int security_socket_setsockopt(struct socket *sock, 1572 int level, int optname) 1573{ 1574 return 0; 1575} 1576 1577static inline int security_socket_shutdown(struct socket *sock, int how) 1578{ 1579 return 0; 1580} 1581static inline int security_sock_rcv_skb(struct sock *sk, 1582 struct sk_buff *skb) 1583{ 1584 return 0; 1585} 1586 1587static inline int security_socket_getpeersec_stream(struct socket *sock, 1588 sockptr_t optval, 1589 sockptr_t optlen, 1590 unsigned int len) 1591{ 1592 return -ENOPROTOOPT; 1593} 1594 1595static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid) 1596{ 1597 return -ENOPROTOOPT; 1598} 1599 1600static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority) 1601{ 1602 return 0; 1603} 1604 1605static inline void security_sk_free(struct sock *sk) 1606{ 1607} 1608 1609static inline void security_sk_clone(const struct sock *sk, struct sock *newsk) 1610{ 1611} 1612 1613static inline void security_sk_classify_flow(struct sock *sk, 1614 struct flowi_common *flic) 1615{ 1616} 1617 1618static inline void security_req_classify_flow(const struct request_sock *req, 1619 struct flowi_common *flic) 1620{ 1621} 1622 1623static inline void security_sock_graft(struct sock *sk, struct socket *parent) 1624{ 1625} 1626 1627static inline int security_inet_conn_request(const struct sock *sk, 1628 struct sk_buff *skb, struct request_sock *req) 1629{ 1630 return 0; 1631} 1632 1633static inline void security_inet_csk_clone(struct sock *newsk, 1634 const struct request_sock *req) 1635{ 1636} 1637 1638static inline void security_inet_conn_established(struct sock *sk, 1639 struct sk_buff *skb) 1640{ 1641} 1642 1643static inline int security_secmark_relabel_packet(u32 secid) 1644{ 1645 return 0; 1646} 1647 1648static inline void security_secmark_refcount_inc(void) 1649{ 1650} 1651 1652static inline void security_secmark_refcount_dec(void) 1653{ 1654} 1655 1656static inline int security_tun_dev_alloc_security(void **security) 1657{ 1658 return 0; 1659} 1660 1661static inline void security_tun_dev_free_security(void *security) 1662{ 1663} 1664 1665static inline int security_tun_dev_create(void) 1666{ 1667 return 0; 1668} 1669 1670static inline int security_tun_dev_attach_queue(void *security) 1671{ 1672 return 0; 1673} 1674 1675static inline int security_tun_dev_attach(struct sock *sk, void *security) 1676{ 1677 return 0; 1678} 1679 1680static inline int security_tun_dev_open(void *security) 1681{ 1682 return 0; 1683} 1684 1685static inline int security_sctp_assoc_request(struct sctp_association *asoc, 1686 struct sk_buff *skb) 1687{ 1688 return 0; 1689} 1690 1691static inline int security_sctp_bind_connect(struct sock *sk, int optname, 1692 struct sockaddr *address, 1693 int addrlen) 1694{ 1695 return 0; 1696} 1697 1698static inline void security_sctp_sk_clone(struct sctp_association *asoc, 1699 struct sock *sk, 1700 struct sock *newsk) 1701{ 1702} 1703 1704static inline int security_sctp_assoc_established(struct sctp_association *asoc, 1705 struct sk_buff *skb) 1706{ 1707 return 0; 1708} 1709#endif /* CONFIG_SECURITY_NETWORK */ 1710 1711#ifdef CONFIG_SECURITY_INFINIBAND 1712int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey); 1713int security_ib_endport_manage_subnet(void *sec, const char *name, u8 port_num); 1714int security_ib_alloc_security(void **sec); 1715void security_ib_free_security(void *sec); 1716#else /* CONFIG_SECURITY_INFINIBAND */ 1717static inline int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey) 1718{ 1719 return 0; 1720} 1721 1722static inline int security_ib_endport_manage_subnet(void *sec, const char *dev_name, u8 port_num) 1723{ 1724 return 0; 1725} 1726 1727static inline int security_ib_alloc_security(void **sec) 1728{ 1729 return 0; 1730} 1731 1732static inline void security_ib_free_security(void *sec) 1733{ 1734} 1735#endif /* CONFIG_SECURITY_INFINIBAND */ 1736 1737#ifdef CONFIG_SECURITY_NETWORK_XFRM 1738 1739int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp, 1740 struct xfrm_user_sec_ctx *sec_ctx, gfp_t gfp); 1741int security_xfrm_policy_clone(struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctxp); 1742void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx); 1743int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx); 1744int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx); 1745int security_xfrm_state_alloc_acquire(struct xfrm_state *x, 1746 struct xfrm_sec_ctx *polsec, u32 secid); 1747int security_xfrm_state_delete(struct xfrm_state *x); 1748void security_xfrm_state_free(struct xfrm_state *x); 1749int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid); 1750int security_xfrm_state_pol_flow_match(struct xfrm_state *x, 1751 struct xfrm_policy *xp, 1752 const struct flowi_common *flic); 1753int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid); 1754void security_skb_classify_flow(struct sk_buff *skb, struct flowi_common *flic); 1755 1756#else /* CONFIG_SECURITY_NETWORK_XFRM */ 1757 1758static inline int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp, 1759 struct xfrm_user_sec_ctx *sec_ctx, 1760 gfp_t gfp) 1761{ 1762 return 0; 1763} 1764 1765static inline int security_xfrm_policy_clone(struct xfrm_sec_ctx *old, struct xfrm_sec_ctx **new_ctxp) 1766{ 1767 return 0; 1768} 1769 1770static inline void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx) 1771{ 1772} 1773 1774static inline int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx) 1775{ 1776 return 0; 1777} 1778 1779static inline int security_xfrm_state_alloc(struct xfrm_state *x, 1780 struct xfrm_user_sec_ctx *sec_ctx) 1781{ 1782 return 0; 1783} 1784 1785static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x, 1786 struct xfrm_sec_ctx *polsec, u32 secid) 1787{ 1788 return 0; 1789} 1790 1791static inline void security_xfrm_state_free(struct xfrm_state *x) 1792{ 1793} 1794 1795static inline int security_xfrm_state_delete(struct xfrm_state *x) 1796{ 1797 return 0; 1798} 1799 1800static inline int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid) 1801{ 1802 return 0; 1803} 1804 1805static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x, 1806 struct xfrm_policy *xp, 1807 const struct flowi_common *flic) 1808{ 1809 return 1; 1810} 1811 1812static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid) 1813{ 1814 return 0; 1815} 1816 1817static inline void security_skb_classify_flow(struct sk_buff *skb, 1818 struct flowi_common *flic) 1819{ 1820} 1821 1822#endif /* CONFIG_SECURITY_NETWORK_XFRM */ 1823 1824#ifdef CONFIG_SECURITY_PATH 1825int security_path_unlink(const struct path *dir, struct dentry *dentry); 1826int security_path_mkdir(const struct path *dir, struct dentry *dentry, umode_t mode); 1827int security_path_rmdir(const struct path *dir, struct dentry *dentry); 1828int security_path_mknod(const struct path *dir, struct dentry *dentry, umode_t mode, 1829 unsigned int dev); 1830int security_path_truncate(const struct path *path); 1831int security_path_symlink(const struct path *dir, struct dentry *dentry, 1832 const char *old_name); 1833int security_path_link(struct dentry *old_dentry, const struct path *new_dir, 1834 struct dentry *new_dentry); 1835int security_path_rename(const struct path *old_dir, struct dentry *old_dentry, 1836 const struct path *new_dir, struct dentry *new_dentry, 1837 unsigned int flags); 1838int security_path_chmod(const struct path *path, umode_t mode); 1839int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid); 1840int security_path_chroot(const struct path *path); 1841#else /* CONFIG_SECURITY_PATH */ 1842static inline int security_path_unlink(const struct path *dir, struct dentry *dentry) 1843{ 1844 return 0; 1845} 1846 1847static inline int security_path_mkdir(const struct path *dir, struct dentry *dentry, 1848 umode_t mode) 1849{ 1850 return 0; 1851} 1852 1853static inline int security_path_rmdir(const struct path *dir, struct dentry *dentry) 1854{ 1855 return 0; 1856} 1857 1858static inline int security_path_mknod(const struct path *dir, struct dentry *dentry, 1859 umode_t mode, unsigned int dev) 1860{ 1861 return 0; 1862} 1863 1864static inline int security_path_truncate(const struct path *path) 1865{ 1866 return 0; 1867} 1868 1869static inline int security_path_symlink(const struct path *dir, struct dentry *dentry, 1870 const char *old_name) 1871{ 1872 return 0; 1873} 1874 1875static inline int security_path_link(struct dentry *old_dentry, 1876 const struct path *new_dir, 1877 struct dentry *new_dentry) 1878{ 1879 return 0; 1880} 1881 1882static inline int security_path_rename(const struct path *old_dir, 1883 struct dentry *old_dentry, 1884 const struct path *new_dir, 1885 struct dentry *new_dentry, 1886 unsigned int flags) 1887{ 1888 return 0; 1889} 1890 1891static inline int security_path_chmod(const struct path *path, umode_t mode) 1892{ 1893 return 0; 1894} 1895 1896static inline int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid) 1897{ 1898 return 0; 1899} 1900 1901static inline int security_path_chroot(const struct path *path) 1902{ 1903 return 0; 1904} 1905#endif /* CONFIG_SECURITY_PATH */ 1906 1907#ifdef CONFIG_KEYS 1908#ifdef CONFIG_SECURITY 1909 1910int security_key_alloc(struct key *key, const struct cred *cred, unsigned long flags); 1911void security_key_free(struct key *key); 1912int security_key_permission(key_ref_t key_ref, const struct cred *cred, 1913 enum key_need_perm need_perm); 1914int security_key_getsecurity(struct key *key, char **_buffer); 1915 1916#else 1917 1918static inline int security_key_alloc(struct key *key, 1919 const struct cred *cred, 1920 unsigned long flags) 1921{ 1922 return 0; 1923} 1924 1925static inline void security_key_free(struct key *key) 1926{ 1927} 1928 1929static inline int security_key_permission(key_ref_t key_ref, 1930 const struct cred *cred, 1931 enum key_need_perm need_perm) 1932{ 1933 return 0; 1934} 1935 1936static inline int security_key_getsecurity(struct key *key, char **_buffer) 1937{ 1938 *_buffer = NULL; 1939 return 0; 1940} 1941 1942#endif 1943#endif /* CONFIG_KEYS */ 1944 1945#ifdef CONFIG_AUDIT 1946#ifdef CONFIG_SECURITY 1947int security_audit_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule); 1948int security_audit_rule_known(struct audit_krule *krule); 1949int security_audit_rule_match(u32 secid, u32 field, u32 op, void *lsmrule); 1950void security_audit_rule_free(void *lsmrule); 1951 1952#else 1953 1954static inline int security_audit_rule_init(u32 field, u32 op, char *rulestr, 1955 void **lsmrule) 1956{ 1957 return 0; 1958} 1959 1960static inline int security_audit_rule_known(struct audit_krule *krule) 1961{ 1962 return 0; 1963} 1964 1965static inline int security_audit_rule_match(u32 secid, u32 field, u32 op, 1966 void *lsmrule) 1967{ 1968 return 0; 1969} 1970 1971static inline void security_audit_rule_free(void *lsmrule) 1972{ } 1973 1974#endif /* CONFIG_SECURITY */ 1975#endif /* CONFIG_AUDIT */ 1976 1977#ifdef CONFIG_SECURITYFS 1978 1979extern struct dentry *securityfs_create_file(const char *name, umode_t mode, 1980 struct dentry *parent, void *data, 1981 const struct file_operations *fops); 1982extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent); 1983struct dentry *securityfs_create_symlink(const char *name, 1984 struct dentry *parent, 1985 const char *target, 1986 const struct inode_operations *iops); 1987extern void securityfs_remove(struct dentry *dentry); 1988 1989#else /* CONFIG_SECURITYFS */ 1990 1991static inline struct dentry *securityfs_create_dir(const char *name, 1992 struct dentry *parent) 1993{ 1994 return ERR_PTR(-ENODEV); 1995} 1996 1997static inline struct dentry *securityfs_create_file(const char *name, 1998 umode_t mode, 1999 struct dentry *parent, 2000 void *data, 2001 const struct file_operations *fops) 2002{ 2003 return ERR_PTR(-ENODEV); 2004} 2005 2006static inline struct dentry *securityfs_create_symlink(const char *name, 2007 struct dentry *parent, 2008 const char *target, 2009 const struct inode_operations *iops) 2010{ 2011 return ERR_PTR(-ENODEV); 2012} 2013 2014static inline void securityfs_remove(struct dentry *dentry) 2015{} 2016 2017#endif 2018 2019#ifdef CONFIG_BPF_SYSCALL 2020union bpf_attr; 2021struct bpf_map; 2022struct bpf_prog; 2023struct bpf_prog_aux; 2024#ifdef CONFIG_SECURITY 2025extern int security_bpf(int cmd, union bpf_attr *attr, unsigned int size); 2026extern int security_bpf_map(struct bpf_map *map, fmode_t fmode); 2027extern int security_bpf_prog(struct bpf_prog *prog); 2028extern int security_bpf_map_alloc(struct bpf_map *map); 2029extern void security_bpf_map_free(struct bpf_map *map); 2030extern int security_bpf_prog_alloc(struct bpf_prog_aux *aux); 2031extern void security_bpf_prog_free(struct bpf_prog_aux *aux); 2032#else 2033static inline int security_bpf(int cmd, union bpf_attr *attr, 2034 unsigned int size) 2035{ 2036 return 0; 2037} 2038 2039static inline int security_bpf_map(struct bpf_map *map, fmode_t fmode) 2040{ 2041 return 0; 2042} 2043 2044static inline int security_bpf_prog(struct bpf_prog *prog) 2045{ 2046 return 0; 2047} 2048 2049static inline int security_bpf_map_alloc(struct bpf_map *map) 2050{ 2051 return 0; 2052} 2053 2054static inline void security_bpf_map_free(struct bpf_map *map) 2055{ } 2056 2057static inline int security_bpf_prog_alloc(struct bpf_prog_aux *aux) 2058{ 2059 return 0; 2060} 2061 2062static inline void security_bpf_prog_free(struct bpf_prog_aux *aux) 2063{ } 2064#endif /* CONFIG_SECURITY */ 2065#endif /* CONFIG_BPF_SYSCALL */ 2066 2067#ifdef CONFIG_PERF_EVENTS 2068struct perf_event_attr; 2069struct perf_event; 2070 2071#ifdef CONFIG_SECURITY 2072extern int security_perf_event_open(struct perf_event_attr *attr, int type); 2073extern int security_perf_event_alloc(struct perf_event *event); 2074extern void security_perf_event_free(struct perf_event *event); 2075extern int security_perf_event_read(struct perf_event *event); 2076extern int security_perf_event_write(struct perf_event *event); 2077#else 2078static inline int security_perf_event_open(struct perf_event_attr *attr, 2079 int type) 2080{ 2081 return 0; 2082} 2083 2084static inline int security_perf_event_alloc(struct perf_event *event) 2085{ 2086 return 0; 2087} 2088 2089static inline void security_perf_event_free(struct perf_event *event) 2090{ 2091} 2092 2093static inline int security_perf_event_read(struct perf_event *event) 2094{ 2095 return 0; 2096} 2097 2098static inline int security_perf_event_write(struct perf_event *event) 2099{ 2100 return 0; 2101} 2102#endif /* CONFIG_SECURITY */ 2103#endif /* CONFIG_PERF_EVENTS */ 2104 2105#ifdef CONFIG_IO_URING 2106#ifdef CONFIG_SECURITY 2107extern int security_uring_override_creds(const struct cred *new); 2108extern int security_uring_sqpoll(void); 2109extern int security_uring_cmd(struct io_uring_cmd *ioucmd); 2110#else 2111static inline int security_uring_override_creds(const struct cred *new) 2112{ 2113 return 0; 2114} 2115static inline int security_uring_sqpoll(void) 2116{ 2117 return 0; 2118} 2119static inline int security_uring_cmd(struct io_uring_cmd *ioucmd) 2120{ 2121 return 0; 2122} 2123#endif /* CONFIG_SECURITY */ 2124#endif /* CONFIG_IO_URING */ 2125 2126#endif /* ! __LINUX_SECURITY_H */