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