~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/security.h

Version: ~ [ linux-5.14-rc3 ] ~ [ linux-5.13.5 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.53 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.135 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.198 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.240 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.276 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.276 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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  *
 10  *      This program is free software; you can redistribute it and/or modify
 11  *      it under the terms of the GNU General Public License as published by
 12  *      the Free Software Foundation; either version 2 of the License, or
 13  *      (at your option) any later version.
 14  *
 15  *      Due to this file being licensed under the GPL there is controversy over
 16  *      whether this permits you to write a module that #includes this file
 17  *      without placing your module under the GPL.  Please consult a lawyer for
 18  *      advice before doing this.
 19  *
 20  */
 21 
 22 #ifndef __LINUX_SECURITY_H
 23 #define __LINUX_SECURITY_H
 24 
 25 #include <linux/key.h>
 26 #include <linux/capability.h>
 27 #include <linux/slab.h>
 28 #include <linux/err.h>
 29 #include <linux/string.h>
 30 
 31 struct linux_binprm;
 32 struct cred;
 33 struct rlimit;
 34 struct siginfo;
 35 struct sem_array;
 36 struct sembuf;
 37 struct kern_ipc_perm;
 38 struct audit_context;
 39 struct super_block;
 40 struct inode;
 41 struct dentry;
 42 struct file;
 43 struct vfsmount;
 44 struct path;
 45 struct qstr;
 46 struct nameidata;
 47 struct iattr;
 48 struct fown_struct;
 49 struct file_operations;
 50 struct shmid_kernel;
 51 struct msg_msg;
 52 struct msg_queue;
 53 struct xattr;
 54 struct xfrm_sec_ctx;
 55 struct mm_struct;
 56 #include <linux/ccsecurity.h>
 57 
 58 /* Maximum number of letters for an LSM name string */
 59 #define SECURITY_NAME_MAX       10
 60 
 61 /* If capable should audit the security request */
 62 #define SECURITY_CAP_NOAUDIT 0
 63 #define SECURITY_CAP_AUDIT 1
 64 
 65 /* LSM Agnostic defines for sb_set_mnt_opts */
 66 #define SECURITY_LSM_NATIVE_LABELS      1
 67 
 68 struct ctl_table;
 69 struct audit_krule;
 70 struct user_namespace;
 71 struct timezone;
 72 
 73 /*
 74  * These functions are in security/capability.c and are used
 75  * as the default capabilities functions
 76  */
 77 extern int cap_capable(const struct cred *cred, struct user_namespace *ns,
 78                        int cap, int audit);
 79 extern int cap_settime(const struct timespec *ts, const struct timezone *tz);
 80 extern int cap_ptrace_access_check(struct task_struct *child, unsigned int mode);
 81 extern int cap_ptrace_traceme(struct task_struct *parent);
 82 extern int cap_capget(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
 83 extern int cap_capset(struct cred *new, const struct cred *old,
 84                       const kernel_cap_t *effective,
 85                       const kernel_cap_t *inheritable,
 86                       const kernel_cap_t *permitted);
 87 extern int cap_bprm_set_creds(struct linux_binprm *bprm);
 88 extern int cap_bprm_secureexec(struct linux_binprm *bprm);
 89 extern int cap_inode_setxattr(struct dentry *dentry, const char *name,
 90                               const void *value, size_t size, int flags);
 91 extern int cap_inode_removexattr(struct dentry *dentry, const char *name);
 92 extern int cap_inode_need_killpriv(struct dentry *dentry);
 93 extern int cap_inode_killpriv(struct dentry *dentry);
 94 extern int cap_mmap_addr(unsigned long addr);
 95 extern int cap_mmap_file(struct file *file, unsigned long reqprot,
 96                          unsigned long prot, unsigned long flags);
 97 extern int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags);
 98 extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
 99                           unsigned long arg4, unsigned long arg5);
