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