LSM: Add the comment to lsm_hooks.h
[firefly-linux-kernel-4.4.55.git] / include / linux / lsm_hooks.h
1 /*
2  * Linux Security Module interfaces
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  * Copyright (C) 2015 Intel Corporation.
10  * Copyright (C) 2015 Casey Schaufler <casey@schaufler-ca.com>
11  *
12  *      This program is free software; you can redistribute it and/or modify
13  *      it under the terms of the GNU General Public License as published by
14  *      the Free Software Foundation; either version 2 of the License, or
15  *      (at your option) any later version.
16  *
17  *      Due to this file being licensed under the GPL there is controversy over
18  *      whether this permits you to write a module that #includes this file
19  *      without placing your module under the GPL.  Please consult a lawyer for
20  *      advice before doing this.
21  *
22  */
23
24 #ifndef __LINUX_LSM_HOOKS_H
25 #define __LINUX_LSM_HOOKS_H
26
27 #include <linux/security.h>
28
29 /* Maximum number of letters for an LSM name string */
30 #define SECURITY_NAME_MAX       10
31
32 #ifdef CONFIG_SECURITY
33
34 /**
35  * struct security_operations - main security structure
36  *
37  * Security module identifier.
38  *
39  * @name:
40  *      A string that acts as a unique identifier for the LSM with max number
41  *      of characters = SECURITY_NAME_MAX.
42  *
43  * Security hooks for program execution operations.
44  *
45  * @bprm_set_creds:
46  *      Save security information in the bprm->security field, typically based
47  *      on information about the bprm->file, for later use by the apply_creds
48  *      hook.  This hook may also optionally check permissions (e.g. for
49  *      transitions between security domains).
50  *      This hook may be called multiple times during a single execve, e.g. for
51  *      interpreters.  The hook can tell whether it has already been called by
52  *      checking to see if @bprm->security is non-NULL.  If so, then the hook
53  *      may decide either to retain the security information saved earlier or
54  *      to replace it.
55  *      @bprm contains the linux_binprm structure.
56  *      Return 0 if the hook is successful and permission is granted.
57  * @bprm_check_security:
58  *      This hook mediates the point when a search for a binary handler will
59  *      begin.  It allows a check the @bprm->security value which is set in the
60  *      preceding set_creds call.  The primary difference from set_creds is
61  *      that the argv list and envp list are reliably available in @bprm.  This
62  *      hook may be called multiple times during a single execve; and in each
63  *      pass set_creds is called first.
64  *      @bprm contains the linux_binprm structure.
65  *      Return 0 if the hook is successful and permission is granted.
66  * @bprm_committing_creds:
67  *      Prepare to install the new security attributes of a process being
68  *      transformed by an execve operation, based on the old credentials
69  *      pointed to by @current->cred and the information set in @bprm->cred by
70  *      the bprm_set_creds hook.  @bprm points to the linux_binprm structure.
71  *      This hook is a good place to perform state changes on the process such
72  *      as closing open file descriptors to which access will no longer be
73  *      granted when the attributes are changed.  This is called immediately
74  *      before commit_creds().
75  * @bprm_committed_creds:
76  *      Tidy up after the installation of the new security attributes of a
77  *      process being transformed by an execve operation.  The new credentials
78  *      have, by this point, been set to @current->cred.  @bprm points to the
79  *      linux_binprm structure.  This hook is a good place to perform state
80  *      changes on the process such as clearing out non-inheritable signal
81  *      state.  This is called immediately after commit_creds().
82  * @bprm_secureexec:
83  *      Return a boolean value (0 or 1) indicating whether a "secure exec"
84  *      is required.  The flag is passed in the auxiliary table
85  *      on the initial stack to the ELF interpreter to indicate whether libc
86  *      should enable secure mode.
87  *      @bprm contains the linux_binprm structure.
88  *
89  * Security hooks for filesystem operations.
90  *
91  * @sb_alloc_security:
92  *      Allocate and attach a security structure to the sb->s_security field.
93  *      The s_security field is initialized to NULL when the structure is
94  *      allocated.
95  *      @sb contains the super_block structure to be modified.
96  *      Return 0 if operation was successful.
97  * @sb_free_security:
98  *      Deallocate and clear the sb->s_security field.
99  *      @sb contains the super_block structure to be modified.
100  * @sb_statfs:
101  *      Check permission before obtaining filesystem statistics for the @mnt
102  *      mountpoint.
103  *      @dentry is a handle on the superblock for the filesystem.
104  *      Return 0 if permission is granted.
105  * @sb_mount:
106  *      Check permission before an object specified by @dev_name is mounted on
107  *      the mount point named by @nd.  For an ordinary mount, @dev_name
108  *      identifies a device if the file system type requires a device.  For a
109  *      remount (@flags & MS_REMOUNT), @dev_name is irrelevant.  For a
110  *      loopback/bind mount (@flags & MS_BIND), @dev_name identifies the
111  *      pathname of the object being mounted.
112  *      @dev_name contains the name for object being mounted.
113  *      @path contains the path for mount point object.
114  *      @type contains the filesystem type.
115  *      @flags contains the mount flags.
116  *      @data contains the filesystem-specific data.
117  *      Return 0 if permission is granted.
118  * @sb_copy_data:
119  *      Allow mount option data to be copied prior to parsing by the filesystem,
120  *      so that the security module can extract security-specific mount
121  *      options cleanly (a filesystem may modify the data e.g. with strsep()).
122  *      This also allows the original mount data to be stripped of security-
123  *      specific options to avoid having to make filesystems aware of them.
124  *      @type the type of filesystem being mounted.
125  *      @orig the original mount data copied from userspace.
126  *      @copy copied data which will be passed to the security module.
127  *      Returns 0 if the copy was successful.
128  * @sb_remount:
129  *      Extracts security system specific mount options and verifies no changes
130  *      are being made to those options.
131  *      @sb superblock being remounted
132  *      @data contains the filesystem-specific data.
133  *      Return 0 if permission is granted.
134  * @sb_umount:
135  *      Check permission before the @mnt file system is unmounted.
136  *      @mnt contains the mounted file system.
137  *      @flags contains the unmount flags, e.g. MNT_FORCE.
138  *      Return 0 if permission is granted.
139  * @sb_pivotroot:
140  *      Check permission before pivoting the root filesystem.
141  *      @old_path contains the path for the new location of the
142  *      current root (put_old).
143  *      @new_path contains the path for the new root (new_root).
144  *      Return 0 if permission is granted.
145  * @sb_set_mnt_opts:
146  *      Set the security relevant mount options used for a superblock
147  *      @sb the superblock to set security mount options for
148  *      @opts binary data structure containing all lsm mount data
149  * @sb_clone_mnt_opts:
150  *      Copy all security options from a given superblock to another
151  *      @oldsb old superblock which contain information to clone
152  *      @newsb new superblock which needs filled in
153  * @sb_parse_opts_str:
154  *      Parse a string of security data filling in the opts structure
155  *      @options string containing all mount options known by the LSM
156  *      @opts binary data structure usable by the LSM
157  * @dentry_init_security:
158  *      Compute a context for a dentry as the inode is not yet available
159  *      since NFSv4 has no label backed by an EA anyway.
160  *      @dentry dentry to use in calculating the context.
161  *      @mode mode used to determine resource type.
162  *      @name name of the last path component used to create file
163  *      @ctx pointer to place the pointer to the resulting context in.
164  *      @ctxlen point to place the length of the resulting context.
165  *
166  *
167  * Security hooks for inode operations.
168  *
169  * @inode_alloc_security:
170  *      Allocate and attach a security structure to @inode->i_security.  The
171  *      i_security field is initialized to NULL when the inode structure is
172  *      allocated.
173  *      @inode contains the inode structure.
174  *      Return 0 if operation was successful.
175  * @inode_free_security:
176  *      @inode contains the inode structure.
177  *      Deallocate the inode security structure and set @inode->i_security to
178  *      NULL.
179  * @inode_init_security:
180  *      Obtain the security attribute name suffix and value to set on a newly
181  *      created inode and set up the incore security field for the new inode.
182  *      This hook is called by the fs code as part of the inode creation
183  *      transaction and provides for atomic labeling of the inode, unlike
184  *      the post_create/mkdir/... hooks called by the VFS.  The hook function
185  *      is expected to allocate the name and value via kmalloc, with the caller
186  *      being responsible for calling kfree after using them.
187  *      If the security module does not use security attributes or does
188  *      not wish to put a security attribute on this particular inode,
189  *      then it should return -EOPNOTSUPP to skip this processing.
190  *      @inode contains the inode structure of the newly created inode.
191  *      @dir contains the inode structure of the parent directory.
192  *      @qstr contains the last path component of the new object
193  *      @name will be set to the allocated name suffix (e.g. selinux).
194  *      @value will be set to the allocated attribute value.
195  *      @len will be set to the length of the value.
196  *      Returns 0 if @name and @value have been successfully set,
197  *              -EOPNOTSUPP if no security attribute is needed, or
198  *              -ENOMEM on memory allocation failure.
199  * @inode_create:
200  *      Check permission to create a regular file.
201  *      @dir contains inode structure of the parent of the new file.
202  *      @dentry contains the dentry structure for the file to be created.
203  *      @mode contains the file mode of the file to be created.
204  *      Return 0 if permission is granted.
205  * @inode_link:
206  *      Check permission before creating a new hard link to a file.
207  *      @old_dentry contains the dentry structure for an existing
208  *      link to the file.
209  *      @dir contains the inode structure of the parent directory
210  *      of the new link.
211  *      @new_dentry contains the dentry structure for the new link.
212  *      Return 0 if permission is granted.
213  * @path_link:
214  *      Check permission before creating a new hard link to a file.
215  *      @old_dentry contains the dentry structure for an existing link
216  *      to the file.
217  *      @new_dir contains the path structure of the parent directory of
218  *      the new link.
219  *      @new_dentry contains the dentry structure for the new link.
220  *      Return 0 if permission is granted.
221  * @inode_unlink:
222  *      Check the permission to remove a hard link to a file.
223  *      @dir contains the inode structure of parent directory of the file.
224  *      @dentry contains the dentry structure for file to be unlinked.
225  *      Return 0 if permission is granted.
226  * @path_unlink:
227  *      Check the permission to remove a hard link to a file.
228  *      @dir contains the path structure of parent directory of the file.
229  *      @dentry contains the dentry structure for file to be unlinked.
230  *      Return 0 if permission is granted.
231  * @inode_symlink:
232  *      Check the permission to create a symbolic link to a file.
233  *      @dir contains the inode structure of parent directory of
234  *      the symbolic link.
235  *      @dentry contains the dentry structure of the symbolic link.
236  *      @old_name contains the pathname of file.
237  *      Return 0 if permission is granted.
238  * @path_symlink:
239  *      Check the permission to create a symbolic link to a file.
240  *      @dir contains the path structure of parent directory of
241  *      the symbolic link.
242  *      @dentry contains the dentry structure of the symbolic link.
243  *      @old_name contains the pathname of file.
244  *      Return 0 if permission is granted.
245  * @inode_mkdir:
246  *      Check permissions to create a new directory in the existing directory
247  *      associated with inode structure @dir.
248  *      @dir contains the inode structure of parent of the directory
249  *      to be created.
250  *      @dentry contains the dentry structure of new directory.
251  *      @mode contains the mode of new directory.
252  *      Return 0 if permission is granted.
253  * @path_mkdir:
254  *      Check permissions to create a new directory in the existing directory
255  *      associated with path structure @path.
256  *      @dir contains the path structure of parent of the directory
257  *      to be created.
258  *      @dentry contains the dentry structure of new directory.
259  *      @mode contains the mode of new directory.
260  *      Return 0 if permission is granted.
261  * @inode_rmdir:
262  *      Check the permission to remove a directory.
263  *      @dir contains the inode structure of parent of the directory
264  *      to be removed.
265  *      @dentry contains the dentry structure of directory to be removed.
266  *      Return 0 if permission is granted.
267  * @path_rmdir:
268  *      Check the permission to remove a directory.
269  *      @dir contains the path structure of parent of the directory to be
270  *      removed.
271  *      @dentry contains the dentry structure of directory to be removed.
272  *      Return 0 if permission is granted.
273  * @inode_mknod:
274  *      Check permissions when creating a special file (or a socket or a fifo
275  *      file created via the mknod system call).  Note that if mknod operation
276  *      is being done for a regular file, then the create hook will be called
277  *      and not this hook.
278  *      @dir contains the inode structure of parent of the new file.
279  *      @dentry contains the dentry structure of the new file.
280  *      @mode contains the mode of the new file.
281  *      @dev contains the device number.
282  *      Return 0 if permission is granted.
283  * @path_mknod:
284  *      Check permissions when creating a file. Note that this hook is called
285  *      even if mknod operation is being done for a regular file.
286  *      @dir contains the path structure of parent of the new file.
287  *      @dentry contains the dentry structure of the new file.
288  *      @mode contains the mode of the new file.
289  *      @dev contains the undecoded device number. Use new_decode_dev() to get
290  *      the decoded device number.
291  *      Return 0 if permission is granted.
292  * @inode_rename:
293  *      Check for permission to rename a file or directory.
294  *      @old_dir contains the inode structure for parent of the old link.
295  *      @old_dentry contains the dentry structure of the old link.
296  *      @new_dir contains the inode structure for parent of the new link.
297  *      @new_dentry contains the dentry structure of the new link.
298  *      Return 0 if permission is granted.
299  * @path_rename:
300  *      Check for permission to rename a file or directory.
301  *      @old_dir contains the path structure for parent of the old link.
302  *      @old_dentry contains the dentry structure of the old link.
303  *      @new_dir contains the path structure for parent of the new link.
304  *      @new_dentry contains the dentry structure of the new link.
305  *      Return 0 if permission is granted.
306  * @path_chmod:
307  *      Check for permission to change DAC's permission of a file or directory.
308  *      @dentry contains the dentry structure.
309  *      @mnt contains the vfsmnt structure.
310  *      @mode contains DAC's mode.
311  *      Return 0 if permission is granted.
312  * @path_chown:
313  *      Check for permission to change owner/group of a file or directory.
314  *      @path contains the path structure.
315  *      @uid contains new owner's ID.
316  *      @gid contains new group's ID.
317  *      Return 0 if permission is granted.
318  * @path_chroot:
319  *      Check for permission to change root directory.
320  *      @path contains the path structure.
321  *      Return 0 if permission is granted.
322  * @inode_readlink:
323  *      Check the permission to read the symbolic link.
324  *      @dentry contains the dentry structure for the file link.
325  *      Return 0 if permission is granted.
326  * @inode_follow_link:
327  *      Check permission to follow a symbolic link when looking up a pathname.
328  *      @dentry contains the dentry structure for the link.
329  *      @nd contains the nameidata structure for the parent directory.
330  *      Return 0 if permission is granted.
331  * @inode_permission:
332  *      Check permission before accessing an inode.  This hook is called by the
333  *      existing Linux permission function, so a security module can use it to
334  *      provide additional checking for existing Linux permission checks.
335  *      Notice that this hook is called when a file is opened (as well as many
336  *      other operations), whereas the file_security_ops permission hook is
337  *      called when the actual read/write operations are performed.
338  *      @inode contains the inode structure to check.
339  *      @mask contains the permission mask.
340  *      Return 0 if permission is granted.
341  * @inode_setattr:
342  *      Check permission before setting file attributes.  Note that the kernel
343  *      call to notify_change is performed from several locations, whenever
344  *      file attributes change (such as when a file is truncated, chown/chmod
345  *      operations, transferring disk quotas, etc).
346  *      @dentry contains the dentry structure for the file.
347  *      @attr is the iattr structure containing the new file attributes.
348  *      Return 0 if permission is granted.
349  * @path_truncate:
350  *      Check permission before truncating a file.
351  *      @path contains the path structure for the file.
352  *      Return 0 if permission is granted.
353  * @inode_getattr:
354  *      Check permission before obtaining file attributes.
355  *      @mnt is the vfsmount where the dentry was looked up
356  *      @dentry contains the dentry structure for the file.
357  *      Return 0 if permission is granted.
358  * @inode_setxattr:
359  *      Check permission before setting the extended attributes
360  *      @value identified by @name for @dentry.
361  *      Return 0 if permission is granted.
362  * @inode_post_setxattr:
363  *      Update inode security field after successful setxattr operation.
364  *      @value identified by @name for @dentry.
365  * @inode_getxattr:
366  *      Check permission before obtaining the extended attributes
367  *      identified by @name for @dentry.
368  *      Return 0 if permission is granted.
369  * @inode_listxattr:
370  *      Check permission before obtaining the list of extended attribute
371  *      names for @dentry.
372  *      Return 0 if permission is granted.
373  * @inode_removexattr:
374  *      Check permission before removing the extended attribute
375  *      identified by @name for @dentry.
376  *      Return 0 if permission is granted.
377  * @inode_getsecurity:
378  *      Retrieve a copy of the extended attribute representation of the
379  *      security label associated with @name for @inode via @buffer.  Note that
380  *      @name is the remainder of the attribute name after the security prefix
381  *      has been removed. @alloc is used to specify of the call should return a
382  *      value via the buffer or just the value length Return size of buffer on
383  *      success.
384  * @inode_setsecurity:
385  *      Set the security label associated with @name for @inode from the
386  *      extended attribute value @value.  @size indicates the size of the
387  *      @value in bytes.  @flags may be XATTR_CREATE, XATTR_REPLACE, or 0.
388  *      Note that @name is the remainder of the attribute name after the
389  *      security. prefix has been removed.
390  *      Return 0 on success.
391  * @inode_listsecurity:
392  *      Copy the extended attribute names for the security labels
393  *      associated with @inode into @buffer.  The maximum size of @buffer
394  *      is specified by @buffer_size.  @buffer may be NULL to request
395  *      the size of the buffer required.
396  *      Returns number of bytes used/required on success.
397  * @inode_need_killpriv:
398  *      Called when an inode has been changed.
399  *      @dentry is the dentry being changed.
400  *      Return <0 on error to abort the inode change operation.
401  *      Return 0 if inode_killpriv does not need to be called.
402  *      Return >0 if inode_killpriv does need to be called.
403  * @inode_killpriv:
404  *      The setuid bit is being removed.  Remove similar security labels.
405  *      Called with the dentry->d_inode->i_mutex held.
406  *      @dentry is the dentry being changed.
407  *      Return 0 on success.  If error is returned, then the operation
408  *      causing setuid bit removal is failed.
409  * @inode_getsecid:
410  *      Get the secid associated with the node.
411  *      @inode contains a pointer to the inode.
412  *      @secid contains a pointer to the location where result will be saved.
413  *      In case of failure, @secid will be set to zero.
414  *
415  * Security hooks for file operations
416  *
417  * @file_permission:
418  *      Check file permissions before accessing an open file.  This hook is
419  *      called by various operations that read or write files.  A security
420  *      module can use this hook to perform additional checking on these
421  *      operations, e.g.  to revalidate permissions on use to support privilege
422  *      bracketing or policy changes.  Notice that this hook is used when the
423  *      actual read/write operations are performed, whereas the
424  *      inode_security_ops hook is called when a file is opened (as well as
425  *      many other operations).
426  *      Caveat:  Although this hook can be used to revalidate permissions for
427  *      various system call operations that read or write files, it does not
428  *      address the revalidation of permissions for memory-mapped files.
429  *      Security modules must handle this separately if they need such
430  *      revalidation.
431  *      @file contains the file structure being accessed.
432  *      @mask contains the requested permissions.
433  *      Return 0 if permission is granted.
434  * @file_alloc_security:
435  *      Allocate and attach a security structure to the file->f_security field.
436  *      The security field is initialized to NULL when the structure is first
437  *      created.
438  *      @file contains the file structure to secure.
439  *      Return 0 if the hook is successful and permission is granted.
440  * @file_free_security:
441  *      Deallocate and free any security structures stored in file->f_security.
442  *      @file contains the file structure being modified.
443  * @file_ioctl:
444  *      @file contains the file structure.
445  *      @cmd contains the operation to perform.
446  *      @arg contains the operational arguments.
447  *      Check permission for an ioctl operation on @file.  Note that @arg
448  *      sometimes represents a user space pointer; in other cases, it may be a
449  *      simple integer value.  When @arg represents a user space pointer, it
450  *      should never be used by the security module.
451  *      Return 0 if permission is granted.
452  * @mmap_addr :
453  *      Check permissions for a mmap operation at @addr.
454  *      @addr contains virtual address that will be used for the operation.
455  *      Return 0 if permission is granted.
456  * @mmap_file :
457  *      Check permissions for a mmap operation.  The @file may be NULL, e.g.
458  *      if mapping anonymous memory.
459  *      @file contains the file structure for file to map (may be NULL).
460  *      @reqprot contains the protection requested by the application.
461  *      @prot contains the protection that will be applied by the kernel.
462  *      @flags contains the operational flags.
463  *      Return 0 if permission is granted.
464  * @file_mprotect:
465  *      Check permissions before changing memory access permissions.
466  *      @vma contains the memory region to modify.
467  *      @reqprot contains the protection requested by the application.
468  *      @prot contains the protection that will be applied by the kernel.
469  *      Return 0 if permission is granted.
470  * @file_lock:
471  *      Check permission before performing file locking operations.
472  *      Note: this hook mediates both flock and fcntl style locks.
473  *      @file contains the file structure.
474  *      @cmd contains the posix-translated lock operation to perform
475  *      (e.g. F_RDLCK, F_WRLCK).
476  *      Return 0 if permission is granted.
477  * @file_fcntl:
478  *      Check permission before allowing the file operation specified by @cmd
479  *      from being performed on the file @file.  Note that @arg sometimes
480  *      represents a user space pointer; in other cases, it may be a simple
481  *      integer value.  When @arg represents a user space pointer, it should
482  *      never be used by the security module.
483  *      @file contains the file structure.
484  *      @cmd contains the operation to be performed.
485  *      @arg contains the operational arguments.
486  *      Return 0 if permission is granted.
487  * @file_set_fowner:
488  *      Save owner security information (typically from current->security) in
489  *      file->f_security for later use by the send_sigiotask hook.
490  *      @file contains the file structure to update.
491  *      Return 0 on success.
492  * @file_send_sigiotask:
493  *      Check permission for the file owner @fown to send SIGIO or SIGURG to the
494  *      process @tsk.  Note that this hook is sometimes called from interrupt.
495  *      Note that the fown_struct, @fown, is never outside the context of a
496  *      struct file, so the file structure (and associated security information)
497  *      can always be obtained:
498  *              container_of(fown, struct file, f_owner)
499  *      @tsk contains the structure of task receiving signal.
500  *      @fown contains the file owner information.
501  *      @sig is the signal that will be sent.  When 0, kernel sends SIGIO.
502  *      Return 0 if permission is granted.
503  * @file_receive:
504  *      This hook allows security modules to control the ability of a process
505  *      to receive an open file descriptor via socket IPC.
506  *      @file contains the file structure being received.
507  *      Return 0 if permission is granted.
508  * @file_open
509  *      Save open-time permission checking state for later use upon
510  *      file_permission, and recheck access if anything has changed
511  *      since inode_permission.
512  *
513  * Security hooks for task operations.
514  *
515  * @task_create:
516  *      Check permission before creating a child process.  See the clone(2)
517  *      manual page for definitions of the @clone_flags.
518  *      @clone_flags contains the flags indicating what should be shared.
519  *      Return 0 if permission is granted.
520  * @task_free:
521  *      @task task being freed
522  *      Handle release of task-related resources. (Note that this can be called
523  *      from interrupt context.)
524  * @cred_alloc_blank:
525  *      @cred points to the credentials.
526  *      @gfp indicates the atomicity of any memory allocations.
527  *      Only allocate sufficient memory and attach to @cred such that
528  *      cred_transfer() will not get ENOMEM.
529  * @cred_free:
530  *      @cred points to the credentials.
531  *      Deallocate and clear the cred->security field in a set of credentials.
532  * @cred_prepare:
533  *      @new points to the new credentials.
534  *      @old points to the original credentials.
535  *      @gfp indicates the atomicity of any memory allocations.
536  *      Prepare a new set of credentials by copying the data from the old set.
537  * @cred_transfer:
538  *      @new points to the new credentials.
539  *      @old points to the original credentials.
540  *      Transfer data from original creds to new creds
541  * @kernel_act_as:
542  *      Set the credentials for a kernel service to act as (subjective context).
543  *      @new points to the credentials to be modified.
544  *      @secid specifies the security ID to be set
545  *      The current task must be the one that nominated @secid.
546  *      Return 0 if successful.
547  * @kernel_create_files_as:
548  *      Set the file creation context in a set of credentials to be the same as
549  *      the objective context of the specified inode.
550  *      @new points to the credentials to be modified.
551  *      @inode points to the inode to use as a reference.
552  *      The current task must be the one that nominated @inode.
553  *      Return 0 if successful.
554  * @kernel_fw_from_file:
555  *      Load firmware from userspace (not called for built-in firmware).
556  *      @file contains the file structure pointing to the file containing
557  *      the firmware to load. This argument will be NULL if the firmware
558  *      was loaded via the uevent-triggered blob-based interface exposed
559  *      by CONFIG_FW_LOADER_USER_HELPER.
560  *      @buf pointer to buffer containing firmware contents.
561  *      @size length of the firmware contents.
562  *      Return 0 if permission is granted.
563  * @kernel_module_request:
564  *      Ability to trigger the kernel to automatically upcall to userspace for
565  *      userspace to load a kernel module with the given name.
566  *      @kmod_name name of the module requested by the kernel
567  *      Return 0 if successful.
568  * @kernel_module_from_file:
569  *      Load a kernel module from userspace.
570  *      @file contains the file structure pointing to the file containing
571  *      the kernel module to load. If the module is being loaded from a blob,
572  *      this argument will be NULL.
573  *      Return 0 if permission is granted.
574  * @task_fix_setuid:
575  *      Update the module's state after setting one or more of the user
576  *      identity attributes of the current process.  The @flags parameter
577  *      indicates which of the set*uid system calls invoked this hook.  If
578  *      @new is the set of credentials that will be installed.  Modifications
579  *      should be made to this rather than to @current->cred.
580  *      @old is the set of credentials that are being replaces
581  *      @flags contains one of the LSM_SETID_* values.
582  *      Return 0 on success.
583  * @task_setpgid:
584  *      Check permission before setting the process group identifier of the
585  *      process @p to @pgid.
586  *      @p contains the task_struct for process being modified.
587  *      @pgid contains the new pgid.
588  *      Return 0 if permission is granted.
589  * @task_getpgid:
590  *      Check permission before getting the process group identifier of the
591  *      process @p.
592  *      @p contains the task_struct for the process.
593  *      Return 0 if permission is granted.
594  * @task_getsid:
595  *      Check permission before getting the session identifier of the process
596  *      @p.
597  *      @p contains the task_struct for the process.
598  *      Return 0 if permission is granted.
599  * @task_getsecid:
600  *      Retrieve the security identifier of the process @p.
601  *      @p contains the task_struct for the process and place is into @secid.
602  *      In case of failure, @secid will be set to zero.
603  *
604  * @task_setnice:
605  *      Check permission before setting the nice value of @p to @nice.
606  *      @p contains the task_struct of process.
607  *      @nice contains the new nice value.
608  *      Return 0 if permission is granted.
609  * @task_setioprio
610  *      Check permission before setting the ioprio value of @p to @ioprio.
611  *      @p contains the task_struct of process.
612  *      @ioprio contains the new ioprio value
613  *      Return 0 if permission is granted.
614  * @task_getioprio
615  *      Check permission before getting the ioprio value of @p.
616  *      @p contains the task_struct of process.
617  *      Return 0 if permission is granted.
618  * @task_setrlimit:
619  *      Check permission before setting the resource limits of the current
620  *      process for @resource to @new_rlim.  The old resource limit values can
621  *      be examined by dereferencing (current->signal->rlim + resource).
622  *      @resource contains the resource whose limit is being set.
623  *      @new_rlim contains the new limits for @resource.
624  *      Return 0 if permission is granted.
625  * @task_setscheduler:
626  *      Check permission before setting scheduling policy and/or parameters of
627  *      process @p based on @policy and @lp.
628  *      @p contains the task_struct for process.
629  *      @policy contains the scheduling policy.
630  *      @lp contains the scheduling parameters.
631  *      Return 0 if permission is granted.
632  * @task_getscheduler:
633  *      Check permission before obtaining scheduling information for process
634  *      @p.
635  *      @p contains the task_struct for process.
636  *      Return 0 if permission is granted.
637  * @task_movememory
638  *      Check permission before moving memory owned by process @p.
639  *      @p contains the task_struct for process.
640  *      Return 0 if permission is granted.
641  * @task_kill:
642  *      Check permission before sending signal @sig to @p.  @info can be NULL,
643  *      the constant 1, or a pointer to a siginfo structure.  If @info is 1 or
644  *      SI_FROMKERNEL(info) is true, then the signal should be viewed as coming
645  *      from the kernel and should typically be permitted.
646  *      SIGIO signals are handled separately by the send_sigiotask hook in
647  *      file_security_ops.
648  *      @p contains the task_struct for process.
649  *      @info contains the signal information.
650  *      @sig contains the signal value.
651  *      @secid contains the sid of the process where the signal originated
652  *      Return 0 if permission is granted.
653  * @task_wait:
654  *      Check permission before allowing a process to reap a child process @p
655  *      and collect its status information.
656  *      @p contains the task_struct for process.
657  *      Return 0 if permission is granted.
658  * @task_prctl:
659  *      Check permission before performing a process control operation on the
660  *      current process.
661  *      @option contains the operation.
662  *      @arg2 contains a argument.
663  *      @arg3 contains a argument.
664  *      @arg4 contains a argument.
665  *      @arg5 contains a argument.
666  *      Return -ENOSYS if no-one wanted to handle this op, any other value to
667  *      cause prctl() to return immediately with that value.
668  * @task_to_inode:
669  *      Set the security attributes for an inode based on an associated task's
670  *      security attributes, e.g. for /proc/pid inodes.
671  *      @p contains the task_struct for the task.
672  *      @inode contains the inode structure for the inode.
673  *
674  * Security hooks for Netlink messaging.
675  *
676  * @netlink_send:
677  *      Save security information for a netlink message so that permission
678  *      checking can be performed when the message is processed.  The security
679  *      information can be saved using the eff_cap field of the
680  *      netlink_skb_parms structure.  Also may be used to provide fine
681  *      grained control over message transmission.
682  *      @sk associated sock of task sending the message.
683  *      @skb contains the sk_buff structure for the netlink message.
684  *      Return 0 if the information was successfully saved and message
685  *      is allowed to be transmitted.
686  *
687  * Security hooks for Unix domain networking.
688  *
689  * @unix_stream_connect:
690  *      Check permissions before establishing a Unix domain stream connection
691  *      between @sock and @other.
692  *      @sock contains the sock structure.
693  *      @other contains the peer sock structure.
694  *      @newsk contains the new sock structure.
695  *      Return 0 if permission is granted.
696  * @unix_may_send:
697  *      Check permissions before connecting or sending datagrams from @sock to
698  *      @other.
699  *      @sock contains the socket structure.
700  *      @other contains the peer socket structure.
701  *      Return 0 if permission is granted.
702  *
703  * The @unix_stream_connect and @unix_may_send hooks were necessary because
704  * Linux provides an alternative to the conventional file name space for Unix
705  * domain sockets.  Whereas binding and connecting to sockets in the file name
706  * space is mediated by the typical file permissions (and caught by the mknod
707  * and permission hooks in inode_security_ops), binding and connecting to
708  * sockets in the abstract name space is completely unmediated.  Sufficient
709  * control of Unix domain sockets in the abstract name space isn't possible
710  * using only the socket layer hooks, since we need to know the actual target
711  * socket, which is not looked up until we are inside the af_unix code.
712  *
713  * Security hooks for socket operations.
714  *
715  * @socket_create:
716  *      Check permissions prior to creating a new socket.
717  *      @family contains the requested protocol family.
718  *      @type contains the requested communications type.
719  *      @protocol contains the requested protocol.
720  *      @kern set to 1 if a kernel socket.
721  *      Return 0 if permission is granted.
722  * @socket_post_create:
723  *      This hook allows a module to update or allocate a per-socket security
724  *      structure. Note that the security field was not added directly to the
725  *      socket structure, but rather, the socket security information is stored
726  *      in the associated inode.  Typically, the inode alloc_security hook will
727  *      allocate and and attach security information to
728  *      sock->inode->i_security.  This hook may be used to update the
729  *      sock->inode->i_security field with additional information that wasn't
730  *      available when the inode was allocated.
731  *      @sock contains the newly created socket structure.
732  *      @family contains the requested protocol family.
733  *      @type contains the requested communications type.
734  *      @protocol contains the requested protocol.
735  *      @kern set to 1 if a kernel socket.
736  * @socket_bind:
737  *      Check permission before socket protocol layer bind operation is
738  *      performed and the socket @sock is bound to the address specified in the
739  *      @address parameter.
740  *      @sock contains the socket structure.
741  *      @address contains the address to bind to.
742  *      @addrlen contains the length of address.
743  *      Return 0 if permission is granted.
744  * @socket_connect:
745  *      Check permission before socket protocol layer connect operation
746  *      attempts to connect socket @sock to a remote address, @address.
747  *      @sock contains the socket structure.
748  *      @address contains the address of remote endpoint.
749  *      @addrlen contains the length of address.
750  *      Return 0 if permission is granted.
751  * @socket_listen:
752  *      Check permission before socket protocol layer listen operation.
753  *      @sock contains the socket structure.
754  *      @backlog contains the maximum length for the pending connection queue.
755  *      Return 0 if permission is granted.
756  * @socket_accept:
757  *      Check permission before accepting a new connection.  Note that the new
758  *      socket, @newsock, has been created and some information copied to it,
759  *      but the accept operation has not actually been performed.
760  *      @sock contains the listening socket structure.
761  *      @newsock contains the newly created server socket for connection.
762  *      Return 0 if permission is granted.
763  * @socket_sendmsg:
764  *      Check permission before transmitting a message to another socket.
765  *      @sock contains the socket structure.
766  *      @msg contains the message to be transmitted.
767  *      @size contains the size of message.
768  *      Return 0 if permission is granted.
769  * @socket_recvmsg:
770  *      Check permission before receiving a message from a socket.
771  *      @sock contains the socket structure.
772  *      @msg contains the message structure.
773  *      @size contains the size of message structure.
774  *      @flags contains the operational flags.
775  *      Return 0 if permission is granted.
776  * @socket_getsockname:
777  *      Check permission before the local address (name) of the socket object
778  *      @sock is retrieved.
779  *      @sock contains the socket structure.
780  *      Return 0 if permission is granted.
781  * @socket_getpeername:
782  *      Check permission before the remote address (name) of a socket object
783  *      @sock is retrieved.
784  *      @sock contains the socket structure.
785  *      Return 0 if permission is granted.
786  * @socket_getsockopt:
787  *      Check permissions before retrieving the options associated with socket
788  *      @sock.
789  *      @sock contains the socket structure.
790  *      @level contains the protocol level to retrieve option from.
791  *      @optname contains the name of option to retrieve.
792  *      Return 0 if permission is granted.
793  * @socket_setsockopt:
794  *      Check permissions before setting the options associated with socket
795  *      @sock.
796  *      @sock contains the socket structure.
797  *      @level contains the protocol level to set options for.
798  *      @optname contains the name of the option to set.
799  *      Return 0 if permission is granted.
800  * @socket_shutdown:
801  *      Checks permission before all or part of a connection on the socket
802  *      @sock is shut down.
803  *      @sock contains the socket structure.
804  *      @how contains the flag indicating how future sends and receives
805  *      are handled.
806  *      Return 0 if permission is granted.
807  * @socket_sock_rcv_skb:
808  *      Check permissions on incoming network packets.  This hook is distinct
809  *      from Netfilter's IP input hooks since it is the first time that the
810  *      incoming sk_buff @skb has been associated with a particular socket, @sk.
811  *      Must not sleep inside this hook because some callers hold spinlocks.
812  *      @sk contains the sock (not socket) associated with the incoming sk_buff.
813  *      @skb contains the incoming network data.
814  * @socket_getpeersec_stream:
815  *      This hook allows the security module to provide peer socket security
816  *      state for unix or connected tcp sockets to userspace via getsockopt
817  *      SO_GETPEERSEC.  For tcp sockets this can be meaningful if the
818  *      socket is associated with an ipsec SA.
819  *      @sock is the local socket.
820  *      @optval userspace memory where the security state is to be copied.
821  *      @optlen userspace int where the module should copy the actual length
822  *      of the security state.
823  *      @len as input is the maximum length to copy to userspace provided
824  *      by the caller.
825  *      Return 0 if all is well, otherwise, typical getsockopt return
826  *      values.
827  * @socket_getpeersec_dgram:
828  *      This hook allows the security module to provide peer socket security
829  *      state for udp sockets on a per-packet basis to userspace via
830  *      getsockopt SO_GETPEERSEC.  The application must first have indicated
831  *      the IP_PASSSEC option via getsockopt.  It can then retrieve the
832  *      security state returned by this hook for a packet via the SCM_SECURITY
833  *      ancillary message type.
834  *      @skb is the skbuff for the packet being queried
835  *      @secdata is a pointer to a buffer in which to copy the security data
836  *      @seclen is the maximum length for @secdata
837  *      Return 0 on success, error on failure.
838  * @sk_alloc_security:
839  *      Allocate and attach a security structure to the sk->sk_security field,
840  *      which is used to copy security attributes between local stream sockets.
841  * @sk_free_security:
842  *      Deallocate security structure.
843  * @sk_clone_security:
844  *      Clone/copy security structure.
845  * @sk_getsecid:
846  *      Retrieve the LSM-specific secid for the sock to enable caching
847  *      of network authorizations.
848  * @sock_graft:
849  *      Sets the socket's isec sid to the sock's sid.
850  * @inet_conn_request:
851  *      Sets the openreq's sid to socket's sid with MLS portion taken
852  *      from peer sid.
853  * @inet_csk_clone:
854  *      Sets the new child socket's sid to the openreq sid.
855  * @inet_conn_established:
856  *      Sets the connection's peersid to the secmark on skb.
857  * @secmark_relabel_packet:
858  *      check if the process should be allowed to relabel packets to
859  *      the given secid
860  * @security_secmark_refcount_inc
861  *      tells the LSM to increment the number of secmark labeling rules loaded
862  * @security_secmark_refcount_dec
863  *      tells the LSM to decrement the number of secmark labeling rules loaded
864  * @req_classify_flow:
865  *      Sets the flow's sid to the openreq sid.
866  * @tun_dev_alloc_security:
867  *      This hook allows a module to allocate a security structure for a TUN
868  *      device.
869  *      @security pointer to a security structure pointer.
870  *      Returns a zero on success, negative values on failure.
871  * @tun_dev_free_security:
872  *      This hook allows a module to free the security structure for a TUN
873  *      device.
874  *      @security pointer to the TUN device's security structure
875  * @tun_dev_create:
876  *      Check permissions prior to creating a new TUN device.
877  * @tun_dev_attach_queue:
878  *      Check permissions prior to attaching to a TUN device queue.
879  *      @security pointer to the TUN device's security structure.
880  * @tun_dev_attach:
881  *      This hook can be used by the module to update any security state
882  *      associated with the TUN device's sock structure.
883  *      @sk contains the existing sock structure.
884  *      @security pointer to the TUN device's security structure.
885  * @tun_dev_open:
886  *      This hook can be used by the module to update any security state
887  *      associated with the TUN device's security structure.
888  *      @security pointer to the TUN devices's security structure.
889  *
890  * Security hooks for XFRM operations.
891  *
892  * @xfrm_policy_alloc_security:
893  *      @ctxp is a pointer to the xfrm_sec_ctx being added to Security Policy
894  *      Database used by the XFRM system.
895  *      @sec_ctx contains the security context information being provided by
896  *      the user-level policy update program (e.g., setkey).
897  *      Allocate a security structure to the xp->security field; the security
898  *      field is initialized to NULL when the xfrm_policy is allocated.
899  *      Return 0 if operation was successful (memory to allocate, legal context)
900  *      @gfp is to specify the context for the allocation
901  * @xfrm_policy_clone_security:
902  *      @old_ctx contains an existing xfrm_sec_ctx.
903  *      @new_ctxp contains a new xfrm_sec_ctx being cloned from old.
904  *      Allocate a security structure in new_ctxp that contains the
905  *      information from the old_ctx structure.
906  *      Return 0 if operation was successful (memory to allocate).
907  * @xfrm_policy_free_security:
908  *      @ctx contains the xfrm_sec_ctx
909  *      Deallocate xp->security.
910  * @xfrm_policy_delete_security:
911  *      @ctx contains the xfrm_sec_ctx.
912  *      Authorize deletion of xp->security.
913  * @xfrm_state_alloc:
914  *      @x contains the xfrm_state being added to the Security Association
915  *      Database by the XFRM system.
916  *      @sec_ctx contains the security context information being provided by
917  *      the user-level SA generation program (e.g., setkey or racoon).
918  *      Allocate a security structure to the x->security field; the security
919  *      field is initialized to NULL when the xfrm_state is allocated. Set the
920  *      context to correspond to sec_ctx. Return 0 if operation was successful
921  *      (memory to allocate, legal context).
922  * @xfrm_state_alloc_acquire:
923  *      @x contains the xfrm_state being added to the Security Association
924  *      Database by the XFRM system.
925  *      @polsec contains the policy's security context.
926  *      @secid contains the secid from which to take the mls portion of the
927  *      context.
928  *      Allocate a security structure to the x->security field; the security
929  *      field is initialized to NULL when the xfrm_state is allocated. Set the
930  *      context to correspond to secid. Return 0 if operation was successful
931  *      (memory to allocate, legal context).
932  * @xfrm_state_free_security:
933  *      @x contains the xfrm_state.
934  *      Deallocate x->security.
935  * @xfrm_state_delete_security:
936  *      @x contains the xfrm_state.
937  *      Authorize deletion of x->security.
938  * @xfrm_policy_lookup:
939  *      @ctx contains the xfrm_sec_ctx for which the access control is being
940  *      checked.
941  *      @fl_secid contains the flow security label that is used to authorize
942  *      access to the policy xp.
943  *      @dir contains the direction of the flow (input or output).
944  *      Check permission when a flow selects a xfrm_policy for processing
945  *      XFRMs on a packet.  The hook is called when selecting either a
946  *      per-socket policy or a generic xfrm policy.
947  *      Return 0 if permission is granted, -ESRCH otherwise, or -errno
948  *      on other errors.
949  * @xfrm_state_pol_flow_match:
950  *      @x contains the state to match.
951  *      @xp contains the policy to check for a match.
952  *      @fl contains the flow to check for a match.
953  *      Return 1 if there is a match.
954  * @xfrm_decode_session:
955  *      @skb points to skb to decode.
956  *      @secid points to the flow key secid to set.
957  *      @ckall says if all xfrms used should be checked for same secid.
958  *      Return 0 if ckall is zero or all xfrms used have the same secid.
959  *
960  * Security hooks affecting all Key Management operations
961  *
962  * @key_alloc:
963  *      Permit allocation of a key and assign security data. Note that key does
964  *      not have a serial number assigned at this point.
965  *      @key points to the key.
966  *      @flags is the allocation flags
967  *      Return 0 if permission is granted, -ve error otherwise.
968  * @key_free:
969  *      Notification of destruction; free security data.
970  *      @key points to the key.
971  *      No return value.
972  * @key_permission:
973  *      See whether a specific operational right is granted to a process on a
974  *      key.
975  *      @key_ref refers to the key (key pointer + possession attribute bit).
976  *      @cred points to the credentials to provide the context against which to
977  *      evaluate the security data on the key.
978  *      @perm describes the combination of permissions required of this key.
979  *      Return 0 if permission is granted, -ve error otherwise.
980  * @key_getsecurity:
981  *      Get a textual representation of the security context attached to a key
982  *      for the purposes of honouring KEYCTL_GETSECURITY.  This function
983  *      allocates the storage for the NUL-terminated string and the caller
984  *      should free it.
985  *      @key points to the key to be queried.
986  *      @_buffer points to a pointer that should be set to point to the
987  *      resulting string (if no label or an error occurs).
988  *      Return the length of the string (including terminating NUL) or -ve if
989  *      an error.
990  *      May also return 0 (and a NULL buffer pointer) if there is no label.
991  *
992  * Security hooks affecting all System V IPC operations.
993  *
994  * @ipc_permission:
995  *      Check permissions for access to IPC
996  *      @ipcp contains the kernel IPC permission structure
997  *      @flag contains the desired (requested) permission set
998  *      Return 0 if permission is granted.
999  * @ipc_getsecid:
1000  *      Get the secid associated with the ipc object.
1001  *      @ipcp contains the kernel IPC permission structure.
1002  *      @secid contains a pointer to the location where result will be saved.
1003  *      In case of failure, @secid will be set to zero.
1004  *
1005  * Security hooks for individual messages held in System V IPC message queues
1006  * @msg_msg_alloc_security:
1007  *      Allocate and attach a security structure to the msg->security field.
1008  *      The security field is initialized to NULL when the structure is first
1009  *      created.
1010  *      @msg contains the message structure to be modified.
1011  *      Return 0 if operation was successful and permission is granted.
1012  * @msg_msg_free_security:
1013  *      Deallocate the security structure for this message.
1014  *      @msg contains the message structure to be modified.
1015  *
1016  * Security hooks for System V IPC Message Queues
1017  *
1018  * @msg_queue_alloc_security:
1019  *      Allocate and attach a security structure to the
1020  *      msq->q_perm.security field. The security field is initialized to
1021  *      NULL when the structure is first created.
1022  *      @msq contains the message queue structure to be modified.
1023  *      Return 0 if operation was successful and permission is granted.
1024  * @msg_queue_free_security:
1025  *      Deallocate security structure for this message queue.
1026  *      @msq contains the message queue structure to be modified.
1027  * @msg_queue_associate:
1028  *      Check permission when a message queue is requested through the
1029  *      msgget system call.  This hook is only called when returning the
1030  *      message queue identifier for an existing message queue, not when a
1031  *      new message queue is created.
1032  *      @msq contains the message queue to act upon.
1033  *      @msqflg contains the operation control flags.
1034  *      Return 0 if permission is granted.
1035  * @msg_queue_msgctl:
1036  *      Check permission when a message control operation specified by @cmd
1037  *      is to be performed on the message queue @msq.
1038  *      The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO.
1039  *      @msq contains the message queue to act upon.  May be NULL.
1040  *      @cmd contains the operation to be performed.
1041  *      Return 0 if permission is granted.
1042  * @msg_queue_msgsnd:
1043  *      Check permission before a message, @msg, is enqueued on the message
1044  *      queue, @msq.
1045  *      @msq contains the message queue to send message to.
1046  *      @msg contains the message to be enqueued.
1047  *      @msqflg contains operational flags.
1048  *      Return 0 if permission is granted.
1049  * @msg_queue_msgrcv:
1050  *      Check permission before a message, @msg, is removed from the message
1051  *      queue, @msq.  The @target task structure contains a pointer to the
1052  *      process that will be receiving the message (not equal to the current
1053  *      process when inline receives are being performed).
1054  *      @msq contains the message queue to retrieve message from.
1055  *      @msg contains the message destination.
1056  *      @target contains the task structure for recipient process.
1057  *      @type contains the type of message requested.
1058  *      @mode contains the operational flags.
1059  *      Return 0 if permission is granted.
1060  *
1061  * Security hooks for System V Shared Memory Segments
1062  *
1063  * @shm_alloc_security:
1064  *      Allocate and attach a security structure to the shp->shm_perm.security
1065  *      field.  The security field is initialized to NULL when the structure is
1066  *      first created.
1067  *      @shp contains the shared memory structure to be modified.
1068  *      Return 0 if operation was successful and permission is granted.
1069  * @shm_free_security:
1070  *      Deallocate the security struct for this memory segment.
1071  *      @shp contains the shared memory structure to be modified.
1072  * @shm_associate:
1073  *      Check permission when a shared memory region is requested through the
1074  *      shmget system call.  This hook is only called when returning the shared
1075  *      memory region identifier for an existing region, not when a new shared
1076  *      memory region is created.
1077  *      @shp contains the shared memory structure to be modified.
1078  *      @shmflg contains the operation control flags.
1079  *      Return 0 if permission is granted.
1080  * @shm_shmctl:
1081  *      Check permission when a shared memory control operation specified by
1082  *      @cmd is to be performed on the shared memory region @shp.
1083  *      The @shp may be NULL, e.g. for IPC_INFO or SHM_INFO.
1084  *      @shp contains shared memory structure to be modified.
1085  *      @cmd contains the operation to be performed.
1086  *      Return 0 if permission is granted.
1087  * @shm_shmat:
1088  *      Check permissions prior to allowing the shmat system call to attach the
1089  *      shared memory segment @shp to the data segment of the calling process.
1090  *      The attaching address is specified by @shmaddr.
1091  *      @shp contains the shared memory structure to be modified.
1092  *      @shmaddr contains the address to attach memory region to.
1093  *      @shmflg contains the operational flags.
1094  *      Return 0 if permission is granted.
1095  *
1096  * Security hooks for System V Semaphores
1097  *
1098  * @sem_alloc_security:
1099  *      Allocate and attach a security structure to the sma->sem_perm.security
1100  *      field.  The security field is initialized to NULL when the structure is
1101  *      first created.
1102  *      @sma contains the semaphore structure
1103  *      Return 0 if operation was successful and permission is granted.
1104  * @sem_free_security:
1105  *      deallocate security struct for this semaphore
1106  *      @sma contains the semaphore structure.
1107  * @sem_associate:
1108  *      Check permission when a semaphore is requested through the semget
1109  *      system call.  This hook is only called when returning the semaphore
1110  *      identifier for an existing semaphore, not when a new one must be
1111  *      created.
1112  *      @sma contains the semaphore structure.
1113  *      @semflg contains the operation control flags.
1114  *      Return 0 if permission is granted.
1115  * @sem_semctl:
1116  *      Check permission when a semaphore operation specified by @cmd is to be
1117  *      performed on the semaphore @sma.  The @sma may be NULL, e.g. for
1118  *      IPC_INFO or SEM_INFO.
1119  *      @sma contains the semaphore structure.  May be NULL.
1120  *      @cmd contains the operation to be performed.
1121  *      Return 0 if permission is granted.
1122  * @sem_semop
1123  *      Check permissions before performing operations on members of the
1124  *      semaphore set @sma.  If the @alter flag is nonzero, the semaphore set
1125  *      may be modified.
1126  *      @sma contains the semaphore structure.
1127  *      @sops contains the operations to perform.
1128  *      @nsops contains the number of operations to perform.
1129  *      @alter contains the flag indicating whether changes are to be made.
1130  *      Return 0 if permission is granted.
1131  *
1132  * @binder_set_context_mgr
1133  *      Check whether @mgr is allowed to be the binder context manager.
1134  *      @mgr contains the task_struct for the task being registered.
1135  *      Return 0 if permission is granted.
1136  * @binder_transaction
1137  *      Check whether @from is allowed to invoke a binder transaction call
1138  *      to @to.
1139  *      @from contains the task_struct for the sending task.
1140  *      @to contains the task_struct for the receiving task.
1141  * @binder_transfer_binder
1142  *      Check whether @from is allowed to transfer a binder reference to @to.
1143  *      @from contains the task_struct for the sending task.
1144  *      @to contains the task_struct for the receiving task.
1145  * @binder_transfer_file
1146  *      Check whether @from is allowed to transfer @file to @to.
1147  *      @from contains the task_struct for the sending task.
1148  *      @file contains the struct file being transferred.
1149  *      @to contains the task_struct for the receiving task.
1150  *
1151  * @ptrace_access_check:
1152  *      Check permission before allowing the current process to trace the
1153  *      @child process.
1154  *      Security modules may also want to perform a process tracing check
1155  *      during an execve in the set_security or apply_creds hooks of
1156  *      tracing check during an execve in the bprm_set_creds hook of
1157  *      binprm_security_ops if the process is being traced and its security
1158  *      attributes would be changed by the execve.
1159  *      @child contains the task_struct structure for the target process.
1160  *      @mode contains the PTRACE_MODE flags indicating the form of access.
1161  *      Return 0 if permission is granted.
1162  * @ptrace_traceme:
1163  *      Check that the @parent process has sufficient permission to trace the
1164  *      current process before allowing the current process to present itself
1165  *      to the @parent process for tracing.
1166  *      @parent contains the task_struct structure for debugger process.
1167  *      Return 0 if permission is granted.
1168  * @capget:
1169  *      Get the @effective, @inheritable, and @permitted capability sets for
1170  *      the @target process.  The hook may also perform permission checking to
1171  *      determine if the current process is allowed to see the capability sets
1172  *      of the @target process.
1173  *      @target contains the task_struct structure for target process.
1174  *      @effective contains the effective capability set.
1175  *      @inheritable contains the inheritable capability set.
1176  *      @permitted contains the permitted capability set.
1177  *      Return 0 if the capability sets were successfully obtained.
1178  * @capset:
1179  *      Set the @effective, @inheritable, and @permitted capability sets for
1180  *      the current process.
1181  *      @new contains the new credentials structure for target process.
1182  *      @old contains the current credentials structure for target process.
1183  *      @effective contains the effective capability set.
1184  *      @inheritable contains the inheritable capability set.
1185  *      @permitted contains the permitted capability set.
1186  *      Return 0 and update @new if permission is granted.
1187  * @capable:
1188  *      Check whether the @tsk process has the @cap capability in the indicated
1189  *      credentials.
1190  *      @cred contains the credentials to use.
1191  *      @ns contains the user namespace we want the capability in
1192  *      @cap contains the capability <include/linux/capability.h>.
1193  *      @audit: Whether to write an audit message or not
1194  *      Return 0 if the capability is granted for @tsk.
1195  * @syslog:
1196  *      Check permission before accessing the kernel message ring or changing
1197  *      logging to the console.
1198  *      See the syslog(2) manual page for an explanation of the @type values.
1199  *      @type contains the type of action.
1200  *      @from_file indicates the context of action (if it came from /proc).
1201  *      Return 0 if permission is granted.
1202  * @settime:
1203  *      Check permission to change the system time.
1204  *      struct timespec and timezone are defined in include/linux/time.h
1205  *      @ts contains new time
1206  *      @tz contains new timezone
1207  *      Return 0 if permission is granted.
1208  * @vm_enough_memory:
1209  *      Check permissions for allocating a new virtual mapping.
1210  *      @mm contains the mm struct it is being added to.
1211  *      @pages contains the number of pages.
1212  *      Return 0 if permission is granted.
1213  *
1214  * @ismaclabel:
1215  *      Check if the extended attribute specified by @name
1216  *      represents a MAC label. Returns 1 if name is a MAC
1217  *      attribute otherwise returns 0.
1218  *      @name full extended attribute name to check against
1219  *      LSM as a MAC label.
1220  *
1221  * @secid_to_secctx:
1222  *      Convert secid to security context.  If secdata is NULL the length of
1223  *      the result will be returned in seclen, but no secdata will be returned.
1224  *      This does mean that the length could change between calls to check the
1225  *      length and the next call which actually allocates and returns the
1226  *      secdata.
1227  *      @secid contains the security ID.
1228  *      @secdata contains the pointer that stores the converted security
1229  *      context.
1230  *      @seclen pointer which contains the length of the data
1231  * @secctx_to_secid:
1232  *      Convert security context to secid.
1233  *      @secid contains the pointer to the generated security ID.
1234  *      @secdata contains the security context.
1235  *
1236  * @release_secctx:
1237  *      Release the security context.
1238  *      @secdata contains the security context.
1239  *      @seclen contains the length of the security context.
1240  *
1241  * Security hooks for Audit
1242  *
1243  * @audit_rule_init:
1244  *      Allocate and initialize an LSM audit rule structure.
1245  *      @field contains the required Audit action.
1246  *      Fields flags are defined in include/linux/audit.h
1247  *      @op contains the operator the rule uses.
1248  *      @rulestr contains the context where the rule will be applied to.
1249  *      @lsmrule contains a pointer to receive the result.
1250  *      Return 0 if @lsmrule has been successfully set,
1251  *      -EINVAL in case of an invalid rule.
1252  *
1253  * @audit_rule_known:
1254  *      Specifies whether given @rule contains any fields related to
1255  *      current LSM.
1256  *      @rule contains the audit rule of interest.
1257  *      Return 1 in case of relation found, 0 otherwise.
1258  *
1259  * @audit_rule_match:
1260  *      Determine if given @secid matches a rule previously approved
1261  *      by @audit_rule_known.
1262  *      @secid contains the security id in question.
1263  *      @field contains the field which relates to current LSM.
1264  *      @op contains the operator that will be used for matching.
1265  *      @rule points to the audit rule that will be checked against.
1266  *      @actx points to the audit context associated with the check.
1267  *      Return 1 if secid matches the rule, 0 if it does not, -ERRNO on failure.
1268  *
1269  * @audit_rule_free:
1270  *      Deallocate the LSM audit rule structure previously allocated by
1271  *      audit_rule_init.
1272  *      @rule contains the allocated rule
1273  *
1274  * @inode_notifysecctx:
1275  *      Notify the security module of what the security context of an inode
1276  *      should be.  Initializes the incore security context managed by the
1277  *      security module for this inode.  Example usage:  NFS client invokes
1278  *      this hook to initialize the security context in its incore inode to the
1279  *      value provided by the server for the file when the server returned the
1280  *      file's attributes to the client.
1281  *
1282  *      Must be called with inode->i_mutex locked.
1283  *
1284  *      @inode we wish to set the security context of.
1285  *      @ctx contains the string which we wish to set in the inode.
1286  *      @ctxlen contains the length of @ctx.
1287  *
1288  * @inode_setsecctx:
1289  *      Change the security context of an inode.  Updates the
1290  *      incore security context managed by the security module and invokes the
1291  *      fs code as needed (via __vfs_setxattr_noperm) to update any backing
1292  *      xattrs that represent the context.  Example usage:  NFS server invokes
1293  *      this hook to change the security context in its incore inode and on the
1294  *      backing filesystem to a value provided by the client on a SETATTR
1295  *      operation.
1296  *
1297  *      Must be called with inode->i_mutex locked.
1298  *
1299  *      @dentry contains the inode we wish to set the security context of.
1300  *      @ctx contains the string which we wish to set in the inode.
1301  *      @ctxlen contains the length of @ctx.
1302  *
1303  * @inode_getsecctx:
1304  *      On success, returns 0 and fills out @ctx and @ctxlen with the security
1305  *      context for the given @inode.
1306  *
1307  *      @inode we wish to get the security context of.
1308  *      @ctx is a pointer in which to place the allocated security context.
1309  *      @ctxlen points to the place to put the length of @ctx.
1310  * This is the main security structure.
1311  */
1312
1313 struct security_operations {
1314         char name[SECURITY_NAME_MAX + 1];
1315
1316         int (*binder_set_context_mgr)(struct task_struct *mgr);
1317         int (*binder_transaction)(struct task_struct *from,
1318                                         struct task_struct *to);
1319         int (*binder_transfer_binder)(struct task_struct *from,
1320                                         struct task_struct *to);
1321         int (*binder_transfer_file)(struct task_struct *from,
1322                                         struct task_struct *to,
1323                                         struct file *file);
1324
1325         int (*ptrace_access_check)(struct task_struct *child,
1326                                         unsigned int mode);
1327         int (*ptrace_traceme)(struct task_struct *parent);
1328         int (*capget)(struct task_struct *target, kernel_cap_t *effective,
1329                         kernel_cap_t *inheritable, kernel_cap_t *permitted);
1330         int (*capset)(struct cred *new, const struct cred *old,
1331                         const kernel_cap_t *effective,
1332                         const kernel_cap_t *inheritable,
1333                         const kernel_cap_t *permitted);
1334         int (*capable)(const struct cred *cred, struct user_namespace *ns,
1335                         int cap, int audit);
1336         int (*quotactl)(int cmds, int type, int id, struct super_block *sb);
1337         int (*quota_on)(struct dentry *dentry);
1338         int (*syslog)(int type);
1339         int (*settime)(const struct timespec *ts, const struct timezone *tz);
1340         int (*vm_enough_memory)(struct mm_struct *mm, long pages);
1341
1342         int (*bprm_set_creds)(struct linux_binprm *bprm);
1343         int (*bprm_check_security)(struct linux_binprm *bprm);
1344         int (*bprm_secureexec)(struct linux_binprm *bprm);
1345         void (*bprm_committing_creds)(struct linux_binprm *bprm);
1346         void (*bprm_committed_creds)(struct linux_binprm *bprm);
1347
1348         int (*sb_alloc_security)(struct super_block *sb);
1349         void (*sb_free_security)(struct super_block *sb);
1350         int (*sb_copy_data)(char *orig, char *copy);
1351         int (*sb_remount)(struct super_block *sb, void *data);
1352         int (*sb_kern_mount)(struct super_block *sb, int flags, void *data);
1353         int (*sb_show_options)(struct seq_file *m, struct super_block *sb);
1354         int (*sb_statfs)(struct dentry *dentry);
1355         int (*sb_mount)(const char *dev_name, struct path *path,
1356                         const char *type, unsigned long flags, void *data);
1357         int (*sb_umount)(struct vfsmount *mnt, int flags);
1358         int (*sb_pivotroot)(struct path *old_path, struct path *new_path);
1359         int (*sb_set_mnt_opts)(struct super_block *sb,
1360                                 struct security_mnt_opts *opts,
1361                                 unsigned long kern_flags,
1362                                 unsigned long *set_kern_flags);
1363         int (*sb_clone_mnt_opts)(const struct super_block *oldsb,
1364                                         struct super_block *newsb);
1365         int (*sb_parse_opts_str)(char *options, struct security_mnt_opts *opts);
1366         int (*dentry_init_security)(struct dentry *dentry, int mode,
1367                                         struct qstr *name, void **ctx,
1368                                         u32 *ctxlen);
1369
1370
1371 #ifdef CONFIG_SECURITY_PATH
1372         int (*path_unlink)(struct path *dir, struct dentry *dentry);
1373         int (*path_mkdir)(struct path *dir, struct dentry *dentry,
1374                                 umode_t mode);
1375         int (*path_rmdir)(struct path *dir, struct dentry *dentry);
1376         int (*path_mknod)(struct path *dir, struct dentry *dentry,
1377                                 umode_t mode, unsigned int dev);
1378         int (*path_truncate)(struct path *path);
1379         int (*path_symlink)(struct path *dir, struct dentry *dentry,
1380                                 const char *old_name);
1381         int (*path_link)(struct dentry *old_dentry, struct path *new_dir,
1382                                 struct dentry *new_dentry);
1383         int (*path_rename)(struct path *old_dir, struct dentry *old_dentry,
1384                                 struct path *new_dir,
1385                                 struct dentry *new_dentry);
1386         int (*path_chmod)(struct path *path, umode_t mode);
1387         int (*path_chown)(struct path *path, kuid_t uid, kgid_t gid);
1388         int (*path_chroot)(struct path *path);
1389 #endif
1390
1391         int (*inode_alloc_security)(struct inode *inode);
1392         void (*inode_free_security)(struct inode *inode);
1393         int (*inode_init_security)(struct inode *inode, struct inode *dir,
1394                                         const struct qstr *qstr,
1395                                         const char **name, void **value,
1396                                         size_t *len);
1397         int (*inode_create)(struct inode *dir, struct dentry *dentry,
1398                                 umode_t mode);
1399         int (*inode_link)(struct dentry *old_dentry, struct inode *dir,
1400                                 struct dentry *new_dentry);
1401         int (*inode_unlink)(struct inode *dir, struct dentry *dentry);
1402         int (*inode_symlink)(struct inode *dir, struct dentry *dentry,
1403                                 const char *old_name);
1404         int (*inode_mkdir)(struct inode *dir, struct dentry *dentry,
1405                                 umode_t mode);
1406         int (*inode_rmdir)(struct inode *dir, struct dentry *dentry);
1407         int (*inode_mknod)(struct inode *dir, struct dentry *dentry,
1408                                 umode_t mode, dev_t dev);
1409         int (*inode_rename)(struct inode *old_dir, struct dentry *old_dentry,
1410                                 struct inode *new_dir,
1411                                 struct dentry *new_dentry);
1412         int (*inode_readlink)(struct dentry *dentry);
1413         int (*inode_follow_link)(struct dentry *dentry, struct nameidata *nd);
1414         int (*inode_permission)(struct inode *inode, int mask);
1415         int (*inode_setattr)(struct dentry *dentry, struct iattr *attr);
1416         int (*inode_getattr)(const struct path *path);
1417         int (*inode_setxattr)(struct dentry *dentry, const char *name,
1418                                 const void *value, size_t size, int flags);
1419         void (*inode_post_setxattr)(struct dentry *dentry, const char *name,
1420                                         const void *value, size_t size,
1421                                         int flags);
1422         int (*inode_getxattr)(struct dentry *dentry, const char *name);
1423         int (*inode_listxattr)(struct dentry *dentry);
1424         int (*inode_removexattr)(struct dentry *dentry, const char *name);
1425         int (*inode_need_killpriv)(struct dentry *dentry);
1426         int (*inode_killpriv)(struct dentry *dentry);
1427         int (*inode_getsecurity)(const struct inode *inode, const char *name,
1428                                         void **buffer, bool alloc);
1429         int (*inode_setsecurity)(struct inode *inode, const char *name,
1430                                         const void *value, size_t size,
1431                                         int flags);
1432         int (*inode_listsecurity)(struct inode *inode, char *buffer,
1433                                         size_t buffer_size);
1434         void (*inode_getsecid)(const struct inode *inode, u32 *secid);
1435
1436         int (*file_permission)(struct file *file, int mask);
1437         int (*file_alloc_security)(struct file *file);
1438         void (*file_free_security)(struct file *file);
1439         int (*file_ioctl)(struct file *file, unsigned int cmd,
1440                                 unsigned long arg);
1441         int (*mmap_addr)(unsigned long addr);
1442         int (*mmap_file)(struct file *file, unsigned long reqprot,
1443                                 unsigned long prot, unsigned long flags);
1444         int (*file_mprotect)(struct vm_area_struct *vma, unsigned long reqprot,
1445                                 unsigned long prot);
1446         int (*file_lock)(struct file *file, unsigned int cmd);
1447         int (*file_fcntl)(struct file *file, unsigned int cmd,
1448                                 unsigned long arg);
1449         void (*file_set_fowner)(struct file *file);
1450         int (*file_send_sigiotask)(struct task_struct *tsk,
1451                                         struct fown_struct *fown, int sig);
1452         int (*file_receive)(struct file *file);
1453         int (*file_open)(struct file *file, const struct cred *cred);
1454
1455         int (*task_create)(unsigned long clone_flags);
1456         void (*task_free)(struct task_struct *task);
1457         int (*cred_alloc_blank)(struct cred *cred, gfp_t gfp);
1458         void (*cred_free)(struct cred *cred);
1459         int (*cred_prepare)(struct cred *new, const struct cred *old,
1460                                 gfp_t gfp);
1461         void (*cred_transfer)(struct cred *new, const struct cred *old);
1462         int (*kernel_act_as)(struct cred *new, u32 secid);
1463         int (*kernel_create_files_as)(struct cred *new, struct inode *inode);
1464         int (*kernel_fw_from_file)(struct file *file, char *buf, size_t size);
1465         int (*kernel_module_request)(char *kmod_name);
1466         int (*kernel_module_from_file)(struct file *file);
1467         int (*task_fix_setuid)(struct cred *new, const struct cred *old,
1468                                 int flags);
1469         int (*task_setpgid)(struct task_struct *p, pid_t pgid);
1470         int (*task_getpgid)(struct task_struct *p);
1471         int (*task_getsid)(struct task_struct *p);
1472         void (*task_getsecid)(struct task_struct *p, u32 *secid);
1473         int (*task_setnice)(struct task_struct *p, int nice);
1474         int (*task_setioprio)(struct task_struct *p, int ioprio);
1475         int (*task_getioprio)(struct task_struct *p);
1476         int (*task_setrlimit)(struct task_struct *p, unsigned int resource,
1477                                 struct rlimit *new_rlim);
1478         int (*task_setscheduler)(struct task_struct *p);
1479         int (*task_getscheduler)(struct task_struct *p);
1480         int (*task_movememory)(struct task_struct *p);
1481         int (*task_kill)(struct task_struct *p, struct siginfo *info,
1482                                 int sig, u32 secid);
1483         int (*task_wait)(struct task_struct *p);
1484         int (*task_prctl)(int option, unsigned long arg2, unsigned long arg3,
1485                                 unsigned long arg4, unsigned long arg5);
1486         void (*task_to_inode)(struct task_struct *p, struct inode *inode);
1487
1488         int (*ipc_permission)(struct kern_ipc_perm *ipcp, short flag);
1489         void (*ipc_getsecid)(struct kern_ipc_perm *ipcp, u32 *secid);
1490
1491         int (*msg_msg_alloc_security)(struct msg_msg *msg);
1492         void (*msg_msg_free_security)(struct msg_msg *msg);
1493
1494         int (*msg_queue_alloc_security)(struct msg_queue *msq);
1495         void (*msg_queue_free_security)(struct msg_queue *msq);
1496         int (*msg_queue_associate)(struct msg_queue *msq, int msqflg);
1497         int (*msg_queue_msgctl)(struct msg_queue *msq, int cmd);
1498         int (*msg_queue_msgsnd)(struct msg_queue *msq, struct msg_msg *msg,
1499                                 int msqflg);
1500         int (*msg_queue_msgrcv)(struct msg_queue *msq, struct msg_msg *msg,
1501                                 struct task_struct *target, long type,
1502                                 int mode);
1503
1504         int (*shm_alloc_security)(struct shmid_kernel *shp);
1505         void (*shm_free_security)(struct shmid_kernel *shp);
1506         int (*shm_associate)(struct shmid_kernel *shp, int shmflg);
1507         int (*shm_shmctl)(struct shmid_kernel *shp, int cmd);
1508         int (*shm_shmat)(struct shmid_kernel *shp, char __user *shmaddr,
1509                                 int shmflg);
1510
1511         int (*sem_alloc_security)(struct sem_array *sma);
1512         void (*sem_free_security)(struct sem_array *sma);
1513         int (*sem_associate)(struct sem_array *sma, int semflg);
1514         int (*sem_semctl)(struct sem_array *sma, int cmd);
1515         int (*sem_semop)(struct sem_array *sma, struct sembuf *sops,
1516                                 unsigned nsops, int alter);
1517
1518         int (*netlink_send)(struct sock *sk, struct sk_buff *skb);
1519
1520         void (*d_instantiate)(struct dentry *dentry, struct inode *inode);
1521
1522         int (*getprocattr)(struct task_struct *p, char *name, char **value);
1523         int (*setprocattr)(struct task_struct *p, char *name, void *value,
1524                                 size_t size);
1525         int (*ismaclabel)(const char *name);
1526         int (*secid_to_secctx)(u32 secid, char **secdata, u32 *seclen);
1527         int (*secctx_to_secid)(const char *secdata, u32 seclen, u32 *secid);
1528         void (*release_secctx)(char *secdata, u32 seclen);
1529
1530         int (*inode_notifysecctx)(struct inode *inode, void *ctx, u32 ctxlen);
1531         int (*inode_setsecctx)(struct dentry *dentry, void *ctx, u32 ctxlen);
1532         int (*inode_getsecctx)(struct inode *inode, void **ctx, u32 *ctxlen);
1533
1534 #ifdef CONFIG_SECURITY_NETWORK
1535         int (*unix_stream_connect)(struct sock *sock, struct sock *other,
1536                                         struct sock *newsk);
1537         int (*unix_may_send)(struct socket *sock, struct socket *other);
1538
1539         int (*socket_create)(int family, int type, int protocol, int kern);
1540         int (*socket_post_create)(struct socket *sock, int family, int type,
1541                                         int protocol, int kern);
1542         int (*socket_bind)(struct socket *sock, struct sockaddr *address,
1543                                 int addrlen);
1544         int (*socket_connect)(struct socket *sock, struct sockaddr *address,
1545                                 int addrlen);
1546         int (*socket_listen)(struct socket *sock, int backlog);
1547         int (*socket_accept)(struct socket *sock, struct socket *newsock);
1548         int (*socket_sendmsg)(struct socket *sock, struct msghdr *msg,
1549                                 int size);
1550         int (*socket_recvmsg)(struct socket *sock, struct msghdr *msg,
1551                                 int size, int flags);
1552         int (*socket_getsockname)(struct socket *sock);
1553         int (*socket_getpeername)(struct socket *sock);
1554         int (*socket_getsockopt)(struct socket *sock, int level, int optname);
1555         int (*socket_setsockopt)(struct socket *sock, int level, int optname);
1556         int (*socket_shutdown)(struct socket *sock, int how);
1557         int (*socket_sock_rcv_skb)(struct sock *sk, struct sk_buff *skb);
1558         int (*socket_getpeersec_stream)(struct socket *sock,
1559                                         char __user *optval,
1560                                         int __user *optlen, unsigned len);
1561         int (*socket_getpeersec_dgram)(struct socket *sock,
1562                                         struct sk_buff *skb, u32 *secid);
1563         int (*sk_alloc_security)(struct sock *sk, int family, gfp_t priority);
1564         void (*sk_free_security)(struct sock *sk);
1565         void (*sk_clone_security)(const struct sock *sk, struct sock *newsk);
1566         void (*sk_getsecid)(struct sock *sk, u32 *secid);
1567         void (*sock_graft)(struct sock *sk, struct socket *parent);
1568         int (*inet_conn_request)(struct sock *sk, struct sk_buff *skb,
1569                                         struct request_sock *req);
1570         void (*inet_csk_clone)(struct sock *newsk,
1571                                 const struct request_sock *req);
1572         void (*inet_conn_established)(struct sock *sk, struct sk_buff *skb);
1573         int (*secmark_relabel_packet)(u32 secid);
1574         void (*secmark_refcount_inc)(void);
1575         void (*secmark_refcount_dec)(void);
1576         void (*req_classify_flow)(const struct request_sock *req,
1577                                         struct flowi *fl);
1578         int (*tun_dev_alloc_security)(void **security);
1579         void (*tun_dev_free_security)(void *security);
1580         int (*tun_dev_create)(void);
1581         int (*tun_dev_attach_queue)(void *security);
1582         int (*tun_dev_attach)(struct sock *sk, void *security);
1583         int (*tun_dev_open)(void *security);
1584 #endif  /* CONFIG_SECURITY_NETWORK */
1585
1586 #ifdef CONFIG_SECURITY_NETWORK_XFRM
1587         int (*xfrm_policy_alloc_security)(struct xfrm_sec_ctx **ctxp,
1588                                           struct xfrm_user_sec_ctx *sec_ctx,
1589                                                 gfp_t gfp);
1590         int (*xfrm_policy_clone_security)(struct xfrm_sec_ctx *old_ctx,
1591                                                 struct xfrm_sec_ctx **new_ctx);
1592         void (*xfrm_policy_free_security)(struct xfrm_sec_ctx *ctx);
1593         int (*xfrm_policy_delete_security)(struct xfrm_sec_ctx *ctx);
1594         int (*xfrm_state_alloc)(struct xfrm_state *x,
1595                                 struct xfrm_user_sec_ctx *sec_ctx);
1596         int (*xfrm_state_alloc_acquire)(struct xfrm_state *x,
1597                                         struct xfrm_sec_ctx *polsec,
1598                                         u32 secid);
1599         void (*xfrm_state_free_security)(struct xfrm_state *x);
1600         int (*xfrm_state_delete_security)(struct xfrm_state *x);
1601         int (*xfrm_policy_lookup)(struct xfrm_sec_ctx *ctx, u32 fl_secid,
1602                                         u8 dir);
1603         int (*xfrm_state_pol_flow_match)(struct xfrm_state *x,
1604                                                 struct xfrm_policy *xp,
1605                                                 const struct flowi *fl);
1606         int (*xfrm_decode_session)(struct sk_buff *skb, u32 *secid, int ckall);
1607 #endif  /* CONFIG_SECURITY_NETWORK_XFRM */
1608
1609         /* key management security hooks */
1610 #ifdef CONFIG_KEYS
1611         int (*key_alloc)(struct key *key, const struct cred *cred,
1612                                 unsigned long flags);
1613         void (*key_free)(struct key *key);
1614         int (*key_permission)(key_ref_t key_ref, const struct cred *cred,
1615                                 unsigned perm);
1616         int (*key_getsecurity)(struct key *key, char **_buffer);
1617 #endif  /* CONFIG_KEYS */
1618
1619 #ifdef CONFIG_AUDIT
1620         int (*audit_rule_init)(u32 field, u32 op, char *rulestr,
1621                                 void **lsmrule);
1622         int (*audit_rule_known)(struct audit_krule *krule);
1623         int (*audit_rule_match)(u32 secid, u32 field, u32 op, void *lsmrule,
1624                                 struct audit_context *actx);
1625         void (*audit_rule_free)(void *lsmrule);
1626 #endif /* CONFIG_AUDIT */
1627 };
1628
1629 /* prototypes */
1630 extern int security_module_enable(struct security_operations *ops);
1631 extern int register_security(struct security_operations *ops);
1632 extern void __init security_fixup_ops(struct security_operations *ops);
1633 extern void reset_security_ops(void);
1634
1635 #endif /* CONFIG_SECURITY */
1636
1637 #endif /* ! __LINUX_LSM_HOOKS_H */