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