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