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