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