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