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