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