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

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

Version: ~ [ linux-5.8-rc3 ] ~ [ linux-5.7.5 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.48 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.129 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.185 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.228 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.228 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ 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_module_request:
707  *      Ability to trigger the kernel to automatically upcall to userspace for
708  *      userspace to load a kernel module with the given name.
709  *      @kmod_name name of the module requested by the kernel
710  *      Return 0 if successful.
711  * @kernel_module_from_file:
712  *      Load a kernel module from userspace.
713  *      @file contains the file structure pointing to the file containing
714  *      the kernel module to load. If the module is being loaded from a blob,
715  *      this argument will be NULL.
716  *      Return 0 if permission is granted.
717  * @task_fix_setuid:
718  *      Update the module's state after setting one or more of the user
719  *      identity attributes of the current process.  The @flags parameter
720  *      indicates which of the set*uid system calls invoked this hook.  If
721  *      @new is the set of credentials that will be installed.  Modifications
722  *      should be made to this rather than to @current->cred.
723  *      @old is the set of credentials that are being replaces
724  *      @flags contains one of the LSM_SETID_* values.
725  *      Return 0 on success.
726  * @task_setpgid:
727  *      Check permission before setting the process group identifier of the
728  *      process @p to @pgid.
729  *      @p contains the task_struct for process being modified.
730  *      @pgid contains the new pgid.
731  *      Return 0 if permission is granted.
732  * @task_getpgid:
733  *      Check permission before getting the process group identifier of the
734  *      process @p.
735  *      @p contains the task_struct for the process.
736  *      Return 0 if permission is granted.
737  * @task_getsid:
738  *      Check permission before getting the session identifier of the process
739  *      @p.
740  *      @p contains the task_struct for the process.
741  *      Return 0 if permission is granted.
742  * @task_getsecid:
743  *      Retrieve the security identifier of the process @p.
744  *      @p contains the task_struct for the process and place is into @secid.
745  *      In case of failure, @secid will be set to zero.
746  *
747  * @task_setnice:
748  *      Check permission before setting the nice value of @p to @nice.
749  *      @p contains the task_struct of process.
750  *      @nice contains the new nice value.
751  *      Return 0 if permission is granted.
752  * @task_setioprio
753  *      Check permission before setting the ioprio value of @p to @ioprio.
754  *      @p contains the task_struct of process.
755  *      @ioprio contains the new ioprio value
756  *      Return 0 if permission is granted.
757  * @task_getioprio
758  *      Check permission before getting the ioprio value of @p.
759  *      @p contains the task_struct of process.
760  *      Return 0 if permission is granted.
761  * @task_setrlimit:
762  *      Check permission before setting the resource limits of the current
763  *      process for @resource to @new_rlim.  The old resource limit values can
764  *      be examined by dereferencing (current->signal->rlim + resource).
765  *      @resource contains the resource whose limit is being set.
766  *      @new_rlim contains the new limits for @resource.
767  *      Return 0 if permission is granted.
768  * @task_setscheduler:
769  *      Check permission before setting scheduling policy and/or parameters of
770  *      process @p based on @policy and @lp.
771  *      @p contains the task_struct for process.
772  *      @policy contains the scheduling policy.
773  *      @lp contains the scheduling parameters.
774  *      Return 0 if permission is granted.
775  * @task_getscheduler:
776  *      Check permission before obtaining scheduling information for process
777  *      @p.
778  *      @p contains the task_struct for process.
779  *      Return 0 if permission is granted.
780  * @task_movememory
781  *      Check permission before moving memory owned by process @p.
782  *      @p contains the task_struct for process.
783  *      Return 0 if permission is granted.
784  * @task_kill:
785  *      Check permission before sending signal @sig to @p.  @info can be NULL,
786  *      the constant 1, or a pointer to a siginfo structure.  If @info is 1 or
787  *      SI_FROMKERNEL(info) is true, then the signal should be viewed as coming
788  *      from the kernel and should typically be permitted.
789  *      SIGIO signals are handled separately by the send_sigiotask hook in
790  *      file_security_ops.
791  *      @p contains the task_struct for process.
792  *      @info contains the signal information.
793  *      @sig contains the signal value.
794  *      @secid contains the sid of the process where the signal originated
795  *      Return 0 if permission is granted.
796  * @task_wait:
797  *      Check permission before allowing a process to reap a child process @p
798  *      and collect its status information.
799  *      @p contains the task_struct for process.
800  *      Return 0 if permission is granted.
801  * @task_prctl:
802  *      Check permission before performing a process control operation on the
803  *      current process.
804  *      @option contains the operation.
805  *      @arg2 contains a argument.
806  *      @arg3 contains a argument.
807  *      @arg4 contains a argument.
808  *      @arg5 contains a argument.
809  *      Return -ENOSYS if no-one wanted to handle this op, any other value to
810  *      cause prctl() to return immediately with that value.
811  * @task_to_inode:
812  *      Set the security attributes for an inode based on an associated task's
813  *      security attributes, e.g. for /proc/pid inodes.
814  *      @p contains the task_struct for the task.
815  *      @inode contains the inode structure for the inode.
816  *
817  * Security hooks for Netlink messaging.
818  *
819  * @netlink_send:
820  *      Save security information for a netlink message so that permission
821  *      checking can be performed when the message is processed.  The security
822  *      information can be saved using the eff_cap field of the
823  *      netlink_skb_parms structure.  Also may be used to provide fine
824  *      grained control over message transmission.
825  *      @sk associated sock of task sending the message.
826  *      @skb contains the sk_buff structure for the netlink message.
827  *      Return 0 if the information was successfully saved and message
828  *      is allowed to be transmitted.
829  *
830  * Security hooks for Unix domain networking.
831  *
832  * @unix_stream_connect:
833  *      Check permissions before establishing a Unix domain stream connection
834  *      between @sock and @other.
835  *      @sock contains the sock structure.
836  *      @other contains the peer sock structure.
837  *      @newsk contains the new sock structure.
838  *      Return 0 if permission is granted.
839  * @unix_may_send:
840  *      Check permissions before connecting or sending datagrams from @sock to
841  *      @other.
842  *      @sock contains the socket structure.
843  *      @other contains the peer socket structure.
844  *      Return 0 if permission is granted.
845  *
846  * The @unix_stream_connect and @unix_may_send hooks were necessary because
847  * Linux provides an alternative to the conventional file name space for Unix
848  * domain sockets.  Whereas binding and connecting to sockets in the file name
849  * space is mediated by the typical file permissions (and caught by the mknod
850  * and permission hooks in inode_security_ops), binding and connecting to
851  * sockets in the abstract name space is completely unmediated.  Sufficient
852  * control of Unix domain sockets in the abstract name space isn't possible
853  * using only the socket layer hooks, since we need to know the actual target
854  * socket, which is not looked up until we are inside the af_unix code.
855  *
856  * Security hooks for socket operations.
857  *
858  * @socket_create:
859  *      Check permissions prior to creating a new socket.
860  *      @family contains the requested protocol family.
861  *      @type contains the requested communications type.
862  *      @protocol contains the requested protocol.
863  *      @kern set to 1 if a kernel socket.
864  *      Return 0 if permission is granted.
865  * @socket_post_create:
866  *      This hook allows a module to update or allocate a per-socket security
867  *      structure. Note that the security field was not added directly to the
868  *      socket structure, but rather, the socket security information is stored
869  *      in the associated inode.  Typically, the inode alloc_security hook will
870  *      allocate and and attach security information to
871  *      sock->inode->i_security.  This hook may be used to update the
872  *      sock->inode->i_security field with additional information that wasn't
873  *      available when the inode was allocated.
874  *      @sock contains the newly created socket structure.
875  *      @family contains the requested protocol family.
876  *      @type contains the requested communications type.
877  *      @protocol contains the requested protocol.
878  *      @kern set to 1 if a kernel socket.
879  * @socket_bind:
880  *      Check permission before socket protocol layer bind operation is
881  *      performed and the socket @sock is bound to the address specified in the
882  *      @address parameter.
883  *      @sock contains the socket structure.
884  *      @address contains the address to bind to.
885  *      @addrlen contains the length of address.
886  *      Return 0 if permission is granted.
887  * @socket_connect:
888  *      Check permission before socket protocol layer connect operation
889  *      attempts to connect socket @sock to a remote address, @address.
890  *      @sock contains the socket structure.
891  *      @address contains the address of remote endpoint.
892  *      @addrlen contains the length of address.
893  *      Return 0 if permission is granted.
894  * @socket_listen:
895  *      Check permission before socket protocol layer listen operation.
896  *      @sock contains the socket structure.
897  *      @backlog contains the maximum length for the pending connection queue.
898  *      Return 0 if permission is granted.
899  * @socket_accept:
900  *      Check permission before accepting a new connection.  Note that the new
901  *      socket, @newsock, has been created and some information copied to it,
902  *      but the accept operation has not actually been performed.
903  *      @sock contains the listening socket structure.
904  *      @newsock contains the newly created server socket for connection.
905  *      Return 0 if permission is granted.
906  * @socket_sendmsg:
907  *      Check permission before transmitting a message to another socket.
908  *      @sock contains the socket structure.
909  *      @msg contains the message to be transmitted.
910  *      @size contains the size of message.
911  *      Return 0 if permission is granted.
912  * @socket_recvmsg:
913  *      Check permission before receiving a message from a socket.
914  *      @sock contains the socket structure.
915  *      @msg contains the message structure.
916  *      @size contains the size of message structure.
917  *      @flags contains the operational flags.
918  *      Return 0 if permission is granted.
919  * @socket_getsockname:
920  *      Check permission before the local address (name) of the socket object
921  *      @sock is retrieved.
922  *      @sock contains the socket structure.
923  *      Return 0 if permission is granted.
924  * @socket_getpeername:
925  *      Check permission before the remote address (name) of a socket object
926  *      @sock is retrieved.
927  *      @sock contains the socket structure.
928  *      Return 0 if permission is granted.
929  * @socket_getsockopt:
930  *      Check permissions before retrieving the options associated with socket
931  *      @sock.
932  *      @sock contains the socket structure.
933  *      @level contains the protocol level to retrieve option from.
934  *      @optname contains the name of option to retrieve.
935  *      Return 0 if permission is granted.
936  * @socket_setsockopt:
937  *      Check permissions before setting the options associated with socket
938  *      @sock.
939  *      @sock contains the socket structure.
940  *      @level contains the protocol level to set options for.
941  *      @optname contains the name of the option to set.
942  *      Return 0 if permission is granted.
943  * @socket_shutdown:
944  *      Checks permission before all or part of a connection on the socket
945  *      @sock is shut down.
946  *      @sock contains the socket structure.
947  *      @how contains the flag indicating how future sends and receives are handled.
948  *      Return 0 if permission is granted.
949  * @socket_sock_rcv_skb:
950  *      Check permissions on incoming network packets.  This hook is distinct
951  *      from Netfilter's IP input hooks since it is the first time that the
952  *      incoming sk_buff @skb has been associated with a particular socket, @sk.
953  *      Must not sleep inside this hook because some callers hold spinlocks.
954  *      @sk contains the sock (not socket) associated with the incoming sk_buff.
955  *      @skb contains the incoming network data.
956  * @socket_getpeersec_stream:
957  *      This hook allows the security module to provide peer socket security
958  *      state for unix or connected tcp sockets to userspace via getsockopt
959  *      SO_GETPEERSEC.  For tcp sockets this can be meaningful if the
960  *      socket is associated with an ipsec SA.
961  *      @sock is the local socket.
962  *      @optval userspace memory where the security state is to be copied.
963  *      @optlen userspace int where the module should copy the actual length
964  *      of the security state.
965  *      @len as input is the maximum length to copy to userspace provided
966  *      by the caller.
967  *      Return 0 if all is well, otherwise, typical getsockopt return
968  *      values.
969  * @socket_getpeersec_dgram:
970  *      This hook allows the security module to provide peer socket security
971  *      state for udp sockets on a per-packet basis to userspace via
972  *      getsockopt SO_GETPEERSEC.  The application must first have indicated
973  *      the IP_PASSSEC option via getsockopt.  It can then retrieve the
974  *      security state returned by this hook for a packet via the SCM_SECURITY
975  *      ancillary message type.
976  *      @skb is the skbuff for the packet being queried
977  *      @secdata is a pointer to a buffer in which to copy the security data
978  *      @seclen is the maximum length for @secdata
979  *      Return 0 on success, error on failure.
980  * @sk_alloc_security:
981  *      Allocate and attach a security structure to the sk->sk_security field,
982  *      which is used to copy security attributes between local stream sockets.
983  * @sk_free_security:
984  *      Deallocate security structure.
985  * @sk_clone_security:
986  *      Clone/copy security structure.
987  * @sk_getsecid:
988  *      Retrieve the LSM-specific secid for the sock to enable caching of network
989  *      authorizations.
990  * @sock_graft:
991  *      Sets the socket's isec sid to the sock's sid.
992  * @inet_conn_request:
993  *      Sets the openreq's sid to socket's sid with MLS portion taken from peer sid.
994  * @inet_csk_clone:
995  *      Sets the new child socket's sid to the openreq sid.
996  * @inet_conn_established:
997  *      Sets the connection's peersid to the secmark on skb.
998  * @secmark_relabel_packet:
999  *      check if the process should be allowed to relabel packets to the given secid
1000  * @security_secmark_refcount_inc
1001  *      tells the LSM to increment the number of secmark labeling rules loaded
1002  * @security_secmark_refcount_dec
1003  *      tells the LSM to decrement the number of secmark labeling rules loaded
1004  * @req_classify_flow:
1005  *      Sets the flow's sid to the openreq sid.
1006  * @tun_dev_alloc_security:
1007  *      This hook allows a module to allocate a security structure for a TUN
1008  *      device.
1009  *      @security pointer to a security structure pointer.
1010  *      Returns a zero on success, negative values on failure.
1011  * @tun_dev_free_security:
1012  *      This hook allows a module to free the security structure for a TUN
1013  *      device.
1014  *      @security pointer to the TUN device's security structure
1015  * @tun_dev_create:
1016  *      Check permissions prior to creating a new TUN device.
1017  * @tun_dev_attach_queue:
1018  *      Check permissions prior to attaching to a TUN device queue.
1019  *      @security pointer to the TUN device's security structure.
1020  * @tun_dev_attach:
1021  *      This hook can be used by the module to update any security state
1022  *      associated with the TUN device's sock structure.
1023  *      @sk contains the existing sock structure.
1024  *      @security pointer to the TUN device's security structure.
1025  * @tun_dev_open:
1026  *      This hook can be used by the module to update any security state
1027  *      associated with the TUN device's security structure.
1028  *      @security pointer to the TUN devices's security structure.
1029  * @skb_owned_by:
1030  *      This hook sets the packet's owning sock.
1031  *      @skb is the packet.
1032  *      @sk the sock which owns the packet.
1033  *
1034  * Security hooks for XFRM operations.
1035  *
1036  * @xfrm_policy_alloc_security:
1037  *      @ctxp is a pointer to the xfrm_sec_ctx being added to Security Policy
1038  *      Database used by the XFRM system.
1039  *      @sec_ctx contains the security context information being provided by
1040  *      the user-level policy update program (e.g., setkey).
1041  *      Allocate a security structure to the xp->security field; the security
1042  *      field is initialized to NULL when the xfrm_policy is allocated.
1043  *      Return 0 if operation was successful (memory to allocate, legal context)
1044  * @xfrm_policy_clone_security:
1045  *      @old_ctx contains an existing xfrm_sec_ctx.
1046  *      @new_ctxp contains a new xfrm_sec_ctx being cloned from old.
1047  *      Allocate a security structure in new_ctxp that contains the
1048  *      information from the old_ctx structure.
1049  *      Return 0 if operation was successful (memory to allocate).
1050  * @xfrm_policy_free_security:
1051  *      @ctx contains the xfrm_sec_ctx
1052  *      Deallocate xp->security.
1053  * @xfrm_policy_delete_security:
1054  *      @ctx contains the xfrm_sec_ctx.
1055  *      Authorize deletion of xp->security.
1056  * @xfrm_state_alloc_security:
1057  *      @x contains the xfrm_state being added to the Security Association
1058  *      Database by the XFRM system.
1059  *      @sec_ctx contains the security context information being provided by
1060  *      the user-level SA generation program (e.g., setkey or racoon).
1061  *      @secid contains the secid from which to take the mls portion of the context.
1062  *      Allocate a security structure to the x->security field; the security
1063  *      field is initialized to NULL when the xfrm_state is allocated. Set the
1064  *      context to correspond to either sec_ctx or polsec, with the mls portion
1065  *      taken from secid in the latter case.
1066  *      Return 0 if operation was successful (memory to allocate, legal context).
1067  * @xfrm_state_free_security:
1068  *      @x contains the xfrm_state.
1069  *      Deallocate x->security.
1070  * @xfrm_state_delete_security:
1071  *      @x contains the xfrm_state.
1072  *      Authorize deletion of x->security.
1073  * @xfrm_policy_lookup:
1074  *      @ctx contains the xfrm_sec_ctx for which the access control is being
1075  *      checked.
1076  *      @fl_secid contains the flow security label that is used to authorize
1077  *      access to the policy xp.
1078  *      @dir contains the direction of the flow (input or output).
1079  *      Check permission when a flow selects a xfrm_policy for processing
1080  *      XFRMs on a packet.  The hook is called when selecting either a
1081  *      per-socket policy or a generic xfrm policy.
1082  *      Return 0 if permission is granted, -ESRCH otherwise, or -errno
1083  *      on other errors.
1084  * @xfrm_state_pol_flow_match:
1085  *      @x contains the state to match.
1086  *      @xp contains the policy to check for a match.
1087  *      @fl contains the flow to check for a match.
1088  *      Return 1 if there is a match.
1089  * @xfrm_decode_session:
1090  *      @skb points to skb to decode.
1091  *      @secid points to the flow key secid to set.
1092  *      @ckall says if all xfrms used should be checked for same secid.
1093  *      Return 0 if ckall is zero or all xfrms used have the same secid.
1094  *
1095  * Security hooks affecting all Key Management operations
1096  *
1097  * @key_alloc:
1098  *      Permit allocation of a key and assign security data. Note that key does
1099  *      not have a serial number assigned at this point.
1100  *      @key points to the key.
1101  *      @flags is the allocation flags
1102  *      Return 0 if permission is granted, -ve error otherwise.
1103  * @key_free:
1104  *      Notification of destruction; free security data.
1105  *      @key points to the key.
1106  *      No return value.
1107  * @key_permission:
1108  *      See whether a specific operational right is granted to a process on a
1109  *      key.
1110  *      @key_ref refers to the key (key pointer + possession attribute bit).
1111  *      @cred points to the credentials to provide the context against which to
1112  *      evaluate the security data on the key.
1113  *      @perm describes the combination of permissions required of this key.
1114  *      Return 0 if permission is granted, -ve error otherwise.
1115  * @key_getsecurity:
1116  *      Get a textual representation of the security context attached to a key
1117  *      for the purposes of honouring KEYCTL_GETSECURITY.  This function
1118  *      allocates the storage for the NUL-terminated string and the caller
1119  *      should free it.
1120  *      @key points to the key to be queried.
1121  *      @_buffer points to a pointer that should be set to point to the
1122  *      resulting string (if no label or an error occurs).
1123  *      Return the length of the string (including terminating NUL) or -ve if
1124  *      an error.
1125  *      May also return 0 (and a NULL buffer pointer) if there is no label.
1126  *
1127  * Security hooks affecting all System V IPC operations.
1128  *
1129  * @ipc_permission:
1130  *      Check permissions for access to IPC
1131  *      @ipcp contains the kernel IPC permission structure
1132  *      @flag contains the desired (requested) permission set
1133  *      Return 0 if permission is granted.
1134  * @ipc_getsecid:
1135  *      Get the secid associated with the ipc object.
1136  *      @ipcp contains the kernel IPC permission structure.
1137  *      @secid contains a pointer to the location where result will be saved.
1138  *      In case of failure, @secid will be set to zero.
1139  *
1140  * Security hooks for individual messages held in System V IPC message queues
1141  * @msg_msg_alloc_security:
1142  *      Allocate and attach a security structure to the msg->security field.
1143  *      The security field is initialized to NULL when the structure is first
1144  *      created.
1145  *      @msg contains the message structure to be modified.
1146  *      Return 0 if operation was successful and permission is granted.
1147  * @msg_msg_free_security:
1148  *      Deallocate the security structure for this message.
1149  *      @msg contains the message structure to be modified.
1150  *
1151  * Security hooks for System V IPC Message Queues
1152  *
1153  * @msg_queue_alloc_security:
1154  *      Allocate and attach a security structure to the
1155  *      msq->q_perm.security field. The security field is initialized to
1156  *      NULL when the structure is first created.
1157  *      @msq contains the message queue structure to be modified.
1158  *      Return 0 if operation was successful and permission is granted.
1159  * @msg_queue_free_security:
1160  *      Deallocate security structure for this message queue.
1161  *      @msq contains the message queue structure to be modified.
1162  * @msg_queue_associate:
1163  *      Check permission when a message queue is requested through the
1164  *      msgget system call.  This hook is only called when returning the
1165  *      message queue identifier for an existing message queue, not when a
1166  *      new message queue is created.
1167  *      @msq contains the message queue to act upon.
1168  *      @msqflg contains the operation control flags.
1169  *      Return 0 if permission is granted.
1170  * @msg_queue_msgctl:
1171  *      Check permission when a message control operation specified by @cmd
1172  *      is to be performed on the message queue @msq.
1173  *      The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO.
1174  *      @msq contains the message queue to act upon.  May be NULL.
1175  *      @cmd contains the operation to be performed.
1176  *      Return 0 if permission is granted.
1177  * @msg_queue_msgsnd:
1178  *      Check permission before a message, @msg, is enqueued on the message
1179  *      queue, @msq.
1180  *      @msq contains the message queue to send message to.
1181  *      @msg contains the message to be enqueued.
1182  *      @msqflg contains operational flags.
1183  *      Return 0 if permission is granted.
1184  * @msg_queue_msgrcv:
1185  *      Check permission before a message, @msg, is removed from the message
1186  *      queue, @msq.  The @target task structure contains a pointer to the
1187  *      process that will be receiving the message (not equal to the current
1188  *      process when inline receives are being performed).
1189  *      @msq contains the message queue to retrieve message from.
1190  *      @msg contains the message destination.
1191  *      @target contains the task structure for recipient process.
1192  *      @type contains the type of message requested.
1193  *      @mode contains the operational flags.
1194  *      Return 0 if permission is granted.
1195  *
1196  * Security hooks for System V Shared Memory Segments
1197  *
1198  * @shm_alloc_security:
1199  *      Allocate and attach a security structure to the shp->shm_perm.security
1200  *      field.  The security field is initialized to NULL when the structure is
1201  *      first created.
1202  *      @shp contains the shared memory structure to be modified.
1203  *      Return 0 if operation was successful and permission is granted.
1204  * @shm_free_security:
1205  *      Deallocate the security struct for this memory segment.
1206  *      @shp contains the shared memory structure to be modified.
1207  * @shm_associate:
1208  *      Check permission when a shared memory region is requested through the
1209  *      shmget system call.  This hook is only called when returning the shared
1210  *      memory region identifier for an existing region, not when a new shared
1211  *      memory region is created.
1212  *      @shp contains the shared memory structure to be modified.
1213  *      @shmflg contains the operation control flags.
1214  *      Return 0 if permission is granted.
1215  * @shm_shmctl:
1216  *      Check permission when a shared memory control operation specified by
1217  *      @cmd is to be performed on the shared memory region @shp.
1218  *      The @shp may be NULL, e.g. for IPC_INFO or SHM_INFO.
1219  *      @shp contains shared memory structure to be modified.
1220  *      @cmd contains the operation to be performed.
1221  *      Return 0 if permission is granted.
1222  * @shm_shmat:
1223  *      Check permissions prior to allowing the shmat system call to attach the
1224  *      shared memory segment @shp to the data segment of the calling process.
1225  *      The attaching address is specified by @shmaddr.
1226  *      @shp contains the shared memory structure to be modified.
1227  *      @shmaddr contains the address to attach memory region to.
1228  *      @shmflg contains the operational flags.
1229  *      Return 0 if permission is granted.
1230  *
1231  * Security hooks for System V Semaphores
1232  *
1233  * @sem_alloc_security:
1234  *      Allocate and attach a security structure to the sma->sem_perm.security
1235  *      field.  The security field is initialized to NULL when the structure is
1236  *      first created.
1237  *      @sma contains the semaphore structure
1238  *      Return 0 if operation was successful and permission is granted.
1239  * @sem_free_security:
1240  *      deallocate security struct for this semaphore
1241  *      @sma contains the semaphore structure.
1242  * @sem_associate:
1243  *      Check permission when a semaphore is requested through the semget
1244  *      system call.  This hook is only called when returning the semaphore
1245  *      identifier for an existing semaphore, not when a new one must be
1246  *      created.
1247  *      @sma contains the semaphore structure.
1248  *      @semflg contains the operation control flags.
1249  *      Return 0 if permission is granted.
1250  * @sem_semctl:
1251  *      Check permission when a semaphore operation specified by @cmd is to be
1252  *      performed on the semaphore @sma.  The @sma may be NULL, e.g. for
1253  *      IPC_INFO or SEM_INFO.
1254  *      @sma contains the semaphore structure.  May be NULL.
1255  *      @cmd contains the operation to be performed.
1256  *      Return 0 if permission is granted.
1257  * @sem_semop
1258  *      Check permissions before performing operations on members of the
1259  *      semaphore set @sma.  If the @alter flag is nonzero, the semaphore set
1260  *      may be modified.
1261  *      @sma contains the semaphore structure.
1262  *      @sops contains the operations to perform.
1263  *      @nsops contains the number of operations to perform.
1264  *      @alter contains the flag indicating whether changes are to be made.
1265  *      Return 0 if permission is granted.
1266  *
1267  * @ptrace_access_check:
1268  *      Check permission before allowing the current process to trace the
1269  *      @child process.
1270  *      Security modules may also want to perform a process tracing check
1271  *      during an execve in the set_security or apply_creds hooks of
1272  *      tracing check during an execve in the bprm_set_creds hook of
1273  *      binprm_security_ops if the process is being traced and its security
1274  *      attributes would be changed by the execve.
1275  *      @child contains the task_struct structure for the target process.
1276  *      @mode contains the PTRACE_MODE flags indicating the form of access.
1277  *      Return 0 if permission is granted.
1278  * @ptrace_traceme:
1279  *      Check that the @parent process has sufficient permission to trace the
1280  *      current process before allowing the current process to present itself
1281  *      to the @parent process for tracing.
1282  *      @parent contains the task_struct structure for debugger process.
1283  *      Return 0 if permission is granted.
1284  * @capget:
1285  *      Get the @effective, @inheritable, and @permitted capability sets for
1286  *      the @target process.  The hook may also perform permission checking to
1287  *      determine if the current process is allowed to see the capability sets
1288  *      of the @target process.
1289  *      @target contains the task_struct structure for target process.
1290  *      @effective contains the effective capability set.
1291  *      @inheritable contains the inheritable capability set.
1292  *      @permitted contains the permitted capability set.
1293  *      Return 0 if the capability sets were successfully obtained.
1294  * @capset:
1295  *      Set the @effective, @inheritable, and @permitted capability sets for
1296  *      the current process.
1297  *      @new contains the new credentials structure for target process.
1298  *      @old contains the current credentials structure for target process.
1299  *      @effective contains the effective capability set.
1300  *      @inheritable contains the inheritable capability set.
1301  *      @permitted contains the permitted capability set.
1302  *      Return 0 and update @new if permission is granted.
1303  * @capable:
1304  *      Check whether the @tsk process has the @cap capability in the indicated
1305  *      credentials.
1306  *      @cred contains the credentials to use.
1307  *      @ns contains the user namespace we want the capability in
1308  *      @cap contains the capability <include/linux/capability.h>.
1309  *      @audit: Whether to write an audit message or not
1310  *      Return 0 if the capability is granted for @tsk.
1311  * @syslog:
1312  *      Check permission before accessing the kernel message ring or changing
1313  *      logging to the console.
1314  *      See the syslog(2) manual page for an explanation of the @type values.
1315  *      @type contains the type of action.
1316  *      @from_file indicates the context of action (if it came from /proc).
1317  *      Return 0 if permission is granted.
1318  * @settime:
1319  *      Check permission to change the system time.
1320  *      struct timespec and timezone are defined in include/linux/time.h
1321  *      @ts contains new time
1322  *      @tz contains new timezone
1323  *      Return 0 if permission is granted.
1324  * @vm_enough_memory:
1325  *      Check permissions for allocating a new virtual mapping.
1326  *      @mm contains the mm struct it is being added to.
1327  *      @pages contains the number of pages.
1328  *      Return 0 if permission is granted.
1329  *
1330  * @ismaclabel:
1331  *      Check if the extended attribute specified by @name
1332  *      represents a MAC label. Returns 1 if name is a MAC
1333  *      attribute otherwise returns 0.
1334  *      @name full extended attribute name to check against
1335  *      LSM as a MAC label.
1336  *
1337  * @secid_to_secctx:
1338  *      Convert secid to security context.  If secdata is NULL the length of
1339  *      the result will be returned in seclen, but no secdata will be returned.
1340  *      This does mean that the length could change between calls to check the
1341  *      length and the next call which actually allocates and returns the secdata.
1342  *      @secid contains the security ID.
1343  *      @secdata contains the pointer that stores the converted security context.
1344  *      @seclen pointer which contains the length of the data
1345  * @secctx_to_secid:
1346  *      Convert security context to secid.
1347  *      @secid contains the pointer to the generated security ID.
1348  *      @secdata contains the security context.
1349  *
1350  * @release_secctx:
1351  *      Release the security context.
1352  *      @secdata contains the security context.
1353  *      @seclen contains the length of the security context.
1354  *
1355  * Security hooks for Audit
1356  *
1357  * @audit_rule_init:
1358  *      Allocate and initialize an LSM audit rule structure.
1359  *      @field contains the required Audit action. Fields flags are defined in include/linux/audit.h
1360  *      @op contains the operator the rule uses.
1361  *      @rulestr contains the context where the rule will be applied to.
1362  *      @lsmrule contains a pointer to receive the result.
1363  *      Return 0 if @lsmrule has been successfully set,
1364  *      -EINVAL in case of an invalid rule.
1365  *
1366  * @audit_rule_known:
1367  *      Specifies whether given @rule contains any fields related to current LSM.
1368  *      @rule contains the audit rule of interest.
1369  *      Return 1 in case of relation found, 0 otherwise.
1370  *
1371  * @audit_rule_match:
1372  *      Determine if given @secid matches a rule previously approved
1373  *      by @audit_rule_known.
1374  *      @secid contains the security id in question.
1375  *      @field contains the field which relates to current LSM.
1376  *      @op contains the operator that will be used for matching.
1377  *      @rule points to the audit rule that will be checked against.
1378  *      @actx points to the audit context associated with the check.
1379  *      Return 1 if secid matches the rule, 0 if it does not, -ERRNO on failure.
1380  *
1381  * @audit_rule_free:
1382  *      Deallocate the LSM audit rule structure previously allocated by
1383  *      audit_rule_init.
1384  *      @rule contains the allocated rule
1385  *
1386  * @inode_notifysecctx:
1387  *      Notify the security module of what the security context of an inode
1388  *      should be.  Initializes the incore security context managed by the
1389  *      security module for this inode.  Example usage:  NFS client invokes
1390  *      this hook to initialize the security context in its incore inode to the
1391  *      value provided by the server for the file when the server returned the
1392  *      file's attributes to the client.
1393  *
1394  *      Must be called with inode->i_mutex locked.
1395  *
1396  *      @inode we wish to set the security context of.
1397  *      @ctx contains the string which we wish to set in the inode.
1398  *      @ctxlen contains the length of @ctx.
1399  *
1400  * @inode_setsecctx:
1401  *      Change the security context of an inode.  Updates the
1402  *      incore security context managed by the security module and invokes the
1403  *      fs code as needed (via __vfs_setxattr_noperm) to update any backing
1404  *      xattrs that represent the context.  Example usage:  NFS server invokes
1405  *      this hook to change the security context in its incore inode and on the
1406  *      backing filesystem to a value provided by the client on a SETATTR
1407  *      operation.
1408  *
1409  *      Must be called with inode->i_mutex locked.
1410  *
1411  *      @dentry contains the inode we wish to set the security context of.
1412  *      @ctx contains the string which we wish to set in the inode.
1413  *      @ctxlen contains the length of @ctx.
1414  *
1415  * @inode_getsecctx:
1416  *      On success, returns 0 and fills out @ctx and @ctxlen with the security
1417  *      context for the given @inode.
1418  *
1419  *      @inode we wish to get the security context of.
1420  *      @ctx is a pointer in which to place the allocated security context.
1421  *      @ctxlen points to the place to put the length of @ctx.
1422  * This is the main security structure.
1423  */
1424 struct security_operations {
1425         char name[SECURITY_NAME_MAX + 1];
1426 
1427         int (*ptrace_access_check) (struct task_struct *child, unsigned int mode);
1428         int (*ptrace_traceme) (struct task_struct *parent);
1429         int (*capget) (struct task_struct *target,
1430                        kernel_cap_t *effective,
1431                        kernel_cap_t *inheritable, kernel_cap_t *permitted);
1432         int (*capset) (struct cred *new,
1433                        const struct cred *old,
1434                        const kernel_cap_t *effective,
1435                        const kernel_cap_t *inheritable,
1436                        const kernel_cap_t *permitted);
1437         int (*capable) (const struct cred *cred, struct user_namespace *ns,
1438                         int cap, int audit);
1439         int (*quotactl) (int cmds, int type, int id, struct super_block *sb);
1440         int (*quota_on) (struct dentry *dentry);
1441         int (*syslog) (int type);
1442         int (*settime) (const struct timespec *ts, const struct timezone *tz);
1443         int (*vm_enough_memory) (struct mm_struct *mm, long pages);
1444 
1445         int (*bprm_set_creds) (struct linux_binprm *bprm);
1446         int (*bprm_check_security) (struct linux_binprm *bprm);
1447         int (*bprm_secureexec) (struct linux_binprm *bprm);
1448         void (*bprm_committing_creds) (struct linux_binprm *bprm);
1449         void (*bprm_committed_creds) (struct linux_binprm *bprm);
1450 
1451         int (*sb_alloc_security) (struct super_block *sb);
1452         void (*sb_free_security) (struct super_block *sb);
1453         int (*sb_copy_data) (char *orig, char *copy);
1454         int (*sb_remount) (struct super_block *sb, void *data);
1455         int (*sb_kern_mount) (struct super_block *sb, int flags, void *data);
1456         int (*sb_show_options) (struct seq_file *m, struct super_block *sb);
1457         int (*sb_statfs) (struct dentry *dentry);
1458         int (*sb_mount) (const char *dev_name, struct path *path,
1459                          const char *type, unsigned long flags, void *data);
1460         int (*sb_umount) (struct vfsmount *mnt, int flags);
1461         int (*sb_pivotroot) (struct path *old_path,
1462                              struct path *new_path);
1463         int (*sb_set_mnt_opts) (struct super_block *sb,
1464                                 struct security_mnt_opts *opts,
1465                                 unsigned long kern_flags,
1466                                 unsigned long *set_kern_flags);
1467         int (*sb_clone_mnt_opts) (const struct super_block *oldsb,
1468                                    struct super_block *newsb);
1469         int (*sb_parse_opts_str) (char *options, struct security_mnt_opts *opts);
1470         int (*dentry_init_security) (struct dentry *dentry, int mode,
1471                                         struct qstr *name, void **ctx,
1472                                         u32 *ctxlen);
1473 
1474 
1475 #ifdef CONFIG_SECURITY_PATH
1476         int (*path_unlink) (struct path *dir, struct dentry *dentry);
1477         int (*path_mkdir) (struct path *dir, struct dentry *dentry, umode_t mode);
1478         int (*path_rmdir) (struct path *dir, struct dentry *dentry);
1479         int (*path_mknod) (struct path *dir, struct dentry *dentry, umode_t mode,
1480                            unsigned int dev);
1481         int (*path_truncate) (struct path *path);
1482         int (*path_symlink) (struct path *dir, struct dentry *dentry,
1483                              const char *old_name);
1484         int (*path_link) (struct dentry *old_dentry, struct path *new_dir,
1485                           struct dentry *new_dentry);
1486         int (*path_rename) (struct path *old_dir, struct dentry *old_dentry,
1487                             struct path *new_dir, struct dentry *new_dentry);
1488         int (*path_chmod) (struct path *path, umode_t mode);
1489         int (*path_chown) (struct path *path, kuid_t uid, kgid_t gid);
1490         int (*path_chroot) (struct path *path);
1491 #endif
1492 
1493         int (*inode_alloc_security) (struct inode *inode);
1494         void (*inode_free_security) (struct inode *inode);
1495         int (*inode_init_security) (struct inode *inode, struct inode *dir,
1496                                     const struct qstr *qstr, char **name,
1497                                     void **value, size_t *len);
1498         int (*inode_create) (struct inode *dir,
1499                              struct dentry *dentry, umode_t mode);
1500         int (*inode_link) (struct dentry *old_dentry,
1501                            struct inode *dir, struct dentry *new_dentry);
1502         int (*inode_unlink) (struct inode *dir, struct dentry *dentry);
1503         int (*inode_symlink) (struct inode *dir,
1504                               struct dentry *dentry, const char *old_name);
1505         int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, umode_t mode);
1506         int (*inode_rmdir) (struct inode *dir, struct dentry *dentry);
1507         int (*inode_mknod) (struct inode *dir, struct dentry *dentry,
1508                             umode_t mode, dev_t dev);
1509         int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
1510                              struct inode *new_dir, struct dentry *new_dentry);
1511         int (*inode_readlink) (struct dentry *dentry);
1512         int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
1513         int (*inode_permission) (struct inode *inode, int mask);
1514         int (*inode_setattr)    (struct dentry *dentry, struct iattr *attr);
1515         int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
1516         int (*inode_setxattr) (struct dentry *dentry, const char *name,
1517                                const void *value, size_t size, int flags);
1518         void (*inode_post_setxattr) (struct dentry *dentry, const char *name,
1519                                      const void *value, size_t size, int flags);
1520         int (*inode_getxattr) (struct dentry *dentry, const char *name);
1521         int (*inode_listxattr) (struct dentry *dentry);
1522         int (*inode_removexattr) (struct dentry *dentry, const char *name);
1523         int (*inode_need_killpriv) (struct dentry *dentry);
1524         int (*inode_killpriv) (struct dentry *dentry);
1525         int (*inode_getsecurity) (const struct inode *inode, const char *name, void **buffer, bool alloc);
1526         int (*inode_setsecurity) (struct inode *inode, const char *name, const void *value, size_t size, int flags);
1527         int (*inode_listsecurity) (struct inode *inode, char *buffer, size_t buffer_size);
1528         void (*inode_getsecid) (const struct inode *inode, u32 *secid);
1529 
1530         int (*file_permission) (struct file *file, int mask);
1531         int (*file_alloc_security) (struct file *file);
1532         void (*file_free_security) (struct file *file);
1533         int (*file_ioctl) (struct file *file, unsigned int cmd,
1534                            unsigned long arg);
1535         int (*mmap_addr) (unsigned long addr);
1536         int (*mmap_file) (struct file *file,
1537                           unsigned long reqprot, unsigned long prot,
1538                           unsigned long flags);
1539         int (*file_mprotect) (struct vm_area_struct *vma,
1540                               unsigned long reqprot,
1541                               unsigned long prot);
1542         int (*file_lock) (struct file *file, unsigned int cmd);
1543         int (*file_fcntl) (struct file *file, unsigned int cmd,
1544                            unsigned long arg);
1545         int (*file_set_fowner) (struct file *file);
1546         int (*file_send_sigiotask) (struct task_struct *tsk,
1547                                     struct fown_struct *fown, int sig);
1548         int (*file_receive) (struct file *file);
1549         int (*file_open) (struct file *file, const struct cred *cred);
1550 
1551         int (*task_create) (unsigned long clone_flags);
1552         void (*task_free) (struct task_struct *task);
1553         int (*cred_alloc_blank) (struct cred *cred, gfp_t gfp);
1554         void (*cred_free) (struct cred *cred);
1555         int (*cred_prepare)(struct cred *new, const struct cred *old,
1556                             gfp_t gfp);
1557         void (*cred_transfer)(struct cred *new, const struct cred *old);
1558         int (*kernel_act_as)(struct cred *new, u32 secid);
1559         int (*kernel_create_files_as)(struct cred *new, struct inode *inode);
1560         int (*kernel_module_request)(char *kmod_name);
1561         int (*kernel_module_from_file)(struct file *file);
1562         int (*task_fix_setuid) (struct cred *new, const struct cred *old,
1563                                 int flags);
1564         int (*task_setpgid) (struct task_struct *p, pid_t pgid);
1565         int (*task_getpgid) (struct task_struct *p);
1566         int (*task_getsid) (struct task_struct *p);
1567         void (*task_getsecid) (struct task_struct *p, u32 *secid);
1568         int (*task_setnice) (struct task_struct *p, int nice);
1569         int (*task_setioprio) (struct task_struct *p, int ioprio);
1570         int (*task_getioprio) (struct task_struct *p);
1571         int (*task_setrlimit) (struct task_struct *p, unsigned int resource,
1572                         struct rlimit *new_rlim);
1573         int (*task_setscheduler) (struct task_struct *p);
1574         int (*task_getscheduler) (struct task_struct *p);
1575         int (*task_movememory) (struct task_struct *p);
1576         int (*task_kill) (struct task_struct *p,
1577                           struct siginfo *info, int sig, u32 secid);
1578         int (*task_wait) (struct task_struct *p);
1579         int (*task_prctl) (int option, unsigned long arg2,
1580                            unsigned long arg3, unsigned long arg4,
1581                            unsigned long arg5);
1582         void (*task_to_inode) (struct task_struct *p, struct inode *inode);
1583 
1584         int (*ipc_permission) (struct kern_ipc_perm *ipcp, short flag);
1585         void (*ipc_getsecid) (struct kern_ipc_perm *ipcp, u32 *secid);
1586 
1587         int (*msg_msg_alloc_security) (struct msg_msg *msg);
1588         void (*msg_msg_free_security) (struct msg_msg *msg);
1589 
1590         int (*msg_queue_alloc_security) (struct msg_queue *msq);
1591         void (*msg_queue_free_security) (struct msg_queue *msq);
1592         int (*msg_queue_associate) (struct msg_queue *msq, int msqflg);
1593         int (*msg_queue_msgctl) (struct msg_queue *msq, int cmd);
1594         int (*msg_queue_msgsnd) (struct msg_queue *msq,
1595                                  struct msg_msg *msg, int msqflg);
1596         int (*msg_queue_msgrcv) (struct msg_queue *msq,
1597                                  struct msg_msg *msg,
1598                                  struct task_struct *target,
1599                                  long type, int mode);
1600 
1601         int (*shm_alloc_security) (struct shmid_kernel *shp);
1602         void (*shm_free_security) (struct shmid_kernel *shp);
1603         int (*shm_associate) (struct shmid_kernel *shp, int shmflg);
1604         int (*shm_shmctl) (struct shmid_kernel *shp, int cmd);
1605         int (*shm_shmat) (struct shmid_kernel *shp,
1606                           char __user *shmaddr, int shmflg);
1607 
1608         int (*sem_alloc_security) (struct sem_array *sma);
1609         void (*sem_free_security) (struct sem_array *sma);
1610         int (*sem_associate) (struct sem_array *sma, int semflg);
1611         int (*sem_semctl) (struct sem_array *sma, int cmd);
1612         int (*sem_semop) (struct sem_array *sma,
1613                           struct sembuf *sops, unsigned nsops, int alter);
1614 
1615         int (*netlink_send) (struct sock *sk, struct sk_buff *skb);
1616 
1617         void (*d_instantiate) (struct dentry *dentry, struct inode *inode);
1618 
1619         int (*getprocattr) (struct task_struct *p, char *name, char **value);
1620         int (*setprocattr) (struct task_struct *p, char *name, void *value, size_t size);
1621         int (*ismaclabel) (const char *name);
1622         int (*secid_to_secctx) (u32 secid, char **secdata, u32 *seclen);
1623         int (*secctx_to_secid) (const char *secdata, u32 seclen, u32 *secid);
1624         void (*release_secctx) (char *secdata, u32 seclen);
1625 
1626         int (*inode_notifysecctx)(struct inode *inode, void *ctx, u32 ctxlen);
1627         int (*inode_setsecctx)(struct dentry *dentry, void *ctx, u32 ctxlen);
1628         int (*inode_getsecctx)(struct inode *inode, void **ctx, u32 *ctxlen);
1629 
1630 #ifdef CONFIG_SECURITY_NETWORK
1631         int (*unix_stream_connect) (struct sock *sock, struct sock *other, struct sock *newsk);
1632         int (*unix_may_send) (struct socket *sock, struct socket *other);
1633 
1634         int (*socket_create) (int family, int type, int protocol, int kern);
1635         int (*socket_post_create) (struct socket *sock, int family,
1636                                    int type, int protocol, int kern);
1637         int (*socket_bind) (struct socket *sock,
1638                             struct sockaddr *address, int addrlen);
1639         int (*socket_connect) (struct socket *sock,
1640                                struct sockaddr *address, int addrlen);
1641         int (*socket_listen) (struct socket *sock, int backlog);
1642         int (*socket_accept) (struct socket *sock, struct socket *newsock);
1643         int (*socket_sendmsg) (struct socket *sock,
1644                                struct msghdr *msg, int size);
1645         int (*socket_recvmsg) (struct socket *sock,
1646                                struct msghdr *msg, int size, int flags);
1647         int (*socket_getsockname) (struct socket *sock);
1648         int (*socket_getpeername) (struct socket *sock);
1649         int (*socket_getsockopt) (struct socket *sock, int level, int optname);
1650         int (*socket_setsockopt) (struct socket *sock, int level, int optname);
1651         int (*socket_shutdown) (struct socket *sock, int how);
1652         int (*socket_sock_rcv_skb) (struct sock *sk, struct sk_buff *skb);
1653         int (*socket_getpeersec_stream) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len);
1654         int (*socket_getpeersec_dgram) (struct socket *sock, struct sk_buff *skb, u32 *secid);
1655         int (*sk_alloc_security) (struct sock *sk, int family, gfp_t priority);
1656         void (*sk_free_security) (struct sock *sk);
1657         void (*sk_clone_security) (const struct sock *sk, struct sock *newsk);
1658         void (*sk_getsecid) (struct sock *sk, u32 *secid);
1659         void (*sock_graft) (struct sock *sk, struct socket *parent);
1660         int (*inet_conn_request) (struct sock *sk, struct sk_buff *skb,
1661                                   struct request_sock *req);
1662         void (*inet_csk_clone) (struct sock *newsk, const struct request_sock *req);
1663         void (*inet_conn_established) (struct sock *sk, struct sk_buff *skb);
1664         int (*secmark_relabel_packet) (u32 secid);
1665         void (*secmark_refcount_inc) (void);
1666         void (*secmark_refcount_dec) (void);
1667         void (*req_classify_flow) (const struct request_sock *req, struct flowi *fl);
1668         int (*tun_dev_alloc_security) (void **security);
1669         void (*tun_dev_free_security) (void *security);
1670         int (*tun_dev_create) (void);
1671         int (*tun_dev_attach_queue) (void *security);
1672         int (*tun_dev_attach) (struct sock *sk, void *security);
1673         int (*tun_dev_open) (void *security);
1674         void (*skb_owned_by) (struct sk_buff *skb, struct sock *sk);
1675 #endif  /* CONFIG_SECURITY_NETWORK */
1676 
1677 #ifdef CONFIG_SECURITY_NETWORK_XFRM
1678         int (*xfrm_policy_alloc_security) (struct xfrm_sec_ctx **ctxp,
1679                         struct xfrm_user_sec_ctx *sec_ctx);
1680         int (*xfrm_policy_clone_security) (struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctx);
1681         void (*xfrm_policy_free_security) (struct xfrm_sec_ctx *ctx);
1682         int (*xfrm_policy_delete_security) (struct xfrm_sec_ctx *ctx);
1683         int (*xfrm_state_alloc_security) (struct xfrm_state *x,
1684                 struct xfrm_user_sec_ctx *sec_ctx,
1685                 u32 secid);
1686         void (*xfrm_state_free_security) (struct xfrm_state *x);
1687         int (*xfrm_state_delete_security) (struct xfrm_state *x);
1688         int (*xfrm_policy_lookup) (struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir);
1689         int (*xfrm_state_pol_flow_match) (struct xfrm_state *x,
1690                                           struct xfrm_policy *xp,
1691                                           const struct flowi *fl);
1692         int (*xfrm_decode_session) (struct sk_buff *skb, u32 *secid, int ckall);
1693 #endif  /* CONFIG_SECURITY_NETWORK_XFRM */
1694 
1695         /* key management security hooks */
1696 #ifdef CONFIG_KEYS
1697         int (*key_alloc) (struct key *key, const struct cred *cred, unsigned long flags);
1698         void (*key_free) (struct key *key);
1699         int (*key_permission) (key_ref_t key_ref,
1700                                const struct cred *cred,
1701                                key_perm_t perm);
1702         int (*key_getsecurity)(struct key *key, char **_buffer);
1703 #endif  /* CONFIG_KEYS */
1704 
1705 #ifdef CONFIG_AUDIT
1706         int (*audit_rule_init) (u32 field, u32 op, char *rulestr, void **lsmrule);
1707         int (*audit_rule_known) (struct audit_krule *krule);
1708         int (*audit_rule_match) (u32 secid, u32 field, u32 op, void *lsmrule,
1709                                  struct audit_context *actx);
1710         void (*audit_rule_free) (void *lsmrule);
1711 #endif /* CONFIG_AUDIT */
1712 };
1713 
1714 /* prototypes */
1715 extern int security_init(void);
1716 extern int security_module_enable(struct security_operations *ops);
1717 extern int register_security(struct security_operations *ops);
1718 extern void __init security_fixup_ops(struct security_operations *ops);
1719 
1720 
1721 /* Security operations */
1722 int security_ptrace_access_check(struct task_struct *child, unsigned int mode);
1723 int security_ptrace_traceme(struct task_struct *parent);
1724 int security_capget(struct task_struct *target,
1725                     kernel_cap_t *effective,
1726                     kernel_cap_t *inheritable,
1727                     kernel_cap_t *permitted);
1728 int security_capset(struct cred *new, const struct cred *old,
1729                     const kernel_cap_t *effective,
1730                     const kernel_cap_t *inheritable,
1731                     const kernel_cap_t *permitted);
1732 int security_capable(const struct cred *cred, struct user_namespace *ns,
1733                         int cap);
1734 int security_capable_noaudit(const struct cred *cred, struct user_namespace *ns,
1735                              int cap);
1736 int security_quotactl(int cmds, int type, int id, struct super_block *sb);
1737 int security_quota_on(struct dentry *dentry);
1738 int security_syslog(int type);
1739 int security_settime(const struct timespec *ts, const struct timezone *tz);
1740 int security_vm_enough_memory_mm(struct mm_struct *mm, long pages);
1741 int security_bprm_set_creds(struct linux_binprm *bprm);
1742 int security_bprm_check(struct linux_binprm *bprm);
1743 void security_bprm_committing_creds(struct linux_binprm *bprm);
1744 void security_bprm_committed_creds(struct linux_binprm *bprm);
1745 int security_bprm_secureexec(struct linux_binprm *bprm);
1746 int security_sb_alloc(struct super_block *sb);
1747 void security_sb_free(struct super_block *sb);
1748 int security_sb_copy_data(char *orig, char *copy);
1749 int security_sb_remount(struct super_block *sb, void *data);
1750 int security_sb_kern_mount(struct super_block *sb, int flags, void *data);
1751 int security_sb_show_options(struct seq_file *m, struct super_block *sb);
1752 int security_sb_statfs(struct dentry *dentry);
1753 int security_sb_mount(const char *dev_name, struct path *path,
1754                       const char *type, unsigned long flags, void *data);
1755 int security_sb_umount(struct vfsmount *mnt, int flags);
1756 int security_sb_pivotroot(struct path *old_path, struct path *new_path);
1757 int security_sb_set_mnt_opts(struct super_block *sb,
1758                                 struct security_mnt_opts *opts,
1759                                 unsigned long kern_flags,
1760                                 unsigned long *set_kern_flags);
1761 int security_sb_clone_mnt_opts(const struct super_block *oldsb,
1762                                 struct super_block *newsb);
1763 int security_sb_parse_opts_str(char *options, struct security_mnt_opts *opts);
1764 int security_dentry_init_security(struct dentry *dentry, int mode,
1765                                         struct qstr *name, void **ctx,
1766                                         u32 *ctxlen);
1767 
1768 int security_inode_alloc(struct inode *inode);
1769 void security_inode_free(struct inode *inode);
1770 int security_inode_init_security(struct inode *inode, struct inode *dir,
1771                                  const struct qstr *qstr,
1772                                  initxattrs initxattrs, void *fs_data);
1773 int security_old_inode_init_security(struct inode *inode, struct inode *dir,
1774                                      const struct qstr *qstr, char **name,
1775                                      void **value, size_t *len);
1776 int security_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode);
1777 int security_inode_link(struct dentry *old_dentry, struct inode *dir,
1778                          struct dentry *new_dentry);
1779 int security_inode_unlink(struct inode *dir, struct dentry *dentry);
1780 int security_inode_symlink(struct inode *dir, struct dentry *dentry,
1781                            const char *old_name);
1782 int security_inode_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode);
1783 int security_inode_rmdir(struct inode *dir, struct dentry *dentry);
1784 int security_inode_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev);
1785 int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
1786                           struct inode *new_dir, struct dentry *new_dentry);
1787 int security_inode_readlink(struct dentry *dentry);
1788 int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd);
1789 int security_inode_permission(struct inode *inode, int mask);
1790 int security_inode_setattr(struct dentry *dentry, struct iattr *attr);
1791 int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry);
1792 int security_inode_setxattr(struct dentry *dentry, const char *name,
1793                             const void *value, size_t size, int flags);
1794 void security_inode_post_setxattr(struct dentry *dentry, const char *name,
1795                                   const void *value, size_t size, int flags);
1796 int security_inode_getxattr(struct dentry *dentry, const char *name);
1797 int security_inode_listxattr(struct dentry *dentry);
1798 int security_inode_removexattr(struct dentry *dentry, const char *name);
1799 int security_inode_need_killpriv(struct dentry *dentry);
1800 int security_inode_killpriv(struct dentry *dentry);
1801 int security_inode_getsecurity(const struct inode *inode, const char *name, void **buffer, bool alloc);
1802 int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags);
1803 int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size);
1804 void security_inode_getsecid(const struct inode *inode, u32 *secid);
1805 int security_file_permission(struct file *file, int mask);
1806 int security_file_alloc(struct file *file);
1807 void security_file_free(struct file *file);
1808 int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
1809 int security_mmap_file(struct file *file, unsigned long prot,
1810                         unsigned long flags);
1811 int security_mmap_addr(unsigned long addr);
1812 int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
1813                            unsigned long prot);
1814 int security_file_lock(struct file *file, unsigned int cmd);
1815 int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
1816 int security_file_set_fowner(struct file *file);
1817 int security_file_send_sigiotask(struct task_struct *tsk,
1818                                  struct fown_struct *fown, int sig);
1819 int security_file_receive(struct file *file);
1820 int security_file_open(struct file *file, const struct cred *cred);
1821 int security_task_create(unsigned long clone_flags);
1822 void security_task_free(struct task_struct *task);
1823 int security_cred_alloc_blank(struct cred *cred, gfp_t gfp);
1824 void security_cred_free(struct cred *cred);
1825 int security_prepare_creds(struct cred *new, const struct cred *old, gfp_t gfp);
1826 void security_transfer_creds(struct cred *new, const struct cred *old);
1827 int security_kernel_act_as(struct cred *new, u32 secid);
1828 int security_kernel_create_files_as(struct cred *new, struct inode *inode);
1829 int security_kernel_module_request(char *kmod_name);
1830 int security_kernel_module_from_file(struct file *file);
1831 int security_task_fix_setuid(struct cred *new, const struct cred *old,
1832                              int flags);
1833 int security_task_setpgid(struct task_struct *p, pid_t pgid);
1834 int security_task_getpgid(struct task_struct *p);
1835 int security_task_getsid(struct task_struct *p);
1836 void security_task_getsecid(struct task_struct *p, u32 *secid);
1837 int security_task_setnice(struct task_struct *p, int nice);
1838 int security_task_setioprio(struct task_struct *p, int ioprio);
1839 int security_task_getioprio(struct task_struct *p);
1840 int security_task_setrlimit(struct task_struct *p, unsigned int resource,
1841                 struct rlimit *new_rlim);
1842 int security_task_setscheduler(struct task_struct *p);
1843 int security_task_getscheduler(struct task_struct *p);
1844 int security_task_movememory(struct task_struct *p);
1845 int security_task_kill(struct task_struct *p, struct siginfo *info,
1846                         int sig, u32 secid);
1847 int security_task_wait(struct task_struct *p);
1848 int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
1849                         unsigned long arg4, unsigned long arg5);
1850 void security_task_to_inode(struct task_struct *p, struct inode *inode);
1851 int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag);
1852 void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid);
1853 int security_msg_msg_alloc(struct msg_msg *msg);
1854 void security_msg_msg_free(struct msg_msg *msg);
1855 int security_msg_queue_alloc(struct msg_queue *msq);
1856 void security_msg_queue_free(struct msg_queue *msq);
1857 int security_msg_queue_associate(struct msg_queue *msq, int msqflg);
1858 int security_msg_queue_msgctl(struct msg_queue *msq, int cmd);
1859 int security_msg_queue_msgsnd(struct msg_queue *msq,
1860                               struct msg_msg *msg, int msqflg);
1861 int security_msg_queue_msgrcv(struct msg_queue *msq, struct msg_msg *msg,
1862                               struct task_struct *target, long type, int mode);
1863 int security_shm_alloc(struct shmid_kernel *shp);
1864 void security_shm_free(struct shmid_kernel *shp);
1865 int security_shm_associate(struct shmid_kernel *shp, int shmflg);
1866 int security_shm_shmctl(struct shmid_kernel *shp, int cmd);
1867 int security_shm_shmat(struct shmid_kernel *shp, char __user *shmaddr, int shmflg);
1868 int security_sem_alloc(struct sem_array *sma);
1869 void security_sem_free(struct sem_array *sma);
1870 int security_sem_associate(struct sem_array *sma, int semflg);
1871 int security_sem_semctl(struct sem_array *sma, int cmd);
1872 int security_sem_semop(struct sem_array *sma, struct sembuf *sops,
1873                         unsigned nsops, int alter);
1874 void security_d_instantiate(struct dentry *dentry, struct inode *inode);
1875 int security_getprocattr(struct task_struct *p, char *name, char **value);
1876 int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size);
1877 int security_netlink_send(struct sock *sk, struct sk_buff *skb);
1878 int security_ismaclabel(const char *name);
1879 int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen);
1880 int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid);
1881 void security_release_secctx(char *secdata, u32 seclen);
1882 
1883 int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen);
1884 int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen);
1885 int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen);
1886 #else /* CONFIG_SECURITY */
1887 struct security_mnt_opts {
1888 };
1889 
1890 static inline void security_init_mnt_opts(struct security_mnt_opts *opts)
1891 {
1892 }
1893 
1894 static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
1895 {
1896 }
1897 
1898 /*
1899  * This is the default capabilities functionality.  Most of these functions
1900  * are just stubbed out, but a few must call the proper capable code.
1901  */
1902 
1903 static inline int security_init(void)
1904 {
1905         return 0;
1906 }
1907 
1908 static inline int security_ptrace_access_check(struct task_struct *child,
1909                                              unsigned int mode)
1910 {
1911         return cap_ptrace_access_check(child, mode);
1912 }
1913 
1914 static inline int security_ptrace_traceme(struct task_struct *parent)
1915 {
1916         return cap_ptrace_traceme(parent);
1917 }
1918 
1919 static inline int security_capget(struct task_struct *target,
1920                                    kernel_cap_t *effective,
1921                                    kernel_cap_t *inheritable,
1922                                    kernel_cap_t *permitted)
1923 {
1924         return cap_capget(target, effective, inheritable, permitted);
1925 }
1926 
1927 static inline int security_capset(struct cred *new,
1928                                    const struct cred *old,
1929                                    const kernel_cap_t *effective,
1930                                    const kernel_cap_t *inheritable,
1931                                    const kernel_cap_t *permitted)
1932 {
1933         return cap_capset(new, old, effective, inheritable, permitted);
1934 }
1935 
1936 static inline int security_capable(const struct cred *cred,
1937                                    struct user_namespace *ns, int cap)
1938 {
1939         return cap_capable(cred, ns, cap, SECURITY_CAP_AUDIT);
1940 }
1941 
1942 static inline int security_capable_noaudit(const struct cred *cred,
1943                                            struct user_namespace *ns, int cap) {
1944         return cap_capable(cred, ns, cap, SECURITY_CAP_NOAUDIT);
1945 }
1946 
1947 static inline int security_quotactl(int cmds, int type, int id,
1948                                      struct super_block *sb)
1949 {
1950         return 0;
1951 }
1952 
1953 static inline int security_quota_on(struct dentry *dentry)
1954 {
1955         return 0;
1956 }
1957 
1958 static inline int security_syslog(int type)
1959 {
1960         return 0;
1961 }
1962 
1963 static inline int security_settime(const struct timespec *ts,
1964                                    const struct timezone *tz)
1965 {
1966         int error = cap_settime(ts, tz);
1967         if (!error && !ccs_capable(CCS_SYS_SETTIME))
1968                 error = -EPERM;
1969         return error;
1970 }
1971 
1972 static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
1973 {
1974         return cap_vm_enough_memory(mm, pages);
1975 }
1976 
1977 static inline int security_bprm_set_creds(struct linux_binprm *bprm)
1978 {
1979         return cap_bprm_set_creds(bprm);
1980 }
1981 
1982 static inline int security_bprm_check(struct linux_binprm *bprm)
1983 {
1984         return 0;
1985 }
1986 
1987 static inline void security_bprm_committing_creds(struct linux_binprm *bprm)
1988 {
1989 }
1990 
1991 static inline void security_bprm_committed_creds(struct linux_binprm *bprm)
1992 {
1993 }
1994 
1995 static inline int security_bprm_secureexec(struct linux_binprm *bprm)
1996 {
1997         return cap_bprm_secureexec(bprm);
1998 }
1999 
2000 static inline int security_sb_alloc(struct super_block *sb)
2001 {
2002         return 0;
2003 }
2004 
2005 static inline void security_sb_free(struct super_block *sb)
2006 { }
2007 
2008 static inline int security_sb_copy_data(char *orig, char *copy)
2009 {
2010         return 0;
2011 }
2012 
2013 static inline int security_sb_remount(struct super_block *sb, void *data)
2014 {
2015         return 0;
2016 }
2017 
2018 static inline int security_sb_kern_mount(struct super_block *sb, int flags, void *data)
2019 {
2020         return 0;
2021 }
2022 
2023 static inline int security_sb_show_options(struct seq_file *m,
2024                                            struct super_block *sb)
2025 {
2026         return 0;
2027 }
2028 
2029 static inline int security_sb_statfs(struct dentry *dentry)
2030 {
2031         return 0;
2032 }
2033 
2034 static inline int security_sb_mount(const char *dev_name, struct path *path,
2035                                     const char *type, unsigned long flags,
2036                                     void *data)
2037 {
2038         return ccs_mount_permission(dev_name, path, type, flags, data);
2039 }
2040 
2041 static inline int security_sb_umount(struct vfsmount *mnt, int flags)
2042 {
2043         return ccs_umount_permission(mnt, flags);
2044 }
2045 
2046 static inline int security_sb_pivotroot(struct path *old_path,
2047                                         struct path *new_path)
2048 {
2049         return ccs_pivot_root_permission(old_path, new_path);
2050 }
2051 
2052 static inline int security_sb_set_mnt_opts(struct super_block *sb,
2053                                            struct security_mnt_opts *opts,
2054                                            unsigned long kern_flags,
2055                                            unsigned long *set_kern_flags)
2056 {
2057         return 0;
2058 }
2059 
2060 static inline int security_sb_clone_mnt_opts(const struct super_block *oldsb,
2061                                               struct super_block *newsb)
2062 {
2063         return 0;
2064 }
2065 
2066 static inline int security_sb_parse_opts_str(char *options, struct security_mnt_opts *opts)
2067 {
2068         return 0;
2069 }
2070 
2071 static inline int security_inode_alloc(struct inode *inode)
2072 {
2073         return 0;
2074 }
2075 
2076 static inline void security_inode_free(struct inode *inode)
2077 { }
2078 
2079 static inline int security_dentry_init_security(struct dentry *dentry,
2080                                                  int mode,
2081                                                  struct qstr *name,
2082                                                  void **ctx,
2083                                                  u32 *ctxlen)
2084 {
2085         return -EOPNOTSUPP;
2086 }
2087 
2088 
2089 static inline int security_inode_init_security(struct inode *inode,
2090                                                 struct inode *dir,
2091                                                 const struct qstr *qstr,
2092                                                 const initxattrs initxattrs,
2093                                                 void *fs_data)
2094 {
2095         return 0;
2096 }
2097 
2098 static inline int security_old_inode_init_security(struct inode *inode,
2099                                                    struct inode *dir,
2100                                                    const struct qstr *qstr,
2101                                                    char **name, void **value,
2102                                                    size_t *len)
2103 {
2104         return -EOPNOTSUPP;
2105 }
2106 
2107 static inline int security_inode_create(struct inode *dir,
2108                                          struct dentry *dentry,
2109                                          umode_t mode)
2110 {
2111         return 0;
2112 }
2113 
2114 static inline int security_inode_link(struct dentry *old_dentry,
2115                                        struct inode *dir,
2116                                        struct dentry *new_dentry)
2117 {
2118         return 0;
2119 }
2120 
2121 static inline int security_inode_unlink(struct inode *dir,
2122                                          struct dentry *dentry)
2123 {
2124         return 0;
2125 }
2126 
2127 static inline int security_inode_symlink(struct inode *dir,
2128                                           struct dentry *dentry,
2129                                           const char *old_name)
2130 {
2131         return 0;
2132 }
2133 
2134 static inline int security_inode_mkdir(struct inode *dir,
2135                                         struct dentry *dentry,
2136                                         int mode)
2137 {
2138         return 0;
2139 }
2140 
2141 static inline int security_inode_rmdir(struct inode *dir,
2142                                         struct dentry *dentry)
2143 {
2144         return 0;
2145 }
2146 
2147 static inline int security_inode_mknod(struct inode *dir,
2148                                         struct dentry *dentry,
2149                                         int mode, dev_t dev)
2150 {
2151         return 0;
2152 }
2153 
2154 static inline int security_inode_rename(struct inode *old_dir,
2155                                          struct dentry *old_dentry,
2156                                          struct inode *new_dir,
2157                                          struct dentry *new_dentry)
2158 {
2159         return 0;
2160 }
2161 
2162 static inline int security_inode_readlink(struct dentry *dentry)
2163 {
2164         return 0;
2165 }
2166 
2167 static inline int security_inode_follow_link(struct dentry *dentry,
2168                                               struct nameidata *nd)
2169 {
2170         return 0;
2171 }
2172 
2173 static inline int security_inode_permission(struct inode *inode, int mask)
2174 {
2175         return 0;
2176 }
2177 
2178 static inline int security_inode_setattr(struct dentry *dentry,
2179                                           struct iattr *attr)
2180 {
2181         return 0;
2182 }
2183 
2184 static inline int security_inode_getattr(struct vfsmount *mnt,
2185                                           struct dentry *dentry)
2186 {
2187         return ccs_getattr_permission(mnt, dentry);
2188 }
2189 
2190 static inline int security_inode_setxattr(struct dentry *dentry,
2191                 const char *name, const void *value, size_t size, int flags)
2192 {
2193         return cap_inode_setxattr(dentry, name, value, size, flags);
2194 }
2195 
2196 static inline void security_inode_post_setxattr(struct dentry *dentry,
2197                 const char *name, const void *value, size_t size, int flags)
2198 { }
2199 
2200 static inline int security_inode_getxattr(struct dentry *dentry,
2201                         const char *name)
2202 {
2203         return 0;
2204 }
2205 
2206 static inline int security_inode_listxattr(struct dentry *dentry)
2207 {
2208         return 0;
2209 }
2210 
2211 static inline int security_inode_removexattr(struct dentry *dentry,
2212                         const char *name)
2213 {
2214         return cap_inode_removexattr(dentry, name);
2215 }
2216 
2217 static inline int security_inode_need_killpriv(struct dentry *dentry)
2218 {
2219         return cap_inode_need_killpriv(dentry);
2220 }
2221 
2222 static inline int security_inode_killpriv(struct dentry *dentry)
2223 {
2224         return cap_inode_killpriv(dentry);
2225 }
2226 
2227 static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void **buffer, bool alloc)
2228 {
2229         return -EOPNOTSUPP;
2230 }
2231 
2232 static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
2233 {
2234         return -EOPNOTSUPP;
2235 }
2236 
2237 static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
2238 {
2239         return 0;
2240 }
2241 
2242 static inline void security_inode_getsecid(const struct inode *inode, u32 *secid)
2243 {
2244         *secid = 0;
2245 }
2246 
2247 static inline int security_file_permission(struct file *file, int mask)
2248 {
2249         return 0;
2250 }
2251 
2252 static inline int security_file_alloc(struct file *file)
2253 {
2254         return 0;
2255 }
2256 
2257 static inline void security_file_free(struct file *file)
2258 { }
2259 
2260 static inline int security_file_ioctl(struct file *file, unsigned int cmd,
2261                                       unsigned long arg)
2262 {
2263         return ccs_ioctl_permission(file, cmd, arg);
2264 }
2265 
2266 static inline int security_mmap_file(struct file *file, unsigned long prot,
2267                                      unsigned long flags)
2268 {
2269         return 0;
2270 }
2271 
2272 static inline int security_mmap_addr(unsigned long addr)
2273 {
2274         return cap_mmap_addr(addr);
2275 }
2276 
2277 static inline int security_file_mprotect(struct vm_area_struct *vma,
2278                                          unsigned long reqprot,
2279                                          unsigned long prot)
2280 {
2281         return 0;
2282 }
2283 
2284 static inline int security_file_lock(struct file *file, unsigned int cmd)
2285 {
2286         return 0;
2287 }
2288 
2289 static inline int security_file_fcntl(struct file *file, unsigned int cmd,
2290                                       unsigned long arg)
2291 {
2292         return ccs_fcntl_permission(file, cmd, arg);
2293 }
2294 
2295 static inline int security_file_set_fowner(struct file *file)
2296 {
2297         return 0;
2298 }
2299 
2300 static inline int security_file_send_sigiotask(struct task_struct *tsk,
2301                                                struct fown_struct *fown,
2302                                                int sig)
2303 {
2304         return 0;
2305 }
2306 
2307 static inline int security_file_receive(struct file *file)
2308 {
2309         return 0;
2310 }
2311 
2312 static inline int security_file_open(struct file *file,
2313                                      const struct cred *cred)
2314 {
2315         return ccs_open_permission(file);
2316 }
2317 
2318 static inline int security_task_create(unsigned long clone_flags)
2319 {
2320         return 0;
2321 }
2322 
2323 static inline void security_task_free(struct task_struct *task)
2324 { }
2325 
2326 static inline int security_cred_alloc_blank(struct cred *cred, gfp_t gfp)
2327 {
2328         return 0;
2329 }
2330 
2331 static inline void security_cred_free(struct cred *cred)
2332 { }
2333 
2334 static inline int security_prepare_creds(struct cred *new,
2335                                          const struct cred *old,
2336                                          gfp_t gfp)
2337 {
2338         return 0;
2339 }
2340 
2341 static inline void security_transfer_creds(struct cred *new,
2342                                            const struct cred *old)
2343 {
2344 }
2345 
2346 static inline int security_kernel_act_as(struct cred *cred, u32 secid)
2347 {
2348         return 0;
2349 }
2350 
2351 static inline int security_kernel_create_files_as(struct cred *cred,
2352                                                   struct inode *inode)
2353 {
2354         return 0;
2355 }
2356 
2357 static inline int security_kernel_module_request(char *kmod_name)
2358 {
2359         return 0;
2360 }
2361 
2362 static inline int security_kernel_module_from_file(struct file *file)
2363 {
2364         return 0;
2365 }
2366 
2367 static inline int security_task_fix_setuid(struct cred *new,
2368                                            const struct cred *old,
2369                                            int flags)
2370 {
2371         return cap_task_fix_setuid(new, old, flags);
2372 }
2373 
2374 static inline int security_task_setpgid(struct task_struct *p, pid_t pgid)
2375 {
2376         return 0;
2377 }
2378 
2379 static inline int security_task_getpgid(struct task_struct *p)
2380 {
2381         return 0;
2382 }
2383 
2384 static inline int security_task_getsid(struct task_struct *p)
2385 {
2386         return 0;
2387 }
2388 
2389 static inline void security_task_getsecid(struct task_struct *p, u32 *secid)
2390 {
2391         *secid = 0;
2392 }
2393 
2394 static inline int security_task_setnice(struct task_struct *p, int nice)
2395 {
2396         return cap_task_setnice(p, nice);
2397 }
2398 
2399 static inline int security_task_setioprio(struct task_struct *p, int ioprio)
2400 {
2401         return cap_task_setioprio(p, ioprio);
2402 }
2403 
2404 static inline int security_task_getioprio(struct task_struct *p)
2405 {
2406         return 0;
2407 }
2408 
2409 static inline int security_task_setrlimit(struct task_struct *p,
2410                                           unsigned int resource,
2411                                           struct rlimit *new_rlim)
2412 {
2413         return 0;
2414 }
2415 
2416 static inline int security_task_setscheduler(struct task_struct *p)
2417 {
2418         return cap_task_setscheduler(p);
2419 }
2420 
2421 static inline int security_task_getscheduler(struct task_struct *p)
2422 {
2423         return 0;
2424 }
2425 
2426 static inline int security_task_movememory(struct task_struct *p)
2427 {
2428         return 0;
2429 }
2430 
2431 static inline int security_task_kill(struct task_struct *p,
2432                                      struct siginfo *info, int sig,
2433                                      u32 secid)
2434 {
2435         return 0;
2436 }
2437 
2438 static inline int security_task_wait(struct task_struct *p)
2439 {
2440         return 0;
2441 }
2442 
2443 static inline int security_task_prctl(int option, unsigned long arg2,
2444                                       unsigned long arg3,
2445                                       unsigned long arg4,
2446                                       unsigned long arg5)
2447 {
2448         return cap_task_prctl(option, arg2, arg3, arg3, arg5);
2449 }
2450 
2451 static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
2452 { }
2453 
2454 static inline int security_ipc_permission(struct kern_ipc_perm *ipcp,
2455                                           short flag)
2456 {
2457         return 0;
2458 }
2459 
2460 static inline void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid)
2461 {
2462         *secid = 0;
2463 }
2464 
2465 static inline int security_msg_msg_alloc(struct msg_msg *msg)
2466 {
2467         return 0;
2468 }
2469 
2470 static inline void security_msg_msg_free(struct msg_msg *msg)
2471 { }
2472 
2473 static inline int security_msg_queue_alloc(struct msg_queue *msq)
2474 {
2475         return 0;
2476 }
2477 
2478 static inline void security_msg_queue_free(struct msg_queue *msq)
2479 { }
2480 
2481 static inline int security_msg_queue_associate(struct msg_queue *msq,
2482                                                int msqflg)
2483 {
2484         return 0;
2485 }
2486 
2487 static inline int security_msg_queue_msgctl(struct msg_queue *msq, int cmd)
2488 {
2489         return 0;
2490 }
2491 
2492 static inline int security_msg_queue_msgsnd(struct msg_queue *msq,
2493                                             struct msg_msg *msg, int msqflg)
2494 {
2495         return 0;
2496 }
2497 
2498 static inline int security_msg_queue_msgrcv(struct msg_queue *msq,
2499                                             struct msg_msg *msg,
2500                                             struct task_struct *target,
2501                                             long type, int mode)
2502 {
2503         return 0;
2504 }
2505 
2506 static inline int security_shm_alloc(struct shmid_kernel *shp)
2507 {
2508         return 0;
2509 }
2510 
2511 static inline void security_shm_free(struct shmid_kernel *shp)
2512 { }
2513 
2514 static inline int security_shm_associate(struct shmid_kernel *shp,
2515                                          int shmflg)
2516 {
2517         return 0;
2518 }
2519 
2520 static inline int security_shm_shmctl(struct shmid_kernel *shp, int cmd)
2521 {
2522         return 0;
2523 }
2524 
2525 static inline int security_shm_shmat(struct shmid_kernel *shp,
2526                                      char __user *shmaddr, int shmflg)
2527 {
2528         return 0;
2529 }
2530 
2531 static inline int security_sem_alloc(struct sem_array *sma)
2532 {
2533         return 0;
2534 }
2535 
2536 static inline void security_sem_free(struct sem_array *sma)
2537 { }
2538 
2539 static inline int security_sem_associate(struct sem_array *sma, int semflg)
2540 {
2541         return 0;
2542 }
2543 
2544 static inline int security_sem_semctl(struct sem_array *sma, int cmd)
2545 {
2546         return 0;
2547 }
2548 
2549 static inline int security_sem_semop(struct sem_array *sma,
2550                                      struct sembuf *sops, unsigned nsops,
2551                                      int alter)
2552 {
2553         return 0;
2554 }
2555 
2556 static inline void security_d_instantiate(struct dentry *dentry, struct inode *inode)
2557 { }
2558 
2559 static inline int security_getprocattr(struct task_struct *p, char *name, char **value)
2560 {
2561         return -EINVAL;
2562 }
2563 
2564 static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2565 {
2566         return -EINVAL;
2567 }
2568 
2569 static inline int security_netlink_send(struct sock *sk, struct sk_buff *skb)
2570 {
2571         return cap_netlink_send(sk, skb);
2572 }
2573 
2574 static inline int security_ismaclabel(const char *name)
2575 {
2576         return 0;
2577 }
2578 
2579 static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
2580 {
2581         return -EOPNOTSUPP;
2582 }
2583 
2584 static inline int security_secctx_to_secid(const char *secdata,
2585                                            u32 seclen,
2586                                            u32 *secid)
2587 {
2588         return -EOPNOTSUPP;
2589 }
2590 
2591 static inline void security_release_secctx(char *secdata, u32 seclen)
2592 {
2593 }
2594 
2595 static inline int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)
2596 {
2597         return -EOPNOTSUPP;
2598 }
2599 static inline int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
2600 {
2601         return -EOPNOTSUPP;
2602 }
2603 static inline int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
2604 {
2605         return -EOPNOTSUPP;
2606 }
2607 #endif  /* CONFIG_SECURITY */
2608 
2609 #ifdef CONFIG_SECURITY_NETWORK
2610 
2611 int security_unix_stream_connect(struct sock *sock, struct sock *other, struct sock *newsk);
2612 int security_unix_may_send(struct socket *sock,  struct socket *other);
2613 int security_socket_create(int family, int type, int protocol, int kern);
2614 int security_socket_post_create(struct socket *sock, int family,
2615                                 int type, int protocol, int kern);
2616 int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen);
2617 int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen);
2618 int security_socket_listen(struct socket *sock, int backlog);
2619 int security_socket_accept(struct socket *sock, struct socket *newsock);
2620 int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size);
2621 int security_socket_recvmsg(struct socket *sock, struct msghdr *msg,
2622                             int size, int flags);
2623 int security_socket_getsockname(struct socket *sock);
2624 int security_socket_getpeername(struct socket *sock);
2625 int security_socket_getsockopt(struct socket *sock, int level, int optname);
2626 int security_socket_setsockopt(struct socket *sock, int level, int optname);
2627 int security_socket_shutdown(struct socket *sock, int how);
2628 int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb);
2629 int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2630                                       int __user *optlen, unsigned len);
2631 int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid);
2632 int security_sk_alloc(struct sock *sk, int family, gfp_t priority);
2633 void security_sk_free(struct sock *sk);
2634 void security_sk_clone(const struct sock *sk, struct sock *newsk);
2635 void security_sk_classify_flow(struct sock *sk, struct flowi *fl);
2636 void security_req_classify_flow(const struct request_sock *req, struct flowi *fl);
2637 void security_sock_graft(struct sock*sk, struct socket *parent);
2638 int security_inet_conn_request(struct sock *sk,
2639                         struct sk_buff *skb, struct request_sock *req);
2640 void security_inet_csk_clone(struct sock *newsk,
2641                         const struct request_sock *req);
2642 void security_inet_conn_established(struct sock *sk,
2643                         struct sk_buff *skb);
2644 int security_secmark_relabel_packet(u32 secid);
2645 void security_secmark_refcount_inc(void);
2646 void security_secmark_refcount_dec(void);
2647 int security_tun_dev_alloc_security(void **security);
2648 void security_tun_dev_free_security(void *security);
2649 int security_tun_dev_create(void);
2650 int security_tun_dev_attach_queue(void *security);
2651 int security_tun_dev_attach(struct sock *sk, void *security);
2652 int security_tun_dev_open(void *security);
2653 
2654 void security_skb_owned_by(struct sk_buff *skb, struct sock *sk);
2655 
2656 #else   /* CONFIG_SECURITY_NETWORK */
2657 static inline int security_unix_stream_connect(struct sock *sock,
2658                                                struct sock *other,
2659                                                struct sock *newsk)
2660 {
2661         return 0;
2662 }
2663 
2664 static inline int security_unix_may_send(struct socket *sock,
2665                                          struct socket *other)
2666 {
2667         return 0;
2668 }
2669 
2670 static inline int security_socket_create(int family, int type,
2671                                          int protocol, int kern)
2672 {
2673         return ccs_socket_create_permission(family, type, protocol);
2674 }
2675 
2676 static inline int security_socket_post_create(struct socket *sock,
2677                                               int family,
2678                                               int type,
2679                                               int protocol, int kern)
2680 {
2681         return 0;
2682 }
2683 
2684 static inline int security_socket_bind(struct socket *sock,
2685                                        struct sockaddr *address,
2686                                        int addrlen)
2687 {
2688         return ccs_socket_bind_permission(sock, address, addrlen);
2689 }
2690 
2691 static inline int security_socket_connect(struct socket *sock,
2692                                           struct sockaddr *address,
2693                                           int addrlen)
2694 {
2695         return ccs_socket_connect_permission(sock, address, addrlen);
2696 }
2697 
2698 static inline int security_socket_listen(struct socket *sock, int backlog)
2699 {
2700         return ccs_socket_listen_permission(sock);
2701 }
2702 
2703 static inline int security_socket_accept(struct socket *sock,
2704                                          struct socket *newsock)
2705 {
2706         return 0;
2707 }
2708 
2709 static inline int security_socket_sendmsg(struct socket *sock,
2710                                           struct msghdr *msg, int size)
2711 {
2712         return ccs_socket_sendmsg_permission(sock, msg, size);
2713 }
2714 
2715 static inline int security_socket_recvmsg(struct socket *sock,
2716                                           struct msghdr *msg, int size,
2717                                           int flags)
2718 {
2719         return 0;
2720 }
2721 
2722 static inline int security_socket_getsockname(struct socket *sock)
2723 {
2724         return 0;
2725 }
2726 
2727 static inline int security_socket_getpeername(struct socket *sock)
2728 {
2729         return 0;
2730 }
2731 
2732 static inline int security_socket_getsockopt(struct socket *sock,
2733                                              int level, int optname)
2734 {
2735         return 0;
2736 }
2737 
2738 static inline int security_socket_setsockopt(struct socket *sock,
2739                                              int level, int optname)
2740 {
2741         return 0;
2742 }
2743 
2744 static inline int security_socket_shutdown(struct socket *sock, int how)
2745 {
2746         return 0;
2747 }
2748 static inline int security_sock_rcv_skb(struct sock *sk,
2749                                         struct sk_buff *skb)
2750 {
2751         return 0;
2752 }
2753 
2754 static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2755                                                     int __user *optlen, unsigned len)
2756 {
2757         return -ENOPROTOOPT;
2758 }
2759 
2760 static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
2761 {
2762         return -ENOPROTOOPT;
2763 }
2764 
2765 static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
2766 {
2767         return 0;
2768 }
2769 
2770 static inline void security_sk_free(struct sock *sk)
2771 {
2772 }
2773 
2774 static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
2775 {
2776 }
2777 
2778 static inline void security_sk_classify_flow(struct sock *sk, struct flowi *fl)
2779 {
2780 }
2781 
2782 static inline void security_req_classify_flow(const struct request_sock *req, struct flowi *fl)
2783 {
2784 }
2785 
2786 static inline void security_sock_graft(struct sock *sk, struct socket *parent)
2787 {
2788 }
2789 
2790 static inline int security_inet_conn_request(struct sock *sk,
2791                         struct sk_buff *skb, struct request_sock *req)
2792 {
2793         return 0;
2794 }
2795 
2796 static inline void security_inet_csk_clone(struct sock *newsk,
2797                         const struct request_sock *req)
2798 {
2799 }
2800 
2801 static inline void security_inet_conn_established(struct sock *sk,
2802                         struct sk_buff *skb)
2803 {
2804 }
2805 
2806 static inline int security_secmark_relabel_packet(u32 secid)
2807 {
2808         return 0;
2809 }
2810 
2811 static inline void security_secmark_refcount_inc(void)
2812 {
2813 }
2814 
2815 static inline void security_secmark_refcount_dec(void)
2816 {
2817 }
2818 
2819 static inline int security_tun_dev_alloc_security(void **security)
2820 {
2821         return 0;
2822 }
2823 
2824 static inline void security_tun_dev_free_security(void *security)
2825 {
2826 }
2827 
2828 static inline int security_tun_dev_create(void)
2829 {
2830         return 0;
2831 }
2832 
2833 static inline int security_tun_dev_attach_queue(void *security)
2834 {
2835         return 0;
2836 }
2837 
2838 static inline int security_tun_dev_attach(struct sock *sk, void *security)
2839 {
2840         return 0;
2841 }
2842 
2843 static inline int security_tun_dev_open(void *security)
2844 {
2845         return 0;
2846 }
2847 
2848 static inline void security_skb_owned_by(struct sk_buff *skb, struct sock *sk)
2849 {
2850 }
2851 
2852 #endif  /* CONFIG_SECURITY_NETWORK */
2853 
2854 #ifdef CONFIG_SECURITY_NETWORK_XFRM
2855 
2856 int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp, struct xfrm_user_sec_ctx *sec_ctx);
2857 int security_xfrm_policy_clone(struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctxp);
2858 void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx);
2859 int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx);
2860 int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
2861 int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
2862                                       struct xfrm_sec_ctx *polsec, u32 secid);
2863 int security_xfrm_state_delete(struct xfrm_state *x);
2864 void security_xfrm_state_free(struct xfrm_state *x);
2865 int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir);
2866 int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
2867                                        struct xfrm_policy *xp,
2868                                        const struct flowi *fl);
2869 int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid);
2870 void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl);
2871 
2872 #else   /* CONFIG_SECURITY_NETWORK_XFRM */
2873 
2874 static inline int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp, struct xfrm_user_sec_ctx *sec_ctx)
2875 {
2876         return 0;
2877 }
2878 
2879 static inline int security_xfrm_policy_clone(struct xfrm_sec_ctx *old, struct xfrm_sec_ctx **new_ctxp)
2880 {
2881         return 0;
2882 }
2883 
2884 static inline void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx)
2885 {
2886 }
2887 
2888 static inline int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx)
2889 {
2890         return 0;
2891 }
2892 
2893 static inline int security_xfrm_state_alloc(struct xfrm_state *x,
2894                                         struct xfrm_user_sec_ctx *sec_ctx)
2895 {
2896         return 0;
2897 }
2898 
2899 static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
2900                                         struct xfrm_sec_ctx *polsec, u32 secid)
2901 {
2902         return 0;
2903 }
2904 
2905 static inline void security_xfrm_state_free(struct xfrm_state *x)
2906 {
2907 }
2908 
2909 static inline int security_xfrm_state_delete(struct xfrm_state *x)
2910 {
2911         return 0;
2912 }
2913 
2914 static inline int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir)
2915 {
2916         return 0;
2917 }
2918 
2919 static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
2920                         struct xfrm_policy *xp, const struct flowi *fl)
2921 {
2922         return 1;
2923 }
2924 
2925 static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
2926 {
2927         return 0;
2928 }
2929 
2930 static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl)
2931 {
2932 }
2933 
2934 #endif  /* CONFIG_SECURITY_NETWORK_XFRM */
2935 
2936 #ifdef CONFIG_SECURITY_PATH
2937 int security_path_unlink(struct path *dir, struct dentry *dentry);
2938 int security_path_mkdir(struct path *dir, struct dentry *dentry, umode_t mode);
2939 int security_path_rmdir(struct path *dir, struct dentry *dentry);
2940 int security_path_mknod(struct path *dir, struct dentry *dentry, umode_t mode,
2941                         unsigned int dev);
2942 int security_path_truncate(struct path *path);
2943 int security_path_symlink(struct path *dir, struct dentry *dentry,
2944                           const char *old_name);
2945 int security_path_link(struct dentry *old_dentry, struct path *new_dir,
2946                        struct dentry *new_dentry);
2947 int security_path_rename(struct path *old_dir, struct dentry *old_dentry,
2948                          struct path *new_dir, struct dentry *new_dentry);
2949 int security_path_chmod(struct path *path, umode_t mode);
2950 int security_path_chown(struct path *path, kuid_t uid, kgid_t gid);
2951 int security_path_chroot(struct path *path);
2952 #else   /* CONFIG_SECURITY_PATH */
2953 
2954 #include <linux/path.h>
2955 
2956 static inline int security_path_unlink(struct path *dir, struct dentry *dentry)
2957 {
2958         return ccs_unlink_permission(dentry, dir->mnt);
2959 }
2960 
2961 static inline int security_path_mkdir(struct path *dir, struct dentry *dentry,
2962                                       umode_t mode)
2963 {
2964         return ccs_mkdir_permission(dentry, dir->mnt, mode);
2965 }
2966 
2967 static inline int security_path_rmdir(struct path *dir, struct dentry *dentry)
2968 {
2969         return ccs_rmdir_permission(dentry, dir->mnt);
2970 }
2971 
2972 static inline int security_path_mknod(struct path *dir, struct dentry *dentry,
2973                                       umode_t mode, unsigned int dev)
2974 {
2975         return ccs_mknod_permission(dentry, dir->mnt, mode, dev);
2976 }
2977 
2978 static inline int security_path_truncate(struct path *path)
2979 {
2980         return ccs_truncate_permission(path->dentry, path->mnt);
2981 }
2982 
2983 static inline int security_path_symlink(struct path *dir, struct dentry *dentry,
2984                                         const char *old_name)
2985 {
2986         return ccs_symlink_permission(dentry, dir->mnt, old_name);
2987 }
2988 
2989 static inline int security_path_link(struct dentry *old_dentry,
2990                                      struct path *new_dir,
2991                                      struct dentry *new_dentry)
2992 {
2993         return ccs_link_permission(old_dentry, new_dentry, new_dir->mnt);
2994 }
2995 
2996 static inline int security_path_rename(struct path *old_dir,
2997                                        struct dentry *old_dentry,
2998                                        struct path *new_dir,
2999                                        struct dentry *new_dentry)
3000 {
3001         return ccs_rename_permission(old_dentry, new_dentry, new_dir->mnt);
3002 }
3003 
3004 static inline int security_path_chmod(struct path *path, umode_t mode)
3005 {
3006         return ccs_chmod_permission(path->dentry, path->mnt, mode);
3007 }
3008 
3009 static inline int security_path_chown(struct path *path, kuid_t uid, kgid_t gid)
3010 {
3011         return ccs_chown_permission(path->dentry, path->mnt, uid, gid);
3012 }
3013 
3014 static inline int security_path_chroot(struct path *path)
3015 {
3016         return ccs_chroot_permission(path);
3017 }
3018 #endif  /* CONFIG_SECURITY_PATH */
3019 
3020 #ifdef CONFIG_KEYS
3021 #ifdef CONFIG_SECURITY
3022 
3023 int security_key_alloc(struct key *key, const struct cred *cred, unsigned long flags);
3024 void security_key_free(struct key *key);
3025 int security_key_permission(key_ref_t key_ref,
3026                             const struct cred *cred, key_perm_t perm);
3027 int security_key_getsecurity(struct key *key, char **_buffer);
3028 
3029 #else
3030 
3031 static inline int security_key_alloc(struct key *key,
3032                                      const struct cred *cred,
3033                                      unsigned long flags)
3034 {
3035         return 0;
3036 }
3037 
3038 static inline void security_key_free(struct key *key)
3039 {
3040 }
3041 
3042 static inline int security_key_permission(key_ref_t key_ref,
3043                                           const struct cred *cred,
3044                                           key_perm_t perm)
3045 {
3046         return 0;
3047 }
3048 
3049 static inline int security_key_getsecurity(struct key *key, char **_buffer)
3050 {
3051         *_buffer = NULL;
3052         return 0;
3053 }
3054 
3055 #endif
3056 #endif /* CONFIG_KEYS */
3057 
3058 #ifdef CONFIG_AUDIT
3059 #ifdef CONFIG_SECURITY
3060 int security_audit_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule);
3061 int security_audit_rule_known(struct audit_krule *krule);
3062 int security_audit_rule_match(u32 secid, u32 field, u32 op, void *lsmrule,
3063                               struct audit_context *actx);
3064 void security_audit_rule_free(void *lsmrule);
3065 
3066 #else
3067 
3068 static inline int security_audit_rule_init(u32 field, u32 op, char *rulestr,
3069                                            void **lsmrule)
3070 {
3071         return 0;
3072 }
3073 
3074 static inline int security_audit_rule_known(struct audit_krule *krule)
3075 {
3076         return 0;
3077 }
3078 
3079 static inline int security_audit_rule_match(u32 secid, u32 field, u32 op,
3080                                    void *lsmrule, struct audit_context *actx)
3081 {
3082         return 0;
3083 }
3084 
3085 static inline void security_audit_rule_free(void *lsmrule)
3086 { }
3087 
3088 #endif /* CONFIG_SECURITY */
3089 #endif /* CONFIG_AUDIT */
3090 
3091 #ifdef CONFIG_SECURITYFS
3092 
3093 extern struct dentry *securityfs_create_file(const char *name, umode_t mode,
3094                                              struct dentry *parent, void *data,
3095                                              const struct file_operations *fops);
3096 extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
3097 extern void securityfs_remove(struct dentry *dentry);
3098 
3099 #else /* CONFIG_SECURITYFS */
3100 
3101 static inline struct dentry *securityfs_create_dir(const char *name,
3102                                                    struct dentry *parent)
3103 {
3104         return ERR_PTR(-ENODEV);
3105 }
3106 
3107 static inline struct dentry *securityfs_create_file(const char *name,
3108                                                     umode_t mode,
3109                                                     struct dentry *parent,
3110                                                     void *data,
3111                                                     const struct file_operations *fops)
3112 {
3113         return ERR_PTR(-ENODEV);
3114 }
3115 
3116 static inline void securityfs_remove(struct dentry *dentry)
3117 {}
3118 
3119 #endif
3120 
3121 #ifdef CONFIG_SECURITY
3122 
3123 static inline char *alloc_secdata(void)
3124 {
3125         return (char *)get_zeroed_page(GFP_KERNEL);
3126 }
3127 
3128 static inline void free_secdata(void *secdata)
3129 {
3130         free_page((unsigned long)secdata);
3131 }
3132 
3133 #else
3134 
3135 static inline char *alloc_secdata(void)
3136 {
3137         return (char *)1;
3138 }
3139 
3140 static inline void free_secdata(void *secdata)
3141 { }
3142 #endif /* CONFIG_SECURITY */
3143 
3144 #ifdef CONFIG_SECURITY_YAMA
3145 extern int yama_ptrace_access_check(struct task_struct *child,
3146                                     unsigned int mode);
3147 extern int yama_ptrace_traceme(struct task_struct *parent);
3148 extern void yama_task_free(struct task_struct *task);
3149 extern int yama_task_prctl(int option, unsigned long arg2, unsigned long arg3,
3150                            unsigned long arg4, unsigned long arg5);
3151 #else
3152 static inline int yama_ptrace_access_check(struct task_struct *child,
3153                                            unsigned int mode)
3154 {
3155         return 0;
3156 }
3157 
3158 static inline int yama_ptrace_traceme(struct task_struct *parent)
3159 {
3160         return 0;
3161 }
3162 
3163 static inline void yama_task_free(struct task_struct *task)
3164 {
3165 }
3166 
3167 static inline int yama_task_prctl(int option, unsigned long arg2,
3168                                   unsigned long arg3, unsigned long arg4,
3169                                   unsigned long arg5)
3170 {
3171         return -ENOSYS;
3172 }
3173 #endif /* CONFIG_SECURITY_YAMA */
3174 
3175 #endif /* ! __LINUX_SECURITY_H */
3176 
3177 

~ [ 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