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