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