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