100 extern int cap_task_setscheduler(struct task_struct *p);
101 extern int cap_task_setioprio(struct task_struct *p, int ioprio);
102 extern int cap_task_setnice(struct task_struct *p, int nice);
103 extern int cap_vm_enough_memory(struct mm_struct *mm, long pages);
104 
105 struct msghdr;
106 struct sk_buff;
107 struct sock;
108 struct sockaddr;
109 struct socket;
110 struct flowi;
111 struct dst_entry;
112 struct xfrm_selector;
113 struct xfrm_policy;
114 struct xfrm_state;
115 struct xfrm_user_sec_ctx;
116 struct seq_file;
117 
118 extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
119 
120 void reset_security_ops(void);
121 
122 #ifdef CONFIG_MMU
123 extern unsigned long mmap_min_addr;
124 extern unsigned long dac_mmap_min_addr;
125 #else
126 #define mmap_min_addr           0UL
127 #define dac_mmap_min_addr       0UL
128 #endif
129 
130 /*
131  * Values used in the task_security_ops calls
132  */
133 /* setuid or setgid, id0 == uid or gid */
134 #define LSM_SETID_ID    1
135 
136 /* setreuid or setregid, id0 == real, id1 == eff */
137 #define LSM_SETID_RE    2
138 
139 /* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
140 #define LSM_SETID_RES   4
141 
142 /* setfsuid or setfsgid, id0 == fsuid or fsgid */
143 #define LSM_SETID_FS    8
144 
145 /* forward declares to avoid warnings */
146 struct sched_param;
147 struct request_sock;
148 
149 /* bprm->unsafe reasons */
150 #define LSM_UNSAFE_SHARE        1
151 #define LSM_UNSAFE_PTRACE       2
152 #define LSM_UNSAFE_PTRACE_CAP   4
153 #define LSM_UNSAFE_NO_NEW_PRIVS 8
154 
155 #ifdef CONFIG_MMU
156 extern int mmap_min_addr_handler(struct ctl_table *table, int write,
157                                  void __user *buffer, size_t *lenp, loff_t *ppos);
158 #endif
159 
160 /* security_inode_init_security callback function to write xattrs */
161 typedef int (*initxattrs) (struct inode *inode,
162                            const struct xattr *xattr_array, void *fs_data);
163 
164 #ifdef CONFIG_SECURITY
165 
166 struct security_mnt_opts {
167         char **mnt_opts;
168         int *mnt_opts_flags;
169         int num_mnt_opts;
170 };
171 
172 static inline void security_init_mnt_opts(struct security_mnt_opts *opts)
173 {
174         opts->mnt_opts = NULL;
175         opts->mnt_opts_flags = NULL;
176         opts->num_mnt_opts = 0;
177 }
178 
179 static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
180 {
181         int i;
182         if (opts->mnt_opts)
183                 for (i = 0; i < opts->num_mnt_opts; i++)
184                         kfree(opts->mnt_opts[i]);
185         kfree(opts->mnt_opts);
186         opts->mnt_opts = NULL;
187         kfree(opts->mnt_opts_flags);
188         opts->mnt_opts_flags = NULL;
189         opts->num_mnt_opts = 0;
190 }
191 
192 /**
193  * struct security_operations - main security structure
194  *
195  * Security module identifier.
196  *
197  * @name:
198  *      A string that acts as a unique identifier for the LSM with max number
199  *      of characters = SECURITY_NAME_MAX.
200  *
201  * Security hooks for program execution operations.
202  *
203  * @bprm_set_creds:
204  *      Save security information in the bprm->security field, typically based
205  *      on information about the bprm->file, for later use by the apply_creds
206  *      hook.  This hook may also optionally check permissions (e.g. for
207  *      transitions between security domains).
208  *      This hook may be called multiple times during a single execve, e.g. for
209  *      interpreters.  The hook can tell whether it has already been called by
210  *      checking to see if @bprm->security is non-NULL.  If so, then the hook
211  *      may decide either to retain the security information saved earlier or
212  *      to replace it.
213  *      @bprm contains the linux_binprm structure.
214  *      Return 0 if the hook is successful and permission is granted.
215  * @bprm_check_security:
216  *      This hook mediates the point when a search for a binary handler will
217  *      begin.  It allows a check the @bprm->security value which is set in the
218  *      preceding set_creds call.  The primary difference from set_creds is
219  *      that the argv list and envp list are reliably available in @bprm.  This
220  *      hook may be called multiple times during a single execve; and in each
221  *      pass set_creds is called first.
222  *      @bprm contains the linux_binprm structure.
223  *      Return 0 if the hook is successful and permission is granted.
224  * @bprm_committing_creds:
225  *      Prepare to install the new security attributes of a process being
226  *      transformed by an execve operation, based on the old credentials
227  *      pointed to by @current->cred and the information set in @bprm->cred by
228  *      the bprm_set_creds hook.  @bprm points to the linux_binprm structure.
229  *      This hook is a good place to perform state changes on the process such
230  *      as closing open file descriptors to which access will no longer be
231  *      granted when the attributes are changed.  This is called immediately
232  *      before commit_creds().
233  * @bprm_committed_creds:
234  *      Tidy up after the installation of the new security attributes of a
235  *      process being transformed by an execve operation.  The new credentials
236  *      have, by this point, been set to @current->cred.  @bprm points to the
237  *      linux_binprm structure.  This hook is a good place to perform state
238  *      changes on the process such as clearing out non-inheritable signal
239  *      state.  This is called immediately after commit_creds().
240  * @bprm_secureexec:
241  *      Return a boolean value (0 or 1) indicating whether a "secure exec"
242  *      is required.  The flag is passed in the auxiliary table
243  *      on the initial stack to the ELF interpreter to indicate whether libc
244  *      should enable secure mode.
245  *      @bprm contains the linux_binprm structure.
246  *
247  * Security hooks for filesystem operations.
248  *
249  * @sb_alloc_security:
250  *      Allocate and attach a security structure to the sb->s_security field.
251  *      The s_security field is initialized to NULL when the structure is
252  *      allocated.
253  *      @sb contains the super_block structure to be modified.
254  *      Return 0 if operation was successful.
255  * @sb_free_security:
256  *      Deallocate and clear the sb->s_security field.
257  *      @sb contains the super_block structure to be modified.
258  * @sb_statfs:
259  *      Check permission before obtaining filesystem statistics for the @mnt
260  *      mountpoint.
261  *      @dentry is a handle on the superblock for the filesystem.
262  *      Return 0 if permission is granted.
263  * @sb_mount:
264  *      Check permission before an object specified by @dev_name is mounted on
265  *      the mount point named by @nd.  For an ordinary mount, @dev_name
266  *      identifies a device if the file system type requires a device.  For a
267  *      remount (@flags & MS_REMOUNT), @dev_name is irrelevant.  For a
268  *      loopback/bind mount (@flags & MS_BIND), @dev_name identifies the
269  *      pathname of the object being mounted.
270  *      @dev_name contains the name for object being mounted.
271  *      @path contains the path for mount point object.
272  *      @type contains the filesystem type.
273  *      @flags contains the mount flags.
274  *      @data contains the filesystem-specific data.
275  *      Return 0 if permission is granted.
276  * @sb_copy_data:
277  *      Allow mount option data to be copied prior to parsing by the filesystem,
278  *      so that the security module can extract security-specific mount
279  *      options cleanly (a filesystem may modify the data e.g. with strsep()).
280  *      This also allows the original mount data to be stripped of security-
281  *      specific options to avoid having to make filesystems aware of them.
282  *      @type the type of filesystem being mounted.
283  *      @orig the original mount data copied from userspace.
284  *      @copy copied data which will be passed to the security module.
285  *      Returns 0 if the copy was successful.
286  * @sb_remount:
287  *      Extracts security system specific mount options and verifies no changes
288  *      are being made to those options.
289  *      @sb superblock being remounted
290  *      @data contains the filesystem-specific data.
291  *      Return 0 if permission is granted.
292  * @sb_umount:
293  *      Check permission before the @mnt file system is unmounted.
294  *      @mnt contains the mounted file system.
295  *      @flags contains the unmount flags, e.g. MNT_FORCE.
296  *      Return 0 if permission is granted.
297  * @sb_pivotroot:
298  *      Check permission before pivoting the root filesystem.
299  *      @old_path contains the path for the new location of the current root (put_old).
300  *      @new_path contains the path for the new root (new_root).
301  *      Return 0 if permission is granted.
302  * @sb_set_mnt_opts:
303  *      Set the security relevant mount options used for a superblock
304  *      @sb the superblock to set security mount options for
305  *      @opts binary data structure containing all lsm mount data
306  * @sb_clone_mnt_opts:
307  *      Copy all security options from a given superblock to another
308  *      @oldsb old superblock which contain information to clone
309  *      @newsb new superblock which needs filled in
310  * @sb_parse_opts_str:
311  *      Parse a string of security data filling in the opts structure
312  *      @options string containing all mount options known by the LSM
313  *      @opts binary data structure usable by the LSM
314  * @dentry_init_security:
315  *      Compute a context for a dentry as the inode is not yet available
316  *      since NFSv4 has no label backed by an EA anyway.
317  *      @dentry dentry to use in calculating the context.
318  *      @mode mode used to determine resource type.
319  *      @name name of the last path component used to create file
320  *      @ctx pointer to place the pointer to the resulting context in.
321  *      @ctxlen point to place the length of the resulting context.
322  *
323  *
324  * Security hooks for inode operations.
325  *
326  * @inode_alloc_security:
327  *      Allocate and attach a security structure to @inode->i_security.  The
328  *      i_security field is initialized to NULL when the inode structure is
329  *      allocated.
330  *      @inode contains the inode structure.
331  *      Return 0 if operation was successful.
332  * @inode_free_security:
333  *      @inode contains the inode structure.
334  *      Deallocate the inode security structure and set @inode->i_security to
335  *      NULL.
336  * @inode_init_security:
337  *      Obtain the security attribute name suffix and value to set on a newly
338  *      created inode and set up the incore security field for the new inode.
339  *      This hook is called by the fs code as part of the inode creation
340  *      transaction and provides for atomic labeling of the inode, unlike
341  *      the post_create/mkdir/... hooks called by the VFS.  The hook function
342  *      is expected to allocate the name and value via kmalloc, with the caller
343  *      being responsible for calling kfree after using them.
344  *      If the security module does not use security attributes or does
345  *      not wish to put a security attribute on this particular inode,
346  *      then it should return -EOPNOTSUPP to skip this processing.
347  *      @inode contains the inode structure of the newly created inode.
348  *      @dir contains the inode structure of the parent directory.
349  *      @qstr contains the last path component of the new object
350  *      @name will be set to the allocated name suffix (e.g. selinux).
351  *      @value will be set to the allocated attribute value.
352  *      @len will be set to the length of the value.
353  *      Returns 0 if @name and @value have been successfully set,
354  *              -EOPNOTSUPP if no security attribute is needed, or
355  *              -ENOMEM on memory allocation failure.
356  * @inode_create:
357  *      Check permission to create a regular file.
358  *      @dir contains inode structure of the parent of the new file.
359  *      @dentry contains the dentry structure for the file to be created.
360  *      @mode contains the file mode of the file to be created.
361  *      Return 0 if permission is granted.
362  * @inode_link:
363  *      Check permission before creating a new hard link to a file.
364  *      @old_dentry contains the dentry structure for an existing link to the file.
365  *      @dir contains the inode structure of the parent directory of the new link.
366  *      @new_dentry contains the dentry structure for the new link.
367  *      Return 0 if permission is granted.
368  * @path_link:
369  *      Check permission before creating a new hard link to a file.
370  *      @old_dentry contains the dentry structure for an existing link
371  *      to the file.
372  *      @new_dir contains the path structure of the parent directory of
373  *      the new link.
374  *      @new_dentry contains the dentry structure for the new link.
375  *      Return 0 if permission is granted.
376  * @inode_unlink:
377  *      Check the permission to remove a hard link to a file.
378  *      @dir contains the inode structure of parent directory of the file.
379  *      @dentry contains the dentry structure for file to be unlinked.
380  *      Return 0 if permission is granted.
381  * @path_unlink:
382  *      Check the permission to remove a hard link to a file.
383  *      @dir contains the path structure of parent directory of the file.
384  *      @dentry contains the dentry structure for file to be unlinked.
385  *      Return 0 if permission is granted.
386  * @inode_symlink:
387  *      Check the permission to create a symbolic link to a file.
388  *      @dir contains the inode structure of parent directory of the symbolic link.
389  *      @dentry contains the dentry structure of the symbolic link.
390  *      @old_name contains the pathname of file.
391  *      Return 0 if permission is granted.
392  * @path_symlink:
393  *      Check the permission to create a symbolic link to a file.
394  *      @dir contains the path structure of parent directory of
395  *      the symbolic link.
396  *      @dentry contains the dentry structure of the symbolic link.
397  *      @old_name contains the pathname of file.
398  *      Return 0 if permission is granted.
399  * @inode_mkdir:
400  *      Check permissions to create a new directory in the existing directory
401  *      associated with inode structure @dir.
402  *      @dir contains the inode structure of parent of the directory to be created.
403  *      @dentry contains the dentry structure of new directory.
404  *      @mode contains the mode of new directory.
405  *      Return 0 if permission is granted.
406  * @path_mkdir:
407  *      Check permissions to create a new directory in the existing directory
408  *      associated with path structure @path.
409  *      @dir contains the path structure of parent of the directory
410  *      to be created.
411  *      @dentry contains the dentry structure of new directory.
412  *      @mode contains the mode of new directory.
413  *      Return 0 if permission is granted.
414  * @inode_rmdir:
415  *      Check the permission to remove a directory.
416  *      @dir contains the inode structure of parent of the directory to be removed.
417  *      @dentry contains the dentry structure of directory to be removed.
418  *      Return 0 if permission is granted.
419  * @path_rmdir:
420  *      Check the permission to remove a directory.
421  *      @dir contains the path structure of parent of the directory to be
422  *      removed.
423  *      @dentry contains the dentry structure of directory to be removed.
424  *      Return 0 if permission is granted.
425  * @inode_mknod:
426  *      Check permissions when creating a special file (or a socket or a fifo
427  *      file created via the mknod system call).  Note that if mknod operation
428  *      is being done for a regular file, then the create hook will be called
429  *      and not this hook.
430  *      @dir contains the inode structure of parent of the new file.
431  *      @dentry contains the dentry structure of the new file.
432  *      @mode contains the mode of the new file.
433  *      @dev contains the device number.
434  *      Return 0 if permission is granted.
435  * @path_mknod:
436  *      Check permissions when creating a file. Note that this hook is called
437  *      even if mknod operation is being done for a regular file.
438  *      @dir contains the path structure of parent of the new file.
439  *      @dentry contains the dentry structure of the new file.
440  *      @mode contains the mode of the new file.
441  *      @dev contains the undecoded device number. Use new_decode_dev() to get
442  *      the decoded device number.
443  *      Return 0 if permission is granted.
444  * @inode_rename:
445  *      Check for permission to rename a file or directory.
446  *      @old_dir contains the inode structure for parent of the old link.
447  *      @old_dentry contains the dentry structure of the old link.
448  *      @new_dir contains the inode structure for parent of the new link.
449  *      @new_dentry contains the dentry structure of the new link.
450  *      Return 0 if permission is granted.
451  * @path_rename:
452  *      Check for permission to rename a file or directory.
453  *      @old_dir contains the path structure for parent of the old link.
454  *      @old_dentry contains the dentry structure of the old link.
455  *      @new_dir contains the path structure for parent of the new link.
456  *      @new_dentry contains the dentry structure of the new link.
457  *      Return 0 if permission is granted.
458  * @path_chmod:
459  *      Check for permission to change DAC's permission of a file or directory.
460  *      @dentry contains the dentry structure.
461  *      @mnt contains the vfsmnt structure.
462  *      @mode contains DAC's mode.
463  *      Return 0 if permission is granted.
464  * @path_chown:
465  *      Check for permission to change owner/group of a file or directory.
466  *      @path contains the path structure.
467  *      @uid contains new owner's ID.
468  *      @gid contains new group's ID.
469  *      Return 0 if permission is granted.
470  * @path_chroot:
471  *      Check for permission to change root directory.
472  *      @path contains the path structure.
473  *      Return 0 if permission is granted.
474  * @inode_readlink:
475  *      Check the permission to read the symbolic link.
476  *      @dentry contains the dentry structure for the file link.
477  *      Return 0 if permission is granted.
478  * @inode_follow_link:
479  *      Check permission to follow a symbolic link when looking up a pathname.
480  *      @dentry contains the dentry structure for the link.
481  *      @nd contains the nameidata structure for the parent directory.
482  *      Return 0 if permission is granted.
483  * @inode_permission:
484  *      Check permission before accessing an inode.  This hook is called by the
485  *      existing Linux permission function, so a security module can use it to
486  *      provide additional checking for existing Linux permission checks.
487  *      Notice that this hook is called when a file is opened (as well as many
488  *      other operations), whereas the file_security_ops permission hook is
489  *      called when the actual read/write operations are performed.
490  *      @inode contains the inode structure to check.
491  *      @mask contains the permission mask.
492  *      Return 0 if permission is granted.
493  * @inode_setattr:
494  *      Check permission before setting file attributes.  Note that the kernel
495  *      call to notify_change is performed from several locations, whenever
496  *      file attributes change (such as when a file is truncated, chown/chmod
497  *      operations, transferring disk quotas, etc).
498  *      @dentry contains the dentry structure for the file.
499  *      @attr is the iattr structure containing the new file attributes.
500  *      Return 0 if permission is granted.
501  * @path_truncate:
502  *      Check permission before truncating a file.
503  *      @path contains the path structure for the file.
504  *      Return 0 if permission is granted.
505  * @inode_getattr:
506  *      Check permission before obtaining file attributes.
507  *      @mnt is the vfsmount where the dentry was looked up
508  *      @dentry contains the dentry structure for the file.
509  *      Return 0 if permission is granted.
510  * @inode_setxattr:
511  *      Check permission before setting the extended attributes
512  *      @value identified by @name for @dentry.
513  *      Return 0 if permission is granted.
514  * @inode_post_setxattr:
515  *      Update inode security field after successful setxattr operation.
516  *      @value identified by @name for @dentry.
517  * @inode_getxattr:
518  *      Check permission before obtaining the extended attributes
519  *      identified by @name for @dentry.
520  *      Return 0 if permission is granted.
521  * @inode_listxattr:
522  *      Check permission before obtaining the list of extended attribute
523  *      names for @dentry.
524  *      Return 0 if permission is granted.
525  * @inode_removexattr:
526  *      Check permission before removing the extended attribute
527  *      identified by @name for @dentry.
528  *      Return 0 if permission is granted.
529  * @inode_getsecurity:
530  *      Retrieve a copy of the extended attribute representation of the
531  *      security label associated with @name for @inode via @buffer.  Note that
532  *      @name is the remainder of the attribute name after the security prefix
533  *      has been removed. @alloc is used to specify of the call should return a
534  *      value via the buffer or just the value length Return size of buffer on
535  *      success.
536  * @inode_setsecurity:
537  *      Set the security label associated with @name for @inode from the
538  *      extended attribute value @value.  @size indicates the size of the
539  *      @value in bytes.  @flags may be XATTR_CREATE, XATTR_REPLACE, or 0.
540  *      Note that @name is the remainder of the attribute name after the
541  *      security. prefix has been removed.
542  *      Return 0 on success.
543  * @inode_listsecurity:
544  *      Copy the extended attribute names for the security labels
545  *      associated with @inode into @buffer.  The maximum size of @buffer
546  *      is specified by @buffer_size.  @buffer may be NULL to request
547  *      the size of the buffer required.
548  *      Returns number of bytes used/required on success.
549  * @inode_need_killpriv:
550  *      Called when an inode has been changed.
551  *      @dentry is the dentry being changed.
552  *      Return <0 on error to abort the inode change operation.
553  *      Return 0 if inode_killpriv does not need to be called.
554  *      Return >0 if inode_killpriv does need to be called.
555  * @inode_killpriv:
556  *      The setuid bit is being removed.  Remove similar security labels.
557  *      Called with the dentry->d_inode->i_mutex held.
558  *      @dentry is the dentry being changed.
559  *      Return 0 on success.  If error is returned, then the operation
560  *      causing setuid bit removal is failed.
561  * @inode_getsecid:
562  *      Get the secid associated with the node.
563  *      @inode contains a pointer to the inode.
564  *      @secid contains a pointer to the location where result will be saved.
565  *      In case of failure, @secid will be set to zero.
566  *
567  * Security hooks for file operations
568  *
569  * @file_permission:
570  *      Check file permissions before accessing an open file.  This hook is
571  *      called by various operations that read or write files.  A security
572  *      module can use this hook to perform additional checking on these
573  *      operations, e.g.  to revalidate permissions on use to support privilege
574  *      bracketing or policy changes.  Notice that this hook is used when the
575  *      actual read/write operations are performed, whereas the
576  *      inode_security_ops hook is called when a file is opened (as well as
577  *      many other operations).
578  *      Caveat:  Although this hook can be used to revalidate permissions for
579  *      various system call operations that read or write files, it does not
580  *      address the revalidation of permissions for memory-mapped files.
581  *      Security modules must handle this separately if they need such
582  *      revalidation.
583  *      @file contains the file structure being accessed.
584  *      @mask contains the requested permissions.
585  *      Return 0 if permission is granted.
586  * @file_alloc_security:
587  *      Allocate and attach a security structure to the file->f_security field.
588  *      The security field is initialized to NULL when the structure is first
589  *      created.
590  *      @file contains the file structure to secure.
591  *      Return 0 if the hook is successful and permission is granted.
592  * @file_free_security:
593  *      Deallocate and free any security structures stored in file->f_security.
594  *      @file contains the file structure being modified.
595  * @file_ioctl:
596  *      @file contains the file structure.
597  *      @cmd contains the operation to perform.
598  *      @arg contains the operational arguments.
599  *      Check permission for an ioctl operation on @file.  Note that @arg
600  *      sometimes represents a user space pointer; in other cases, it may be a
601  *      simple integer value.  When @arg represents a user space pointer, it
602  *      should never be used by the security module.
603  *      Return 0 if permission is granted.
604  * @mmap_addr :
605  *      Check permissions for a mmap operation at @addr.
606  *      @addr contains virtual address that will be used for the operation.
607  *      Return 0 if permission is granted.
608  * @mmap_file :
609  *      Check permissions for a mmap operation.  The @file may be NULL, e.g.
610  *      if mapping anonymous memory.
611  *      @file contains the file structure for file to map (may be NULL).
612  *      @reqprot contains the protection requested by the application.
613  *      @prot contains the protection that will be applied by the kernel.
614  *      @flags contains the operational flags.
615  *      Return 0 if permission is granted.
616  * @file_mprotect:
617  *      Check permissions before changing memory access permissions.
618  *      @vma contains the memory region to modify.
619  *      @reqprot contains the protection requested by the application.
620  *      @prot contains the protection that will be applied by the kernel.
621  *      Return 0 if permission is granted.
622  * @file_lock:
623  *      Check permission before performing file locking operations.
624  *      Note: this hook mediates both flock and fcntl style locks.
625  *      @file contains the file structure.
626  *      @cmd contains the posix-translated lock operation to perform
627  *      (e.g. F_RDLCK, F_WRLCK).
628  *      Return 0 if permission is granted.
629  * @file_fcntl:
630  *      Check permission before allowing the file operation specified by @cmd
631  *      from being performed on the file @file.  Note that @arg sometimes
632  *      represents a user space pointer; in other cases, it may be a simple
633  *      integer value.  When @arg represents a user space pointer, it should
634  *      never be used by the security module.
635  *      @file contains the file structure.
636  *      @cmd contains the operation to be performed.
637  *      @arg contains the operational arguments.
638  *      Return 0 if permission is granted.
639  * @file_set_fowner:
640  *      Save owner security information (typically from current->security) in
641  *      file->f_security for later use by the send_sigiotask hook.
642  *      @file contains the file structure to update.
643  *      Return 0 on success.
644  * @file_send_sigiotask:
645  *      Check permission for the file owner @fown to send SIGIO or SIGURG to the
646  *      process @tsk.  Note that this hook is sometimes called from interrupt.
647  *      Note that the fown_struct, @fown, is never outside the context of a
648  *      struct file, so the file structure (and associated security information)
649  *      can always be obtained:
650  *              container_of(fown, struct file, f_owner)
651  *      @tsk contains the structure of task receiving signal.
652  *      @fown contains the file owner information.
653  *      @sig is the signal that will be sent.  When 0, kernel sends SIGIO.
654  *      Return 0 if permission is granted.
655  * @file_receive:
656  *      This hook allows security modules to control the ability of a process
657  *      to receive an open file descriptor via socket IPC.
658  *      @file contains the file structure being received.
659  *      Return 0 if permission is granted.
660  * @file_open
661  *      Save open-time permission checking state for later use upon
662  *      file_permission, and recheck access if anything has changed
663  *      since inode_permission.
664  *
665  * Security hooks for task operations.
666  *
667  * @task_create:
668  *      Check permission before creating a child process.  See the clone(2)
669  *      manual page for definitions of the @clone_flags.
670  *      @clone_flags contains the flags indicating what should be shared.
671  *      Return 0 if permission is granted.
672  * @task_free:
673  *      @task task being freed
674  *      Handle release of task-related resources. (Note that this can be called
675  *      from interrupt context.)
676  * @cred_alloc_blank:
677  *      @cred points to the credentials.
678  *      @gfp indicates the atomicity of any memory allocations.
679  *      Only allocate sufficient memory and attach to @cred such that
680  *      cred_transfer() will not get ENOMEM.
681  * @cred_free:
682  *      @cred points to the credentials.
683  *      Deallocate and clear the cred->security field in a set of credentials.
684  * @cred_prepare:
685  *      @new points to the new credentials.
686  *      @old points to the original credentials.
687  *      @gfp indicates the atomicity of any memory allocations.
688  *      Prepare a new set of credentials by copying the data from the old set.
689  * @cred_transfer:
690  *      @new points to the new credentials.
691  *      @old points to the original credentials.
692  *      Transfer data from original creds to new creds
693  * @kernel_act_as:
694  *      Set the credentials for a kernel service to act as (subjective context).
695  *      @new points to the credentials to be modified.
696  *      @secid specifies the security ID to be set
697  *      The current task must be the one that nominated @secid.
698  *      Return 0 if successful.
699  * @kernel_create_files_as:
700  *      Set the file creation context in a set of credentials to be the same as
701  *      the objective context of the specified inode.
702  *      @new points to the credentials to be modified.
703  *      @inode points to the inode to use as a reference.
704  *      The current task must be the one that nominated @inode.
705  *      Return 0 if successful.
706  * @kernel_fw_from_file:
707  *      Load firmware from userspace (not called for built-in firmware).
708  *      @file contains the file structure pointing to the file containing
709  *      the firmware to load. This argument will be NULL if the firmware
710  *      was loaded via the uevent-triggered blob-based interface exposed
711  *      by CONFIG_FW_LOADER_USER_HELPER.
712  *      @buf pointer to buffer containing firmware contents.
713  *      @size length of the firmware contents.
714  *      Return 0 if permission is granted.
715  * @kernel_module_request:
716  *      Ability to trigger the kernel to automatically upcall to userspace for
717  *      userspace to load a kernel module with the given name.
718  *      @kmod_name name of the module requested by the kernel
719  *      Return 0 if successful.
720  * @kernel_module_from_file:
721  *      Load a kernel module from userspace.
722  *      @file contains the file structure pointing to the file containing
723  *      the kernel module to load. If the module is being loaded from a blob,
724  *      this argument will be NULL.
725  *      Return 0 if permission is granted.
726  * @task_fix_setuid:
727  *      Update the module's state after setting one or more of the user
728  *      identity attributes of the current process.  The @flags parameter
729  *      indicates which of the set*uid system calls invoked this hook.  If
730  *      @new is the set of credentials that will be installed.  Modifications
731  *      should be made to this rather than to @current->cred.
732  *      @old is the set of credentials that are being replaces
733  *      @flags contains one of the LSM_SETID_* values.
734  *      Return 0 on success.
735  * @task_setpgid:
736  *      Check permission before setting the process group identifier of the
737  *      process @p to @pgid.
738  *      @p contains the task_struct for process being modified.
739  *      @pgid contains the new pgid.
740  *      Return 0 if permission is granted.
741  * @task_getpgid:
742  *      Check permission before getting the process group identifier of the
743  *      process @p.
744  *      @p contains the task_struct for the process.
745  *      Return 0 if permission is granted.
746  * @task_getsid:
747  *      Check permission before getting the session identifier of the process
748  *      @p.
749  *      @p contains the task_struct for the process.
750  *      Return 0 if permission is granted.
751  * @task_getsecid:
752  *      Retrieve the security identifier of the process @p.
753  *      @p contains the task_struct for the process and place is into @secid.
754  *      In case of failure, @secid will be set to zero.
755  *
756  * @task_setnice:
757  *      Check permission before setting the nice value of @p to @nice.
758  *      @p contains the task_struct of process.
759  *      @nice contains the new nice value.
760  *      Return 0 if permission is granted.
761  * @task_setioprio
762  *      Check permission before setting the ioprio value of @p to @ioprio.
763  *      @p contains the task_struct of process.
764  *      @ioprio contains the new ioprio value
765  *      Return 0 if permission is granted.
766  * @task_getioprio
767  *      Check permission before getting the ioprio value of @p.
768  *      @p contains the task_struct of process.
769  *      Return 0 if permission is granted.
770  * @task_setrlimit:
771  *      Check permission before setting the resource limits of the current
772  *      process for @resource to @new_rlim.  The old resource limit values can
773  *      be examined by dereferencing (current->signal->rlim + resource).
774  *      @resource contains the resource whose limit is being set.
775  *      @new_rlim contains the new limits for @resource.
776  *      Return 0 if permission is granted.
777  * @task_setscheduler:
778  *      Check permission before setting scheduling policy and/or parameters of
779  *      process @p based on @policy and @lp.
780  *      @p contains the task_struct for process.
781  *      @policy contains the scheduling policy.
782  *      @lp contains the scheduling parameters.
783  *      Return 0 if permission is granted.
784  * @task_getscheduler:
785  *      Check permission before obtaining scheduling information for process
786  *      @p.
787  *      @p contains the task_struct for process.
788  *      Return 0 if permission is granted.
789  * @task_movememory
790  *      Check permission before moving memory owned by process @p.
791  *      @p contains the task_struct for process.
792  *      Return 0 if permission is granted.
793  * @task_kill:
794  *      Check permission before sending signal @sig to @p.  @info can be NULL,
795  *      the constant 1, or a pointer to a siginfo structure.  If @info is 1 or
796  *      SI_FROMKERNEL(info) is true, then the signal should be viewed as coming
797  *      from the kernel and should typically be permitted.
798  *      SIGIO signals are handled separately by the send_sigiotask hook in
799  *      file_security_ops.
800  *      @p contains the task_struct for process.
801  *      @info contains the signal information.
802  *      @sig contains the signal value.
803  *      @secid contains the sid of the process where the signal originated
804  *      Return 0 if permission is granted.
805  * @task_wait:
806  *      Check permission before allowing a process to reap a child process @p
807  *      and collect its status information.
808  *      @p contains the task_struct for process.
809  *      Return 0 if permission is granted.
810  * @task_prctl:
811  *      Check permission before performing a process control operation on the
812  *      current process.
813  *      @option contains the operation.
814  *      @arg2 contains a argument.
815  *      @arg3 contains a argument.
816  *      @arg4 contains a argument.
817  *      @arg5 contains a argument.
818  *      Return -ENOSYS if no-one wanted to handle this op, any other value to
819  *      cause prctl() to return immediately with that value.
820  * @task_to_inode:
821  *      Set the security attributes for an inode based on an associated task's
822  *      security attributes, e.g. for /proc/pid inodes.
823  *      @p contains the task_struct for the task.
824  *      @inode contains the inode structure for the inode.
825  *
826  * Security hooks for Netlink messaging.
827  *
828  * @netlink_send:
829  *      Save security information for a netlink message so that permission
830  *      checking can be performed when the message is processed.  The security
831  *      information can be saved using the eff_cap field of the
832  *      netlink_skb_parms structure.  Also may be used to provide fine
833  *      grained control over message transmission.
834  *      @sk associated sock of task sending the message.
835  *      @skb contains the sk_buff structure for the netlink message.
836  *      Return 0 if the information was successfully saved and message
837  *      is allowed to be transmitted.
838  *
839  * Security hooks for Unix domain networking.
840  *
841  * @unix_stream_connect:
842  *      Check permissions before establishing a Unix domain stream connection
843  *      between @sock and @other.
844  *      @sock contains the sock structure.
845  *      @other contains the peer sock structure.
846  *      @newsk contains the new sock structure.
847  *      Return 0 if permission is granted.
848  * @unix_may_send:
849  *      Check permissions before connecting or sending datagrams from @sock to
850  *      @other.
851  *      @sock contains the socket structure.
852  *      @other contains the peer socket structure.
853  *      Return 0 if permission is granted.
854  *
855  * The @unix_stream_connect and @unix_may_send hooks were necessary because
856  * Linux provides an alternative to the conventional file name space for Unix
857  * domain sockets.  Whereas binding and connecting to sockets in the file name
858  * space is mediated by the typical file permissions (and caught by the mknod
859  * and permission hooks in inode_security_ops), binding and connecting to
860  * sockets in the abstract name space is completely unmediated.  Sufficient
861  * control of Unix domain sockets in the abstract name space isn't possible
862  * using only the socket layer hooks, since we need to know the actual target
863  * socket, which is not looked up until we are inside the af_unix code.
864  *
865  * Security hooks for socket operations.
866  *
867  * @socket_create:
868  *      Check permissions prior to creating a new socket.
869  *      @family contains the requested protocol family.
870  *      @type contains the requested communications type.
871  *      @protocol contains the requested protocol.
872  *      @kern set to 1 if a kernel socket.
873  *      Return 0 if permission is granted.
874  * @socket_post_create:
875  *      This hook allows a module to update or allocate a per-socket security
876  *      structure. Note that the security field was not added directly to the
877  *      socket structure, but rather, the socket security information is stored
878  *      in the associated inode.  Typically, the inode alloc_security hook will
879  *      allocate and and attach security information to
880  *      sock->inode->i_security.  This hook may be used to update the
881  *      sock->inode->i_security field with additional information that wasn't
882  *      available when the inode was allocated.
883  *      @sock contains the newly created socket structure.
884  *      @family contains the requested protocol family.
885  *      @type contains the requested communications type.
886  *      @protocol contains the requested protocol.
887  *      @kern set to 1 if a kernel socket.
888  * @socket_bind:
889  *      Check permission before socket protocol layer bind operation is
890  *      performed and the socket @sock is bound to the address specified in the
891  *      @address parameter.
892  *      @sock contains the socket structure.
893  *      @address contains the address to bind to.
894  *      @addrlen contains the length of address.
895  *      Return 0 if permission is granted.
896  * @socket_connect:
897  *      Check permission before socket protocol layer connect operation
898  *      attempts to connect socket @sock to a remote address, @address.
899  *      @sock contains the socket structure.
900  *      @address contains the address of remote endpoint.
901  *      @addrlen contains the length of address.
902  *      Return 0 if permission is granted.
903  * @socket_listen:
904  *      Check permission before socket protocol layer listen operation.
905  *      @sock contains the socket structure.
906  *      @backlog contains the maximum length for the pending connection queue.
907  *      Return 0 if permission is granted.
908  * @socket_accept:
909  *      Check permission before accepting a new connection.  Note that the new
910  *      socket, @newsock, has been created and some information copied to it,
911  *      but the accept operation has not actually been performed.
912  *      @sock contains the listening socket structure.
913  *      @newsock contains the newly created server socket for connection.
914  *      Return 0 if permission is granted.
915  * @socket_sendmsg:
916  *      Check permission before transmitting a message to another socket.
917  *      @sock contains the socket structure.
918  *      @msg contains the message to be transmitted.
919  *      @size contains the size of message.
920  *      Return 0 if permission is granted.
921  * @socket_recvmsg:
922  *      Check permission before receiving a message from a socket.
923  *      @sock contains the socket structure.
924  *      @msg contains the message structure.
925  *      @size contains the size of message structure.
926  *      @flags contains the operational flags.
927  *      Return 0 if permission is granted.
928  * @socket_getsockname:
929  *      Check permission before the local address (name) of the socket object
930  *      @sock is retrieved.
931  *      @sock contains the socket structure.
932  *      Return 0 if permission is granted.
933  * @socket_getpeername:
934  *      Check permission before the remote address (name) of a socket object
935  *      @sock is retrieved.
936  *      @sock contains the socket structure.
937  *      Return 0 if permission is granted.
938  * @socket_getsockopt:
939  *      Check permissions before retrieving the options associated with socket
940  *      @sock.
941  *      @sock contains the socket structure.
942  *      @level contains the protocol level to retrieve option from.
943  *      @optname contains the name of option to retrieve.
944  *      Return 0 if permission is granted.
945  * @socket_setsockopt:
946  *      Check permissions before setting the options associated with socket
947  *      @sock.
948  *      @sock contains the socket structure.
949  *      @level contains the protocol level to set options for.
950  *      @optname contains the name of the option to set.
951  *      Return 0 if permission is granted.
952  * @socket_shutdown:
953  *      Checks permission before all or part of a connection on the socket
954  *      @sock is shut down.
955  *      @sock contains the socket structure.
956  *      @how contains the flag indicating how future sends and receives are handled.
957  *      Return 0 if permission is granted.
958  * @socket_sock_rcv_skb:
959  *      Check permissions on incoming network packets.  This hook is distinct
960  *      from Netfilter's IP input hooks since it is the first time that the
961  *      incoming sk_buff @skb has been associated with a particular socket, @sk.
962  *      Must not sleep inside this hook because some callers hold spinlocks.
963  *      @sk contains the sock (not socket) associated with the incoming sk_buff.
964  *      @skb contains the incoming network data.
965  * @socket_getpeersec_stream:
966  *      This hook allows the security module to provide peer socket security
967  *      state for unix or connected tcp sockets to userspace via getsockopt
968  *      SO_GETPEERSEC.  For tcp sockets this can be meaningful if the
969  *      socket is associated with an ipsec SA.
970  *      @sock is the local socket.
971  *      @optval userspace memory where the security state is to be copied.
972  *      @optlen userspace int where the module should copy the actual length
973  *      of the security state.
974  *      @len as input is the maximum length to copy to userspace provided
975  *      by the caller.
976  *      Return 0 if all is well, otherwise, typical getsockopt return
977  *      values.
978  * @socket_getpeersec_dgram:
979  *      This hook allows the security module to provide peer socket security
980  *      state for udp sockets on a per-packet basis to userspace via
981  *      getsockopt SO_GETPEERSEC.  The application must first have indicated
982  *      the IP_PASSSEC option via getsockopt.  It can then retrieve the
983  *      security state returned by this hook for a packet via the SCM_SECURITY
984  *      ancillary message type.
985  *      @skb is the skbuff for the packet being queried
986  *      @secdata is a pointer to a buffer in which to copy the security data
987  *      @seclen is the maximum length for @secdata
988  *      Return 0 on success, error on failure.
989  * @sk_alloc_security:
990  *      Allocate and attach a security structure to the sk->sk_security field,
991  *      which is used to copy security attributes between local stream sockets.
992  * @sk_free_security:
993  *      Deallocate security structure.
994  * @sk_clone_security:
995  *      Clone/copy security structure.
996  * @sk_getsecid:
997  *      Retrieve the LSM-specific secid for the sock to enable caching of network
998  *      authorizations.
999  * @sock_graft:
1000  *      Sets the socket's isec sid to the sock's sid.
1001  * @inet_conn_request:
1002  *      Sets the openreq's sid to socket's sid with MLS portion taken from peer sid.
1003  * @inet_csk_clone:
1004  *      Sets the new child socket's sid to the openreq sid.
1005  * @inet_conn_established:
1006  *      Sets the connection's peersid to the secmark on skb.
1007  * @secmark_relabel_packet:
1008  *      check if the process should be allowed to relabel packets to the given secid
1009  * @security_secmark_refcount_inc
1010  *      tells the LSM to increment the number of secmark labeling rules loaded
1011  * @security_secmark_refcount_dec
1012  *      tells the LSM to decrement the number of secmark labeling rules loaded
1013  * @req_classify_flow:
1014  *      Sets the flow's sid to the openreq sid.
1015  * @tun_dev_alloc_security:
1016  *      This hook allows a module to allocate a security structure for a TUN
1017  *      device.
1018  *      @security pointer to a security structure pointer.
1019  *      Returns a zero on success, negative values on failure.
1020  * @tun_dev_free_security:
1021  *      This hook allows a module to free the security structure for a TUN
1022  *      device.
1023  *      @security pointer to the TUN device's security structure
1024  * @tun_dev_create:
1025  *      Check permissions prior to creating a new TUN device.
1026  * @tun_dev_attach_queue:
1027  *      Check permissions prior to attaching to a TUN device queue.
1028  *      @security pointer to the TUN device's security structure.
1029  * @tun_dev_attach:
1030  *      This hook can be used by the module to update any security state
1031  *      associated with the TUN device's sock structure.
1032  *      @sk contains the existing sock structure.
1033  *      @security pointer to the TUN device's security structure.
1034  * @tun_dev_open:
1035  *      This hook can be used by the module to update any security state
1036  *      associated with the TUN device's security structure.
1037  *      @security pointer to the TUN devices's security structure.
1038  * @skb_owned_by:
1039  *      This hook sets the packet's owning sock.
1040  *      @skb is the packet.
1041  *      @sk the sock which owns the packet.
1042  *
1043  * Security hooks for XFRM operations.
1044  *
1045  * @xfrm_policy_alloc_security:
1046  *      @ctxp is a pointer to the xfrm_sec_ctx being added to Security Policy
1047  *      Database used by the XFRM system.
1048  *      @sec_ctx contains the security context information being provided by
1049  *      the user-level policy update program (e.g., setkey).
1050  *      Allocate a security structure to the xp->security field; the security
1051  *      field is initialized to NULL when the xfrm_policy is allocated.
1052  *      Return 0 if operation was successful (memory to allocate, legal context)
1053  *      @gfp is to specify the context for the allocation
1054  * @xfrm_policy_clone_security:
1055  *      @old_ctx contains an existing xfrm_sec_ctx.
1056  *      @new_ctxp contains a new xfrm_sec_ctx being cloned from old.
1057  *      Allocate a security structure in new_ctxp that contains the
1058  *      information from the old_ctx structure.
1059  *      Return 0 if operation was successful (memory to allocate).
1060  * @xfrm_policy_free_security:
1061  *      @ctx contains the xfrm_sec_ctx
1062  *      Deallocate xp->security.
1063  * @xfrm_policy_delete_security:
1064  *      @ctx contains the xfrm_sec_ctx.
1065  *      Authorize deletion of xp->security.
1066  * @xfrm_state_alloc:
1067  *      @x contains the xfrm_state being added to the Security Association
1068  *      Database by the XFRM system.
1069  *      @sec_ctx contains the security context information being provided by
1070  *      the user-level SA generation program (e.g., setkey or racoon).
1071  *      Allocate a security structure to the x->security field; the security
1072  *      field is initialized to NULL when the xfrm_state is allocated. Set the
1073  *      context to correspond to sec_ctx. Return 0 if operation was successful
1074  *      (memory to allocate, legal context).
1075  * @xfrm_state_alloc_acquire:
1076  *      @x contains the xfrm_state being added to the Security Association
1077  *      Database by the XFRM system.
1078  *      @polsec contains the policy's security context.
1079  *      @secid contains the secid from which to take the mls portion of the
1080  *      context.
1081  *      Allocate a security structure to the x->security field; the security
1082  *      field is initialized to NULL when the xfrm_state is allocated. Set the
1083  *      context to correspond to secid. Return 0 if operation was successful
1084  *      (memory to allocate, legal context).
1085  * @xfrm_state_free_security:
1086  *      @x contains the xfrm_state.
1087  *      Deallocate x->security.
1088  * @xfrm_state_delete_security:
1089  *      @x contains the xfrm_state.
1090  *      Authorize deletion of x->security.
1091  * @xfrm_policy_lookup:
1092  *      @ctx contains the xfrm_sec_ctx for which the access control is being
1093  *      checked.
1094  *      @fl_secid contains the flow security label that is used to authorize
1095  *      access to the policy xp.
1096  *      @dir contains the direction of the flow (input or output).
1097  *      Check permission when a flow selects a xfrm_policy for processing
1098  *      XFRMs on a packet.  The hook is called when selecting either a
1099  *      per-socket policy or a generic xfrm policy.
1100  *      Return 0 if permission is granted, -ESRCH otherwise, or -errno
1101  *      on other errors.
1102  * @xfrm_state_pol_flow_match:
1103  *      @x contains the state to match.
1104  *      @xp contains the policy to check for a match.
1105  *      @fl contains the flow to check for a match.
1106  *      Return 1 if there is a match.
1107  * @xfrm_decode_session:
1108  *      @skb points to skb to decode.
1109  *      @secid points to the flow key secid to set.
1110  *      @ckall says if all xfrms used should be checked for same secid.
1111  *      Return 0 if ckall is zero or all xfrms used have the same secid.
1112  *
1113  * Security hooks affecting all Key Management operations
1114  *
1115  * @key_alloc:
1116  *      Permit allocation of a key and assign security data. Note that key does
1117  *      not have a serial number assigned at this point.
1118  *      @key points to the key.
1119  *      @flags is the allocation flags
1120  *      Return 0 if permission is granted, -ve error otherwise.
1121  * @key_free:
1122  *      Notification of destruction; free security data.
1123  *      @key points to the key.
1124  *      No return value.
1125  * @key_permission:
1126  *      See whether a specific operational right is granted to a process on a
1127  *      key.
1128  *      @key_ref refers to the key (key pointer + possession attribute bit).
1129  *      @cred points to the credentials to provide the context against which to
1130  *      evaluate the security data on the key.
1131  *      @perm describes the combination of permissions required of this key.
1132  *      Return 0 if permission is granted, -ve error otherwise.
1133  * @key_getsecurity:
1134  *      Get a textual representation of the security context attached to a key
1135  *      for the purposes of honouring KEYCTL_GETSECURITY.  This function
1136  *      allocates the storage for the NUL-terminated string and the caller
1137  *      should free it.
1138  *      @key points to the key to be queried.
1139  *      @_buffer points to a pointer that should be set to point to the
1140  *      resulting string (if no label or an error occurs).
1141  *      Return the length of the string (including terminating NUL) or -ve if
1142  *      an error.
1143  *      May also return 0 (and a NULL buffer pointer) if there is no label.
1144  *
1145  * Security hooks affecting all System V IPC operations.
1146  *
1147  * @ipc_permission:
1148  *      Check permissions for access to IPC
1149  *      @ipcp contains the kernel IPC permission structure
1150  *      @flag contains the desired (requested) permission set
1151  *      Return 0 if permission is granted.
1152  * @ipc_getsecid:
1153  *      Get the secid associated with the ipc object.
1154  *      @ipcp contains the kernel IPC permission structure.
1155  *      @secid contains a pointer to the location where result will be saved.
1156  *      In case of failure, @secid will be set to zero.
1157  *
1158  * Security hooks for individual messages held in System V IPC message queues
1159  * @msg_msg_alloc_security:
1160  *      Allocate and attach a security structure to the msg->security field.
1161  *      The security field is initialized to NULL when the structure is first
1162  *      created.
1163  *      @msg contains the message structure to be modified.
1164  *      Return 0 if operation was successful and permission is granted.
1165  * @msg_msg_free_security:
1166  *      Deallocate the security structure for this message.
1167  *      @msg contains the message structure to be modified.
1168  *
1169  * Security hooks for System V IPC Message Queues
1170  *
1171  * @msg_queue_alloc_security:
1172  *      Allocate and attach a security structure to the
1173  *      msq->q_perm.security field. The security field is initialized to
1174  *      NULL when the structure is first created.
1175  *      @msq contains the message queue structure to be modified.
1176  *      Return 0 if operation was successful and permission is granted.
1177  * @msg_queue_free_security:
1178  *      Deallocate security structure for this message queue.
1179  *      @msq contains the message queue structure to be modified.
1180  * @msg_queue_associate:
1181  *      Check permission when a message queue is requested through the
1182  *      msgget system call.  This hook is only called when returning the
1183  *      message queue identifier for an existing message queue, not when a
1184  *      new message queue is created.
1185  *      @msq contains the message queue to act upon.
1186  *      @msqflg contains the operation control flags.
1187  *      Return 0 if permission is granted.
1188  * @msg_queue_msgctl:
1189  *      Check permission when a message control operation specified by @cmd
1190  *      is to be performed on the message queue @msq.
1191  *      The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO.
1192  *      @msq contains the message queue to act upon.  May be NULL.
1193  *      @cmd contains the operation to be performed.
1194  *      Return 0 if permission is granted.
1195  * @msg_queue_msgsnd:
1196  *      Check permission before a message, @msg, is enqueued on the message
1197  *      queue, @msq.
1198  *      @msq contains the message queue to send message to.
1199  *      @msg contains the message to be enqueued.
1200  *      @msqflg contains operational flags.
1201  *      Return 0 if permission is granted.
1202  * @msg_queue_msgrcv:
1203  *      Check permission before a message, @msg, is removed from the message
1204  *      queue, @msq.  The @target task structure contains a pointer to the
1205  *      process that will be receiving the message (not equal to the current
1206  *      process when inline receives are being performed).
1207  *      @msq contains the message queue to retrieve message from.
1208  *      @msg contains the message destination.
1209  *      @target contains the task structure for recipient process.
1210  *      @type contains the type of message requested.
1211  *      @mode contains the operational flags.
1212  *      Return 0 if permission is granted.
1213  *
1214  * Security hooks for System V Shared Memory Segments
1215  *
1216  * @shm_alloc_security:
1217  *      Allocate and attach a security structure to the shp->shm_perm.security
1218  *      field.  The security field is initialized to NULL when the structure is
1219  *      first created.
1220  *      @shp contains the shared memory structure to be modified.
1221  *      Return 0 if operation was successful and permission is granted.
1222  * @shm_free_security:
1223  *      Deallocate the security struct for this memory segment.
1224  *      @shp contains the shared memory structure to be modified.
1225  * @shm_associate:
1226  *      Check permission when a shared memory region is requested through the
1227  *      shmget system call.  This hook is only called when returning the shared
1228  *      memory region identifier for an existing region, not when a new shared
1229  *      memory region is created.
1230  *      @shp contains the shared memory structure to be modified.
1231  *      @shmflg contains the operation control flags.
1232  *      Return 0 if permission is granted.
1233  * @shm_shmctl:
1234  *      Check permission when a shared memory control operation specified by
1235  *      @cmd is to be performed on the shared memory region @shp.
1236  *      The @shp may be NULL, e.g. for IPC_INFO or SHM_INFO.
1237  *      @shp contains shared memory structure to be modified.
1238  *      @cmd contains the operation to be performed.
1239  *      Return 0 if permission is granted.
1240  * @shm_shmat:
1241  *      Check permissions prior to allowing the shmat system call to attach the
1242  *      shared memory segment @shp to the data segment of the calling process.
1243  *      The attaching address is specified by @shmaddr.
1244  *      @shp contains the shared memory structure to be modified.
1245  *      @shmaddr contains the address to attach memory region to.
1246  *      @shmflg contains the operational flags.
1247  *      Return 0 if permission is granted.
1248  *
1249  * Security hooks for System V Semaphores
1250  *
1251  * @sem_alloc_security:
1252  *      Allocate and attach a security structure to the sma->sem_perm.security
1253  *      field.  The security field is initialized to NULL when the structure is
1254  *      first created.
1255  *      @sma contains the semaphore structure
1256  *      Return 0 if operation was successful and permission is granted.
1257  * @sem_free_security:
1258  *      deallocate security struct for this semaphore
1259  *      @sma contains the semaphore structure.
1260  * @sem_associate:
1261  *      Check permission when a semaphore is requested through the semget
1262  *      system call.  This hook is only called when returning the semaphore
1263  *      identifier for an existing semaphore, not when a new one must be
1264  *      created.
1265  *      @sma contains the semaphore structure.
1266  *      @semflg contains the operation control flags.
1267  *      Return 0 if permission is granted.
1268  * @sem_semctl:
1269  *      Check permission when a semaphore operation specified by @cmd is to be
1270  *      performed on the semaphore @sma.  The @sma may be NULL, e.g. for
1271  *      IPC_INFO or SEM_INFO.
1272  *      @sma contains the semaphore structure.  May be NULL.
1273  *      @cmd contains the operation to be performed.
1274  *      Return 0 if permission is granted.
1275  * @sem_semop
1276  *      Check permissions before performing operations on members of the
1277  *      semaphore set @sma.  If the @alter flag is nonzero, the semaphore set
1278  *      may be modified.
1279  *      @sma contains the semaphore structure.
1280  *      @sops contains the operations to perform.
1281  *      @nsops contains the number of operations to perform.
1282  *      @alter contains the flag indicating whether changes are to be made.
1283  *      Return 0 if permission is granted.
1284  *
1285  * @binder_set_context_mgr
1286  *      Check whether @mgr is allowed to be the binder context manager.
1287  *      @mgr contains the task_struct for the task being registered.
1288  *      Return 0 if permission is granted.
1289  * @binder_transaction
1290  *      Check whether @from is allowed to invoke a binder transaction call
1291  *      to @to.
1292  *      @from contains the task_struct for the sending task.
1293  *      @to contains the task_struct for the receiving task.
1294  * @binder_transfer_binder
1295  *      Check whether @from is allowed to transfer a binder reference to @to.
1296  *      @from contains the task_struct for the sending task.
1297  *      @to contains the task_struct for the receiving task.
1298  * @binder_transfer_file
1299  *      Check whether @from is allowed to transfer @file to @to.
1300  *      @from contains the task_struct for the sending task.
1301  *      @file contains the struct file being transferred.
1302  *      @to contains the task_struct for the receiving task.
1303  *
1304  * @ptrace_access_check:
1305  *      Check permission before allowing the current process to trace the
1306  *      @child process.
1307  *      Security modules may also want to perform a process tracing check
1308  *      during an execve in the set_security or apply_creds hooks of
1309  *      tracing check during an execve in the bprm_set_creds hook of
1310  *      binprm_security_ops if the process is being traced and its security
1311  *      attributes would be changed by the execve.
1312  *      @child contains the task_struct structure for the target process.
1313  *      @mode contains the PTRACE_MODE flags indicating the form of access.
1314  *      Return 0 if permission is granted.
1315  * @ptrace_traceme:
1316  *      Check that the @parent process has sufficient permission to trace the
1317  *      current process before allowing the current process to present itself
1318  *      to the @parent process for tracing.
1319  *      @parent contains the task_struct structure for debugger process.
1320  *      Return 0 if permission is granted.
1321  * @capget:
1322  *      Get the @effective, @inheritable, and @permitted capability sets for
1323  *      the @target process.  The hook may also perform permission checking to
1324  *      determine if the current process is allowed to see the capability sets
1325  *      of the @target process.
1326  *      @target contains the task_struct structure for target process.
1327  *      @effective contains the effective capability set.
1328  *      @inheritable contains the inheritable capability set.
1329  *      @permitted contains the permitted capability set.
1330  *      Return 0 if the capability sets were successfully obtained.
1331  * @capset:
1332  *      Set the @effective, @inheritable, and @permitted capability sets for
1333  *      the current process.
1334  *      @new contains the new credentials structure for target process.
1335  *      @old contains the current credentials structure for target process.
1336  *      @effective contains the effective capability set.
1337  *      @inheritable contains the inheritable capability set.
1338  *      @permitted contains the permitted capability set.
1339  *      Return 0 and update @new if permission is granted.
1340  * @capable:
1341  *      Check whether the @tsk process has the @cap capability in the indicated
1342  *      credentials.
1343  *      @cred contains the credentials to use.
1344  *      @ns contains the user namespace we want the capability in
1345  *      @cap contains the capability <include/linux/capability.h>.
1346  *      @audit: Whether to write an audit message or not
1347  *      Return 0 if the capability is granted for @tsk.
1348  * @syslog:
1349  *      Check permission before accessing the kernel message ring or changing
1350  *      logging to the console.
1351  *      See the syslog(2) manual page for an explanation of the @type values.
1352  *      @type contains the type of action.
1353  *      @from_file indicates the context of action (if it came from /proc).
1354  *      Return 0 if permission is granted.
1355  * @settime:
1356  *      Check permission to change the system time.
1357  *      struct timespec and timezone are defined in include/linux/time.h
1358  *      @ts contains new time
1359  *      @tz contains new timezone
1360  *      Return 0 if permission is granted.
1361  * @vm_enough_memory:
1362  *      Check permissions for allocating a new virtual mapping.
1363  *      @mm contains the mm struct it is being added to.
1364  *      @pages contains the number of pages.
1365  *      Return 0 if permission is granted.
1366  *
1367  * @ismaclabel:
1368  *      Check if the extended attribute specified by @name
1369  *      represents a MAC label. Returns 1 if name is a MAC
1370  *      attribute otherwise returns 0.
1371  *      @name full extended attribute name to check against
1372  *      LSM as a MAC label.
1373  *
1374  * @secid_to_secctx:
1375  *      Convert secid to security context.  If secdata is NULL the length of
1376  *      the result will be returned in seclen, but no secdata will be returned.
1377  *      This does mean that the length could change between calls to check the
1378  *      length and the next call which actually allocates and returns the secdata.
1379  *      @secid contains the security ID.
1380  *      @secdata contains the pointer that stores the converted security context.
1381  *      @seclen pointer which contains the length of the data
1382  * @secctx_to_secid:
1383  *      Convert security context to secid.
1384  *      @secid contains the pointer to the generated security ID.
1385  *      @secdata contains the security context.
1386  *
1387  * @release_secctx:
1388  *      Release the security context.
1389  *      @secdata contains the security context.
1390  *      @seclen contains the length of the security context.
1391  *
1392  * Security hooks for Audit
1393  *
1394  * @audit_rule_init:
1395  *      Allocate and initialize an LSM audit rule structure.
1396  *      @field contains the required Audit action. Fields flags are defined in include/linux/audit.h
1397  *      @op contains the operator the rule uses.
1398  *      @rulestr contains the context where the rule will be applied to.
1399  *      @lsmrule contains a pointer to receive the result.
1400  *      Return 0 if @lsmrule has been successfully set,
1401  *      -EINVAL in case of an invalid rule.
1402  *
1403  * @audit_rule_known:
1404  *      Specifies whether given @rule contains any fields related to current LSM.
1405  *      @rule contains the audit rule of interest.
1406  *      Return 1 in case of relation found, 0 otherwise.
1407  *
1408  * @audit_rule_match:
1409  *      Determine if given @secid matches a rule previously approved
1410  *      by @audit_rule_known.
1411  *      @secid contains the security id in question.
1412  *      @field contains the field which relates to current LSM.
1413  *      @op contains the operator that will be used for matching.
1414  *      @rule points to the audit rule that will be checked against.
1415  *      @actx points to the audit context associated with the check.
1416  *      Return 1 if secid matches the rule, 0 if it does not, -ERRNO on failure.
1417  *
1418  * @audit_rule_free:
1419  *      Deallocate the LSM audit rule structure previously allocated by
1420  *      audit_rule_init.
1421  *      @rule contains the allocated rule
1422  *
1423  * @inode_notifysecctx:
1424  *      Notify the security module of what the security context of an inode
1425  *      should be.  Initializes the incore security context managed by the
1426  *      security module for this inode.  Example usage:  NFS client invokes
1427  *      this hook to initialize the security context in its incore inode to the
1428  *      value provided by the server for the file when the server returned the
1429  *      file's attributes to the client.
1430  *
1431  *      Must be called with inode->i_mutex locked.
1432  *
1433  *      @inode we wish to set the security context of.
1434  *      @ctx contains the string which we wish to set in the inode.
1435  *      @ctxlen contains the length of @ctx.
1436  *
1437  * @inode_setsecctx:
1438  *      Change the security context of an inode.  Updates the
1439  *      incore security context managed by the security module and invokes the
1440  *      fs code as needed (via __vfs_setxattr_noperm) to update any backing
1441  *      xattrs that represent the context.  Example usage:  NFS server invokes
1442  *      this hook to change the security context in its incore inode and on the
1443  *      backing filesystem to a value provided by the client on a SETATTR
1444  *      operation.
1445  *
1446  *      Must be called with inode->i_mutex locked.
1447  *
1448  *      @dentry contains the inode we wish to set the security context of.
1449  *      @ctx contains the string which we wish to set in the inode.
1450  *      @ctxlen contains the length of @ctx.
1451  *
1452  * @inode_getsecctx:
1453  *      On success, returns 0 and fills out @ctx and @ctxlen with the security
1454  *      context for the given @inode.
1455  *
1456  *      @inode we wish to get the security context of.
1457  *      @ctx is a pointer in which to place the allocated security context.
1458  *      @ctxlen points to the place to put the length of @ctx.
1459  * This is the main security structure.
1460  */
1461 struct security_operations {
1462         char name[SECURITY_NAME_MAX + 1];
1463 
1464         int (*binder_set_context_mgr) (struct task_struct *mgr);
1465         int (*binder_transaction) (struct task_struct *from,
1466                                    struct task_struct *to);
1467         int (*binder_transfer_binder) (struct task_struct *from,
1468                                        struct task_struct *to);
1469         int (*binder_transfer_file) (struct task_struct *from,
1470                                      struct task_struct *to, struct file *file);
1471 
1472         int (*ptrace_access_check) (struct task_struct *child, unsigned int mode);
1473         int (*ptrace_traceme) (struct task_struct *parent);
1474         int (*capget) (struct task_struct *target,
1475                        kernel_cap_t *effective,
1476                        kernel_cap_t *inheritable, kernel_cap_t *permitted);
1477         int (*capset) (struct cred *new,
1478                        const struct cred *old,
1479                        const kernel_cap_t *effective,
1480                        const kernel_cap_t *inheritable,
1481                        const kernel_cap_t *permitted);
1482         int (*capable) (const struct cred *cred, struct user_namespace *ns,
1483                         int cap, int audit);
1484         int (*quotactl) (int cmds, int type, int id, struct super_block *sb);
1485         int (*quota_on) (struct dentry *dentry);
1486         int (*syslog) (int type);
1487         int (*settime) (const struct timespec *ts, const struct timezone *tz);
1488         int (*vm_enough_memory) (struct mm_struct *mm, long pages);
1489 
1490         int (*bprm_set_creds) (struct linux_binprm *bprm);
1491         int (*bprm_check_security) (struct linux_binprm *bprm);
1492         int (*bprm_secureexec) (struct linux_binprm *bprm);
1493         void (*bprm_committing_creds) (struct linux_binprm *bprm);
1494         void (*bprm_committed_creds) (struct linux_binprm *bprm);
1495 
1496         int (*sb_alloc_security) (struct super_block *sb);
1497         void (*sb_free_security) (struct super_block *sb);
1498         int (*sb_copy_data) (char *orig, char *copy);
1499         int (*sb_remount) (struct super_block *sb, void *data);
1500         int (*sb_kern_mount) (struct super_block *sb, int flags, void *data);
1501         int (*sb_show_options) (struct seq_file *m, struct super_block *sb);
1502         int (*sb_statfs) (struct dentry *dentry);
1503         int (*sb_mount) (const char *dev_name, struct path *path,
1504                          const char *type, unsigned long flags, void *data);
1505         int (*sb_umount) (struct vfsmount *mnt, int flags);
1506         int (*sb_pivotroot) (struct path *old_path,
1507                              struct path *new_path);
1508         int (*sb_set_mnt_opts) (struct super_block *sb,
1509                                 struct security_mnt_opts *opts,
1510                                 unsigned long kern_flags,
1511                                 unsigned long *set_kern_flags);
1512         int (*sb_clone_mnt_opts) (const struct super_block *oldsb,
1513                                    struct super_block *newsb);
1514         int (*sb_parse_opts_str) (char *options, struct security_mnt_opts *opts);
1515         int (*dentry_init_security) (struct dentry *dentry, int mode,
1516                                         struct qstr *name, void **ctx,
1517                                         u32 *ctxlen);
1518 
1519 
1520 #ifdef CONFIG_SECURITY_PATH
1521         int (*path_unlink) (struct path *dir, struct dentry *dentry);
1522         int (*path_mkdir) (struct path *dir, struct dentry *dentry, umode_t mode);
1523         int (*path_rmdir) (struct path *dir, struct dentry *dentry);
1524         int (*path_mknod) (struct path *dir, struct dentry *dentry, umode_t mode,
1525                            unsigned int dev);
1526         int (*path_truncate) (struct path *path);
1527         int (*path_symlink) (struct path *dir, struct dentry *dentry,
1528                              const char *old_name);
1529         int (*path_link) (struct dentry *old_dentry, struct path *new_dir,
1530                           struct dentry *new_dentry);
1531         int (*path_rename) (struct path *old_dir, struct dentry *old_dentry,
1532                             struct path *new_dir, struct dentry *new_dentry);
1533         int (*path_chmod) (struct path *path, umode_t mode);
1534         int (*path_chown) (struct path *path, kuid_t uid, kgid_t gid);
1535         int (*path_chroot) (struct path *path);
1536 #endif
1537 
1538         int (*inode_alloc_security) (struct inode *inode);
1539         void (*inode_free_security) (struct inode *inode);
1540         int (*inode_init_security) (struct inode *inode, struct inode *dir,
1541                                     const struct qstr *qstr, const char **name,
1542                                     void **value, size_t *len);
1543         int (*inode_create) (struct inode *dir,
1544                              struct dentry *dentry, umode_t mode);
1545         int (*inode_link) (struct dentry *old_dentry,
1546                            struct inode *dir, struct dentry *new_dentry);
1547         int (*inode_unlink) (struct inode *dir, struct dentry *dentry);
1548         int (*inode_symlink) (struct inode *dir,
1549                               struct dentry *dentry, const char *old_name);
1550         int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, umode_t mode);
1551         int (*inode_rmdir) (struct inode *dir, struct dentry *dentry);
1552         int (*inode_mknod) (struct inode *dir, struct dentry *dentry,
1553                             umode_t mode, dev_t dev);
1554         int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
1555                              struct inode *new_dir, struct dentry *new_dentry);
1556         int (*inode_readlink) (struct dentry *dentry);
1557         int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
1558         int (*inode_permission) (struct inode *inode, int mask);
1559         int (*inode_setattr)    (struct dentry *dentry, struct iattr *attr);
1560         int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
1561         int (*inode_setxattr) (struct dentry *dentry, const char *name,
1562                                const void *value, size_t size, int flags);
1563         void (*inode_post_setxattr) (struct dentry *dentry, const char *name,
1564                                      const void *value, size_t size, int flags);
1565         int (*inode_getxattr) (struct dentry *dentry, const char *name);
1566         int (*inode_listxattr) (struct dentry *dentry);
1567         int (*inode_removexattr) (struct dentry *dentry, const char *name);
1568         int (*inode_need_killpriv) (struct dentry *dentry);
1569         int (*inode_killpriv) (struct dentry *dentry);
1570         int (*inode_getsecurity) (const struct inode *inode, const char *name, void **buffer, bool alloc);
1571         int (*inode_setsecurity) (struct inode *inode, const char *name, const void *value, size_t size, int flags);
1572         int (*inode_listsecurity) (struct inode *inode, char *buffer, size_t buffer_size);
1573         void (*inode_getsecid) (const struct inode *inode, u32 *secid);
1574 
1575         int (*file_permission) (struct file *file, int mask);
1576         int (*file_alloc_security) (struct file *file);
1577         void (*file_free_security) (struct file *file);
1578         int (*file_ioctl) (struct file *file, unsigned int cmd,
1579                            unsigned long arg);
1580         int (*mmap_addr) (unsigned long addr);
1581         int (*mmap_file) (struct file *file,
1582                           unsigned long reqprot, unsigned long prot,
1583                           unsigned long flags);
1584         int (*file_mprotect) (struct vm_area_struct *vma,
1585                               unsigned long reqprot,
1586                               unsigned long prot);
1587         int (*file_lock) (struct file *file, unsigned int cmd);
1588         int (*file_fcntl) (struct file *file, unsigned int cmd,
1589                            unsigned long arg);
1590         void (*file_set_fowner) (struct file *file);
1591         int (*file_send_sigiotask) (struct task_struct *tsk,
1592                                     struct fown_struct *fown, int sig);
1593         int (*file_receive) (struct file *file);
1594         int (*file_open) (struct file *file, const struct cred *cred);
1595 
1596         int (*task_create) (unsigned long clone_flags);
1597         void (*task_free) (struct task_struct *task);
1598         int (*cred_alloc_blank) (struct cred *cred, gfp_t gfp);
1599         void (*cred_free) (struct cred *cred);
1600         int (*cred_prepare)(struct cred *new, const struct cred *old,
1601                             gfp_t gfp);
1602         void (*cred_transfer)(struct cred *new, const struct cred *old);
1603         int (*kernel_act_as)(struct cred *new, u32 secid);
1604         int (*kernel_create_files_as)(struct cred *new, struct inode *inode);
1605         int (*kernel_fw_from_file)(struct file *file, char *buf, size_t size);
1606         int (*kernel_module_request)(char *kmod_name);
1607         int (*kernel_module_from_file)(struct file *file);
1608         int (*task_fix_setuid) (struct cred *new, const struct cred *old,
1609                                 int flags);
1610         int (*task_setpgid) (struct task_struct *p, pid_t pgid);
1611         int (*task_getpgid) (struct task_struct *p);
1612         int (*task_getsid) (struct task_struct *p);
1613         void (*task_getsecid) (struct task_struct *p, u32 *secid);
1614         int (*task_setnice) (struct task_struct *p, int nice);
1615         int (*task_setioprio) (struct task_struct *p, int ioprio);
1616         int (*task_getioprio) (struct task_struct *p);
1617         int (*task_setrlimit) (struct task_struct *p, unsigned int resource,
1618                         struct rlimit *new_rlim);
1619         int (*task_setscheduler) (struct task_struct *p);
1620         int (*task_getscheduler) (struct task_struct *p);
1621         int (*task_movememory) (struct task_struct *p);
1622         int (*task_kill) (struct task_struct *p,
1623                           struct siginfo *info, int sig, u32 secid);
1624         int (*task_wait) (struct task_struct *p);
1625         int (*task_prctl) (int option, unsigned long arg2,
1626                            unsigned long arg3, unsigned long arg4,
1627                            unsigned long arg5);
1628         void (*task_to_inode) (struct task_struct *p, struct inode *inode);
1629 
1630         int (*ipc_permission) (struct kern_ipc_perm *ipcp, short flag);
1631         void (*ipc_getsecid) (struct kern_ipc_perm *ipcp, u32 *secid);
1632 
1633         int (*msg_msg_alloc_security) (struct msg_msg *msg);
1634         void (*msg_msg_free_security) (struct msg_msg *msg);
1635 
1636         int (*msg_queue_alloc_security) (struct msg_queue *msq);
1637         void (*msg_queue_free_security) (struct msg_queue *msq);
1638         int (*msg_queue_associate) (struct msg_queue *msq, int msqflg);
1639         int (*msg_queue_msgctl) (struct msg_queue *msq, int cmd);
1640         int (*msg_queue_msgsnd) (struct msg_queue *msq,
1641                                  struct msg_msg *msg, int msqflg);
1642         int (*msg_queue_msgrcv) (struct msg_queue *msq,
1643                                  struct msg_msg *msg,
1644                                  struct task_struct *target,
1645                                  long type, int mode);
1646 
1647         int (*shm_alloc_security) (struct shmid_kernel *shp);
1648         void (*shm_free_security) (struct shmid_kernel *shp);
1649         int (*shm_associate) (struct shmid_kernel *shp, int shmflg);
1650         int (*shm_shmctl) (struct shmid_kernel *shp, int cmd);
1651         int (*shm_shmat) (struct shmid_kernel *shp,
1652                           char __user *shmaddr, int shmflg);
1653 
1654         int (*sem_alloc_security) (struct sem_array *sma);
1655         void (*sem_free_security) (struct sem_array *sma);
1656         int (*sem_associate) (struct sem_array *sma, int semflg);
1657         int (*sem_semctl) (struct sem_array *sma, int cmd);
1658         int (*sem_semop) (struct sem_array *sma,
1659                           struct sembuf *sops, unsigned nsops, int alter);
1660 
1661         int (*netlink_send) (struct sock *sk, struct sk_buff *skb);
1662 
1663         void (*d_instantiate) (struct dentry *dentry, struct inode *inode);
1664 
1665         int (*getprocattr) (struct task_struct *p, char *name, char **value);
1666         int (*setprocattr) (struct task_struct *p, char *name, void *value, size_t size);
1667         int (*ismaclabel) (const char *name);
1668         int (*secid_to_secctx) (u32 secid, char **secdata, u32 *seclen);
1669         int (*secctx_to_secid) (const char *secdata, u32 seclen, u32 *secid);
1670         void (*release_secctx) (char *secdata, u32 seclen);
1671 
1672         int (*inode_notifysecctx)(struct inode *inode, void *ctx, u32 ctxlen);
1673         int (*inode_setsecctx)(struct dentry *dentry, void *ctx, u32 ctxlen);
1674         int (*inode_getsecctx)(struct inode *inode, void **ctx, u32 *ctxlen);
1675 
1676 #ifdef CONFIG_SECURITY_NETWORK
1677         int (*unix_stream_connect) (struct sock *sock, struct sock *other, struct sock *newsk);
1678         int (*unix_may_send) (struct socket *sock, struct socket *other);
1679 
1680         int (*socket_create) (int family, int type, int protocol, int kern);
1681         int (*socket_post_create) (struct socket *sock, int family,
1682                                    int type, int protocol, int kern);
1683         int (*socket_bind) (struct socket *sock,
1684                             struct sockaddr *address, int addrlen);
1685         int (*socket_connect) (struct socket *sock,
1686                                struct sockaddr *address, int addrlen);
1687         int (*socket_listen) (struct socket *sock, int backlog);
1688         int (*socket_accept) (struct socket *sock, struct socket *newsock);
1689         int (*socket_sendmsg) (struct socket *sock,
1690                                struct msghdr *msg, int size);
1691         int (*socket_recvmsg) (struct socket *sock,
1692                                struct msghdr *msg, int size, int flags);
1693         int (*socket_getsockname) (struct socket *sock);
1694         int (*socket_getpeername) (struct socket *sock);
1695         int (*socket_getsockopt) (struct socket *sock, int level, int optname);
1696         int (*socket_setsockopt) (struct socket *sock, int level, int optname);
1697         int (*socket_shutdown) (struct socket *sock, int how);
1698         int (*socket_sock_rcv_skb) (struct sock *sk, struct sk_buff *skb);
1699         int (*socket_getpeersec_stream) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len);
1700         int (*socket_getpeersec_dgram) (struct socket *sock, struct sk_buff *skb, u32 *secid);
1701         int (*sk_alloc_security) (struct sock *sk, int family, gfp_t priority);
1702         void (*sk_free_security) (struct sock *sk);
1703         void (*sk_clone_security) (const struct sock *sk, struct sock *newsk);
1704         void (*sk_getsecid) (struct sock *sk, u32 *secid);
1705         void (*sock_graft) (struct sock *sk, struct socket *parent);
1706         int (*inet_conn_request) (struct sock *sk, struct sk_buff *skb,
1707                                   struct request_sock *req);
1708         void (*inet_csk_clone) (struct sock *newsk, const struct request_sock *req);
1709         void (*inet_conn_established) (struct sock *sk, struct sk_buff *skb);
1710         int (*secmark_relabel_packet) (u32 secid);
1711         void (*secmark_refcount_inc) (void);
1712         void (*secmark_refcount_dec) (void);
1713         void (*req_classify_flow) (const struct request_sock *req, struct flowi *fl);
1714         int (*tun_dev_alloc_security) (void **security);
1715         void (*tun_dev_free_security) (void *security);
1716         int (*tun_dev_create) (void);
1717         int (*tun_dev_attach_queue) (void *security);
1718         int (*tun_dev_attach) (struct sock *sk, void *security);
1719         int (*tun_dev_open) (void *security);
1720         void (*skb_owned_by) (struct sk_buff *skb, struct sock *sk);
1721 #endif  /* CONFIG_SECURITY_NETWORK */
1722 
1723 #ifdef CONFIG_SECURITY_NETWORK_XFRM
1724         int (*xfrm_policy_alloc_security) (struct xfrm_sec_ctx **ctxp,
1725                         struct xfrm_user_sec_ctx *sec_ctx, gfp_t gfp);
1726         int (*xfrm_policy_clone_security) (struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctx);
1727         void (*xfrm_policy_free_security) (struct xfrm_sec_ctx *ctx);
1728         int (*xfrm_policy_delete_security) (struct xfrm_sec_ctx *ctx);
1729         int (*xfrm_state_alloc) (struct xfrm_state *x,
1730                                  struct xfrm_user_sec_ctx *sec_ctx);
1731         int (*xfrm_state_alloc_acquire) (struct xfrm_state *x,
1732                                          struct xfrm_sec_ctx *polsec,
1733                                          u32 secid);
1734         void (*xfrm_state_free_security) (struct xfrm_state *x);
1735         int (*xfrm_state_delete_security) (struct xfrm_state *x);
1736         int (*xfrm_policy_lookup) (struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir);
1737         int (*xfrm_state_pol_flow_match) (struct xfrm_state *x,
1738                                           struct xfrm_policy *xp,
1739                                           const struct flowi *fl);
1740         int (*xfrm_decode_session) (struct sk_buff *skb, u32 *secid, int ckall);
1741 #endif  /* CONFIG_SECURITY_NETWORK_XFRM */
1742 
1743         /* key management security hooks */
1744 #ifdef CONFIG_KEYS
1745         int (*key_alloc) (struct key *key, const struct cred *cred, unsigned long flags);
1746         void (*key_free) (struct key *key);
1747         int (*key_permission) (key_ref_t key_ref,
1748                                const struct cred *cred,
1749                                unsigned perm);
1750         int (*key_getsecurity)(struct key *key, char **_buffer);
1751 #endif  /* CONFIG_KEYS */
1752 
1753 #ifdef CONFIG_AUDIT
1754         int (*audit_rule_init) (u32 field, u32 op, char *rulestr, void **lsmrule);
1755         int (*audit_rule_known) (struct audit_krule *krule);
1756         int (*audit_rule_match) (u32 secid, u32 field, u32 op, void *lsmrule,
1757                                  struct audit_context *actx);
1758         void (*audit_rule_free) (void *lsmrule);
1759 #endif /* CONFIG_AUDIT */
1760 };
1761 
1762 /* prototypes */
1763 extern int security_init(void);
1764 extern int security_module_enable(struct security_operations *ops);
1765 extern int register_security(struct security_operations *ops);
1766 extern void __init security_fixup_ops(struct security_operations *ops);
1767 
1768 
1769 /* Security operations */
1770 int security_binder_set_context_mgr(struct task_struct *mgr);
1771 int security_binder_transaction(struct task_struct *from,
1772                                 struct task_struct *to);
1773 int security_binder_transfer_binder(struct task_struct *from,
1774                                     struct task_struct *to);
1775 int security_binder_transfer_file(struct task_struct *from,
1776                                   struct task_struct *to, struct file *file);
1777 int security_ptrace_access_check(struct task_struct *child, unsigned int mode);
1778 int security_ptrace_traceme(struct task_struct *parent);
1779 int security_capget(struct task_struct *target,
1780                     kernel_cap_t *effective,
1781                     kernel_cap_t *inheritable,
1782                     kernel_cap_t *permitted);
1783 int security_capset(struct cred *new, const struct cred *old,
1784                     const kernel_cap_t *effective,
1785                     const kernel_cap_t *inheritable,
1786                     const kernel_cap_t *permitted);
1787 int security_capable(const struct cred *cred, struct user_namespace *ns,
1788                         int cap);
1789 int security_capable_noaudit(const struct cred *cred, struct user_namespace *ns,
1790                              int cap);
1791 int security_quotactl(int cmds, int type, int id, struct super_block *sb);
1792 int security_quota_on(struct dentry *dentry);
1793 int security_syslog(int type);
1794 int security_settime(const struct timespec *ts, const struct timezone *tz);
1795 int security_vm_enough_memory_mm(struct mm_struct *mm, long pages);
1796 int security_bprm_set_creds(struct linux_binprm *bprm);
1797 int security_bprm_check(struct linux_binprm *bprm);
1798 void security_bprm_committing_creds(struct linux_binprm *bprm);
1799 void security_bprm_committed_creds(struct linux_binprm *bprm);
1800 int security_bprm_secureexec(struct linux_binprm *bprm);
1801 int security_sb_alloc(struct super_block *sb);
1802 void security_sb_free(struct super_block *sb);
1803 int security_sb_copy_data(char *orig, char *copy);
1804 int security_sb_remount(struct super_block *sb, void *data);
1805 int security_sb_kern_mount(struct super_block *sb, int flags, void *data);
1806 int security_sb_show_options(struct seq_file *m, struct super_block *sb);
1807 int security_sb_statfs(struct dentry *dentry);
1808 int security_sb_mount(const char *dev_name, struct path *path,
1809                       const char *type, unsigned long flags, void *data);
1810 int security_sb_umount(struct vfsmount *mnt, int flags);
1811 int security_sb_pivotroot(struct path *old_path, struct path *new_path);
1812 int security_sb_set_mnt_opts(struct super_block *sb,
1813                                 struct security_mnt_opts *opts,
1814                                 unsigned long kern_flags,
1815                                 unsigned long *set_kern_flags);
1816 int security_sb_clone_mnt_opts(const struct super_block *oldsb,
1817                                 struct super_block *newsb);
1818 int security_sb_parse_opts_str(char *options, struct security_mnt_opts *opts);
1819 int security_dentry_init_security(struct dentry *dentry, int mode,
1820                                         struct qstr *name, void **ctx,
1821                                         u32 *ctxlen);
1822 
1823 int security_inode_alloc(struct inode *inode);
1824 void security_inode_free(struct inode *inode);
1825 int security_inode_init_security(struct inode *inode, struct inode *dir,
1826                                  const struct qstr *qstr,
1827                                  initxattrs initxattrs, void *fs_data);
1828 int security_old_inode_init_security(struct inode *inode, struct inode *dir,
1829                                      const struct qstr *qstr, const char **name,
1830                                      void **value, size_t *len);
1831 int security_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode);
1832 int security_inode_link(struct dentry *old_dentry, struct inode *dir,
1833                          struct dentry *new_dentry);
1834 int security_inode_unlink(struct inode *dir, struct dentry *dentry);
1835 int security_inode_symlink(struct inode *dir, struct dentry *dentry,
1836                            const char *old_name);
1837 int security_inode_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode);
1838 int security_inode_rmdir(struct inode *dir, struct dentry *dentry);
1839 int security_inode_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev);
1840 int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
1841                           struct inode *new_dir, struct dentry *new_dentry,
1842                           unsigned int flags);
1843 int security_inode_readlink(struct dentry *dentry);
1844 int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd);
1845 int security_inode_permission(struct inode *inode, int mask);
1846 int security_inode_setattr(struct dentry *dentry, struct iattr *attr);
1847 int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry);
1848 int security_inode_setxattr(struct dentry *dentry, const char *name,
1849                             const void *value, size_t size, int flags);
1850 void security_inode_post_setxattr(struct dentry *dentry, const char *name,
1851                                   const void *value, size_t size, int flags);
1852 int security_inode_getxattr(struct dentry *dentry, const char *name);
1853 int security_inode_listxattr(struct dentry *dentry);
1854 int security_inode_removexattr(struct dentry *dentry, const char *name);
1855 int security_inode_need_killpriv(struct dentry *dentry);
1856 int security_inode_killpriv(struct dentry *dentry);
1857 int security_inode_getsecurity(const struct inode *inode, const char *name, void **buffer, bool alloc);
1858 int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags);
1859 int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size);
1860 void security_inode_getsecid(const struct inode *inode, u32 *secid);
1861 int security_file_permission(struct file *file, int mask);
1862 int security_file_alloc(struct file *file);
1863 void security_file_free(struct file *file);
1864 int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
1865 int security_mmap_file(struct file *file, unsigned long prot,
1866                         unsigned long flags);
1867 int security_mmap_addr(unsigned long addr);
1868 int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
1869                            unsigned long prot);
1870 int security_file_lock(struct file *file, unsigned int cmd);
1871 int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
1872 void security_file_set_fowner(struct file *file);
1873 int security_file_send_sigiotask(struct task_struct *tsk,
1874                                  struct fown_struct *fown, int sig);
1875 int security_file_receive(struct file *file);
1876 int security_file_open(struct file *file, const struct cred *cred);
1877 int security_task_create(unsigned long clone_flags);
1878 void security_task_free(struct task_struct *task);
1879 int security_cred_alloc_blank(struct cred *cred, gfp_t gfp);
1880 void security_cred_free(struct cred *cred);
1881 int security_prepare_creds(struct cred *new, const struct cred *old, gfp_t gfp);
1882 void security_transfer_creds(struct cred *new, const struct cred *old);
1883 int security_kernel_act_as(struct cred *new, u32 secid);
1884 int security_kernel_create_files_as(struct cred *new, struct inode *inode);
1885 int security_kernel_fw_from_file(struct file *file, char *buf, size_t size);
1886 int security_kernel_module_request(char *kmod_name);
1887 int security_kernel_module_from_file(struct file *file);
1888 int security_task_fix_setuid(struct cred *new, const struct cred *old,
1889                              int flags);
1890 int security_task_setpgid(struct task_struct *p, pid_t pgid);
1891 int security_task_getpgid(struct task_struct *p);
1892 int security_task_getsid(struct task_struct *p);
1893 void security_task_getsecid(struct task_struct *p, u32 *secid);
1894 int security_task_setnice(struct task_struct *p, int nice);
1895 int security_task_setioprio(struct task_struct *p, int ioprio);
1896 int security_task_getioprio(struct task_struct *p);
1897 int security_task_setrlimit(struct task_struct *p, unsigned int resource,
1898                 struct rlimit *new_rlim);
1899 int security_task_setscheduler(struct task_struct *p);
1900 int security_task_getscheduler(struct task_struct *p);
1901 int security_task_movememory(struct task_struct *p);
1902 int security_task_kill(struct task_struct *p, struct siginfo *info,
1903                         int sig, u32 secid);
1904 int security_task_wait(struct task_struct *p);
1905 int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
1906                         unsigned long arg4, unsigned long arg5);
1907 void security_task_to_inode(struct task_struct *p, struct inode *inode);
1908 int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag);
1909 void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid);
1910 int security_msg_msg_alloc(struct msg_msg *msg);
1911 void security_msg_msg_free(struct msg_msg *msg);
1912 int security_msg_queue_alloc(struct msg_queue *msq);
1913 void security_msg_queue_free(struct msg_queue *msq);
1914 int security_msg_queue_associate(struct msg_queue *msq, int msqflg);
1915 int security_msg_queue_msgctl(struct msg_queue *msq, int cmd);
1916 int security_msg_queue_msgsnd(struct msg_queue *msq,
1917                               struct msg_msg *msg, int msqflg);
1918 int security_msg_queue_msgrcv(struct msg_queue *msq, struct msg_msg *msg,
1919                               struct task_struct *target, long type, int mode);
1920 int security_shm_alloc(struct shmid_kernel *shp);
1921 void security_shm_free(struct shmid_kernel *shp);
1922 int security_shm_associate(struct shmid_kernel *shp, int shmflg);
1923 int security_shm_shmctl(struct shmid_kernel *shp, int cmd);
1924 int security_shm_shmat(struct shmid_kernel *shp, char __user *shmaddr, int shmflg);
1925 int security_sem_alloc(struct sem_array *sma);
1926 void security_sem_free(struct sem_array *sma);
1927 int security_sem_associate(struct sem_array *sma, int semflg);
1928 int security_sem_semctl(struct sem_array *sma, int cmd);
1929 int security_sem_semop(struct sem_array *sma, struct sembuf *sops,
1930                         unsigned nsops, int alter);
1931 void security_d_instantiate(struct dentry *dentry, struct inode *inode);
1932 int security_getprocattr(struct task_struct *p, char *name, char **value);
1933 int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size);
1934 int security_netlink_send(struct sock *sk, struct sk_buff *skb);
1935 int security_ismaclabel(const char *name);
1936 int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen);
1937 int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid);
1938 void security_release_secctx(char *secdata, u32 seclen);
1939 
1940 int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen);
1941 int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen);
1942 int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen);
1943 #else /* CONFIG_SECURITY */
1944 struct security_mnt_opts {
1945 };
1946 
1947 static inline void security_init_mnt_opts(struct security_mnt_opts *opts)
1948 {
1949 }
1950 
1951 static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
1952 {
1953 }
1954 
1955 /*
1956  * This is the default capabilities functionality.  Most of these functions
1957  * are just stubbed out, but a few must call the proper capable code.
1958  */
1959 
1960 static inline int security_init(void)
1961 {
1962         return 0;
1963 }
1964 
1965 static inline int security_binder_set_context_mgr(struct task_struct *mgr)
1966 {
1967         return 0;
1968 }
1969 
1970 static inline int security_binder_transaction(struct task_struct *from,
1971                                               struct task_struct *to)
1972 {
1973         return 0;
1974 }
1975 
1976 static inline int security_binder_transfer_binder(struct task_struct *from,
1977                                                   struct task_struct *to)
1978 {
1979         return 0;
1980 }
1981 
1982 static inline int security_binder_transfer_file(struct task_struct *from,
1983                                                 struct task_struct *to,
1984                                                 struct file *file)
1985 {
1986         return 0;
1987 }
1988 
1989 static inline int security_ptrace_access_check(struct task_struct *child,
1990                                              unsigned int mode)
1991 {
1992         return cap_ptrace_access_check(child, mode);
1993 }
1994 
1995 static inline int security_ptrace_traceme(struct task_struct *parent)
1996 {
1997         return cap_ptrace_traceme(parent);
1998 }
1999 
2000 static inline int security_capget(struct task_struct *target,
2001                                    kernel_cap_t *effective,
2002                                    kernel_cap_t *inheritable,
2003                                    kernel_cap_t *permitted)
2004 {
2005         return cap_capget(target, effective, inheritable, permitted);
2006 }
2007 
2008 static inline int security_capset(struct cred *new,
2009                                    const struct cred *old,
2010                                    const kernel_cap_t *effective,
2011                                    const kernel_cap_t *inheritable,
2012                                    const kernel_cap_t *permitted)
2013 {
2014         return cap_capset(new, old, effective, inheritable, permitted);
2015 }
2016 
2017 static inline int security_capable(const struct cred *cred,
2018                                    struct user_namespace *ns, int cap)
2019 {
2020         return cap_capable(cred, ns, cap, SECURITY_CAP_AUDIT);
2021 }
2022 
2023 static inline int security_capable_noaudit(const struct cred *cred,
2024                                            struct user_namespace *ns, int cap) {
2025         return cap_capable(cred, ns, cap, SECURITY_CAP_NOAUDIT);
2026 }
2027 
2028 static inline int security_quotactl(int cmds, int type, int id,
2029                                      struct super_block *sb)
2030 {
2031         return 0;
2032 }
2033 
2034 static inline int security_quota_on(struct dentry *dentry)
2035 {
2036         return 0;
2037 }
2038 
2039 static inline int security_syslog(int type)
2040 {
2041         return 0;
2042 }
2043 
2044 static inline int security_settime(const struct timespec *ts,
2045                                    const struct timezone *tz)
2046 {
2047         int error = cap_settime(ts, tz);
2048         if (!error)
2049                 error = ccs_settime(ts, tz);
2050         return error;
2051 }
2052 
2053 static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
2054 {
2055         return cap_vm_enough_memory(mm, pages);
2056 }
2057 
2058 static inline int security_bprm_set_creds(struct linux_binprm *bprm)
2059 {
2060         return cap_bprm_set_creds(bprm);
2061 }
2062 
2063 static inline int security_bprm_check(struct linux_binprm *bprm)
2064 {
2065         return 0;
2066 }
2067 
2068 static inline void security_bprm_committing_creds(struct linux_binprm *bprm)
2069 {
2070 }
2071 
2072 static inline void security_bprm_committed_creds(struct linux_binprm *bprm)
2073 {
2074 }
2075 
2076 static inline int security_bprm_secureexec(struct linux_binprm *bprm)
2077 {
2078         return cap_bprm_secureexec(bprm);
2079 }
2080 
2081 static inline int security_sb_alloc(struct super_block *sb)
2082 {
2083         return 0;
2084 }
2085 
2086 static inline void security_sb_free(struct super_block *sb)
2087 { }
2088 
2089 static inline int security_sb_copy_data(char *orig, char *copy)
2090 {
2091         return 0;
2092 }
2093 
2094 static inline int security_sb_remount(struct super_block *sb, void *data)
2095 {
2096         return 0;
2097 }
2098 
2099 static inline int security_sb_kern_mount(struct super_block *sb, int flags, void *data)
2100 {
2101         return 0;
2102 }
2103 
2104 static inline int security_sb_show_options(struct seq_file *m,
2105                                            struct super_block *sb)
2106 {
2107         return 0;
2108 }
2109 
2110 static inline int security_sb_statfs(struct dentry *dentry)
2111 {
2112         return 0;
2113 }
2114 
2115 static inline int security_sb_mount(const char *dev_name, struct path *path,
2116                                     const char *type, unsigned long flags,
2117                                     void *data)
2118 {
2119         return ccs_sb_mount(dev_name, path, type, flags, data);
2120 }
2121 
2122 static inline int security_sb_umount(struct vfsmount *mnt, int flags)
2123 {
2124         return ccs_sb_umount(mnt, flags);
2125 }
2126 
2127 static inline int security_sb_pivotroot(struct path *old_path,
2128                                         struct path *new_path)
2129 {
2130         return ccs_sb_pivotroot(old_path, new_path);
2131 }
2132 
2133 static inline int security_sb_set_mnt_opts(struct super_block *sb,
2134                                            struct security_mnt_opts *opts,
2135                                            unsigned long kern_flags,
2136                                            unsigned long *set_kern_flags)
2137 {
2138         return 0;
2139 }
2140 
2141 static inline int security_sb_clone_mnt_opts(const struct super_block *oldsb,
2142                                               struct super_block *newsb)
2143 {
2144         return 0;
2145 }
2146 
2147 static inline int security_sb_parse_opts_str(char *options, struct security_mnt_opts *opts)
2148 {
2149         return 0;
2150 }
2151 
2152 static inline int security_inode_alloc(struct inode *inode)
2153 {
2154         return 0;
2155 }
2156 
2157 static inline void security_inode_free(struct inode *inode)
2158 { }
2159 
2160 static inline int security_dentry_init_security(struct dentry *dentry,
2161                                                  int mode,
2162                                                  struct qstr *name,
2163                                                  void **ctx,
2164                                                  u32 *ctxlen)
2165 {
2166         return -EOPNOTSUPP;
2167 }
2168 
2169 
2170 static inline int security_inode_init_security(struct inode *inode,
2171                                                 struct inode *dir,
2172                                                 const struct qstr *qstr,
2173                                                 const initxattrs xattrs,
2174                                                 void *fs_data)
2175 {
2176         return 0;
2177 }
2178 
2179 static inline int security_old_inode_init_security(struct inode *inode,
2180                                                    struct inode *dir,
2181                                                    const struct qstr *qstr,
2182                                                    const char **name,
2183                                                    void **value, size_t *len)
2184 {
2185         return -EOPNOTSUPP;
2186 }
2187 
2188 static inline int security_inode_create(struct inode *dir,
2189                                          struct dentry *dentry,
2190                                          umode_t mode)
2191 {
2192         return 0;
2193 }
2194 
2195 static inline int security_inode_link(struct dentry *old_dentry,
2196                                        struct inode *dir,
2197                                        struct dentry *new_dentry)
2198 {
2199         return 0;
2200 }
2201 
2202 static inline int security_inode_unlink(struct inode *dir,
2203                                          struct dentry *dentry)
2204 {
2205         return 0;
2206 }
2207 
2208 static inline int security_inode_symlink(struct inode *dir,
2209                                           struct dentry *dentry,
2210                                           const char *old_name)
2211 {
2212         return 0;
2213 }
2214 
2215 static inline int security_inode_mkdir(struct inode *dir,
2216                                         struct dentry *dentry,
2217                                         int mode)
2218 {
2219         return 0;
2220 }
2221 
2222 static inline int security_inode_rmdir(struct inode *dir,
2223                                         struct dentry *dentry)
2224 {
2225         return 0;
2226 }
2227 
2228 static inline int security_inode_mknod(struct inode *dir,
2229                                         struct dentry *dentry,
2230                                         int mode, dev_t dev)
2231 {
2232         return 0;
2233 }
2234 
2235 static inline int security_inode_rename(struct inode *old_dir,
2236                                          struct dentry *old_dentry,
2237                                          struct inode *new_dir,
2238                                          struct dentry *new_dentry,
2239                                          unsigned int flags)
2240 {
2241         return 0;
2242 }
2243 
2244 static inline int security_inode_readlink(struct dentry *dentry)
2245 {
2246         return 0;
2247 }
2248 
2249 static inline int security_inode_follow_link(struct dentry *dentry,
2250                                               struct nameidata *nd)
2251 {
2252         return 0;
2253 }
2254 
2255 static inline int security_inode_permission(struct inode *inode, int mask)
2256 {
2257         return 0;
2258 }
2259 
2260 static inline int security_inode_setattr(struct dentry *dentry,
2261                                           struct iattr *attr)
2262 {
2263         return 0;
2264 }
2265 
2266 static inline int security_inode_getattr(struct vfsmount *mnt,
2267                                           struct dentry *dentry)
2268 {
2269         return ccs_inode_getattr(mnt, dentry);
2270 }
2271 
2272 static inline int security_inode_setxattr(struct dentry *dentry,
2273                 const char *name, const void *value, size_t size, int flags)
2274 {
2275         return cap_inode_setxattr(dentry, name, value, size, flags);
2276 }
2277 
2278 static inline void security_inode_post_setxattr(struct dentry *dentry,
2279                 const char *name, const void *value, size_t size, int flags)
2280 { }
2281 
2282 static inline int security_inode_getxattr(struct dentry *dentry,
2283                         const char *name)
2284 {
2285         return 0;
2286 }
2287 
2288 static inline int security_inode_listxattr(struct dentry *dentry)
2289 {
2290         return 0;
2291 }
2292 
2293 static inline int security_inode_removexattr(struct dentry *dentry,
2294                         const char *name)
2295 {
2296         return cap_inode_removexattr(dentry, name);
2297 }
2298 
2299 static inline int security_inode_need_killpriv(struct dentry *dentry)
2300 {
2301         return cap_inode_need_killpriv(dentry);
2302 }
2303 
2304 static inline int security_inode_killpriv(struct dentry *dentry)
2305 {
2306         return cap_inode_killpriv(dentry);
2307 }
2308 
2309 static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void **buffer, bool alloc)
2310 {
2311         return -EOPNOTSUPP;
2312 }
2313 
2314 static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
2315 {
2316         return -EOPNOTSUPP;
2317 }
2318 
2319 static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
2320 {
2321         return 0;
2322 }
2323 
2324 static inline void security_inode_getsecid(const struct inode *inode, u32 *secid)
2325 {
2326         *secid = 0;
2327 }
2328 
2329 static inline int security_file_permission(struct file *file, int mask)
2330 {
2331         return 0;
2332 }
2333 
2334 static inline int security_file_alloc(struct file *file)
2335 {
2336         return 0;
2337 }
2338 
2339 static inline void security_file_free(struct file *file)
2340 { }
2341 
2342 static inline int security_file_ioctl(struct file *file, unsigned int cmd,
2343                                       unsigned long arg)
2344 {
2345         return ccs_file_ioctl(file, cmd, arg);
2346 }
2347 
2348 static inline int security_mmap_file(struct file *file, unsigned long prot,
2349                                      unsigned long flags)
2350 {
2351         return 0;
2352 }
2353 
2354 static inline int security_mmap_addr(unsigned long addr)
2355 {
2356         return cap_mmap_addr(addr);
2357 }
2358 
2359 static inline int security_file_mprotect(struct vm_area_struct *vma,
2360                                          unsigned long reqprot,
2361                                          unsigned long prot)
2362 {
2363         return 0;
2364 }
2365 
2366 static inline int security_file_lock(struct file *file, unsigned int cmd)
2367 {
2368         return 0;
2369 }
2370 
2371 static inline int security_file_fcntl(struct file *file, unsigned int cmd,
2372                                       unsigned long arg)
2373 {
2374         return ccs_file_fcntl(file, cmd, arg);
2375 }
2376 
2377 static inline void security_file_set_fowner(struct file *file)
2378 {
2379         return;
2380 }
2381 
2382 static inline int security_file_send_sigiotask(struct task_struct *tsk,
2383                                                struct fown_struct *fown,
2384                                                int sig)
2385 {
2386         return 0;
2387 }
2388 
2389 static inline int security_file_receive(struct file *file)
2390 {
2391         return 0;
2392 }
2393 
2394 static inline int security_file_open(struct file *file,
2395                                      const struct cred *cred)
2396 {
2397         return ccs_file_open(file, cred);
2398 }
2399 
2400 static inline int security_task_create(unsigned long clone_flags)
2401 {
2402         return 0;
2403 }
2404 
2405 static inline void security_task_free(struct task_struct *task)
2406 { }
2407 
2408 static inline int security_cred_alloc_blank(struct cred *cred, gfp_t gfp)
2409 {
2410         return 0;
2411 }
2412 
2413 static inline void security_cred_free(struct cred *cred)
2414 { }
2415 
2416 static inline int security_prepare_creds(struct cred *new,
2417                                          const struct cred *old,
2418                                          gfp_t gfp)
2419 {
2420         return 0;
2421 }
2422 
2423 static inline void security_transfer_creds(struct cred *new,
2424                                            const struct cred *old)
2425 {
2426 }
2427 
2428 static inline int security_kernel_act_as(struct cred *cred, u32 secid)
2429 {
2430         return 0;
2431 }
2432 
2433 static inline int security_kernel_create_files_as(struct cred *cred,
2434                                                   struct inode *inode)
2435 {
2436         return 0;
2437 }
2438 
2439 static inline int security_kernel_fw_from_file(struct file *file,
2440                                                char *buf, size_t size)
2441 {
2442         return 0;
2443 }
2444 
2445 static inline int security_kernel_module_request(char *kmod_name)
2446 {
2447         return 0;
2448 }
2449 
2450 static inline int security_kernel_module_from_file(struct file *file)
2451 {
2452         return 0;
2453 }
2454 
2455 static inline int security_task_fix_setuid(struct cred *new,
2456                                            const struct cred *old,
2457                                            int flags)
2458 {
2459         return cap_task_fix_setuid(new, old, flags);
2460 }
2461 
2462 static inline int security_task_setpgid(struct task_struct *p, pid_t pgid)
2463 {
2464         return 0;
2465 }
2466 
2467 static inline int security_task_getpgid(struct task_struct *p)
2468 {
2469         return 0;
2470 }
2471 
2472 static inline int security_task_getsid(struct task_struct *p)
2473 {
2474         return 0;
2475 }
2476 
2477 static inline void security_task_getsecid(struct task_struct *p, u32 *secid)
2478 {
2479         *secid = 0;
2480 }
2481 
2482 static inline int security_task_setnice(struct task_struct *p, int nice)
2483 {
2484         return cap_task_setnice(p, nice);
2485 }
2486 
2487 static inline int security_task_setioprio(struct task_struct *p, int ioprio)
2488 {
2489         return cap_task_setioprio(p, ioprio);
2490 }
2491 
2492 static inline int security_task_getioprio(struct task_struct *p)
2493 {
2494         return 0;
2495 }
2496 
2497 static inline int security_task_setrlimit(struct task_struct *p,
2498                                           unsigned int resource,
2499                                           struct rlimit *new_rlim)
2500 {
2501         return 0;
2502 }
2503 
2504 static inline int security_task_setscheduler(struct task_struct *p)
2505 {
2506         return cap_task_setscheduler(p);
2507 }
2508 
2509 static inline int security_task_getscheduler(struct task_struct *p)
2510 {
2511         return 0;
2512 }
2513 
2514 static inline int security_task_movememory(struct task_struct *p)
2515 {
2516         return 0;
2517 }
2518 
2519 static inline int security_task_kill(struct task_struct *p,
2520                                      struct siginfo *info, int sig,
2521                                      u32 secid)
2522 {
2523         return 0;
2524 }
2525 
2526 static inline int security_task_wait(struct task_struct *p)
2527 {
2528         return 0;
2529 }
2530 
2531 static inline int security_task_prctl(int option, unsigned long arg2,
2532                                       unsigned long arg3,
2533                                       unsigned long arg4,
2534                                       unsigned long arg5)
2535 {
2536         return cap_task_prctl(option, arg2, arg3, arg3, arg5);
2537 }
2538 
2539 static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
2540 { }
2541 
2542 static inline int security_ipc_permission(struct kern_ipc_perm *ipcp,
2543                                           short flag)
2544 {
2545         return 0;
2546 }
2547 
2548 static inline void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid)
2549 {
2550         *secid = 0;
2551 }
2552 
2553 static inline int security_msg_msg_alloc(struct msg_msg *msg)
2554 {
2555         return 0;
2556 }
2557 
2558 static inline void security_msg_msg_free(struct msg_msg *msg)
2559 { }
2560 
2561 static inline int security_msg_queue_alloc(struct msg_queue *msq)
2562 {
2563         return 0;
2564 }
2565 
2566 static inline void security_msg_queue_free(struct msg_queue *msq)
2567 { }
2568 
2569 static inline int security_msg_queue_associate(struct msg_queue *msq,
2570                                                int msqflg)
2571 {
2572         return 0;
2573 }
2574 
2575 static inline int security_msg_queue_msgctl(struct msg_queue *msq, int cmd)
2576 {
2577         return 0;
2578 }
2579 
2580 static inline int security_msg_queue_msgsnd(struct msg_queue *msq,
2581                                             struct msg_msg *msg, int msqflg)
2582 {
2583         return 0;
2584 }
2585 
2586 static inline int security_msg_queue_msgrcv(struct msg_queue *msq,
2587                                             struct msg_msg *msg,
2588                                             struct task_struct *target,
2589                                             long type, int mode)
2590 {
2591         return 0;
2592 }
2593 
2594 static inline int security_shm_alloc(struct shmid_kernel *shp)
2595 {
2596         return 0;
2597 }
2598 
2599 static inline void security_shm_free(struct shmid_kernel *shp)
2600 { }
2601 
2602 static inline int security_shm_associate(struct shmid_kernel *shp,
2603                                          int shmflg)
2604 {
2605         return 0;
2606 }
2607 
2608 static inline int security_shm_shmctl(struct shmid_kernel *shp, int cmd)
2609 {
2610         return 0;
2611 }
2612 
2613 static inline int security_shm_shmat(struct shmid_kernel *shp,
2614                                      char __user *shmaddr, int shmflg)
2615 {
2616         return 0;
2617 }
2618 
2619 static inline int security_sem_alloc(struct sem_array *sma)
2620 {
2621         return 0;
2622 }
2623 
2624 static inline void security_sem_free(struct sem_array *sma)
2625 { }
2626 
2627 static inline int security_sem_associate(struct sem_array *sma, int semflg)
2628 {
2629         return 0;
2630 }
2631 
2632 static inline int security_sem_semctl(struct sem_array *sma, int cmd)
2633 {
2634         return 0;
2635 }
2636 
2637 static inline int security_sem_semop(struct sem_array *sma,
2638                                      struct sembuf *sops, unsigned nsops,
2639                                      int alter)
2640 {
2641         return 0;
2642 }
2643 
2644 static inline void security_d_instantiate(struct dentry *dentry, struct inode *inode)
2645 { }
2646 
2647 static inline int security_getprocattr(struct task_struct *p, char *name, char **value)
2648 {
2649         return -EINVAL;
2650 }
2651 
2652 static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2653 {
2654         return -EINVAL;
2655 }
2656 
2657 static inline int security_netlink_send(struct sock *sk, struct sk_buff *skb)
2658 {
2659         return cap_netlink_send(sk, skb);
2660 }
2661 
2662 static inline int security_ismaclabel(const char *name)
2663 {
2664         return 0;
2665 }
2666 
2667 static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
2668 {
2669         return -EOPNOTSUPP;
2670 }
2671 
2672 static inline int security_secctx_to_secid(const char *secdata,
2673                                            u32 seclen,
2674                                            u32 *secid)
2675 {
2676         return -EOPNOTSUPP;
2677 }
2678 
2679 static inline void security_release_secctx(char *secdata, u32 seclen)
2680 {
2681 }
2682 
2683 static inline int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)
2684 {
2685         return -EOPNOTSUPP;
2686 }
2687 static inline int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
2688 {
2689         return -EOPNOTSUPP;
2690 }
2691 static inline int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
2692 {
2693         return -EOPNOTSUPP;
2694 }
2695 #endif  /* CONFIG_SECURITY */
2696 
2697 #ifdef CONFIG_SECURITY_NETWORK
2698 
2699 int security_unix_stream_connect(struct sock *sock, struct sock *other, struct sock *newsk);
2700 int security_unix_may_send(struct socket *sock,  struct socket *other);
2701 int security_socket_create(int family, int type, int protocol, int kern);
2702 int security_socket_post_create(struct socket *sock, int family,
2703                                 int type, int protocol, int kern);
2704 int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen);
2705 int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen);
2706 int security_socket_listen(struct socket *sock, int backlog);
2707 int security_socket_accept(struct socket *sock, struct socket *newsock);
2708 int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size);
2709 int security_socket_recvmsg(struct socket *sock, struct msghdr *msg,
2710                             int size, int flags);
2711 int security_socket_getsockname(struct socket *sock);
2712 int security_socket_getpeername(struct socket *sock);
2713 int security_socket_getsockopt(struct socket *sock, int level, int optname);
2714 int security_socket_setsockopt(struct socket *sock, int level, int optname);
2715 int security_socket_shutdown(struct socket *sock, int how);
2716 int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb);
2717 int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2718                                       int __user *optlen, unsigned len);
2719 int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid);
2720 int security_sk_alloc(struct sock *sk, int family, gfp_t priority);
2721 void security_sk_free(struct sock *sk);
2722 void security_sk_clone(const struct sock *sk, struct sock *newsk);
2723 void security_sk_classify_flow(struct sock *sk, struct flowi *fl);
2724 void security_req_classify_flow(const struct request_sock *req, struct flowi *fl);
2725 void security_sock_graft(struct sock*sk, struct socket *parent);
2726 int security_inet_conn_request(struct sock *sk,
2727                         struct sk_buff *skb, struct request_sock *req);
2728 void security_inet_csk_clone(struct sock *newsk,
2729                         const struct request_sock *req);
2730 void security_inet_conn_established(struct sock *sk,
2731                         struct sk_buff *skb);
2732 int security_secmark_relabel_packet(u32 secid);
2733 void security_secmark_refcount_inc(void);
2734 void security_secmark_refcount_dec(void);
2735 int security_tun_dev_alloc_security(void **security);
2736 void security_tun_dev_free_security(void *security);
2737 int security_tun_dev_create(void);
2738 int security_tun_dev_attach_queue(void *security);
2739 int security_tun_dev_attach(struct sock *sk, void *security);
2740 int security_tun_dev_open(void *security);
2741 
2742 void security_skb_owned_by(struct sk_buff *skb, struct sock *sk);
2743 
2744 #else   /* CONFIG_SECURITY_NETWORK */
2745 static inline int security_unix_stream_connect(struct sock *sock,
2746                                                struct sock *other,
2747                                                struct sock *newsk)
2748 {
2749         return 0;
2750 }
2751 
2752 static inline int security_unix_may_send(struct socket *sock,
2753                                          struct socket *other)
2754 {
2755         return 0;
2756 }
2757 
2758 static inline int security_socket_create(int family, int type,
2759                                          int protocol, int kern)
2760 {
2761         return ccs_socket_create(family, type, protocol, kern);
2762 }
2763 
2764 static inline int security_socket_post_create(struct socket *sock,
2765                                               int family,
2766                                               int type,
2767                                               int protocol, int kern)
2768 {
2769         return 0;
2770 }
2771 
2772 static inline int security_socket_bind(struct socket *sock,
2773                                        struct sockaddr *address,
2774                                        int addrlen)
2775 {
2776         return ccs_socket_bind(sock, address, addrlen);
2777 }
2778 
2779 static inline int security_socket_connect(struct socket *sock,
2780                                           struct sockaddr *address,
2781                                           int addrlen)
2782 {
2783         return ccs_socket_connect(sock, address, addrlen);
2784 }
2785 
2786 static inline int security_socket_listen(struct socket *sock, int backlog)
2787 {
2788         return ccs_socket_listen(sock, backlog);
2789 }
2790 
2791 static inline int security_socket_accept(struct socket *sock,
2792                                          struct socket *newsock)
2793 {
2794         return 0;
2795 }
2796 
2797 static inline int security_socket_sendmsg(struct socket *sock,
2798                                           struct msghdr *msg, int size)
2799 {
2800         return ccs_socket_sendmsg(sock, msg, size);
2801 }
2802 
2803 static inline int security_socket_recvmsg(struct socket *sock,
2804                                           struct msghdr *msg, int size,
2805                                           int flags)
2806 {
2807         return 0;
2808 }
2809 
2810 static inline int security_socket_getsockname(struct socket *sock)
2811 {
2812         return 0;
2813 }
2814 
2815 static inline int security_socket_getpeername(struct socket *sock)
2816 {
2817         return 0;
2818 }
2819 
2820 static inline int security_socket_getsockopt(struct socket *sock,
2821                                              int level, int optname)
2822 {
2823         return 0;
2824 }
2825 
2826 static inline int security_socket_setsockopt(struct socket *sock,
2827                                              int level, int optname)
2828 {
2829         return 0;
2830 }
2831 
2832 static inline int security_socket_shutdown(struct socket *sock, int how)
2833 {
2834         return 0;
2835 }
2836 static inline int security_sock_rcv_skb(struct sock *sk,
2837                                         struct sk_buff *skb)
2838 {
2839         return 0;
2840 }
2841 
2842 static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2843                                                     int __user *optlen, unsigned len)
2844 {
2845         return -ENOPROTOOPT;
2846 }
2847 
2848 static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
2849 {
2850         return -ENOPROTOOPT;
2851 }
2852 
2853 static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
2854 {
2855         return 0;
2856 }
2857 
2858 static inline void security_sk_free(struct sock *sk)
2859 {
2860 }
2861 
2862 static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
2863 {
2864 }
2865 
2866 static inline void security_sk_classify_flow(struct sock *sk, struct flowi *fl)
2867 {
2868 }
2869 
2870 static inline void security_req_classify_flow(const struct request_sock *req, struct flowi *fl)
2871 {
2872 }
2873 
2874 static inline void security_sock_graft(struct sock *sk, struct socket *parent)
2875 {
2876 }
2877 
2878 static inline int security_inet_conn_request(struct sock *sk,
2879                         struct sk_buff *skb, struct request_sock *req)
2880 {
2881         return 0;
2882 }
2883 
2884 static inline void security_inet_csk_clone(struct sock *newsk,
2885                         const struct request_sock *req)
2886 {
2887 }
2888 
2889 static inline void security_inet_conn_established(struct sock *sk,
2890                         struct sk_buff *skb)
2891 {
2892 }
2893 
2894 static inline int security_secmark_relabel_packet(u32 secid)
2895 {
2896         return 0;
2897 }
2898 
2899 static inline void security_secmark_refcount_inc(void)
2900 {
2901 }
2902 
2903 static inline void security_secmark_refcount_dec(void)
2904 {
2905 }
2906 
2907 static inline int security_tun_dev_alloc_security(void **security)
2908 {
2909         return 0;
2910 }
2911 
2912 static inline void security_tun_dev_free_security(void *security)
2913 {
2914 }
2915 
2916 static inline int security_tun_dev_create(void)
2917 {
2918         return 0;
2919 }
2920 
2921 static inline int security_tun_dev_attach_queue(void *security)
2922 {
2923         return 0;
2924 }
2925 
2926 static inline int security_tun_dev_attach(struct sock *sk, void *security)
2927 {
2928         return 0;
2929 }
2930 
2931 static inline int security_tun_dev_open(void *security)
2932 {
2933         return 0;
2934 }
2935 
2936 static inline void security_skb_owned_by(struct sk_buff *skb, struct sock *sk)
2937 {
2938 }
2939 
2940 #endif  /* CONFIG_SECURITY_NETWORK */
2941 
2942 #ifdef CONFIG_SECURITY_NETWORK_XFRM
2943 
2944 int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
2945                                struct xfrm_user_sec_ctx *sec_ctx, gfp_t gfp);
2946 int security_xfrm_policy_clone(struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctxp);
2947 void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx);
2948 int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx);
2949 int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
2950 int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
2951                                       struct xfrm_sec_ctx *polsec, u32 secid);
2952 int security_xfrm_state_delete(struct xfrm_state *x);
2953 void security_xfrm_state_free(struct xfrm_state *x);
2954 int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir);
2955 int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
2956                                        struct xfrm_policy *xp,
2957                                        const struct flowi *fl);
2958 int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid);
2959 void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl);
2960 
2961 #else   /* CONFIG_SECURITY_NETWORK_XFRM */
2962 
2963 static inline int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
2964                                              struct xfrm_user_sec_ctx *sec_ctx,
2965                                              gfp_t gfp)
2966 {
2967         return 0;
2968 }
2969 
2970 static inline int security_xfrm_policy_clone(struct xfrm_sec_ctx *old, struct xfrm_sec_ctx **new_ctxp)
2971 {
2972         return 0;
2973 }
2974 
2975 static inline void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx)
2976 {
2977 }
2978 
2979 static inline int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx)
2980 {
2981         return 0;
2982 }
2983 
2984 static inline int security_xfrm_state_alloc(struct xfrm_state *x,
2985                                         struct xfrm_user_sec_ctx *sec_ctx)
2986 {
2987         return 0;
2988 }
2989 
2990 static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
2991                                         struct xfrm_sec_ctx *polsec, u32 secid)
2992 {
2993         return 0;
2994 }
2995 
2996 static inline void security_xfrm_state_free(struct xfrm_state *x)
2997 {
2998 }
2999 
3000 static inline int security_xfrm_state_delete(struct xfrm_state *x)
3001 {
3002         return 0;
3003 }
3004 
3005 static inline int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir)
3006 {
3007         return 0;
3008 }
3009 
3010 static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
3011                         struct xfrm_policy *xp, const struct flowi *fl)
3012 {
3013         return 1;
3014 }
3015 
3016 static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
3017 {
3018         return 0;
3019 }
3020 
3021 static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl)
3022 {
3023 }
3024 
3025 #endif  /* CONFIG_SECURITY_NETWORK_XFRM */
3026 
3027 #ifdef CONFIG_SECURITY_PATH
3028 int security_path_unlink(struct path *dir, struct dentry *dentry);
3029 int security_path_mkdir(struct path *dir, struct dentry *dentry, umode_t mode);
3030 int security_path_rmdir(struct path *dir, struct dentry *dentry);
3031 int security_path_mknod(struct path *dir, struct dentry *dentry, umode_t mode,
3032                         unsigned int dev);
3033 int security_path_truncate(struct path *path);
3034 int security_path_symlink(struct path *dir, struct dentry *dentry,
3035                           const char *old_name);
3036 int security_path_link(struct dentry *old_dentry, struct path *new_dir,
3037                        struct dentry *new_dentry);
3038 int security_path_rename(struct path *old_dir, struct dentry *old_dentry,
3039                          struct path *new_dir, struct dentry *new_dentry,
3040                          unsigned int flags);
3041 int security_path_chmod(struct path *path, umode_t mode);
3042 int security_path_chown(struct path *path, kuid_t uid, kgid_t gid);
3043 int security_path_chroot(struct path *path);
3044 #else   /* CONFIG_SECURITY_PATH */
3045 static inline int security_path_unlink(struct path *dir, struct dentry *dentry)
3046 {
3047         return ccs_path_unlink(dir, dentry);
3048 }
3049 
3050 static inline int security_path_mkdir(struct path *dir, struct dentry *dentry,
3051                                       umode_t mode)
3052 {
3053         return ccs_path_mkdir(dir, dentry, mode);
3054 }
3055 
3056 static inline int security_path_rmdir(struct path *dir, struct dentry *dentry)
3057 {
3058         return ccs_path_rmdir(dir, dentry);
3059 }
3060 
3061 static inline int security_path_mknod(struct path *dir, struct dentry *dentry,
3062                                       umode_t mode, unsigned int dev)
3063 {
3064         return ccs_path_mknod(dir, dentry, mode, dev);
3065 }
3066 
3067 static inline int security_path_truncate(struct path *path)
3068 {
3069         return ccs_path_truncate(path);
3070 }
3071 
3072 static inline int security_path_symlink(struct path *dir, struct dentry *dentry,
3073                                         const char *old_name)
3074 {
3075         return ccs_path_symlink(dir, dentry, old_name);
3076 }
3077 
3078 static inline int security_path_link(struct dentry *old_dentry,
3079                                      struct path *new_dir,
3080                                      struct dentry *new_dentry)
3081 {
3082         return ccs_path_link(old_dentry, new_dir, new_dentry);
3083 }
3084 
3085 static inline int security_path_rename(struct path *old_dir,
3086                                        struct dentry *old_dentry,
3087                                        struct path *new_dir,
3088                                        struct dentry *new_dentry,
3089                                        unsigned int flags)
3090 {
3091         /*
3092          * Not using RENAME_EXCHANGE here in order to avoid KABI breakage
3093          * by doing "#include <uapi/linux/fs.h>" .
3094          */
3095         if (flags & (1 << 1)) {
3096                 int err = ccs_path_rename(new_dir, new_dentry, old_dir,
3097                                           old_dentry);
3098                 if (err)
3099                         return err;
3100         }
3101         return ccs_path_rename(old_dir, old_dentry, new_dir, new_dentry);
3102 }
3103 
3104 static inline int security_path_chmod(struct path *path, umode_t mode)
3105 {
3106         return ccs_path_chmod(path, mode);
3107 }
3108 
3109 static inline int security_path_chown(struct path *path, kuid_t uid, kgid_t gid)
3110 {
3111         return ccs_path_chown(path, uid, gid);
3112 }
3113 
3114 static inline int security_path_chroot(struct path *path)
3115 {
3116         return ccs_path_chroot(path);
3117 }
3118 #endif  /* CONFIG_SECURITY_PATH */
3119 
3120 #ifdef CONFIG_KEYS
3121 #ifdef CONFIG_SECURITY
3122 
3123 int security_key_alloc(struct key *key, const struct cred *cred, unsigned long flags);
3124 void security_key_free(struct key *key);
3125 int security_key_permission(key_ref_t key_ref,
3126                             const struct cred *cred, unsigned perm);
3127 int security_key_getsecurity(struct key *key, char **_buffer);
3128 
3129 #else
3130 
3131 static inline int security_key_alloc(struct key *key,
3132                                      const struct cred *cred,
3133                                      unsigned long flags)
3134 {
3135         return 0;
3136 }
3137 
3138 static inline void security_key_free(struct key *key)
3139 {
3140 }
3141 
3142 static inline int security_key_permission(key_ref_t key_ref,
3143                                           const struct cred *cred,
3144                                           unsigned perm)
3145 {
3146         return 0;
3147 }
3148 
3149 static inline int security_key_getsecurity(struct key *key, char **_buffer)
3150 {
3151         *_buffer = NULL;
3152         return 0;
3153 }
3154 
3155 #endif
3156 #endif /* CONFIG_KEYS */
3157 
3158 #ifdef CONFIG_AUDIT
3159 #ifdef CONFIG_SECURITY
3160 int security_audit_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule);
3161 int security_audit_rule_known(struct audit_krule *krule);
3162 int security_audit_rule_match(u32 secid, u32 field, u32 op, void *lsmrule,
3163                               struct audit_context *actx);
3164 void security_audit_rule_free(void *lsmrule);
3165 
3166 #else
3167 
3168 static inline int security_audit_rule_init(u32 field, u32 op, char *rulestr,
3169                                            void **lsmrule)
3170 {
3171         return 0;
3172 }
3173 
3174 static inline int security_audit_rule_known(struct audit_krule *krule)
3175 {
3176         return 0;
3177 }
3178 
3179 static inline int security_audit_rule_match(u32 secid, u32 field, u32 op,
3180                                    void *lsmrule, struct audit_context *actx)
3181 {
3182         return 0;
3183 }
3184 
3185 static inline void security_audit_rule_free(void *lsmrule)
3186 { }
3187 
3188 #endif /* CONFIG_SECURITY */
3189 #endif /* CONFIG_AUDIT */
3190 
3191 #ifdef CONFIG_SECURITYFS
3192 
3193 extern struct dentry *securityfs_create_file(const char *name, umode_t mode,
3194                                              struct dentry *parent, void *data,
3195                                              const struct file_operations *fops);
3196 extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
3197 extern void securityfs_remove(struct dentry *dentry);
3198 
3199 #else /* CONFIG_SECURITYFS */
3200 
3201 static inline struct dentry *securityfs_create_dir(const char *name,
3202                                                    struct dentry *parent)
3203 {
3204         return ERR_PTR(-ENODEV);
3205 }
3206 
3207 static inline struct dentry *securityfs_create_file(const char *name,
3208                                                     umode_t mode,
3209                                                     struct dentry *parent,
3210                                                     void *data,
3211                                                     const struct file_operations *fops)
3212 {
3213         return ERR_PTR(-ENODEV);
3214 }
3215 
3216 static inline void securityfs_remove(struct dentry *dentry)
3217 {}
3218 
3219 #endif
3220 
3221 #ifdef CONFIG_SECURITY
3222 
3223 static inline char *alloc_secdata(void)
3224 {
3225         return (char *)get_zeroed_page(GFP_KERNEL);
3226 }
3227 
3228 static inline void free_secdata(void *secdata)
3229 {
3230         free_page((unsigned long)secdata);
3231 }
3232 
3233 #else
3234 
3235 static inline char *alloc_secdata(void)
3236 {
3237         return (char *)1;
3238 }
3239 
3240 static inline void free_secdata(void *secdata)
3241 { }
3242 #endif /* CONFIG_SECURITY */
3243 
3244 #ifdef CONFIG_SECURITY_YAMA
3245 extern int yama_ptrace_access_check(struct task_struct *child,
3246                                     unsigned int mode);
3247 extern int yama_ptrace_traceme(struct task_struct *parent);
3248 extern void yama_task_free(struct task_struct *task);
3249 extern int yama_task_prctl(int option, unsigned long arg2, unsigned long arg3,
3250                            unsigned long arg4, unsigned long arg5);
3251 #else
3252 static inline int yama_ptrace_access_check(struct task_struct *child,
3253                                            unsigned int mode)
3254 {
3255         return 0;
3256 }
3257 
3258 static inline int yama_ptrace_traceme(struct task_struct *parent)
3259 {
3260         return 0;
3261 }
3262 
3263 static inline void yama_task_free(struct task_struct *task)
3264 {
3265 }
3266 
3267 static inline int yama_task_prctl(int option, unsigned long arg2,
3268                                   unsigned long arg3, unsigned long arg4,
3269                                   unsigned long arg5)
3270 {
3271         return -ENOSYS;
3272 }
3273 #endif /* CONFIG_SECURITY_YAMA */
3274 
3275 #endif /* ! __LINUX_SECURITY_H */
3276 
3277 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp