Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland...
[sfrench/cifs-2.6.git] / 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 (struct mm_struct *mm, 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  *      @mm contains the mm struct it is being added to.
1129  *      @pages contains the number of pages.
1130  *      Return 0 if permission is granted.
1131  *
1132  * @register_security:
1133  *      allow module stacking.
1134  *      @name contains the name of the security module being stacked.
1135  *      @ops contains a pointer to the struct security_operations of the module to stack.
1136  * @unregister_security:
1137  *      remove a stacked module.
1138  *      @name contains the name of the security module being unstacked.
1139  *      @ops contains a pointer to the struct security_operations of the module to unstack.
1140  * 
1141  * @secid_to_secctx:
1142  *      Convert secid to security context.
1143  *      @secid contains the security ID.
1144  *      @secdata contains the pointer that stores the converted security context.
1145  *
1146  * @release_secctx:
1147  *      Release the security context.
1148  *      @secdata contains the security context.
1149  *      @seclen contains the length of the security context.
1150  *
1151  * This is the main security structure.
1152  */
1153 struct security_operations {
1154         int (*ptrace) (struct task_struct * parent, struct task_struct * child);
1155         int (*capget) (struct task_struct * target,
1156                        kernel_cap_t * effective,
1157                        kernel_cap_t * inheritable, kernel_cap_t * permitted);
1158         int (*capset_check) (struct task_struct * target,
1159                              kernel_cap_t * effective,
1160                              kernel_cap_t * inheritable,
1161                              kernel_cap_t * permitted);
1162         void (*capset_set) (struct task_struct * target,
1163                             kernel_cap_t * effective,
1164                             kernel_cap_t * inheritable,
1165                             kernel_cap_t * permitted);
1166         int (*capable) (struct task_struct * tsk, int cap);
1167         int (*acct) (struct file * file);
1168         int (*sysctl) (struct ctl_table * table, int op);
1169         int (*quotactl) (int cmds, int type, int id, struct super_block * sb);
1170         int (*quota_on) (struct dentry * dentry);
1171         int (*syslog) (int type);
1172         int (*settime) (struct timespec *ts, struct timezone *tz);
1173         int (*vm_enough_memory) (struct mm_struct *mm, long pages);
1174
1175         int (*bprm_alloc_security) (struct linux_binprm * bprm);
1176         void (*bprm_free_security) (struct linux_binprm * bprm);
1177         void (*bprm_apply_creds) (struct linux_binprm * bprm, int unsafe);
1178         void (*bprm_post_apply_creds) (struct linux_binprm * bprm);
1179         int (*bprm_set_security) (struct linux_binprm * bprm);
1180         int (*bprm_check_security) (struct linux_binprm * bprm);
1181         int (*bprm_secureexec) (struct linux_binprm * bprm);
1182
1183         int (*sb_alloc_security) (struct super_block * sb);
1184         void (*sb_free_security) (struct super_block * sb);
1185         int (*sb_copy_data)(struct file_system_type *type,
1186                             void *orig, void *copy);
1187         int (*sb_kern_mount) (struct super_block *sb, void *data);
1188         int (*sb_statfs) (struct dentry *dentry);
1189         int (*sb_mount) (char *dev_name, struct nameidata * nd,
1190                          char *type, unsigned long flags, void *data);
1191         int (*sb_check_sb) (struct vfsmount * mnt, struct nameidata * nd);
1192         int (*sb_umount) (struct vfsmount * mnt, int flags);
1193         void (*sb_umount_close) (struct vfsmount * mnt);
1194         void (*sb_umount_busy) (struct vfsmount * mnt);
1195         void (*sb_post_remount) (struct vfsmount * mnt,
1196                                  unsigned long flags, void *data);
1197         void (*sb_post_mountroot) (void);
1198         void (*sb_post_addmount) (struct vfsmount * mnt,
1199                                   struct nameidata * mountpoint_nd);
1200         int (*sb_pivotroot) (struct nameidata * old_nd,
1201                              struct nameidata * new_nd);
1202         void (*sb_post_pivotroot) (struct nameidata * old_nd,
1203                                    struct nameidata * new_nd);
1204
1205         int (*inode_alloc_security) (struct inode *inode);      
1206         void (*inode_free_security) (struct inode *inode);
1207         int (*inode_init_security) (struct inode *inode, struct inode *dir,
1208                                     char **name, void **value, size_t *len);
1209         int (*inode_create) (struct inode *dir,
1210                              struct dentry *dentry, int mode);
1211         int (*inode_link) (struct dentry *old_dentry,
1212                            struct inode *dir, struct dentry *new_dentry);
1213         int (*inode_unlink) (struct inode *dir, struct dentry *dentry);
1214         int (*inode_symlink) (struct inode *dir,
1215                               struct dentry *dentry, const char *old_name);
1216         int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode);
1217         int (*inode_rmdir) (struct inode *dir, struct dentry *dentry);
1218         int (*inode_mknod) (struct inode *dir, struct dentry *dentry,
1219                             int mode, dev_t dev);
1220         int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
1221                              struct inode *new_dir, struct dentry *new_dentry);
1222         int (*inode_readlink) (struct dentry *dentry);
1223         int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
1224         int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd);
1225         int (*inode_setattr)    (struct dentry *dentry, struct iattr *attr);
1226         int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
1227         void (*inode_delete) (struct inode *inode);
1228         int (*inode_setxattr) (struct dentry *dentry, char *name, void *value,
1229                                size_t size, int flags);
1230         void (*inode_post_setxattr) (struct dentry *dentry, char *name, void *value,
1231                                      size_t size, int flags);
1232         int (*inode_getxattr) (struct dentry *dentry, char *name);
1233         int (*inode_listxattr) (struct dentry *dentry);
1234         int (*inode_removexattr) (struct dentry *dentry, char *name);
1235         const char *(*inode_xattr_getsuffix) (void);
1236         int (*inode_getsecurity)(const struct inode *inode, const char *name, void *buffer, size_t size, int err);
1237         int (*inode_setsecurity)(struct inode *inode, const char *name, const void *value, size_t size, int flags);
1238         int (*inode_listsecurity)(struct inode *inode, char *buffer, size_t buffer_size);
1239
1240         int (*file_permission) (struct file * file, int mask);
1241         int (*file_alloc_security) (struct file * file);
1242         void (*file_free_security) (struct file * file);
1243         int (*file_ioctl) (struct file * file, unsigned int cmd,
1244                            unsigned long arg);
1245         int (*file_mmap) (struct file * file,
1246                           unsigned long reqprot, unsigned long prot,
1247                           unsigned long flags, unsigned long addr,
1248                           unsigned long addr_only);
1249         int (*file_mprotect) (struct vm_area_struct * vma,
1250                               unsigned long reqprot,
1251                               unsigned long prot);
1252         int (*file_lock) (struct file * file, unsigned int cmd);
1253         int (*file_fcntl) (struct file * file, unsigned int cmd,
1254                            unsigned long arg);
1255         int (*file_set_fowner) (struct file * file);
1256         int (*file_send_sigiotask) (struct task_struct * tsk,
1257                                     struct fown_struct * fown, int sig);
1258         int (*file_receive) (struct file * file);
1259
1260         int (*task_create) (unsigned long clone_flags);
1261         int (*task_alloc_security) (struct task_struct * p);
1262         void (*task_free_security) (struct task_struct * p);
1263         int (*task_setuid) (uid_t id0, uid_t id1, uid_t id2, int flags);
1264         int (*task_post_setuid) (uid_t old_ruid /* or fsuid */ ,
1265                                  uid_t old_euid, uid_t old_suid, int flags);
1266         int (*task_setgid) (gid_t id0, gid_t id1, gid_t id2, int flags);
1267         int (*task_setpgid) (struct task_struct * p, pid_t pgid);
1268         int (*task_getpgid) (struct task_struct * p);
1269         int (*task_getsid) (struct task_struct * p);
1270         void (*task_getsecid) (struct task_struct * p, u32 * secid);
1271         int (*task_setgroups) (struct group_info *group_info);
1272         int (*task_setnice) (struct task_struct * p, int nice);
1273         int (*task_setioprio) (struct task_struct * p, int ioprio);
1274         int (*task_getioprio) (struct task_struct * p);
1275         int (*task_setrlimit) (unsigned int resource, struct rlimit * new_rlim);
1276         int (*task_setscheduler) (struct task_struct * p, int policy,
1277                                   struct sched_param * lp);
1278         int (*task_getscheduler) (struct task_struct * p);
1279         int (*task_movememory) (struct task_struct * p);
1280         int (*task_kill) (struct task_struct * p,
1281                           struct siginfo * info, int sig, u32 secid);
1282         int (*task_wait) (struct task_struct * p);
1283         int (*task_prctl) (int option, unsigned long arg2,
1284                            unsigned long arg3, unsigned long arg4,
1285                            unsigned long arg5);
1286         void (*task_reparent_to_init) (struct task_struct * p);
1287         void (*task_to_inode)(struct task_struct *p, struct inode *inode);
1288
1289         int (*ipc_permission) (struct kern_ipc_perm * ipcp, short flag);
1290
1291         int (*msg_msg_alloc_security) (struct msg_msg * msg);
1292         void (*msg_msg_free_security) (struct msg_msg * msg);
1293
1294         int (*msg_queue_alloc_security) (struct msg_queue * msq);
1295         void (*msg_queue_free_security) (struct msg_queue * msq);
1296         int (*msg_queue_associate) (struct msg_queue * msq, int msqflg);
1297         int (*msg_queue_msgctl) (struct msg_queue * msq, int cmd);
1298         int (*msg_queue_msgsnd) (struct msg_queue * msq,
1299                                  struct msg_msg * msg, int msqflg);
1300         int (*msg_queue_msgrcv) (struct msg_queue * msq,
1301                                  struct msg_msg * msg,
1302                                  struct task_struct * target,
1303                                  long type, int mode);
1304
1305         int (*shm_alloc_security) (struct shmid_kernel * shp);
1306         void (*shm_free_security) (struct shmid_kernel * shp);
1307         int (*shm_associate) (struct shmid_kernel * shp, int shmflg);
1308         int (*shm_shmctl) (struct shmid_kernel * shp, int cmd);
1309         int (*shm_shmat) (struct shmid_kernel * shp, 
1310                           char __user *shmaddr, int shmflg);
1311
1312         int (*sem_alloc_security) (struct sem_array * sma);
1313         void (*sem_free_security) (struct sem_array * sma);
1314         int (*sem_associate) (struct sem_array * sma, int semflg);
1315         int (*sem_semctl) (struct sem_array * sma, int cmd);
1316         int (*sem_semop) (struct sem_array * sma, 
1317                           struct sembuf * sops, unsigned nsops, int alter);
1318
1319         int (*netlink_send) (struct sock * sk, struct sk_buff * skb);
1320         int (*netlink_recv) (struct sk_buff * skb, int cap);
1321
1322         /* allow module stacking */
1323         int (*register_security) (const char *name,
1324                                   struct security_operations *ops);
1325         int (*unregister_security) (const char *name,
1326                                     struct security_operations *ops);
1327
1328         void (*d_instantiate) (struct dentry *dentry, struct inode *inode);
1329
1330         int (*getprocattr)(struct task_struct *p, char *name, char **value);
1331         int (*setprocattr)(struct task_struct *p, char *name, void *value, size_t size);
1332         int (*secid_to_secctx)(u32 secid, char **secdata, u32 *seclen);
1333         void (*release_secctx)(char *secdata, u32 seclen);
1334
1335 #ifdef CONFIG_SECURITY_NETWORK
1336         int (*unix_stream_connect) (struct socket * sock,
1337                                     struct socket * other, struct sock * newsk);
1338         int (*unix_may_send) (struct socket * sock, struct socket * other);
1339
1340         int (*socket_create) (int family, int type, int protocol, int kern);
1341         int (*socket_post_create) (struct socket * sock, int family,
1342                                    int type, int protocol, int kern);
1343         int (*socket_bind) (struct socket * sock,
1344                             struct sockaddr * address, int addrlen);
1345         int (*socket_connect) (struct socket * sock,
1346                                struct sockaddr * address, int addrlen);
1347         int (*socket_listen) (struct socket * sock, int backlog);
1348         int (*socket_accept) (struct socket * sock, struct socket * newsock);
1349         void (*socket_post_accept) (struct socket * sock,
1350                                     struct socket * newsock);
1351         int (*socket_sendmsg) (struct socket * sock,
1352                                struct msghdr * msg, int size);
1353         int (*socket_recvmsg) (struct socket * sock,
1354                                struct msghdr * msg, int size, int flags);
1355         int (*socket_getsockname) (struct socket * sock);
1356         int (*socket_getpeername) (struct socket * sock);
1357         int (*socket_getsockopt) (struct socket * sock, int level, int optname);
1358         int (*socket_setsockopt) (struct socket * sock, int level, int optname);
1359         int (*socket_shutdown) (struct socket * sock, int how);
1360         int (*socket_sock_rcv_skb) (struct sock * sk, struct sk_buff * skb);
1361         int (*socket_getpeersec_stream) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len);
1362         int (*socket_getpeersec_dgram) (struct socket *sock, struct sk_buff *skb, u32 *secid);
1363         int (*sk_alloc_security) (struct sock *sk, int family, gfp_t priority);
1364         void (*sk_free_security) (struct sock *sk);
1365         void (*sk_clone_security) (const struct sock *sk, struct sock *newsk);
1366         void (*sk_getsecid) (struct sock *sk, u32 *secid);
1367         void (*sock_graft)(struct sock* sk, struct socket *parent);
1368         int (*inet_conn_request)(struct sock *sk, struct sk_buff *skb,
1369                                         struct request_sock *req);
1370         void (*inet_csk_clone)(struct sock *newsk, const struct request_sock *req);
1371         void (*inet_conn_established)(struct sock *sk, struct sk_buff *skb);
1372         void (*req_classify_flow)(const struct request_sock *req, struct flowi *fl);
1373 #endif  /* CONFIG_SECURITY_NETWORK */
1374
1375 #ifdef CONFIG_SECURITY_NETWORK_XFRM
1376         int (*xfrm_policy_alloc_security) (struct xfrm_policy *xp,
1377                         struct xfrm_user_sec_ctx *sec_ctx);
1378         int (*xfrm_policy_clone_security) (struct xfrm_policy *old, struct xfrm_policy *new);
1379         void (*xfrm_policy_free_security) (struct xfrm_policy *xp);
1380         int (*xfrm_policy_delete_security) (struct xfrm_policy *xp);
1381         int (*xfrm_state_alloc_security) (struct xfrm_state *x,
1382                 struct xfrm_user_sec_ctx *sec_ctx,
1383                 u32 secid);
1384         void (*xfrm_state_free_security) (struct xfrm_state *x);
1385         int (*xfrm_state_delete_security) (struct xfrm_state *x);
1386         int (*xfrm_policy_lookup)(struct xfrm_policy *xp, u32 fl_secid, u8 dir);
1387         int (*xfrm_state_pol_flow_match)(struct xfrm_state *x,
1388                         struct xfrm_policy *xp, struct flowi *fl);
1389         int (*xfrm_decode_session)(struct sk_buff *skb, u32 *secid, int ckall);
1390 #endif  /* CONFIG_SECURITY_NETWORK_XFRM */
1391
1392         /* key management security hooks */
1393 #ifdef CONFIG_KEYS
1394         int (*key_alloc)(struct key *key, struct task_struct *tsk, unsigned long flags);
1395         void (*key_free)(struct key *key);
1396         int (*key_permission)(key_ref_t key_ref,
1397                               struct task_struct *context,
1398                               key_perm_t perm);
1399
1400 #endif  /* CONFIG_KEYS */
1401
1402 };
1403
1404 /* global variables */
1405 extern struct security_operations *security_ops;
1406
1407 /* inline stuff */
1408 static inline int security_ptrace (struct task_struct * parent, struct task_struct * child)
1409 {
1410         return security_ops->ptrace (parent, child);
1411 }
1412
1413 static inline int security_capget (struct task_struct *target,
1414                                    kernel_cap_t *effective,
1415                                    kernel_cap_t *inheritable,
1416                                    kernel_cap_t *permitted)
1417 {
1418         return security_ops->capget (target, effective, inheritable, permitted);
1419 }
1420
1421 static inline int security_capset_check (struct task_struct *target,
1422                                          kernel_cap_t *effective,
1423                                          kernel_cap_t *inheritable,
1424                                          kernel_cap_t *permitted)
1425 {
1426         return security_ops->capset_check (target, effective, inheritable, permitted);
1427 }
1428
1429 static inline void security_capset_set (struct task_struct *target,
1430                                         kernel_cap_t *effective,
1431                                         kernel_cap_t *inheritable,
1432                                         kernel_cap_t *permitted)
1433 {
1434         security_ops->capset_set (target, effective, inheritable, permitted);
1435 }
1436
1437 static inline int security_capable(struct task_struct *tsk, int cap)
1438 {
1439         return security_ops->capable(tsk, cap);
1440 }
1441
1442 static inline int security_acct (struct file *file)
1443 {
1444         return security_ops->acct (file);
1445 }
1446
1447 static inline int security_sysctl(struct ctl_table *table, int op)
1448 {
1449         return security_ops->sysctl(table, op);
1450 }
1451
1452 static inline int security_quotactl (int cmds, int type, int id,
1453                                      struct super_block *sb)
1454 {
1455         return security_ops->quotactl (cmds, type, id, sb);
1456 }
1457
1458 static inline int security_quota_on (struct dentry * dentry)
1459 {
1460         return security_ops->quota_on (dentry);
1461 }
1462
1463 static inline int security_syslog(int type)
1464 {
1465         return security_ops->syslog(type);
1466 }
1467
1468 static inline int security_settime(struct timespec *ts, struct timezone *tz)
1469 {
1470         return security_ops->settime(ts, tz);
1471 }
1472
1473 static inline int security_vm_enough_memory(long pages)
1474 {
1475         return security_ops->vm_enough_memory(current->mm, pages);
1476 }
1477
1478 static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
1479 {
1480         return security_ops->vm_enough_memory(mm, pages);
1481 }
1482
1483 static inline int security_bprm_alloc (struct linux_binprm *bprm)
1484 {
1485         return security_ops->bprm_alloc_security (bprm);
1486 }
1487 static inline void security_bprm_free (struct linux_binprm *bprm)
1488 {
1489         security_ops->bprm_free_security (bprm);
1490 }
1491 static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
1492 {
1493         security_ops->bprm_apply_creds (bprm, unsafe);
1494 }
1495 static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
1496 {
1497         security_ops->bprm_post_apply_creds (bprm);
1498 }
1499 static inline int security_bprm_set (struct linux_binprm *bprm)
1500 {
1501         return security_ops->bprm_set_security (bprm);
1502 }
1503
1504 static inline int security_bprm_check (struct linux_binprm *bprm)
1505 {
1506         return security_ops->bprm_check_security (bprm);
1507 }
1508
1509 static inline int security_bprm_secureexec (struct linux_binprm *bprm)
1510 {
1511         return security_ops->bprm_secureexec (bprm);
1512 }
1513
1514 static inline int security_sb_alloc (struct super_block *sb)
1515 {
1516         return security_ops->sb_alloc_security (sb);
1517 }
1518
1519 static inline void security_sb_free (struct super_block *sb)
1520 {
1521         security_ops->sb_free_security (sb);
1522 }
1523
1524 static inline int security_sb_copy_data (struct file_system_type *type,
1525                                          void *orig, void *copy)
1526 {
1527         return security_ops->sb_copy_data (type, orig, copy);
1528 }
1529
1530 static inline int security_sb_kern_mount (struct super_block *sb, void *data)
1531 {
1532         return security_ops->sb_kern_mount (sb, data);
1533 }
1534
1535 static inline int security_sb_statfs (struct dentry *dentry)
1536 {
1537         return security_ops->sb_statfs (dentry);
1538 }
1539
1540 static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
1541                                     char *type, unsigned long flags,
1542                                     void *data)
1543 {
1544         return security_ops->sb_mount (dev_name, nd, type, flags, data);
1545 }
1546
1547 static inline int security_sb_check_sb (struct vfsmount *mnt,
1548                                         struct nameidata *nd)
1549 {
1550         return security_ops->sb_check_sb (mnt, nd);
1551 }
1552
1553 static inline int security_sb_umount (struct vfsmount *mnt, int flags)
1554 {
1555         return security_ops->sb_umount (mnt, flags);
1556 }
1557
1558 static inline void security_sb_umount_close (struct vfsmount *mnt)
1559 {
1560         security_ops->sb_umount_close (mnt);
1561 }
1562
1563 static inline void security_sb_umount_busy (struct vfsmount *mnt)
1564 {
1565         security_ops->sb_umount_busy (mnt);
1566 }
1567
1568 static inline void security_sb_post_remount (struct vfsmount *mnt,
1569                                              unsigned long flags, void *data)
1570 {
1571         security_ops->sb_post_remount (mnt, flags, data);
1572 }
1573
1574 static inline void security_sb_post_mountroot (void)
1575 {
1576         security_ops->sb_post_mountroot ();
1577 }
1578
1579 static inline void security_sb_post_addmount (struct vfsmount *mnt,
1580                                               struct nameidata *mountpoint_nd)
1581 {
1582         security_ops->sb_post_addmount (mnt, mountpoint_nd);
1583 }
1584
1585 static inline int security_sb_pivotroot (struct nameidata *old_nd,
1586                                          struct nameidata *new_nd)
1587 {
1588         return security_ops->sb_pivotroot (old_nd, new_nd);
1589 }
1590
1591 static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
1592                                                struct nameidata *new_nd)
1593 {
1594         security_ops->sb_post_pivotroot (old_nd, new_nd);
1595 }
1596
1597 static inline int security_inode_alloc (struct inode *inode)
1598 {
1599         inode->i_security = NULL;
1600         return security_ops->inode_alloc_security (inode);
1601 }
1602
1603 static inline void security_inode_free (struct inode *inode)
1604 {
1605         security_ops->inode_free_security (inode);
1606 }
1607
1608 static inline int security_inode_init_security (struct inode *inode,
1609                                                 struct inode *dir,
1610                                                 char **name,
1611                                                 void **value,
1612                                                 size_t *len)
1613 {
1614         if (unlikely (IS_PRIVATE (inode)))
1615                 return -EOPNOTSUPP;
1616         return security_ops->inode_init_security (inode, dir, name, value, len);
1617 }
1618         
1619 static inline int security_inode_create (struct inode *dir,
1620                                          struct dentry *dentry,
1621                                          int mode)
1622 {
1623         if (unlikely (IS_PRIVATE (dir)))
1624                 return 0;
1625         return security_ops->inode_create (dir, dentry, mode);
1626 }
1627
1628 static inline int security_inode_link (struct dentry *old_dentry,
1629                                        struct inode *dir,
1630                                        struct dentry *new_dentry)
1631 {
1632         if (unlikely (IS_PRIVATE (old_dentry->d_inode)))
1633                 return 0;
1634         return security_ops->inode_link (old_dentry, dir, new_dentry);
1635 }
1636
1637 static inline int security_inode_unlink (struct inode *dir,
1638                                          struct dentry *dentry)
1639 {
1640         if (unlikely (IS_PRIVATE (dentry->d_inode)))
1641                 return 0;
1642         return security_ops->inode_unlink (dir, dentry);
1643 }
1644
1645 static inline int security_inode_symlink (struct inode *dir,
1646                                           struct dentry *dentry,
1647                                           const char *old_name)
1648 {
1649         if (unlikely (IS_PRIVATE (dir)))
1650                 return 0;
1651         return security_ops->inode_symlink (dir, dentry, old_name);
1652 }
1653
1654 static inline int security_inode_mkdir (struct inode *dir,
1655                                         struct dentry *dentry,
1656                                         int mode)
1657 {
1658         if (unlikely (IS_PRIVATE (dir)))
1659                 return 0;
1660         return security_ops->inode_mkdir (dir, dentry, mode);
1661 }
1662
1663 static inline int security_inode_rmdir (struct inode *dir,
1664                                         struct dentry *dentry)
1665 {
1666         if (unlikely (IS_PRIVATE (dentry->d_inode)))
1667                 return 0;
1668         return security_ops->inode_rmdir (dir, dentry);
1669 }
1670
1671 static inline int security_inode_mknod (struct inode *dir,
1672                                         struct dentry *dentry,
1673                                         int mode, dev_t dev)
1674 {
1675         if (unlikely (IS_PRIVATE (dir)))
1676                 return 0;
1677         return security_ops->inode_mknod (dir, dentry, mode, dev);
1678 }
1679
1680 static inline int security_inode_rename (struct inode *old_dir,
1681                                          struct dentry *old_dentry,
1682                                          struct inode *new_dir,
1683                                          struct dentry *new_dentry)
1684 {
1685         if (unlikely (IS_PRIVATE (old_dentry->d_inode) ||
1686             (new_dentry->d_inode && IS_PRIVATE (new_dentry->d_inode))))
1687                 return 0;
1688         return security_ops->inode_rename (old_dir, old_dentry,
1689                                            new_dir, new_dentry);
1690 }
1691
1692 static inline int security_inode_readlink (struct dentry *dentry)
1693 {
1694         if (unlikely (IS_PRIVATE (dentry->d_inode)))
1695                 return 0;
1696         return security_ops->inode_readlink (dentry);
1697 }
1698
1699 static inline int security_inode_follow_link (struct dentry *dentry,
1700                                               struct nameidata *nd)
1701 {
1702         if (unlikely (IS_PRIVATE (dentry->d_inode)))
1703                 return 0;
1704         return security_ops->inode_follow_link (dentry, nd);
1705 }
1706
1707 static inline int security_inode_permission (struct inode *inode, int mask,
1708                                              struct nameidata *nd)
1709 {
1710         if (unlikely (IS_PRIVATE (inode)))
1711                 return 0;
1712         return security_ops->inode_permission (inode, mask, nd);
1713 }
1714
1715 static inline int security_inode_setattr (struct dentry *dentry,
1716                                           struct iattr *attr)
1717 {
1718         if (unlikely (IS_PRIVATE (dentry->d_inode)))
1719                 return 0;
1720         return security_ops->inode_setattr (dentry, attr);
1721 }
1722
1723 static inline int security_inode_getattr (struct vfsmount *mnt,
1724                                           struct dentry *dentry)
1725 {
1726         if (unlikely (IS_PRIVATE (dentry->d_inode)))
1727                 return 0;
1728         return security_ops->inode_getattr (mnt, dentry);
1729 }
1730
1731 static inline void security_inode_delete (struct inode *inode)
1732 {
1733         if (unlikely (IS_PRIVATE (inode)))
1734                 return;
1735         security_ops->inode_delete (inode);
1736 }
1737
1738 static inline int security_inode_setxattr (struct dentry *dentry, char *name,
1739                                            void *value, size_t size, int flags)
1740 {
1741         if (unlikely (IS_PRIVATE (dentry->d_inode)))
1742                 return 0;
1743         return security_ops->inode_setxattr (dentry, name, value, size, flags);
1744 }
1745
1746 static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
1747                                                 void *value, size_t size, int flags)
1748 {
1749         if (unlikely (IS_PRIVATE (dentry->d_inode)))
1750                 return;
1751         security_ops->inode_post_setxattr (dentry, name, value, size, flags);
1752 }
1753
1754 static inline int security_inode_getxattr (struct dentry *dentry, char *name)
1755 {
1756         if (unlikely (IS_PRIVATE (dentry->d_inode)))
1757                 return 0;
1758         return security_ops->inode_getxattr (dentry, name);
1759 }
1760
1761 static inline int security_inode_listxattr (struct dentry *dentry)
1762 {
1763         if (unlikely (IS_PRIVATE (dentry->d_inode)))
1764                 return 0;
1765         return security_ops->inode_listxattr (dentry);
1766 }
1767
1768 static inline int security_inode_removexattr (struct dentry *dentry, char *name)
1769 {
1770         if (unlikely (IS_PRIVATE (dentry->d_inode)))
1771                 return 0;
1772         return security_ops->inode_removexattr (dentry, name);
1773 }
1774
1775 static inline const char *security_inode_xattr_getsuffix(void)
1776 {
1777         return security_ops->inode_xattr_getsuffix();
1778 }
1779
1780 static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void *buffer, size_t size, int err)
1781 {
1782         if (unlikely (IS_PRIVATE (inode)))
1783                 return 0;
1784         return security_ops->inode_getsecurity(inode, name, buffer, size, err);
1785 }
1786
1787 static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
1788 {
1789         if (unlikely (IS_PRIVATE (inode)))
1790                 return 0;
1791         return security_ops->inode_setsecurity(inode, name, value, size, flags);
1792 }
1793
1794 static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
1795 {
1796         if (unlikely (IS_PRIVATE (inode)))
1797                 return 0;
1798         return security_ops->inode_listsecurity(inode, buffer, buffer_size);
1799 }
1800
1801 static inline int security_file_permission (struct file *file, int mask)
1802 {
1803         return security_ops->file_permission (file, mask);
1804 }
1805
1806 static inline int security_file_alloc (struct file *file)
1807 {
1808         return security_ops->file_alloc_security (file);
1809 }
1810
1811 static inline void security_file_free (struct file *file)
1812 {
1813         security_ops->file_free_security (file);
1814 }
1815
1816 static inline int security_file_ioctl (struct file *file, unsigned int cmd,
1817                                        unsigned long arg)
1818 {
1819         return security_ops->file_ioctl (file, cmd, arg);
1820 }
1821
1822 static inline int security_file_mmap (struct file *file, unsigned long reqprot,
1823                                       unsigned long prot,
1824                                       unsigned long flags,
1825                                       unsigned long addr,
1826                                       unsigned long addr_only)
1827 {
1828         return security_ops->file_mmap (file, reqprot, prot, flags, addr,
1829                                         addr_only);
1830 }
1831
1832 static inline int security_file_mprotect (struct vm_area_struct *vma,
1833                                           unsigned long reqprot,
1834                                           unsigned long prot)
1835 {
1836         return security_ops->file_mprotect (vma, reqprot, prot);
1837 }
1838
1839 static inline int security_file_lock (struct file *file, unsigned int cmd)
1840 {
1841         return security_ops->file_lock (file, cmd);
1842 }
1843
1844 static inline int security_file_fcntl (struct file *file, unsigned int cmd,
1845                                        unsigned long arg)
1846 {
1847         return security_ops->file_fcntl (file, cmd, arg);
1848 }
1849
1850 static inline int security_file_set_fowner (struct file *file)
1851 {
1852         return security_ops->file_set_fowner (file);
1853 }
1854
1855 static inline int security_file_send_sigiotask (struct task_struct *tsk,
1856                                                 struct fown_struct *fown,
1857                                                 int sig)
1858 {
1859         return security_ops->file_send_sigiotask (tsk, fown, sig);
1860 }
1861
1862 static inline int security_file_receive (struct file *file)
1863 {
1864         return security_ops->file_receive (file);
1865 }
1866
1867 static inline int security_task_create (unsigned long clone_flags)
1868 {
1869         return security_ops->task_create (clone_flags);
1870 }
1871
1872 static inline int security_task_alloc (struct task_struct *p)
1873 {
1874         return security_ops->task_alloc_security (p);
1875 }
1876
1877 static inline void security_task_free (struct task_struct *p)
1878 {
1879         security_ops->task_free_security (p);
1880 }
1881
1882 static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
1883                                         int flags)
1884 {
1885         return security_ops->task_setuid (id0, id1, id2, flags);
1886 }
1887
1888 static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
1889                                              uid_t old_suid, int flags)
1890 {
1891         return security_ops->task_post_setuid (old_ruid, old_euid, old_suid, flags);
1892 }
1893
1894 static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
1895                                         int flags)
1896 {
1897         return security_ops->task_setgid (id0, id1, id2, flags);
1898 }
1899
1900 static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
1901 {
1902         return security_ops->task_setpgid (p, pgid);
1903 }
1904
1905 static inline int security_task_getpgid (struct task_struct *p)
1906 {
1907         return security_ops->task_getpgid (p);
1908 }
1909
1910 static inline int security_task_getsid (struct task_struct *p)
1911 {
1912         return security_ops->task_getsid (p);
1913 }
1914
1915 static inline void security_task_getsecid (struct task_struct *p, u32 *secid)
1916 {
1917         security_ops->task_getsecid (p, secid);
1918 }
1919
1920 static inline int security_task_setgroups (struct group_info *group_info)
1921 {
1922         return security_ops->task_setgroups (group_info);
1923 }
1924
1925 static inline int security_task_setnice (struct task_struct *p, int nice)
1926 {
1927         return security_ops->task_setnice (p, nice);
1928 }
1929
1930 static inline int security_task_setioprio (struct task_struct *p, int ioprio)
1931 {
1932         return security_ops->task_setioprio (p, ioprio);
1933 }
1934
1935 static inline int security_task_getioprio (struct task_struct *p)
1936 {
1937         return security_ops->task_getioprio (p);
1938 }
1939
1940 static inline int security_task_setrlimit (unsigned int resource,
1941                                            struct rlimit *new_rlim)
1942 {
1943         return security_ops->task_setrlimit (resource, new_rlim);
1944 }
1945
1946 static inline int security_task_setscheduler (struct task_struct *p,
1947                                               int policy,
1948                                               struct sched_param *lp)
1949 {
1950         return security_ops->task_setscheduler (p, policy, lp);
1951 }
1952
1953 static inline int security_task_getscheduler (struct task_struct *p)
1954 {
1955         return security_ops->task_getscheduler (p);
1956 }
1957
1958 static inline int security_task_movememory (struct task_struct *p)
1959 {
1960         return security_ops->task_movememory (p);
1961 }
1962
1963 static inline int security_task_kill (struct task_struct *p,
1964                                       struct siginfo *info, int sig,
1965                                       u32 secid)
1966 {
1967         return security_ops->task_kill (p, info, sig, secid);
1968 }
1969
1970 static inline int security_task_wait (struct task_struct *p)
1971 {
1972         return security_ops->task_wait (p);
1973 }
1974
1975 static inline int security_task_prctl (int option, unsigned long arg2,
1976                                        unsigned long arg3,
1977                                        unsigned long arg4,
1978                                        unsigned long arg5)
1979 {
1980         return security_ops->task_prctl (option, arg2, arg3, arg4, arg5);
1981 }
1982
1983 static inline void security_task_reparent_to_init (struct task_struct *p)
1984 {
1985         security_ops->task_reparent_to_init (p);
1986 }
1987
1988 static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
1989 {
1990         security_ops->task_to_inode(p, inode);
1991 }
1992
1993 static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
1994                                            short flag)
1995 {
1996         return security_ops->ipc_permission (ipcp, flag);
1997 }
1998
1999 static inline int security_msg_msg_alloc (struct msg_msg * msg)
2000 {
2001         return security_ops->msg_msg_alloc_security (msg);
2002 }
2003
2004 static inline void security_msg_msg_free (struct msg_msg * msg)
2005 {
2006         security_ops->msg_msg_free_security(msg);
2007 }
2008
2009 static inline int security_msg_queue_alloc (struct msg_queue *msq)
2010 {
2011         return security_ops->msg_queue_alloc_security (msq);
2012 }
2013
2014 static inline void security_msg_queue_free (struct msg_queue *msq)
2015 {
2016         security_ops->msg_queue_free_security (msq);
2017 }
2018
2019 static inline int security_msg_queue_associate (struct msg_queue * msq, 
2020                                                 int msqflg)
2021 {
2022         return security_ops->msg_queue_associate (msq, msqflg);
2023 }
2024
2025 static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
2026 {
2027         return security_ops->msg_queue_msgctl (msq, cmd);
2028 }
2029
2030 static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
2031                                              struct msg_msg * msg, int msqflg)
2032 {
2033         return security_ops->msg_queue_msgsnd (msq, msg, msqflg);
2034 }
2035
2036 static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
2037                                              struct msg_msg * msg,
2038                                              struct task_struct * target,
2039                                              long type, int mode)
2040 {
2041         return security_ops->msg_queue_msgrcv (msq, msg, target, type, mode);
2042 }
2043
2044 static inline int security_shm_alloc (struct shmid_kernel *shp)
2045 {
2046         return security_ops->shm_alloc_security (shp);
2047 }
2048
2049 static inline void security_shm_free (struct shmid_kernel *shp)
2050 {
2051         security_ops->shm_free_security (shp);
2052 }
2053
2054 static inline int security_shm_associate (struct shmid_kernel * shp, 
2055                                           int shmflg)
2056 {
2057         return security_ops->shm_associate(shp, shmflg);
2058 }
2059
2060 static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
2061 {
2062         return security_ops->shm_shmctl (shp, cmd);
2063 }
2064
2065 static inline int security_shm_shmat (struct shmid_kernel * shp, 
2066                                       char __user *shmaddr, int shmflg)
2067 {
2068         return security_ops->shm_shmat(shp, shmaddr, shmflg);
2069 }
2070
2071 static inline int security_sem_alloc (struct sem_array *sma)
2072 {
2073         return security_ops->sem_alloc_security (sma);
2074 }
2075
2076 static inline void security_sem_free (struct sem_array *sma)
2077 {
2078         security_ops->sem_free_security (sma);
2079 }
2080
2081 static inline int security_sem_associate (struct sem_array * sma, int semflg)
2082 {
2083         return security_ops->sem_associate (sma, semflg);
2084 }
2085
2086 static inline int security_sem_semctl (struct sem_array * sma, int cmd)
2087 {
2088         return security_ops->sem_semctl(sma, cmd);
2089 }
2090
2091 static inline int security_sem_semop (struct sem_array * sma, 
2092                                       struct sembuf * sops, unsigned nsops, 
2093                                       int alter)
2094 {
2095         return security_ops->sem_semop(sma, sops, nsops, alter);
2096 }
2097
2098 static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
2099 {
2100         if (unlikely (inode && IS_PRIVATE (inode)))
2101                 return;
2102         security_ops->d_instantiate (dentry, inode);
2103 }
2104
2105 static inline int security_getprocattr(struct task_struct *p, char *name, char **value)
2106 {
2107         return security_ops->getprocattr(p, name, value);
2108 }
2109
2110 static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2111 {
2112         return security_ops->setprocattr(p, name, value, size);
2113 }
2114
2115 static inline int security_netlink_send(struct sock *sk, struct sk_buff * skb)
2116 {
2117         return security_ops->netlink_send(sk, skb);
2118 }
2119
2120 static inline int security_netlink_recv(struct sk_buff * skb, int cap)
2121 {
2122         return security_ops->netlink_recv(skb, cap);
2123 }
2124
2125 static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
2126 {
2127         return security_ops->secid_to_secctx(secid, secdata, seclen);
2128 }
2129
2130 static inline void security_release_secctx(char *secdata, u32 seclen)
2131 {
2132         return security_ops->release_secctx(secdata, seclen);
2133 }
2134
2135 /* prototypes */
2136 extern int security_init        (void);
2137 extern int register_security    (struct security_operations *ops);
2138 extern int unregister_security  (struct security_operations *ops);
2139 extern int mod_reg_security     (const char *name, struct security_operations *ops);
2140 extern int mod_unreg_security   (const char *name, struct security_operations *ops);
2141 extern struct dentry *securityfs_create_file(const char *name, mode_t mode,
2142                                              struct dentry *parent, void *data,
2143                                              const struct file_operations *fops);
2144 extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
2145 extern void securityfs_remove(struct dentry *dentry);
2146
2147
2148 #else /* CONFIG_SECURITY */
2149
2150 /*
2151  * This is the default capabilities functionality.  Most of these functions
2152  * are just stubbed out, but a few must call the proper capable code.
2153  */
2154
2155 static inline int security_init(void)
2156 {
2157         return 0;
2158 }
2159
2160 static inline int security_ptrace (struct task_struct *parent, struct task_struct * child)
2161 {
2162         return cap_ptrace (parent, child);
2163 }
2164
2165 static inline int security_capget (struct task_struct *target,
2166                                    kernel_cap_t *effective,
2167                                    kernel_cap_t *inheritable,
2168                                    kernel_cap_t *permitted)
2169 {
2170         return cap_capget (target, effective, inheritable, permitted);
2171 }
2172
2173 static inline int security_capset_check (struct task_struct *target,
2174                                          kernel_cap_t *effective,
2175                                          kernel_cap_t *inheritable,
2176                                          kernel_cap_t *permitted)
2177 {
2178         return cap_capset_check (target, effective, inheritable, permitted);
2179 }
2180
2181 static inline void security_capset_set (struct task_struct *target,
2182                                         kernel_cap_t *effective,
2183                                         kernel_cap_t *inheritable,
2184                                         kernel_cap_t *permitted)
2185 {
2186         cap_capset_set (target, effective, inheritable, permitted);
2187 }
2188
2189 static inline int security_capable(struct task_struct *tsk, int cap)
2190 {
2191         return cap_capable(tsk, cap);
2192 }
2193
2194 static inline int security_acct (struct file *file)
2195 {
2196         return 0;
2197 }
2198
2199 static inline int security_sysctl(struct ctl_table *table, int op)
2200 {
2201         return 0;
2202 }
2203
2204 static inline int security_quotactl (int cmds, int type, int id,
2205                                      struct super_block * sb)
2206 {
2207         return 0;
2208 }
2209
2210 static inline int security_quota_on (struct dentry * dentry)
2211 {
2212         return 0;
2213 }
2214
2215 static inline int security_syslog(int type)
2216 {
2217         return cap_syslog(type);
2218 }
2219
2220 static inline int security_settime(struct timespec *ts, struct timezone *tz)
2221 {
2222         return cap_settime(ts, tz);
2223 }
2224
2225 static inline int security_vm_enough_memory(long pages)
2226 {
2227         return cap_vm_enough_memory(current->mm, pages);
2228 }
2229
2230 static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
2231 {
2232         return cap_vm_enough_memory(mm, pages);
2233 }
2234
2235 static inline int security_bprm_alloc (struct linux_binprm *bprm)
2236 {
2237         return 0;
2238 }
2239
2240 static inline void security_bprm_free (struct linux_binprm *bprm)
2241 { }
2242
2243 static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
2244
2245         cap_bprm_apply_creds (bprm, unsafe);
2246 }
2247
2248 static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
2249 {
2250         return;
2251 }
2252
2253 static inline int security_bprm_set (struct linux_binprm *bprm)
2254 {
2255         return cap_bprm_set_security (bprm);
2256 }
2257
2258 static inline int security_bprm_check (struct linux_binprm *bprm)
2259 {
2260         return 0;
2261 }
2262
2263 static inline int security_bprm_secureexec (struct linux_binprm *bprm)
2264 {
2265         return cap_bprm_secureexec(bprm);
2266 }
2267
2268 static inline int security_sb_alloc (struct super_block *sb)
2269 {
2270         return 0;
2271 }
2272
2273 static inline void security_sb_free (struct super_block *sb)
2274 { }
2275
2276 static inline int security_sb_copy_data (struct file_system_type *type,
2277                                          void *orig, void *copy)
2278 {
2279         return 0;
2280 }
2281
2282 static inline int security_sb_kern_mount (struct super_block *sb, void *data)
2283 {
2284         return 0;
2285 }
2286
2287 static inline int security_sb_statfs (struct dentry *dentry)
2288 {
2289         return 0;
2290 }
2291
2292 static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
2293                                     char *type, unsigned long flags,
2294                                     void *data)
2295 {
2296         return 0;
2297 }
2298
2299 static inline int security_sb_check_sb (struct vfsmount *mnt,
2300                                         struct nameidata *nd)
2301 {
2302         return 0;
2303 }
2304
2305 static inline int security_sb_umount (struct vfsmount *mnt, int flags)
2306 {
2307         return 0;
2308 }
2309
2310 static inline void security_sb_umount_close (struct vfsmount *mnt)
2311 { }
2312
2313 static inline void security_sb_umount_busy (struct vfsmount *mnt)
2314 { }
2315
2316 static inline void security_sb_post_remount (struct vfsmount *mnt,
2317                                              unsigned long flags, void *data)
2318 { }
2319
2320 static inline void security_sb_post_mountroot (void)
2321 { }
2322
2323 static inline void security_sb_post_addmount (struct vfsmount *mnt,
2324                                               struct nameidata *mountpoint_nd)
2325 { }
2326
2327 static inline int security_sb_pivotroot (struct nameidata *old_nd,
2328                                          struct nameidata *new_nd)
2329 {
2330         return 0;
2331 }
2332
2333 static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
2334                                                struct nameidata *new_nd)
2335 { }
2336
2337 static inline int security_inode_alloc (struct inode *inode)
2338 {
2339         return 0;
2340 }
2341
2342 static inline void security_inode_free (struct inode *inode)
2343 { }
2344
2345 static inline int security_inode_init_security (struct inode *inode,
2346                                                 struct inode *dir,
2347                                                 char **name,
2348                                                 void **value,
2349                                                 size_t *len)
2350 {
2351         return -EOPNOTSUPP;
2352 }
2353         
2354 static inline int security_inode_create (struct inode *dir,
2355                                          struct dentry *dentry,
2356                                          int mode)
2357 {
2358         return 0;
2359 }
2360
2361 static inline int security_inode_link (struct dentry *old_dentry,
2362                                        struct inode *dir,
2363                                        struct dentry *new_dentry)
2364 {
2365         return 0;
2366 }
2367
2368 static inline int security_inode_unlink (struct inode *dir,
2369                                          struct dentry *dentry)
2370 {
2371         return 0;
2372 }
2373
2374 static inline int security_inode_symlink (struct inode *dir,
2375                                           struct dentry *dentry,
2376                                           const char *old_name)
2377 {
2378         return 0;
2379 }
2380
2381 static inline int security_inode_mkdir (struct inode *dir,
2382                                         struct dentry *dentry,
2383                                         int mode)
2384 {
2385         return 0;
2386 }
2387
2388 static inline int security_inode_rmdir (struct inode *dir,
2389                                         struct dentry *dentry)
2390 {
2391         return 0;
2392 }
2393
2394 static inline int security_inode_mknod (struct inode *dir,
2395                                         struct dentry *dentry,
2396                                         int mode, dev_t dev)
2397 {
2398         return 0;
2399 }
2400
2401 static inline int security_inode_rename (struct inode *old_dir,
2402                                          struct dentry *old_dentry,
2403                                          struct inode *new_dir,
2404                                          struct dentry *new_dentry)
2405 {
2406         return 0;
2407 }
2408
2409 static inline int security_inode_readlink (struct dentry *dentry)
2410 {
2411         return 0;
2412 }
2413
2414 static inline int security_inode_follow_link (struct dentry *dentry,
2415                                               struct nameidata *nd)
2416 {
2417         return 0;
2418 }
2419
2420 static inline int security_inode_permission (struct inode *inode, int mask,
2421                                              struct nameidata *nd)
2422 {
2423         return 0;
2424 }
2425
2426 static inline int security_inode_setattr (struct dentry *dentry,
2427                                           struct iattr *attr)
2428 {
2429         return 0;
2430 }
2431
2432 static inline int security_inode_getattr (struct vfsmount *mnt,
2433                                           struct dentry *dentry)
2434 {
2435         return 0;
2436 }
2437
2438 static inline void security_inode_delete (struct inode *inode)
2439 { }
2440
2441 static inline int security_inode_setxattr (struct dentry *dentry, char *name,
2442                                            void *value, size_t size, int flags)
2443 {
2444         return cap_inode_setxattr(dentry, name, value, size, flags);
2445 }
2446
2447 static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
2448                                                  void *value, size_t size, int flags)
2449 { }
2450
2451 static inline int security_inode_getxattr (struct dentry *dentry, char *name)
2452 {
2453         return 0;
2454 }
2455
2456 static inline int security_inode_listxattr (struct dentry *dentry)
2457 {
2458         return 0;
2459 }
2460
2461 static inline int security_inode_removexattr (struct dentry *dentry, char *name)
2462 {
2463         return cap_inode_removexattr(dentry, name);
2464 }
2465
2466 static inline const char *security_inode_xattr_getsuffix (void)
2467 {
2468         return NULL ;
2469 }
2470
2471 static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void *buffer, size_t size, int err)
2472 {
2473         return -EOPNOTSUPP;
2474 }
2475
2476 static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
2477 {
2478         return -EOPNOTSUPP;
2479 }
2480
2481 static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
2482 {
2483         return 0;
2484 }
2485
2486 static inline int security_file_permission (struct file *file, int mask)
2487 {
2488         return 0;
2489 }
2490
2491 static inline int security_file_alloc (struct file *file)
2492 {
2493         return 0;
2494 }
2495
2496 static inline void security_file_free (struct file *file)
2497 { }
2498
2499 static inline int security_file_ioctl (struct file *file, unsigned int cmd,
2500                                        unsigned long arg)
2501 {
2502         return 0;
2503 }
2504
2505 static inline int security_file_mmap (struct file *file, unsigned long reqprot,
2506                                       unsigned long prot,
2507                                       unsigned long flags,
2508                                       unsigned long addr,
2509                                       unsigned long addr_only)
2510 {
2511         return 0;
2512 }
2513
2514 static inline int security_file_mprotect (struct vm_area_struct *vma,
2515                                           unsigned long reqprot,
2516                                           unsigned long prot)
2517 {
2518         return 0;
2519 }
2520
2521 static inline int security_file_lock (struct file *file, unsigned int cmd)
2522 {
2523         return 0;
2524 }
2525
2526 static inline int security_file_fcntl (struct file *file, unsigned int cmd,
2527                                        unsigned long arg)
2528 {
2529         return 0;
2530 }
2531
2532 static inline int security_file_set_fowner (struct file *file)
2533 {
2534         return 0;
2535 }
2536
2537 static inline int security_file_send_sigiotask (struct task_struct *tsk,
2538                                                 struct fown_struct *fown,
2539                                                 int sig)
2540 {
2541         return 0;
2542 }
2543
2544 static inline int security_file_receive (struct file *file)
2545 {
2546         return 0;
2547 }
2548
2549 static inline int security_task_create (unsigned long clone_flags)
2550 {
2551         return 0;
2552 }
2553
2554 static inline int security_task_alloc (struct task_struct *p)
2555 {
2556         return 0;
2557 }
2558
2559 static inline void security_task_free (struct task_struct *p)
2560 { }
2561
2562 static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
2563                                         int flags)
2564 {
2565         return 0;
2566 }
2567
2568 static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
2569                                              uid_t old_suid, int flags)
2570 {
2571         return cap_task_post_setuid (old_ruid, old_euid, old_suid, flags);
2572 }
2573
2574 static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
2575                                         int flags)
2576 {
2577         return 0;
2578 }
2579
2580 static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
2581 {
2582         return 0;
2583 }
2584
2585 static inline int security_task_getpgid (struct task_struct *p)
2586 {
2587         return 0;
2588 }
2589
2590 static inline int security_task_getsid (struct task_struct *p)
2591 {
2592         return 0;
2593 }
2594
2595 static inline void security_task_getsecid (struct task_struct *p, u32 *secid)
2596 { }
2597
2598 static inline int security_task_setgroups (struct group_info *group_info)
2599 {
2600         return 0;
2601 }
2602
2603 static inline int security_task_setnice (struct task_struct *p, int nice)
2604 {
2605         return 0;
2606 }
2607
2608 static inline int security_task_setioprio (struct task_struct *p, int ioprio)
2609 {
2610         return 0;
2611 }
2612
2613 static inline int security_task_getioprio (struct task_struct *p)
2614 {
2615         return 0;
2616 }
2617
2618 static inline int security_task_setrlimit (unsigned int resource,
2619                                            struct rlimit *new_rlim)
2620 {
2621         return 0;
2622 }
2623
2624 static inline int security_task_setscheduler (struct task_struct *p,
2625                                               int policy,
2626                                               struct sched_param *lp)
2627 {
2628         return 0;
2629 }
2630
2631 static inline int security_task_getscheduler (struct task_struct *p)
2632 {
2633         return 0;
2634 }
2635
2636 static inline int security_task_movememory (struct task_struct *p)
2637 {
2638         return 0;
2639 }
2640
2641 static inline int security_task_kill (struct task_struct *p,
2642                                       struct siginfo *info, int sig,
2643                                       u32 secid)
2644 {
2645         return 0;
2646 }
2647
2648 static inline int security_task_wait (struct task_struct *p)
2649 {
2650         return 0;
2651 }
2652
2653 static inline int security_task_prctl (int option, unsigned long arg2,
2654                                        unsigned long arg3,
2655                                        unsigned long arg4,
2656                                        unsigned long arg5)
2657 {
2658         return 0;
2659 }
2660
2661 static inline void security_task_reparent_to_init (struct task_struct *p)
2662 {
2663         cap_task_reparent_to_init (p);
2664 }
2665
2666 static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
2667 { }
2668
2669 static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
2670                                            short flag)
2671 {
2672         return 0;
2673 }
2674
2675 static inline int security_msg_msg_alloc (struct msg_msg * msg)
2676 {
2677         return 0;
2678 }
2679
2680 static inline void security_msg_msg_free (struct msg_msg * msg)
2681 { }
2682
2683 static inline int security_msg_queue_alloc (struct msg_queue *msq)
2684 {
2685         return 0;
2686 }
2687
2688 static inline void security_msg_queue_free (struct msg_queue *msq)
2689 { }
2690
2691 static inline int security_msg_queue_associate (struct msg_queue * msq, 
2692                                                 int msqflg)
2693 {
2694         return 0;
2695 }
2696
2697 static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
2698 {
2699         return 0;
2700 }
2701
2702 static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
2703                                              struct msg_msg * msg, int msqflg)
2704 {
2705         return 0;
2706 }
2707
2708 static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
2709                                              struct msg_msg * msg,
2710                                              struct task_struct * target,
2711                                              long type, int mode)
2712 {
2713         return 0;
2714 }
2715
2716 static inline int security_shm_alloc (struct shmid_kernel *shp)
2717 {
2718         return 0;
2719 }
2720
2721 static inline void security_shm_free (struct shmid_kernel *shp)
2722 { }
2723
2724 static inline int security_shm_associate (struct shmid_kernel * shp, 
2725                                           int shmflg)
2726 {
2727         return 0;
2728 }
2729
2730 static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
2731 {
2732         return 0;
2733 }
2734
2735 static inline int security_shm_shmat (struct shmid_kernel * shp, 
2736                                       char __user *shmaddr, int shmflg)
2737 {
2738         return 0;
2739 }
2740
2741 static inline int security_sem_alloc (struct sem_array *sma)
2742 {
2743         return 0;
2744 }
2745
2746 static inline void security_sem_free (struct sem_array *sma)
2747 { }
2748
2749 static inline int security_sem_associate (struct sem_array * sma, int semflg)
2750 {
2751         return 0;
2752 }
2753
2754 static inline int security_sem_semctl (struct sem_array * sma, int cmd)
2755 {
2756         return 0;
2757 }
2758
2759 static inline int security_sem_semop (struct sem_array * sma, 
2760                                       struct sembuf * sops, unsigned nsops, 
2761                                       int alter)
2762 {
2763         return 0;
2764 }
2765
2766 static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
2767 { }
2768
2769 static inline int security_getprocattr(struct task_struct *p, char *name, char **value)
2770 {
2771         return -EINVAL;
2772 }
2773
2774 static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2775 {
2776         return -EINVAL;
2777 }
2778
2779 static inline int security_netlink_send (struct sock *sk, struct sk_buff *skb)
2780 {
2781         return cap_netlink_send (sk, skb);
2782 }
2783
2784 static inline int security_netlink_recv (struct sk_buff *skb, int cap)
2785 {
2786         return cap_netlink_recv (skb, cap);
2787 }
2788
2789 static inline struct dentry *securityfs_create_dir(const char *name,
2790                                         struct dentry *parent)
2791 {
2792         return ERR_PTR(-ENODEV);
2793 }
2794
2795 static inline struct dentry *securityfs_create_file(const char *name,
2796                                                 mode_t mode,
2797                                                 struct dentry *parent,
2798                                                 void *data,
2799                                                 struct file_operations *fops)
2800 {
2801         return ERR_PTR(-ENODEV);
2802 }
2803
2804 static inline void securityfs_remove(struct dentry *dentry)
2805 {
2806 }
2807
2808 static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
2809 {
2810         return -EOPNOTSUPP;
2811 }
2812
2813 static inline void security_release_secctx(char *secdata, u32 seclen)
2814 {
2815 }
2816 #endif  /* CONFIG_SECURITY */
2817
2818 #ifdef CONFIG_SECURITY_NETWORK
2819 static inline int security_unix_stream_connect(struct socket * sock,
2820                                                struct socket * other, 
2821                                                struct sock * newsk)
2822 {
2823         return security_ops->unix_stream_connect(sock, other, newsk);
2824 }
2825
2826
2827 static inline int security_unix_may_send(struct socket * sock, 
2828                                          struct socket * other)
2829 {
2830         return security_ops->unix_may_send(sock, other);
2831 }
2832
2833 static inline int security_socket_create (int family, int type,
2834                                           int protocol, int kern)
2835 {
2836         return security_ops->socket_create(family, type, protocol, kern);
2837 }
2838
2839 static inline int security_socket_post_create(struct socket * sock,
2840                                               int family,
2841                                               int type,
2842                                               int protocol, int kern)
2843 {
2844         return security_ops->socket_post_create(sock, family, type,
2845                                                 protocol, kern);
2846 }
2847
2848 static inline int security_socket_bind(struct socket * sock, 
2849                                        struct sockaddr * address, 
2850                                        int addrlen)
2851 {
2852         return security_ops->socket_bind(sock, address, addrlen);
2853 }
2854
2855 static inline int security_socket_connect(struct socket * sock, 
2856                                           struct sockaddr * address, 
2857                                           int addrlen)
2858 {
2859         return security_ops->socket_connect(sock, address, addrlen);
2860 }
2861
2862 static inline int security_socket_listen(struct socket * sock, int backlog)
2863 {
2864         return security_ops->socket_listen(sock, backlog);
2865 }
2866
2867 static inline int security_socket_accept(struct socket * sock, 
2868                                          struct socket * newsock)
2869 {
2870         return security_ops->socket_accept(sock, newsock);
2871 }
2872
2873 static inline void security_socket_post_accept(struct socket * sock, 
2874                                                struct socket * newsock)
2875 {
2876         security_ops->socket_post_accept(sock, newsock);
2877 }
2878
2879 static inline int security_socket_sendmsg(struct socket * sock, 
2880                                           struct msghdr * msg, int size)
2881 {
2882         return security_ops->socket_sendmsg(sock, msg, size);
2883 }
2884
2885 static inline int security_socket_recvmsg(struct socket * sock, 
2886                                           struct msghdr * msg, int size, 
2887                                           int flags)
2888 {
2889         return security_ops->socket_recvmsg(sock, msg, size, flags);
2890 }
2891
2892 static inline int security_socket_getsockname(struct socket * sock)
2893 {
2894         return security_ops->socket_getsockname(sock);
2895 }
2896
2897 static inline int security_socket_getpeername(struct socket * sock)
2898 {
2899         return security_ops->socket_getpeername(sock);
2900 }
2901
2902 static inline int security_socket_getsockopt(struct socket * sock, 
2903                                              int level, int optname)
2904 {
2905         return security_ops->socket_getsockopt(sock, level, optname);
2906 }
2907
2908 static inline int security_socket_setsockopt(struct socket * sock, 
2909                                              int level, int optname)
2910 {
2911         return security_ops->socket_setsockopt(sock, level, optname);
2912 }
2913
2914 static inline int security_socket_shutdown(struct socket * sock, int how)
2915 {
2916         return security_ops->socket_shutdown(sock, how);
2917 }
2918
2919 static inline int security_sock_rcv_skb (struct sock * sk, 
2920                                          struct sk_buff * skb)
2921 {
2922         return security_ops->socket_sock_rcv_skb (sk, skb);
2923 }
2924
2925 static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2926                                                     int __user *optlen, unsigned len)
2927 {
2928         return security_ops->socket_getpeersec_stream(sock, optval, optlen, len);
2929 }
2930
2931 static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
2932 {
2933         return security_ops->socket_getpeersec_dgram(sock, skb, secid);
2934 }
2935
2936 static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
2937 {
2938         return security_ops->sk_alloc_security(sk, family, priority);
2939 }
2940
2941 static inline void security_sk_free(struct sock *sk)
2942 {
2943         return security_ops->sk_free_security(sk);
2944 }
2945
2946 static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
2947 {
2948         return security_ops->sk_clone_security(sk, newsk);
2949 }
2950
2951 static inline void security_sk_classify_flow(struct sock *sk, struct flowi *fl)
2952 {
2953         security_ops->sk_getsecid(sk, &fl->secid);
2954 }
2955
2956 static inline void security_req_classify_flow(const struct request_sock *req, struct flowi *fl)
2957 {
2958         security_ops->req_classify_flow(req, fl);
2959 }
2960
2961 static inline void security_sock_graft(struct sock* sk, struct socket *parent)
2962 {
2963         security_ops->sock_graft(sk, parent);
2964 }
2965
2966 static inline int security_inet_conn_request(struct sock *sk,
2967                         struct sk_buff *skb, struct request_sock *req)
2968 {
2969         return security_ops->inet_conn_request(sk, skb, req);
2970 }
2971
2972 static inline void security_inet_csk_clone(struct sock *newsk,
2973                         const struct request_sock *req)
2974 {
2975         security_ops->inet_csk_clone(newsk, req);
2976 }
2977
2978 static inline void security_inet_conn_established(struct sock *sk,
2979                         struct sk_buff *skb)
2980 {
2981         security_ops->inet_conn_established(sk, skb);
2982 }
2983 #else   /* CONFIG_SECURITY_NETWORK */
2984 static inline int security_unix_stream_connect(struct socket * sock,
2985                                                struct socket * other,
2986                                                struct sock * newsk)
2987 {
2988         return 0;
2989 }
2990
2991 static inline int security_unix_may_send(struct socket * sock, 
2992                                          struct socket * other)
2993 {
2994         return 0;
2995 }
2996
2997 static inline int security_socket_create (int family, int type,
2998                                           int protocol, int kern)
2999 {
3000         return 0;
3001 }
3002
3003 static inline int security_socket_post_create(struct socket * sock,
3004                                               int family,
3005                                               int type,
3006                                               int protocol, int kern)
3007 {
3008         return 0;
3009 }
3010
3011 static inline int security_socket_bind(struct socket * sock, 
3012                                        struct sockaddr * address, 
3013                                        int addrlen)
3014 {
3015         return 0;
3016 }
3017
3018 static inline int security_socket_connect(struct socket * sock, 
3019                                           struct sockaddr * address, 
3020                                           int addrlen)
3021 {
3022         return 0;
3023 }
3024
3025 static inline int security_socket_listen(struct socket * sock, int backlog)
3026 {
3027         return 0;
3028 }
3029
3030 static inline int security_socket_accept(struct socket * sock, 
3031                                          struct socket * newsock)
3032 {
3033         return 0;
3034 }
3035
3036 static inline void security_socket_post_accept(struct socket * sock, 
3037                                                struct socket * newsock)
3038 {
3039 }
3040
3041 static inline int security_socket_sendmsg(struct socket * sock, 
3042                                           struct msghdr * msg, int size)
3043 {
3044         return 0;
3045 }
3046
3047 static inline int security_socket_recvmsg(struct socket * sock, 
3048                                           struct msghdr * msg, int size, 
3049                                           int flags)
3050 {
3051         return 0;
3052 }
3053
3054 static inline int security_socket_getsockname(struct socket * sock)
3055 {
3056         return 0;
3057 }
3058
3059 static inline int security_socket_getpeername(struct socket * sock)
3060 {
3061         return 0;
3062 }
3063
3064 static inline int security_socket_getsockopt(struct socket * sock, 
3065                                              int level, int optname)
3066 {
3067         return 0;
3068 }
3069
3070 static inline int security_socket_setsockopt(struct socket * sock, 
3071                                              int level, int optname)
3072 {
3073         return 0;
3074 }
3075
3076 static inline int security_socket_shutdown(struct socket * sock, int how)
3077 {
3078         return 0;
3079 }
3080 static inline int security_sock_rcv_skb (struct sock * sk, 
3081                                          struct sk_buff * skb)
3082 {
3083         return 0;
3084 }
3085
3086 static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
3087                                                     int __user *optlen, unsigned len)
3088 {
3089         return -ENOPROTOOPT;
3090 }
3091
3092 static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
3093 {
3094         return -ENOPROTOOPT;
3095 }
3096
3097 static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
3098 {
3099         return 0;
3100 }
3101
3102 static inline void security_sk_free(struct sock *sk)
3103 {
3104 }
3105
3106 static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
3107 {
3108 }
3109
3110 static inline void security_sk_classify_flow(struct sock *sk, struct flowi *fl)
3111 {
3112 }
3113
3114 static inline void security_req_classify_flow(const struct request_sock *req, struct flowi *fl)
3115 {
3116 }
3117
3118 static inline void security_sock_graft(struct sock* sk, struct socket *parent)
3119 {
3120 }
3121
3122 static inline int security_inet_conn_request(struct sock *sk,
3123                         struct sk_buff *skb, struct request_sock *req)
3124 {
3125         return 0;
3126 }
3127
3128 static inline void security_inet_csk_clone(struct sock *newsk,
3129                         const struct request_sock *req)
3130 {
3131 }
3132
3133 static inline void security_inet_conn_established(struct sock *sk,
3134                         struct sk_buff *skb)
3135 {
3136 }
3137 #endif  /* CONFIG_SECURITY_NETWORK */
3138
3139 #ifdef CONFIG_SECURITY_NETWORK_XFRM
3140 static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx)
3141 {
3142         return security_ops->xfrm_policy_alloc_security(xp, sec_ctx);
3143 }
3144
3145 static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
3146 {
3147         return security_ops->xfrm_policy_clone_security(old, new);
3148 }
3149
3150 static inline void security_xfrm_policy_free(struct xfrm_policy *xp)
3151 {
3152         security_ops->xfrm_policy_free_security(xp);
3153 }
3154
3155 static inline int security_xfrm_policy_delete(struct xfrm_policy *xp)
3156 {
3157         return security_ops->xfrm_policy_delete_security(xp);
3158 }
3159
3160 static inline int security_xfrm_state_alloc(struct xfrm_state *x,
3161                         struct xfrm_user_sec_ctx *sec_ctx)
3162 {
3163         return security_ops->xfrm_state_alloc_security(x, sec_ctx, 0);
3164 }
3165
3166 static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
3167                                 struct xfrm_sec_ctx *polsec, u32 secid)
3168 {
3169         if (!polsec)
3170                 return 0;
3171         /*
3172          * We want the context to be taken from secid which is usually
3173          * from the sock.
3174          */
3175         return security_ops->xfrm_state_alloc_security(x, NULL, secid);
3176 }
3177
3178 static inline int security_xfrm_state_delete(struct xfrm_state *x)
3179 {
3180         return security_ops->xfrm_state_delete_security(x);
3181 }
3182
3183 static inline void security_xfrm_state_free(struct xfrm_state *x)
3184 {
3185         security_ops->xfrm_state_free_security(x);
3186 }
3187
3188 static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir)
3189 {
3190         return security_ops->xfrm_policy_lookup(xp, fl_secid, dir);
3191 }
3192
3193 static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
3194                         struct xfrm_policy *xp, struct flowi *fl)
3195 {
3196         return security_ops->xfrm_state_pol_flow_match(x, xp, fl);
3197 }
3198
3199 static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
3200 {
3201         return security_ops->xfrm_decode_session(skb, secid, 1);
3202 }
3203
3204 static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl)
3205 {
3206         int rc = security_ops->xfrm_decode_session(skb, &fl->secid, 0);
3207
3208         BUG_ON(rc);
3209 }
3210 #else   /* CONFIG_SECURITY_NETWORK_XFRM */
3211 static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx)
3212 {
3213         return 0;
3214 }
3215
3216 static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
3217 {
3218         return 0;
3219 }
3220
3221 static inline void security_xfrm_policy_free(struct xfrm_policy *xp)
3222 {
3223 }
3224
3225 static inline int security_xfrm_policy_delete(struct xfrm_policy *xp)
3226 {
3227         return 0;
3228 }
3229
3230 static inline int security_xfrm_state_alloc(struct xfrm_state *x,
3231                                         struct xfrm_user_sec_ctx *sec_ctx)
3232 {
3233         return 0;
3234 }
3235
3236 static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
3237                                         struct xfrm_sec_ctx *polsec, u32 secid)
3238 {
3239         return 0;
3240 }
3241
3242 static inline void security_xfrm_state_free(struct xfrm_state *x)
3243 {
3244 }
3245
3246 static inline int security_xfrm_state_delete(struct xfrm_state *x)
3247 {
3248         return 0;
3249 }
3250
3251 static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir)
3252 {
3253         return 0;
3254 }
3255
3256 static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
3257                         struct xfrm_policy *xp, struct flowi *fl)
3258 {
3259         return 1;
3260 }
3261
3262 static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
3263 {
3264         return 0;
3265 }
3266
3267 static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl)
3268 {
3269 }
3270
3271 #endif  /* CONFIG_SECURITY_NETWORK_XFRM */
3272
3273 #ifdef CONFIG_KEYS
3274 #ifdef CONFIG_SECURITY
3275 static inline int security_key_alloc(struct key *key,
3276                                      struct task_struct *tsk,
3277                                      unsigned long flags)
3278 {
3279         return security_ops->key_alloc(key, tsk, flags);
3280 }
3281
3282 static inline void security_key_free(struct key *key)
3283 {
3284         security_ops->key_free(key);
3285 }
3286
3287 static inline int security_key_permission(key_ref_t key_ref,
3288                                           struct task_struct *context,
3289                                           key_perm_t perm)
3290 {
3291         return security_ops->key_permission(key_ref, context, perm);
3292 }
3293
3294 #else
3295
3296 static inline int security_key_alloc(struct key *key,
3297                                      struct task_struct *tsk,
3298                                      unsigned long flags)
3299 {
3300         return 0;
3301 }
3302
3303 static inline void security_key_free(struct key *key)
3304 {
3305 }
3306
3307 static inline int security_key_permission(key_ref_t key_ref,
3308                                           struct task_struct *context,
3309                                           key_perm_t perm)
3310 {
3311         return 0;
3312 }
3313
3314 #endif
3315 #endif /* CONFIG_KEYS */
3316
3317 #endif /* ! __LINUX_SECURITY_H */
3318