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