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