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