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