4 * Copyright (C) 2001 WireX Communications, Inc <chris@wirex.com>
5 * Copyright (C) 2001 Greg Kroah-Hartman <greg@kroah.com>
6 * Copyright (C) 2001 Networks Associates Technology, Inc <ssmalley@nai.com>
7 * Copyright (C) 2001 James Morris <jmorris@intercode.com.au>
8 * Copyright (C) 2001 Silicon Graphics, Inc. (Trust Technology Group)
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.
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.
22 #ifndef __LINUX_SECURITY_H
23 #define __LINUX_SECURITY_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>
40 * These functions are in security/capability.c and are used
41 * as the default capabilities functions
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);
69 struct xfrm_user_sec_ctx;
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);
74 extern unsigned long mmap_min_addr;
76 * Values used in the task_security_ops calls
78 /* setuid or setgid, id0 == uid or gid */
79 #define LSM_SETID_ID 1
81 /* setreuid or setregid, id0 == real, id1 == eff */
82 #define LSM_SETID_RE 2
84 /* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
85 #define LSM_SETID_RES 4
87 /* setfsuid or setfsgid, id0 == fsuid or fsgid */
88 #define LSM_SETID_FS 8
90 /* forward declares to avoid warnings */
93 struct swap_info_struct;
96 /* bprm_apply_creds unsafe reasons */
97 #define LSM_UNSAFE_SHARE 1
98 #define LSM_UNSAFE_PTRACE 2
99 #define LSM_UNSAFE_PTRACE_CAP 4
101 #ifdef CONFIG_SECURITY
104 * struct security_operations - main security structure
106 * Security hooks for program execution operations.
108 * @bprm_alloc_security:
109 * Allocate and attach a security structure to the @bprm->security field.
110 * The security field is initialized to NULL when the bprm structure is
112 * @bprm contains the linux_binprm structure to be modified.
113 * Return 0 if operation was successful.
114 * @bprm_free_security:
115 * @bprm contains the linux_binprm structure to be modified.
116 * Deallocate and clear the @bprm->security field.
118 * Compute and set the security attributes of a process being transformed
119 * by an execve operation based on the old attributes (current->security)
120 * and the information saved in @bprm->security by the set_security hook.
121 * Since this hook function (and its caller) are void, this hook can not
122 * return an error. However, it can leave the security attributes of the
123 * process unchanged if an access failure occurs at this point.
124 * bprm_apply_creds is called under task_lock. @unsafe indicates various
125 * reasons why it may be unsafe to change security state.
126 * @bprm contains the linux_binprm structure.
127 * @bprm_post_apply_creds:
128 * Runs after bprm_apply_creds with the task_lock dropped, so that
129 * functions which cannot be called safely under the task_lock can
130 * be used. This hook is a good place to perform state changes on
131 * the process such as closing open file descriptors to which access
132 * is no longer granted if the attributes were changed.
133 * Note that a security module might need to save state between
134 * bprm_apply_creds and bprm_post_apply_creds to store the decision
135 * on whether the process may proceed.
136 * @bprm contains the linux_binprm structure.
137 * @bprm_set_security:
138 * Save security information in the bprm->security field, typically based
139 * on information about the bprm->file, for later use by the apply_creds
140 * hook. This hook may also optionally check permissions (e.g. for
141 * transitions between security domains).
142 * This hook may be called multiple times during a single execve, e.g. for
143 * interpreters. The hook can tell whether it has already been called by
144 * checking to see if @bprm->security is non-NULL. If so, then the hook
145 * may decide either to retain the security information saved earlier or
147 * @bprm contains the linux_binprm structure.
148 * Return 0 if the hook is successful and permission is granted.
149 * @bprm_check_security:
150 * This hook mediates the point when a search for a binary handler will
151 * begin. It allows a check the @bprm->security value which is set in
152 * the preceding set_security call. The primary difference from
153 * set_security is that the argv list and envp list are reliably
154 * available in @bprm. This hook may be called multiple times
155 * during a single execve; and in each pass set_security is called
157 * @bprm contains the linux_binprm structure.
158 * Return 0 if the hook is successful and permission is granted.
160 * Return a boolean value (0 or 1) indicating whether a "secure exec"
161 * is required. The flag is passed in the auxiliary table
162 * on the initial stack to the ELF interpreter to indicate whether libc
163 * should enable secure mode.
164 * @bprm contains the linux_binprm structure.
166 * Security hooks for filesystem operations.
168 * @sb_alloc_security:
169 * Allocate and attach a security structure to the sb->s_security field.
170 * The s_security field is initialized to NULL when the structure is
172 * @sb contains the super_block structure to be modified.
173 * Return 0 if operation was successful.
175 * Deallocate and clear the sb->s_security field.
176 * @sb contains the super_block structure to be modified.
178 * Check permission before obtaining filesystem statistics for the @mnt
180 * @dentry is a handle on the superblock for the filesystem.
181 * Return 0 if permission is granted.
183 * Check permission before an object specified by @dev_name is mounted on
184 * the mount point named by @nd. For an ordinary mount, @dev_name
185 * identifies a device if the file system type requires a device. For a
186 * remount (@flags & MS_REMOUNT), @dev_name is irrelevant. For a
187 * loopback/bind mount (@flags & MS_BIND), @dev_name identifies the
188 * pathname of the object being mounted.
189 * @dev_name contains the name for object being mounted.
190 * @nd contains the nameidata structure for mount point object.
191 * @type contains the filesystem type.
192 * @flags contains the mount flags.
193 * @data contains the filesystem-specific data.
194 * Return 0 if permission is granted.
196 * Allow mount option data to be copied prior to parsing by the filesystem,
197 * so that the security module can extract security-specific mount
198 * options cleanly (a filesystem may modify the data e.g. with strsep()).
199 * This also allows the original mount data to be stripped of security-
200 * specific options to avoid having to make filesystems aware of them.
201 * @type the type of filesystem being mounted.
202 * @orig the original mount data copied from userspace.
203 * @copy copied data which will be passed to the security module.
204 * Returns 0 if the copy was successful.
206 * Check permission before the device with superblock @mnt->sb is mounted
207 * on the mount point named by @nd.
208 * @mnt contains the vfsmount for device being mounted.
209 * @nd contains the nameidata object for the mount point.
210 * Return 0 if permission is granted.
212 * Check permission before the @mnt file system is unmounted.
213 * @mnt contains the mounted file system.
214 * @flags contains the unmount flags, e.g. MNT_FORCE.
215 * Return 0 if permission is granted.
217 * Close any files in the @mnt mounted filesystem that are held open by
218 * the security module. This hook is called during an umount operation
219 * prior to checking whether the filesystem is still busy.
220 * @mnt contains the mounted filesystem.
222 * Handle a failed umount of the @mnt mounted filesystem, e.g. re-opening
223 * any files that were closed by umount_close. This hook is called during
224 * an umount operation if the umount fails after a call to the
226 * @mnt contains the mounted filesystem.
228 * Update the security module's state when a filesystem is remounted.
229 * This hook is only called if the remount was successful.
230 * @mnt contains the mounted file system.
231 * @flags contains the new filesystem flags.
232 * @data contains the filesystem-specific data.
233 * @sb_post_mountroot:
234 * Update the security module's state when the root filesystem is mounted.
235 * This hook is only called if the mount was successful.
237 * Update the security module's state when a filesystem is mounted.
238 * This hook is called any time a mount is successfully grafetd to
240 * @mnt contains the mounted filesystem.
241 * @mountpoint_nd contains the nameidata structure for the mount point.
243 * Check permission before pivoting the root filesystem.
244 * @old_nd contains the nameidata structure for the new location of the current root (put_old).
245 * @new_nd contains the nameidata structure for the new root (new_root).
246 * Return 0 if permission is granted.
247 * @sb_post_pivotroot:
248 * Update module state after a successful pivot.
249 * @old_nd contains the nameidata structure for the old root.
250 * @new_nd contains the nameidata structure for the new root.
252 * Security hooks for inode operations.
254 * @inode_alloc_security:
255 * Allocate and attach a security structure to @inode->i_security. The
256 * i_security field is initialized to NULL when the inode structure is
258 * @inode contains the inode structure.
259 * Return 0 if operation was successful.
260 * @inode_free_security:
261 * @inode contains the inode structure.
262 * Deallocate the inode security structure and set @inode->i_security to
264 * @inode_init_security:
265 * Obtain the security attribute name suffix and value to set on a newly
266 * created inode and set up the incore security field for the new inode.
267 * This hook is called by the fs code as part of the inode creation
268 * transaction and provides for atomic labeling of the inode, unlike
269 * the post_create/mkdir/... hooks called by the VFS. The hook function
270 * is expected to allocate the name and value via kmalloc, with the caller
271 * being responsible for calling kfree after using them.
272 * If the security module does not use security attributes or does
273 * not wish to put a security attribute on this particular inode,
274 * then it should return -EOPNOTSUPP to skip this processing.
275 * @inode contains the inode structure of the newly created inode.
276 * @dir contains the inode structure of the parent directory.
277 * @name will be set to the allocated name suffix (e.g. selinux).
278 * @value will be set to the allocated attribute value.
279 * @len will be set to the length of the value.
280 * Returns 0 if @name and @value have been successfully set,
281 * -EOPNOTSUPP if no security attribute is needed, or
282 * -ENOMEM on memory allocation failure.
284 * Check permission to create a regular file.
285 * @dir contains inode structure of the parent of the new file.
286 * @dentry contains the dentry structure for the file to be created.
287 * @mode contains the file mode of the file to be created.
288 * Return 0 if permission is granted.
290 * Check permission before creating a new hard link to a file.
291 * @old_dentry contains the dentry structure for an existing link to the file.
292 * @dir contains the inode structure of the parent directory of the new link.
293 * @new_dentry contains the dentry structure for the new link.
294 * Return 0 if permission is granted.
296 * Check the permission to remove a hard link to a file.
297 * @dir contains the inode structure of parent directory of the file.
298 * @dentry contains the dentry structure for file to be unlinked.
299 * Return 0 if permission is granted.
301 * Check the permission to create a symbolic link to a file.
302 * @dir contains the inode structure of parent directory of the symbolic link.
303 * @dentry contains the dentry structure of the symbolic link.
304 * @old_name contains the pathname of file.
305 * Return 0 if permission is granted.
307 * Check permissions to create a new directory in the existing directory
308 * associated with inode strcture @dir.
309 * @dir containst the inode structure of parent of the directory to be created.
310 * @dentry contains the dentry structure of new directory.
311 * @mode contains the mode of new directory.
312 * Return 0 if permission is granted.
314 * Check the permission to remove a directory.
315 * @dir contains the inode structure of parent of the directory to be removed.
316 * @dentry contains the dentry structure of directory to be removed.
317 * Return 0 if permission is granted.
319 * Check permissions when creating a special file (or a socket or a fifo
320 * file created via the mknod system call). Note that if mknod operation
321 * is being done for a regular file, then the create hook will be called
323 * @dir contains the inode structure of parent of the new file.
324 * @dentry contains the dentry structure of the new file.
325 * @mode contains the mode of the new file.
326 * @dev contains the device number.
327 * Return 0 if permission is granted.
329 * Check for permission to rename a file or directory.
330 * @old_dir contains the inode structure for parent of the old link.
331 * @old_dentry contains the dentry structure of the old link.
332 * @new_dir contains the inode structure for parent of the new link.
333 * @new_dentry contains the dentry structure of the new link.
334 * Return 0 if permission is granted.
336 * Check the permission to read the symbolic link.
337 * @dentry contains the dentry structure for the file link.
338 * Return 0 if permission is granted.
339 * @inode_follow_link:
340 * Check permission to follow a symbolic link when looking up a pathname.
341 * @dentry contains the dentry structure for the link.
342 * @nd contains the nameidata structure for the parent directory.
343 * Return 0 if permission is granted.
345 * Check permission before accessing an inode. This hook is called by the
346 * existing Linux permission function, so a security module can use it to
347 * provide additional checking for existing Linux permission checks.
348 * Notice that this hook is called when a file is opened (as well as many
349 * other operations), whereas the file_security_ops permission hook is
350 * called when the actual read/write operations are performed.
351 * @inode contains the inode structure to check.
352 * @mask contains the permission mask.
353 * @nd contains the nameidata (may be NULL).
354 * Return 0 if permission is granted.
356 * Check permission before setting file attributes. Note that the kernel
357 * call to notify_change is performed from several locations, whenever
358 * file attributes change (such as when a file is truncated, chown/chmod
359 * operations, transferring disk quotas, etc).
360 * @dentry contains the dentry structure for the file.
361 * @attr is the iattr structure containing the new file attributes.
362 * Return 0 if permission is granted.
364 * Check permission before obtaining file attributes.
365 * @mnt is the vfsmount where the dentry was looked up
366 * @dentry contains the dentry structure for the file.
367 * Return 0 if permission is granted.
369 * @inode contains the inode structure for deleted inode.
370 * This hook is called when a deleted inode is released (i.e. an inode
371 * with no hard links has its use count drop to zero). A security module
372 * can use this hook to release any persistent label associated with the
375 * Check permission before setting the extended attributes
376 * @value identified by @name for @dentry.
377 * Return 0 if permission is granted.
378 * @inode_post_setxattr:
379 * Update inode security field after successful setxattr operation.
380 * @value identified by @name for @dentry.
382 * Check permission before obtaining the extended attributes
383 * identified by @name for @dentry.
384 * Return 0 if permission is granted.
386 * Check permission before obtaining the list of extended attribute
388 * Return 0 if permission is granted.
389 * @inode_removexattr:
390 * Check permission before removing the extended attribute
391 * identified by @name for @dentry.
392 * Return 0 if permission is granted.
393 * @inode_getsecurity:
394 * Copy the extended attribute representation of the security label
395 * associated with @name for @inode into @buffer. @buffer may be
396 * NULL to request the size of the buffer required. @size indicates
397 * the size of @buffer in bytes. Note that @name is the remainder
398 * of the attribute name after the security. prefix has been removed.
399 * @err is the return value from the preceding fs getxattr call,
400 * and can be used by the security module to determine whether it
401 * should try and canonicalize the attribute value.
402 * Return number of bytes used/required on success.
403 * @inode_setsecurity:
404 * Set the security label associated with @name for @inode from the
405 * extended attribute value @value. @size indicates the size of the
406 * @value in bytes. @flags may be XATTR_CREATE, XATTR_REPLACE, or 0.
407 * Note that @name is the remainder of the attribute name after the
408 * security. prefix has been removed.
409 * Return 0 on success.
410 * @inode_listsecurity:
411 * Copy the extended attribute names for the security labels
412 * associated with @inode into @buffer. The maximum size of @buffer
413 * is specified by @buffer_size. @buffer may be NULL to request
414 * the size of the buffer required.
415 * Returns number of bytes used/required on success.
417 * Security hooks for file operations
420 * Check file permissions before accessing an open file. This hook is
421 * called by various operations that read or write files. A security
422 * module can use this hook to perform additional checking on these
423 * operations, e.g. to revalidate permissions on use to support privilege
424 * bracketing or policy changes. Notice that this hook is used when the
425 * actual read/write operations are performed, whereas the
426 * inode_security_ops hook is called when a file is opened (as well as
427 * many other operations).
428 * Caveat: Although this hook can be used to revalidate permissions for
429 * various system call operations that read or write files, it does not
430 * address the revalidation of permissions for memory-mapped files.
431 * Security modules must handle this separately if they need such
433 * @file contains the file structure being accessed.
434 * @mask contains the requested permissions.
435 * Return 0 if permission is granted.
436 * @file_alloc_security:
437 * Allocate and attach a security structure to the file->f_security field.
438 * The security field is initialized to NULL when the structure is first
440 * @file contains the file structure to secure.
441 * Return 0 if the hook is successful and permission is granted.
442 * @file_free_security:
443 * Deallocate and free any security structures stored in file->f_security.
444 * @file contains the file structure being modified.
446 * @file contains the file structure.
447 * @cmd contains the operation to perform.
448 * @arg contains the operational arguments.
449 * Check permission for an ioctl operation on @file. Note that @arg can
450 * sometimes represents a user space pointer; in other cases, it may be a
451 * simple integer value. When @arg represents a user space pointer, it
452 * should never be used by the security module.
453 * Return 0 if permission is granted.
455 * Check permissions for a mmap operation. The @file may be NULL, e.g.
456 * if mapping anonymous memory.
457 * @file contains the file structure for file to map (may be NULL).
458 * @reqprot contains the protection requested by the application.
459 * @prot contains the protection that will be applied by the kernel.
460 * @flags contains the operational flags.
461 * Return 0 if permission is granted.
463 * Check permissions before changing memory access permissions.
464 * @vma contains the memory region to modify.
465 * @reqprot contains the protection requested by the application.
466 * @prot contains the protection that will be applied by the kernel.
467 * Return 0 if permission is granted.
469 * Check permission before performing file locking operations.
470 * Note: this hook mediates both flock and fcntl style locks.
471 * @file contains the file structure.
472 * @cmd contains the posix-translated lock operation to perform
473 * (e.g. F_RDLCK, F_WRLCK).
474 * Return 0 if permission is granted.
476 * Check permission before allowing the file operation specified by @cmd
477 * from being performed on the file @file. Note that @arg can sometimes
478 * represents a user space pointer; in other cases, it may be a simple
479 * integer value. When @arg represents a user space pointer, it should
480 * never be used by the security module.
481 * @file contains the file structure.
482 * @cmd contains the operation to be performed.
483 * @arg contains the operational arguments.
484 * Return 0 if permission is granted.
486 * Save owner security information (typically from current->security) in
487 * file->f_security for later use by the send_sigiotask hook.
488 * @file contains the file structure to update.
489 * Return 0 on success.
490 * @file_send_sigiotask:
491 * Check permission for the file owner @fown to send SIGIO or SIGURG to the
492 * process @tsk. Note that this hook is sometimes called from interrupt.
493 * Note that the fown_struct, @fown, is never outside the context of a
494 * struct file, so the file structure (and associated security information)
495 * can always be obtained:
496 * container_of(fown, struct file, f_owner)
497 * @tsk contains the structure of task receiving signal.
498 * @fown contains the file owner information.
499 * @sig is the signal that will be sent. When 0, kernel sends SIGIO.
500 * Return 0 if permission is granted.
502 * This hook allows security modules to control the ability of a process
503 * to receive an open file descriptor via socket IPC.
504 * @file contains the file structure being received.
505 * Return 0 if permission is granted.
507 * Security hooks for task operations.
510 * Check permission before creating a child process. See the clone(2)
511 * manual page for definitions of the @clone_flags.
512 * @clone_flags contains the flags indicating what should be shared.
513 * Return 0 if permission is granted.
514 * @task_alloc_security:
515 * @p contains the task_struct for child process.
516 * Allocate and attach a security structure to the p->security field. The
517 * security field is initialized to NULL when the task structure is
519 * Return 0 if operation was successful.
520 * @task_free_security:
521 * @p contains the task_struct for process.
522 * Deallocate and clear the p->security field.
524 * Check permission before setting one or more of the user identity
525 * attributes of the current process. The @flags parameter indicates
526 * which of the set*uid system calls invoked this hook and how to
527 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
528 * definitions at the beginning of this file for the @flags values and
530 * @id0 contains a uid.
531 * @id1 contains a uid.
532 * @id2 contains a uid.
533 * @flags contains one of the LSM_SETID_* values.
534 * Return 0 if permission is granted.
536 * Update the module's state after setting one or more of the user
537 * identity attributes of the current process. The @flags parameter
538 * indicates which of the set*uid system calls invoked this hook. If
539 * @flags is LSM_SETID_FS, then @old_ruid is the old fs uid and the other
540 * parameters are not used.
541 * @old_ruid contains the old real uid (or fs uid if LSM_SETID_FS).
542 * @old_euid contains the old effective uid (or -1 if LSM_SETID_FS).
543 * @old_suid contains the old saved uid (or -1 if LSM_SETID_FS).
544 * @flags contains one of the LSM_SETID_* values.
545 * Return 0 on success.
547 * Check permission before setting one or more of the group identity
548 * attributes of the current process. The @flags parameter indicates
549 * which of the set*gid system calls invoked this hook and how to
550 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
551 * definitions at the beginning of this file for the @flags values and
553 * @id0 contains a gid.
554 * @id1 contains a gid.
555 * @id2 contains a gid.
556 * @flags contains one of the LSM_SETID_* values.
557 * Return 0 if permission is granted.
559 * Check permission before setting the process group identifier of the
560 * process @p to @pgid.
561 * @p contains the task_struct for process being modified.
562 * @pgid contains the new pgid.
563 * Return 0 if permission is granted.
565 * Check permission before getting the process group identifier of the
567 * @p contains the task_struct for the process.
568 * Return 0 if permission is granted.
570 * Check permission before getting the session identifier of the process
572 * @p contains the task_struct for the process.
573 * Return 0 if permission is granted.
575 * Retrieve the security identifier of the process @p.
576 * @p contains the task_struct for the process and place is into @secid.
578 * Check permission before setting the supplementary group set of the
580 * @group_info contains the new group information.
581 * Return 0 if permission is granted.
583 * Check permission before setting the nice value of @p to @nice.
584 * @p contains the task_struct of process.
585 * @nice contains the new nice value.
586 * Return 0 if permission is granted.
588 * Check permission before setting the ioprio value of @p to @ioprio.
589 * @p contains the task_struct of process.
590 * @ioprio contains the new ioprio value
591 * Return 0 if permission is granted.
593 * Check permission before getting the ioprio value of @p.
594 * @p contains the task_struct of process.
595 * Return 0 if permission is granted.
597 * Check permission before setting the resource limits of the current
598 * process for @resource to @new_rlim. The old resource limit values can
599 * be examined by dereferencing (current->signal->rlim + resource).
600 * @resource contains the resource whose limit is being set.
601 * @new_rlim contains the new limits for @resource.
602 * Return 0 if permission is granted.
603 * @task_setscheduler:
604 * Check permission before setting scheduling policy and/or parameters of
605 * process @p based on @policy and @lp.
606 * @p contains the task_struct for process.
607 * @policy contains the scheduling policy.
608 * @lp contains the scheduling parameters.
609 * Return 0 if permission is granted.
610 * @task_getscheduler:
611 * Check permission before obtaining scheduling information for process
613 * @p contains the task_struct for process.
614 * Return 0 if permission is granted.
616 * Check permission before moving memory owned by process @p.
617 * @p contains the task_struct for process.
618 * Return 0 if permission is granted.
620 * Check permission before sending signal @sig to @p. @info can be NULL,
621 * the constant 1, or a pointer to a siginfo structure. If @info is 1 or
622 * SI_FROMKERNEL(info) is true, then the signal should be viewed as coming
623 * from the kernel and should typically be permitted.
624 * SIGIO signals are handled separately by the send_sigiotask hook in
626 * @p contains the task_struct for process.
627 * @info contains the signal information.
628 * @sig contains the signal value.
629 * @secid contains the sid of the process where the signal originated
630 * Return 0 if permission is granted.
632 * Check permission before allowing a process to reap a child process @p
633 * and collect its status information.
634 * @p contains the task_struct for process.
635 * Return 0 if permission is granted.
637 * Check permission before performing a process control operation on the
639 * @option contains the operation.
640 * @arg2 contains a argument.
641 * @arg3 contains a argument.
642 * @arg4 contains a argument.
643 * @arg5 contains a argument.
644 * Return 0 if permission is granted.
645 * @task_reparent_to_init:
646 * Set the security attributes in @p->security for a kernel thread that
647 * is being reparented to the init task.
648 * @p contains the task_struct for the kernel thread.
650 * Set the security attributes for an inode based on an associated task's
651 * security attributes, e.g. for /proc/pid inodes.
652 * @p contains the task_struct for the task.
653 * @inode contains the inode structure for the inode.
655 * Security hooks for Netlink messaging.
658 * Save security information for a netlink message so that permission
659 * checking can be performed when the message is processed. The security
660 * information can be saved using the eff_cap field of the
661 * netlink_skb_parms structure. Also may be used to provide fine
662 * grained control over message transmission.
663 * @sk associated sock of task sending the message.,
664 * @skb contains the sk_buff structure for the netlink message.
665 * Return 0 if the information was successfully saved and message
666 * is allowed to be transmitted.
668 * Check permission before processing the received netlink message in
670 * @skb contains the sk_buff structure for the netlink message.
671 * @cap indicates the capability required
672 * Return 0 if permission is granted.
674 * Security hooks for Unix domain networking.
676 * @unix_stream_connect:
677 * Check permissions before establishing a Unix domain stream connection
678 * between @sock and @other.
679 * @sock contains the socket structure.
680 * @other contains the peer socket structure.
681 * Return 0 if permission is granted.
683 * Check permissions before connecting or sending datagrams from @sock to
685 * @sock contains the socket structure.
686 * @sock contains the peer socket structure.
687 * Return 0 if permission is granted.
689 * The @unix_stream_connect and @unix_may_send hooks were necessary because
690 * Linux provides an alternative to the conventional file name space for Unix
691 * domain sockets. Whereas binding and connecting to sockets in the file name
692 * space is mediated by the typical file permissions (and caught by the mknod
693 * and permission hooks in inode_security_ops), binding and connecting to
694 * sockets in the abstract name space is completely unmediated. Sufficient
695 * control of Unix domain sockets in the abstract name space isn't possible
696 * using only the socket layer hooks, since we need to know the actual target
697 * socket, which is not looked up until we are inside the af_unix code.
699 * Security hooks for socket operations.
702 * Check permissions prior to creating a new socket.
703 * @family contains the requested protocol family.
704 * @type contains the requested communications type.
705 * @protocol contains the requested protocol.
706 * @kern set to 1 if a kernel socket.
707 * Return 0 if permission is granted.
708 * @socket_post_create:
709 * This hook allows a module to update or allocate a per-socket security
710 * structure. Note that the security field was not added directly to the
711 * socket structure, but rather, the socket security information is stored
712 * in the associated inode. Typically, the inode alloc_security hook will
713 * allocate and and attach security information to
714 * sock->inode->i_security. This hook may be used to update the
715 * sock->inode->i_security field with additional information that wasn't
716 * available when the inode was allocated.
717 * @sock contains the newly created socket structure.
718 * @family contains the requested protocol family.
719 * @type contains the requested communications type.
720 * @protocol contains the requested protocol.
721 * @kern set to 1 if a kernel socket.
723 * Check permission before socket protocol layer bind operation is
724 * performed and the socket @sock is bound to the address specified in the
725 * @address parameter.
726 * @sock contains the socket structure.
727 * @address contains the address to bind to.
728 * @addrlen contains the length of address.
729 * Return 0 if permission is granted.
731 * Check permission before socket protocol layer connect operation
732 * attempts to connect socket @sock to a remote address, @address.
733 * @sock contains the socket structure.
734 * @address contains the address of remote endpoint.
735 * @addrlen contains the length of address.
736 * Return 0 if permission is granted.
738 * Check permission before socket protocol layer listen operation.
739 * @sock contains the socket structure.
740 * @backlog contains the maximum length for the pending connection queue.
741 * Return 0 if permission is granted.
743 * Check permission before accepting a new connection. Note that the new
744 * socket, @newsock, has been created and some information copied to it,
745 * but the accept operation has not actually been performed.
746 * @sock contains the listening socket structure.
747 * @newsock contains the newly created server socket for connection.
748 * Return 0 if permission is granted.
749 * @socket_post_accept:
750 * This hook allows a security module to copy security
751 * information into the newly created socket's inode.
752 * @sock contains the listening socket structure.
753 * @newsock contains the newly created server socket for connection.
755 * Check permission before transmitting a message to another socket.
756 * @sock contains the socket structure.
757 * @msg contains the message to be transmitted.
758 * @size contains the size of message.
759 * Return 0 if permission is granted.
761 * Check permission before receiving a message from a socket.
762 * @sock contains the socket structure.
763 * @msg contains the message structure.
764 * @size contains the size of message structure.
765 * @flags contains the operational flags.
766 * Return 0 if permission is granted.
767 * @socket_getsockname:
768 * Check permission before the local address (name) of the socket object
769 * @sock is retrieved.
770 * @sock contains the socket structure.
771 * Return 0 if permission is granted.
772 * @socket_getpeername:
773 * Check permission before the remote address (name) of a socket object
774 * @sock is retrieved.
775 * @sock contains the socket structure.
776 * Return 0 if permission is granted.
777 * @socket_getsockopt:
778 * Check permissions before retrieving the options associated with socket
780 * @sock contains the socket structure.
781 * @level contains the protocol level to retrieve option from.
782 * @optname contains the name of option to retrieve.
783 * Return 0 if permission is granted.
784 * @socket_setsockopt:
785 * Check permissions before setting the options associated with socket
787 * @sock contains the socket structure.
788 * @level contains the protocol level to set options for.
789 * @optname contains the name of the option to set.
790 * Return 0 if permission is granted.
792 * Checks permission before all or part of a connection on the socket
793 * @sock is shut down.
794 * @sock contains the socket structure.
795 * @how contains the flag indicating how future sends and receives are handled.
796 * Return 0 if permission is granted.
797 * @socket_sock_rcv_skb:
798 * Check permissions on incoming network packets. This hook is distinct
799 * from Netfilter's IP input hooks since it is the first time that the
800 * incoming sk_buff @skb has been associated with a particular socket, @sk.
801 * @sk contains the sock (not socket) associated with the incoming sk_buff.
802 * @skb contains the incoming network data.
803 * @socket_getpeersec:
804 * This hook allows the security module to provide peer socket security
805 * state to userspace via getsockopt SO_GETPEERSEC.
806 * @sock is the local socket.
807 * @optval userspace memory where the security state is to be copied.
808 * @optlen userspace int where the module should copy the actual length
809 * of the security state.
810 * @len as input is the maximum length to copy to userspace provided
812 * Return 0 if all is well, otherwise, typical getsockopt return
814 * @sk_alloc_security:
815 * Allocate and attach a security structure to the sk->sk_security field,
816 * which is used to copy security attributes between local stream sockets.
818 * Deallocate security structure.
819 * @sk_clone_security:
820 * Clone/copy security structure.
822 * Retrieve the LSM-specific secid for the sock to enable caching of network
825 * Sets the socket's isec sid to the sock's sid.
826 * @inet_conn_request:
827 * Sets the openreq's sid to socket's sid with MLS portion taken from peer sid.
829 * Sets the new child socket's sid to the openreq sid.
830 * @inet_conn_established:
831 * Sets the connection's peersid to the secmark on skb.
832 * @req_classify_flow:
833 * Sets the flow's sid to the openreq sid.
835 * Security hooks for XFRM operations.
837 * @xfrm_policy_alloc_security:
838 * @xp contains the xfrm_policy being added to Security Policy Database
839 * used by the XFRM system.
840 * @sec_ctx contains the security context information being provided by
841 * the user-level policy update program (e.g., setkey).
842 * Allocate a security structure to the xp->security field; the security
843 * field is initialized to NULL when the xfrm_policy is allocated.
844 * Return 0 if operation was successful (memory to allocate, legal context)
845 * @xfrm_policy_clone_security:
846 * @old contains an existing xfrm_policy in the SPD.
847 * @new contains a new xfrm_policy being cloned from old.
848 * Allocate a security structure to the new->security field
849 * that contains the information from the old->security field.
850 * Return 0 if operation was successful (memory to allocate).
851 * @xfrm_policy_free_security:
852 * @xp contains the xfrm_policy
853 * Deallocate xp->security.
854 * @xfrm_policy_delete_security:
855 * @xp contains the xfrm_policy.
856 * Authorize deletion of xp->security.
857 * @xfrm_state_alloc_security:
858 * @x contains the xfrm_state being added to the Security Association
859 * Database by the XFRM system.
860 * @sec_ctx contains the security context information being provided by
861 * the user-level SA generation program (e.g., setkey or racoon).
862 * @secid contains the secid from which to take the mls portion of the context.
863 * Allocate a security structure to the x->security field; the security
864 * field is initialized to NULL when the xfrm_state is allocated. Set the
865 * context to correspond to either sec_ctx or polsec, with the mls portion
866 * taken from secid in the latter case.
867 * Return 0 if operation was successful (memory to allocate, legal context).
868 * @xfrm_state_free_security:
869 * @x contains the xfrm_state.
870 * Deallocate x->security.
871 * @xfrm_state_delete_security:
872 * @x contains the xfrm_state.
873 * Authorize deletion of x->security.
874 * @xfrm_policy_lookup:
875 * @xp contains the xfrm_policy for which the access control is being
877 * @fl_secid contains the flow security label that is used to authorize
878 * access to the policy xp.
879 * @dir contains the direction of the flow (input or output).
880 * Check permission when a flow selects a xfrm_policy for processing
881 * XFRMs on a packet. The hook is called when selecting either a
882 * per-socket policy or a generic xfrm policy.
883 * Return 0 if permission is granted, -ESRCH otherwise, or -errno
885 * @xfrm_state_pol_flow_match:
886 * @x contains the state to match.
887 * @xp contains the policy to check for a match.
888 * @fl contains the flow to check for a match.
889 * Return 1 if there is a match.
890 * @xfrm_decode_session:
891 * @skb points to skb to decode.
892 * @secid points to the flow key secid to set.
893 * @ckall says if all xfrms used should be checked for same secid.
894 * Return 0 if ckall is zero or all xfrms used have the same secid.
896 * Security hooks affecting all Key Management operations
899 * Permit allocation of a key and assign security data. Note that key does
900 * not have a serial number assigned at this point.
901 * @key points to the key.
902 * @flags is the allocation flags
903 * Return 0 if permission is granted, -ve error otherwise.
905 * Notification of destruction; free security data.
906 * @key points to the key.
909 * See whether a specific operational right is granted to a process on a
911 * @key_ref refers to the key (key pointer + possession attribute bit).
912 * @context points to the process to provide the context against which to
913 * evaluate the security data on the key.
914 * @perm describes the combination of permissions required of this key.
915 * Return 1 if permission granted, 0 if permission denied and -ve it the
916 * normal permissions model should be effected.
918 * Security hooks affecting all System V IPC operations.
921 * Check permissions for access to IPC
922 * @ipcp contains the kernel IPC permission structure
923 * @flag contains the desired (requested) permission set
924 * Return 0 if permission is granted.
926 * Security hooks for individual messages held in System V IPC message queues
927 * @msg_msg_alloc_security:
928 * Allocate and attach a security structure to the msg->security field.
929 * The security field is initialized to NULL when the structure is first
931 * @msg contains the message structure to be modified.
932 * Return 0 if operation was successful and permission is granted.
933 * @msg_msg_free_security:
934 * Deallocate the security structure for this message.
935 * @msg contains the message structure to be modified.
937 * Security hooks for System V IPC Message Queues
939 * @msg_queue_alloc_security:
940 * Allocate and attach a security structure to the
941 * msq->q_perm.security field. The security field is initialized to
942 * NULL when the structure is first created.
943 * @msq contains the message queue structure to be modified.
944 * Return 0 if operation was successful and permission is granted.
945 * @msg_queue_free_security:
946 * Deallocate security structure for this message queue.
947 * @msq contains the message queue structure to be modified.
948 * @msg_queue_associate:
949 * Check permission when a message queue is requested through the
950 * msgget system call. This hook is only called when returning the
951 * message queue identifier for an existing message queue, not when a
952 * new message queue is created.
953 * @msq contains the message queue to act upon.
954 * @msqflg contains the operation control flags.
955 * Return 0 if permission is granted.
957 * Check permission when a message control operation specified by @cmd
958 * is to be performed on the message queue @msq.
959 * The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO.
960 * @msq contains the message queue to act upon. May be NULL.
961 * @cmd contains the operation to be performed.
962 * Return 0 if permission is granted.
964 * Check permission before a message, @msg, is enqueued on the message
966 * @msq contains the message queue to send message to.
967 * @msg contains the message to be enqueued.
968 * @msqflg contains operational flags.
969 * Return 0 if permission is granted.
971 * Check permission before a message, @msg, is removed from the message
972 * queue, @msq. The @target task structure contains a pointer to the
973 * process that will be receiving the message (not equal to the current
974 * process when inline receives are being performed).
975 * @msq contains the message queue to retrieve message from.
976 * @msg contains the message destination.
977 * @target contains the task structure for recipient process.
978 * @type contains the type of message requested.
979 * @mode contains the operational flags.
980 * Return 0 if permission is granted.
982 * Security hooks for System V Shared Memory Segments
984 * @shm_alloc_security:
985 * Allocate and attach a security structure to the shp->shm_perm.security
986 * field. The security field is initialized to NULL when the structure is
988 * @shp contains the shared memory structure to be modified.
989 * Return 0 if operation was successful and permission is granted.
990 * @shm_free_security:
991 * Deallocate the security struct for this memory segment.
992 * @shp contains the shared memory structure to be modified.
994 * Check permission when a shared memory region is requested through the
995 * shmget system call. This hook is only called when returning the shared
996 * memory region identifier for an existing region, not when a new shared
997 * memory region is created.
998 * @shp contains the shared memory structure to be modified.
999 * @shmflg contains the operation control flags.
1000 * Return 0 if permission is granted.
1002 * Check permission when a shared memory control operation specified by
1003 * @cmd is to be performed on the shared memory region @shp.
1004 * The @shp may be NULL, e.g. for IPC_INFO or SHM_INFO.
1005 * @shp contains shared memory structure to be modified.
1006 * @cmd contains the operation to be performed.
1007 * Return 0 if permission is granted.
1009 * Check permissions prior to allowing the shmat system call to attach the
1010 * shared memory segment @shp to the data segment of the calling process.
1011 * The attaching address is specified by @shmaddr.
1012 * @shp contains the shared memory structure to be modified.
1013 * @shmaddr contains the address to attach memory region to.
1014 * @shmflg contains the operational flags.
1015 * Return 0 if permission is granted.
1017 * Security hooks for System V Semaphores
1019 * @sem_alloc_security:
1020 * Allocate and attach a security structure to the sma->sem_perm.security
1021 * field. The security field is initialized to NULL when the structure is
1023 * @sma contains the semaphore structure
1024 * Return 0 if operation was successful and permission is granted.
1025 * @sem_free_security:
1026 * deallocate security struct for this semaphore
1027 * @sma contains the semaphore structure.
1029 * Check permission when a semaphore is requested through the semget
1030 * system call. This hook is only called when returning the semaphore
1031 * identifier for an existing semaphore, not when a new one must be
1033 * @sma contains the semaphore structure.
1034 * @semflg contains the operation control flags.
1035 * Return 0 if permission is granted.
1037 * Check permission when a semaphore operation specified by @cmd is to be
1038 * performed on the semaphore @sma. The @sma may be NULL, e.g. for
1039 * IPC_INFO or SEM_INFO.
1040 * @sma contains the semaphore structure. May be NULL.
1041 * @cmd contains the operation to be performed.
1042 * Return 0 if permission is granted.
1044 * Check permissions before performing operations on members of the
1045 * semaphore set @sma. If the @alter flag is nonzero, the semaphore set
1047 * @sma contains the semaphore structure.
1048 * @sops contains the operations to perform.
1049 * @nsops contains the number of operations to perform.
1050 * @alter contains the flag indicating whether changes are to be made.
1051 * Return 0 if permission is granted.
1054 * Check permission before allowing the @parent process to trace the
1056 * Security modules may also want to perform a process tracing check
1057 * during an execve in the set_security or apply_creds hooks of
1058 * binprm_security_ops if the process is being traced and its security
1059 * attributes would be changed by the execve.
1060 * @parent contains the task_struct structure for parent process.
1061 * @child contains the task_struct structure for child process.
1062 * Return 0 if permission is granted.
1064 * Get the @effective, @inheritable, and @permitted capability sets for
1065 * the @target process. The hook may also perform permission checking to
1066 * determine if the current process is allowed to see the capability sets
1067 * of the @target process.
1068 * @target contains the task_struct structure for target process.
1069 * @effective contains the effective capability set.
1070 * @inheritable contains the inheritable capability set.
1071 * @permitted contains the permitted capability set.
1072 * Return 0 if the capability sets were successfully obtained.
1074 * Check permission before setting the @effective, @inheritable, and
1075 * @permitted capability sets for the @target process.
1076 * Caveat: @target is also set to current if a set of processes is
1077 * specified (i.e. all processes other than current and init or a
1078 * particular process group). Hence, the capset_set hook may need to
1079 * revalidate permission to the actual target process.
1080 * @target contains the task_struct structure for target process.
1081 * @effective contains the effective capability set.
1082 * @inheritable contains the inheritable capability set.
1083 * @permitted contains the permitted capability set.
1084 * Return 0 if permission is granted.
1086 * Set the @effective, @inheritable, and @permitted capability sets for
1087 * the @target process. Since capset_check cannot always check permission
1088 * to the real @target process, this hook may also perform permission
1089 * checking to determine if the current process is allowed to set the
1090 * capability sets of the @target process. However, this hook has no way
1091 * of returning an error due to the structure of the sys_capset code.
1092 * @target contains the task_struct structure for target process.
1093 * @effective contains the effective capability set.
1094 * @inheritable contains the inheritable capability set.
1095 * @permitted contains the permitted capability set.
1097 * Check whether the @tsk process has the @cap capability.
1098 * @tsk contains the task_struct for the process.
1099 * @cap contains the capability <include/linux/capability.h>.
1100 * Return 0 if the capability is granted for @tsk.
1102 * Check permission before enabling or disabling process accounting. If
1103 * accounting is being enabled, then @file refers to the open file used to
1104 * store accounting records. If accounting is being disabled, then @file
1106 * @file contains the file structure for the accounting file (may be NULL).
1107 * Return 0 if permission is granted.
1109 * Check permission before accessing the @table sysctl variable in the
1110 * manner specified by @op.
1111 * @table contains the ctl_table structure for the sysctl variable.
1112 * @op contains the operation (001 = search, 002 = write, 004 = read).
1113 * Return 0 if permission is granted.
1115 * Check permission before accessing the kernel message ring or changing
1116 * logging to the console.
1117 * See the syslog(2) manual page for an explanation of the @type values.
1118 * @type contains the type of action.
1119 * Return 0 if permission is granted.
1121 * Check permission to change the system time.
1122 * struct timespec and timezone are defined in include/linux/time.h
1123 * @ts contains new time
1124 * @tz contains new timezone
1125 * Return 0 if permission is granted.
1126 * @vm_enough_memory:
1127 * Check permissions for allocating a new virtual mapping.
1128 * @pages contains the number of pages.
1129 * Return 0 if permission is granted.
1131 * @register_security:
1132 * allow module stacking.
1133 * @name contains the name of the security module being stacked.
1134 * @ops contains a pointer to the struct security_operations of the module to stack.
1135 * @unregister_security:
1136 * remove a stacked module.
1137 * @name contains the name of the security module being unstacked.
1138 * @ops contains a pointer to the struct security_operations of the module to unstack.
1141 * Convert secid to security context.
1142 * @secid contains the security ID.
1143 * @secdata contains the pointer that stores the converted security context.
1146 * Release the security context.
1147 * @secdata contains the security context.
1148 * @seclen contains the length of the security context.
1150 * This is the main security structure.
1152 struct security_operations {
1153 int (*ptrace) (struct task_struct * parent, struct task_struct * child);
1154 int (*capget) (struct task_struct * target,
1155 kernel_cap_t * effective,
1156 kernel_cap_t * inheritable, kernel_cap_t * permitted);
1157 int (*capset_check) (struct task_struct * target,
1158 kernel_cap_t * effective,
1159 kernel_cap_t * inheritable,
1160 kernel_cap_t * permitted);
1161 void (*capset_set) (struct task_struct * target,
1162 kernel_cap_t * effective,
1163 kernel_cap_t * inheritable,
1164 kernel_cap_t * permitted);
1165 int (*capable) (struct task_struct * tsk, int cap);
1166 int (*acct) (struct file * file);
1167 int (*sysctl) (struct ctl_table * table, int op);
1168 int (*quotactl) (int cmds, int type, int id, struct super_block * sb);
1169 int (*quota_on) (struct dentry * dentry);
1170 int (*syslog) (int type);
1171 int (*settime) (struct timespec *ts, struct timezone *tz);
1172 int (*vm_enough_memory) (long pages);
1174 int (*bprm_alloc_security) (struct linux_binprm * bprm);
1175 void (*bprm_free_security) (struct linux_binprm * bprm);
1176 void (*bprm_apply_creds) (struct linux_binprm * bprm, int unsafe);
1177 void (*bprm_post_apply_creds) (struct linux_binprm * bprm);
1178 int (*bprm_set_security) (struct linux_binprm * bprm);
1179 int (*bprm_check_security) (struct linux_binprm * bprm);
1180 int (*bprm_secureexec) (struct linux_binprm * bprm);
1182 int (*sb_alloc_security) (struct super_block * sb);
1183 void (*sb_free_security) (struct super_block * sb);
1184 int (*sb_copy_data)(struct file_system_type *type,
1185 void *orig, void *copy);
1186 int (*sb_kern_mount) (struct super_block *sb, void *data);
1187 int (*sb_statfs) (struct dentry *dentry);
1188 int (*sb_mount) (char *dev_name, struct nameidata * nd,
1189 char *type, unsigned long flags, void *data);
1190 int (*sb_check_sb) (struct vfsmount * mnt, struct nameidata * nd);
1191 int (*sb_umount) (struct vfsmount * mnt, int flags);
1192 void (*sb_umount_close) (struct vfsmount * mnt);
1193 void (*sb_umount_busy) (struct vfsmount * mnt);
1194 void (*sb_post_remount) (struct vfsmount * mnt,
1195 unsigned long flags, void *data);
1196 void (*sb_post_mountroot) (void);
1197 void (*sb_post_addmount) (struct vfsmount * mnt,
1198 struct nameidata * mountpoint_nd);
1199 int (*sb_pivotroot) (struct nameidata * old_nd,
1200 struct nameidata * new_nd);
1201 void (*sb_post_pivotroot) (struct nameidata * old_nd,
1202 struct nameidata * new_nd);
1204 int (*inode_alloc_security) (struct inode *inode);
1205 void (*inode_free_security) (struct inode *inode);
1206 int (*inode_init_security) (struct inode *inode, struct inode *dir,
1207 char **name, void **value, size_t *len);
1208 int (*inode_create) (struct inode *dir,
1209 struct dentry *dentry, int mode);
1210 int (*inode_link) (struct dentry *old_dentry,
1211 struct inode *dir, struct dentry *new_dentry);
1212 int (*inode_unlink) (struct inode *dir, struct dentry *dentry);
1213 int (*inode_symlink) (struct inode *dir,
1214 struct dentry *dentry, const char *old_name);
1215 int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode);
1216 int (*inode_rmdir) (struct inode *dir, struct dentry *dentry);
1217 int (*inode_mknod) (struct inode *dir, struct dentry *dentry,
1218 int mode, dev_t dev);
1219 int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
1220 struct inode *new_dir, struct dentry *new_dentry);
1221 int (*inode_readlink) (struct dentry *dentry);
1222 int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
1223 int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd);
1224 int (*inode_setattr) (struct dentry *dentry, struct iattr *attr);
1225 int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
1226 void (*inode_delete) (struct inode *inode);
1227 int (*inode_setxattr) (struct dentry *dentry, char *name, void *value,
1228 size_t size, int flags);
1229 void (*inode_post_setxattr) (struct dentry *dentry, char *name, void *value,
1230 size_t size, int flags);
1231 int (*inode_getxattr) (struct dentry *dentry, char *name);
1232 int (*inode_listxattr) (struct dentry *dentry);
1233 int (*inode_removexattr) (struct dentry *dentry, char *name);
1234 const char *(*inode_xattr_getsuffix) (void);
1235 int (*inode_getsecurity)(const struct inode *inode, const char *name, void *buffer, size_t size, int err);
1236 int (*inode_setsecurity)(struct inode *inode, const char *name, const void *value, size_t size, int flags);
1237 int (*inode_listsecurity)(struct inode *inode, char *buffer, size_t buffer_size);
1239 int (*file_permission) (struct file * file, int mask);
1240 int (*file_alloc_security) (struct file * file);
1241 void (*file_free_security) (struct file * file);
1242 int (*file_ioctl) (struct file * file, unsigned int cmd,
1244 int (*file_mmap) (struct file * file,
1245 unsigned long reqprot, unsigned long prot,
1246 unsigned long flags, unsigned long addr,
1247 unsigned long addr_only);
1248 int (*file_mprotect) (struct vm_area_struct * vma,
1249 unsigned long reqprot,
1250 unsigned long prot);
1251 int (*file_lock) (struct file * file, unsigned int cmd);
1252 int (*file_fcntl) (struct file * file, unsigned int cmd,
1254 int (*file_set_fowner) (struct file * file);
1255 int (*file_send_sigiotask) (struct task_struct * tsk,
1256 struct fown_struct * fown, int sig);
1257 int (*file_receive) (struct file * file);
1259 int (*task_create) (unsigned long clone_flags);
1260 int (*task_alloc_security) (struct task_struct * p);
1261 void (*task_free_security) (struct task_struct * p);
1262 int (*task_setuid) (uid_t id0, uid_t id1, uid_t id2, int flags);
1263 int (*task_post_setuid) (uid_t old_ruid /* or fsuid */ ,
1264 uid_t old_euid, uid_t old_suid, int flags);
1265 int (*task_setgid) (gid_t id0, gid_t id1, gid_t id2, int flags);
1266 int (*task_setpgid) (struct task_struct * p, pid_t pgid);
1267 int (*task_getpgid) (struct task_struct * p);
1268 int (*task_getsid) (struct task_struct * p);
1269 void (*task_getsecid) (struct task_struct * p, u32 * secid);
1270 int (*task_setgroups) (struct group_info *group_info);
1271 int (*task_setnice) (struct task_struct * p, int nice);
1272 int (*task_setioprio) (struct task_struct * p, int ioprio);
1273 int (*task_getioprio) (struct task_struct * p);
1274 int (*task_setrlimit) (unsigned int resource, struct rlimit * new_rlim);
1275 int (*task_setscheduler) (struct task_struct * p, int policy,
1276 struct sched_param * lp);
1277 int (*task_getscheduler) (struct task_struct * p);
1278 int (*task_movememory) (struct task_struct * p);
1279 int (*task_kill) (struct task_struct * p,
1280 struct siginfo * info, int sig, u32 secid);
1281 int (*task_wait) (struct task_struct * p);
1282 int (*task_prctl) (int option, unsigned long arg2,
1283 unsigned long arg3, unsigned long arg4,
1284 unsigned long arg5);
1285 void (*task_reparent_to_init) (struct task_struct * p);
1286 void (*task_to_inode)(struct task_struct *p, struct inode *inode);
1288 int (*ipc_permission) (struct kern_ipc_perm * ipcp, short flag);
1290 int (*msg_msg_alloc_security) (struct msg_msg * msg);
1291 void (*msg_msg_free_security) (struct msg_msg * msg);
1293 int (*msg_queue_alloc_security) (struct msg_queue * msq);
1294 void (*msg_queue_free_security) (struct msg_queue * msq);
1295 int (*msg_queue_associate) (struct msg_queue * msq, int msqflg);
1296 int (*msg_queue_msgctl) (struct msg_queue * msq, int cmd);
1297 int (*msg_queue_msgsnd) (struct msg_queue * msq,
1298 struct msg_msg * msg, int msqflg);
1299 int (*msg_queue_msgrcv) (struct msg_queue * msq,
1300 struct msg_msg * msg,
1301 struct task_struct * target,
1302 long type, int mode);
1304 int (*shm_alloc_security) (struct shmid_kernel * shp);
1305 void (*shm_free_security) (struct shmid_kernel * shp);
1306 int (*shm_associate) (struct shmid_kernel * shp, int shmflg);
1307 int (*shm_shmctl) (struct shmid_kernel * shp, int cmd);
1308 int (*shm_shmat) (struct shmid_kernel * shp,
1309 char __user *shmaddr, int shmflg);
1311 int (*sem_alloc_security) (struct sem_array * sma);
1312 void (*sem_free_security) (struct sem_array * sma);
1313 int (*sem_associate) (struct sem_array * sma, int semflg);
1314 int (*sem_semctl) (struct sem_array * sma, int cmd);
1315 int (*sem_semop) (struct sem_array * sma,
1316 struct sembuf * sops, unsigned nsops, int alter);
1318 int (*netlink_send) (struct sock * sk, struct sk_buff * skb);
1319 int (*netlink_recv) (struct sk_buff * skb, int cap);
1321 /* allow module stacking */
1322 int (*register_security) (const char *name,
1323 struct security_operations *ops);
1324 int (*unregister_security) (const char *name,
1325 struct security_operations *ops);
1327 void (*d_instantiate) (struct dentry *dentry, struct inode *inode);
1329 int (*getprocattr)(struct task_struct *p, char *name, char **value);
1330 int (*setprocattr)(struct task_struct *p, char *name, void *value, size_t size);
1331 int (*secid_to_secctx)(u32 secid, char **secdata, u32 *seclen);
1332 void (*release_secctx)(char *secdata, u32 seclen);
1334 #ifdef CONFIG_SECURITY_NETWORK
1335 int (*unix_stream_connect) (struct socket * sock,
1336 struct socket * other, struct sock * newsk);
1337 int (*unix_may_send) (struct socket * sock, struct socket * other);
1339 int (*socket_create) (int family, int type, int protocol, int kern);
1340 int (*socket_post_create) (struct socket * sock, int family,
1341 int type, int protocol, int kern);
1342 int (*socket_bind) (struct socket * sock,
1343 struct sockaddr * address, int addrlen);
1344 int (*socket_connect) (struct socket * sock,
1345 struct sockaddr * address, int addrlen);
1346 int (*socket_listen) (struct socket * sock, int backlog);
1347 int (*socket_accept) (struct socket * sock, struct socket * newsock);
1348 void (*socket_post_accept) (struct socket * sock,
1349 struct socket * newsock);
1350 int (*socket_sendmsg) (struct socket * sock,
1351 struct msghdr * msg, int size);
1352 int (*socket_recvmsg) (struct socket * sock,
1353 struct msghdr * msg, int size, int flags);
1354 int (*socket_getsockname) (struct socket * sock);
1355 int (*socket_getpeername) (struct socket * sock);
1356 int (*socket_getsockopt) (struct socket * sock, int level, int optname);
1357 int (*socket_setsockopt) (struct socket * sock, int level, int optname);
1358 int (*socket_shutdown) (struct socket * sock, int how);
1359 int (*socket_sock_rcv_skb) (struct sock * sk, struct sk_buff * skb);
1360 int (*socket_getpeersec_stream) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len);
1361 int (*socket_getpeersec_dgram) (struct socket *sock, struct sk_buff *skb, u32 *secid);
1362 int (*sk_alloc_security) (struct sock *sk, int family, gfp_t priority);
1363 void (*sk_free_security) (struct sock *sk);
1364 void (*sk_clone_security) (const struct sock *sk, struct sock *newsk);
1365 void (*sk_getsecid) (struct sock *sk, u32 *secid);
1366 void (*sock_graft)(struct sock* sk, struct socket *parent);
1367 int (*inet_conn_request)(struct sock *sk, struct sk_buff *skb,
1368 struct request_sock *req);
1369 void (*inet_csk_clone)(struct sock *newsk, const struct request_sock *req);
1370 void (*inet_conn_established)(struct sock *sk, struct sk_buff *skb);
1371 void (*req_classify_flow)(const struct request_sock *req, struct flowi *fl);
1372 #endif /* CONFIG_SECURITY_NETWORK */
1374 #ifdef CONFIG_SECURITY_NETWORK_XFRM
1375 int (*xfrm_policy_alloc_security) (struct xfrm_policy *xp,
1376 struct xfrm_user_sec_ctx *sec_ctx);
1377 int (*xfrm_policy_clone_security) (struct xfrm_policy *old, struct xfrm_policy *new);
1378 void (*xfrm_policy_free_security) (struct xfrm_policy *xp);
1379 int (*xfrm_policy_delete_security) (struct xfrm_policy *xp);
1380 int (*xfrm_state_alloc_security) (struct xfrm_state *x,
1381 struct xfrm_user_sec_ctx *sec_ctx,
1383 void (*xfrm_state_free_security) (struct xfrm_state *x);
1384 int (*xfrm_state_delete_security) (struct xfrm_state *x);
1385 int (*xfrm_policy_lookup)(struct xfrm_policy *xp, u32 fl_secid, u8 dir);
1386 int (*xfrm_state_pol_flow_match)(struct xfrm_state *x,
1387 struct xfrm_policy *xp, struct flowi *fl);
1388 int (*xfrm_decode_session)(struct sk_buff *skb, u32 *secid, int ckall);
1389 #endif /* CONFIG_SECURITY_NETWORK_XFRM */
1391 /* key management security hooks */
1393 int (*key_alloc)(struct key *key, struct task_struct *tsk, unsigned long flags);
1394 void (*key_free)(struct key *key);
1395 int (*key_permission)(key_ref_t key_ref,
1396 struct task_struct *context,
1399 #endif /* CONFIG_KEYS */
1403 /* global variables */
1404 extern struct security_operations *security_ops;
1407 static inline int security_ptrace (struct task_struct * parent, struct task_struct * child)
1409 return security_ops->ptrace (parent, child);
1412 static inline int security_capget (struct task_struct *target,
1413 kernel_cap_t *effective,
1414 kernel_cap_t *inheritable,
1415 kernel_cap_t *permitted)
1417 return security_ops->capget (target, effective, inheritable, permitted);
1420 static inline int security_capset_check (struct task_struct *target,
1421 kernel_cap_t *effective,
1422 kernel_cap_t *inheritable,
1423 kernel_cap_t *permitted)
1425 return security_ops->capset_check (target, effective, inheritable, permitted);
1428 static inline void security_capset_set (struct task_struct *target,
1429 kernel_cap_t *effective,
1430 kernel_cap_t *inheritable,
1431 kernel_cap_t *permitted)
1433 security_ops->capset_set (target, effective, inheritable, permitted);
1436 static inline int security_capable(struct task_struct *tsk, int cap)
1438 return security_ops->capable(tsk, cap);
1441 static inline int security_acct (struct file *file)
1443 return security_ops->acct (file);
1446 static inline int security_sysctl(struct ctl_table *table, int op)
1448 return security_ops->sysctl(table, op);
1451 static inline int security_quotactl (int cmds, int type, int id,
1452 struct super_block *sb)
1454 return security_ops->quotactl (cmds, type, id, sb);
1457 static inline int security_quota_on (struct dentry * dentry)
1459 return security_ops->quota_on (dentry);
1462 static inline int security_syslog(int type)
1464 return security_ops->syslog(type);
1467 static inline int security_settime(struct timespec *ts, struct timezone *tz)
1469 return security_ops->settime(ts, tz);
1473 static inline int security_vm_enough_memory(long pages)
1475 return security_ops->vm_enough_memory(pages);
1478 static inline int security_bprm_alloc (struct linux_binprm *bprm)
1480 return security_ops->bprm_alloc_security (bprm);
1482 static inline void security_bprm_free (struct linux_binprm *bprm)
1484 security_ops->bprm_free_security (bprm);
1486 static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
1488 security_ops->bprm_apply_creds (bprm, unsafe);
1490 static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
1492 security_ops->bprm_post_apply_creds (bprm);
1494 static inline int security_bprm_set (struct linux_binprm *bprm)
1496 return security_ops->bprm_set_security (bprm);
1499 static inline int security_bprm_check (struct linux_binprm *bprm)
1501 return security_ops->bprm_check_security (bprm);
1504 static inline int security_bprm_secureexec (struct linux_binprm *bprm)
1506 return security_ops->bprm_secureexec (bprm);
1509 static inline int security_sb_alloc (struct super_block *sb)
1511 return security_ops->sb_alloc_security (sb);
1514 static inline void security_sb_free (struct super_block *sb)
1516 security_ops->sb_free_security (sb);
1519 static inline int security_sb_copy_data (struct file_system_type *type,
1520 void *orig, void *copy)
1522 return security_ops->sb_copy_data (type, orig, copy);
1525 static inline int security_sb_kern_mount (struct super_block *sb, void *data)
1527 return security_ops->sb_kern_mount (sb, data);
1530 static inline int security_sb_statfs (struct dentry *dentry)
1532 return security_ops->sb_statfs (dentry);
1535 static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
1536 char *type, unsigned long flags,
1539 return security_ops->sb_mount (dev_name, nd, type, flags, data);
1542 static inline int security_sb_check_sb (struct vfsmount *mnt,
1543 struct nameidata *nd)
1545 return security_ops->sb_check_sb (mnt, nd);
1548 static inline int security_sb_umount (struct vfsmount *mnt, int flags)
1550 return security_ops->sb_umount (mnt, flags);
1553 static inline void security_sb_umount_close (struct vfsmount *mnt)
1555 security_ops->sb_umount_close (mnt);
1558 static inline void security_sb_umount_busy (struct vfsmount *mnt)
1560 security_ops->sb_umount_busy (mnt);
1563 static inline void security_sb_post_remount (struct vfsmount *mnt,
1564 unsigned long flags, void *data)
1566 security_ops->sb_post_remount (mnt, flags, data);
1569 static inline void security_sb_post_mountroot (void)
1571 security_ops->sb_post_mountroot ();
1574 static inline void security_sb_post_addmount (struct vfsmount *mnt,
1575 struct nameidata *mountpoint_nd)
1577 security_ops->sb_post_addmount (mnt, mountpoint_nd);
1580 static inline int security_sb_pivotroot (struct nameidata *old_nd,
1581 struct nameidata *new_nd)
1583 return security_ops->sb_pivotroot (old_nd, new_nd);
1586 static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
1587 struct nameidata *new_nd)
1589 security_ops->sb_post_pivotroot (old_nd, new_nd);
1592 static inline int security_inode_alloc (struct inode *inode)
1594 inode->i_security = NULL;
1595 return security_ops->inode_alloc_security (inode);
1598 static inline void security_inode_free (struct inode *inode)
1600 security_ops->inode_free_security (inode);
1603 static inline int security_inode_init_security (struct inode *inode,
1609 if (unlikely (IS_PRIVATE (inode)))
1611 return security_ops->inode_init_security (inode, dir, name, value, len);
1614 static inline int security_inode_create (struct inode *dir,
1615 struct dentry *dentry,
1618 if (unlikely (IS_PRIVATE (dir)))
1620 return security_ops->inode_create (dir, dentry, mode);
1623 static inline int security_inode_link (struct dentry *old_dentry,
1625 struct dentry *new_dentry)
1627 if (unlikely (IS_PRIVATE (old_dentry->d_inode)))
1629 return security_ops->inode_link (old_dentry, dir, new_dentry);
1632 static inline int security_inode_unlink (struct inode *dir,
1633 struct dentry *dentry)
1635 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1637 return security_ops->inode_unlink (dir, dentry);
1640 static inline int security_inode_symlink (struct inode *dir,
1641 struct dentry *dentry,
1642 const char *old_name)
1644 if (unlikely (IS_PRIVATE (dir)))
1646 return security_ops->inode_symlink (dir, dentry, old_name);
1649 static inline int security_inode_mkdir (struct inode *dir,
1650 struct dentry *dentry,
1653 if (unlikely (IS_PRIVATE (dir)))
1655 return security_ops->inode_mkdir (dir, dentry, mode);
1658 static inline int security_inode_rmdir (struct inode *dir,
1659 struct dentry *dentry)
1661 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1663 return security_ops->inode_rmdir (dir, dentry);
1666 static inline int security_inode_mknod (struct inode *dir,
1667 struct dentry *dentry,
1668 int mode, dev_t dev)
1670 if (unlikely (IS_PRIVATE (dir)))
1672 return security_ops->inode_mknod (dir, dentry, mode, dev);
1675 static inline int security_inode_rename (struct inode *old_dir,
1676 struct dentry *old_dentry,
1677 struct inode *new_dir,
1678 struct dentry *new_dentry)
1680 if (unlikely (IS_PRIVATE (old_dentry->d_inode) ||
1681 (new_dentry->d_inode && IS_PRIVATE (new_dentry->d_inode))))
1683 return security_ops->inode_rename (old_dir, old_dentry,
1684 new_dir, new_dentry);
1687 static inline int security_inode_readlink (struct dentry *dentry)
1689 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1691 return security_ops->inode_readlink (dentry);
1694 static inline int security_inode_follow_link (struct dentry *dentry,
1695 struct nameidata *nd)
1697 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1699 return security_ops->inode_follow_link (dentry, nd);
1702 static inline int security_inode_permission (struct inode *inode, int mask,
1703 struct nameidata *nd)
1705 if (unlikely (IS_PRIVATE (inode)))
1707 return security_ops->inode_permission (inode, mask, nd);
1710 static inline int security_inode_setattr (struct dentry *dentry,
1713 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1715 return security_ops->inode_setattr (dentry, attr);
1718 static inline int security_inode_getattr (struct vfsmount *mnt,
1719 struct dentry *dentry)
1721 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1723 return security_ops->inode_getattr (mnt, dentry);
1726 static inline void security_inode_delete (struct inode *inode)
1728 if (unlikely (IS_PRIVATE (inode)))
1730 security_ops->inode_delete (inode);
1733 static inline int security_inode_setxattr (struct dentry *dentry, char *name,
1734 void *value, size_t size, int flags)
1736 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1738 return security_ops->inode_setxattr (dentry, name, value, size, flags);
1741 static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
1742 void *value, size_t size, int flags)
1744 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1746 security_ops->inode_post_setxattr (dentry, name, value, size, flags);
1749 static inline int security_inode_getxattr (struct dentry *dentry, char *name)
1751 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1753 return security_ops->inode_getxattr (dentry, name);
1756 static inline int security_inode_listxattr (struct dentry *dentry)
1758 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1760 return security_ops->inode_listxattr (dentry);
1763 static inline int security_inode_removexattr (struct dentry *dentry, char *name)
1765 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1767 return security_ops->inode_removexattr (dentry, name);
1770 static inline const char *security_inode_xattr_getsuffix(void)
1772 return security_ops->inode_xattr_getsuffix();
1775 static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void *buffer, size_t size, int err)
1777 if (unlikely (IS_PRIVATE (inode)))
1779 return security_ops->inode_getsecurity(inode, name, buffer, size, err);
1782 static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
1784 if (unlikely (IS_PRIVATE (inode)))
1786 return security_ops->inode_setsecurity(inode, name, value, size, flags);
1789 static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
1791 if (unlikely (IS_PRIVATE (inode)))
1793 return security_ops->inode_listsecurity(inode, buffer, buffer_size);
1796 static inline int security_file_permission (struct file *file, int mask)
1798 return security_ops->file_permission (file, mask);
1801 static inline int security_file_alloc (struct file *file)
1803 return security_ops->file_alloc_security (file);
1806 static inline void security_file_free (struct file *file)
1808 security_ops->file_free_security (file);
1811 static inline int security_file_ioctl (struct file *file, unsigned int cmd,
1814 return security_ops->file_ioctl (file, cmd, arg);
1817 static inline int security_file_mmap (struct file *file, unsigned long reqprot,
1819 unsigned long flags,
1821 unsigned long addr_only)
1823 return security_ops->file_mmap (file, reqprot, prot, flags, addr,
1827 static inline int security_file_mprotect (struct vm_area_struct *vma,
1828 unsigned long reqprot,
1831 return security_ops->file_mprotect (vma, reqprot, prot);
1834 static inline int security_file_lock (struct file *file, unsigned int cmd)
1836 return security_ops->file_lock (file, cmd);
1839 static inline int security_file_fcntl (struct file *file, unsigned int cmd,
1842 return security_ops->file_fcntl (file, cmd, arg);
1845 static inline int security_file_set_fowner (struct file *file)
1847 return security_ops->file_set_fowner (file);
1850 static inline int security_file_send_sigiotask (struct task_struct *tsk,
1851 struct fown_struct *fown,
1854 return security_ops->file_send_sigiotask (tsk, fown, sig);
1857 static inline int security_file_receive (struct file *file)
1859 return security_ops->file_receive (file);
1862 static inline int security_task_create (unsigned long clone_flags)
1864 return security_ops->task_create (clone_flags);
1867 static inline int security_task_alloc (struct task_struct *p)
1869 return security_ops->task_alloc_security (p);
1872 static inline void security_task_free (struct task_struct *p)
1874 security_ops->task_free_security (p);
1877 static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
1880 return security_ops->task_setuid (id0, id1, id2, flags);
1883 static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
1884 uid_t old_suid, int flags)
1886 return security_ops->task_post_setuid (old_ruid, old_euid, old_suid, flags);
1889 static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
1892 return security_ops->task_setgid (id0, id1, id2, flags);
1895 static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
1897 return security_ops->task_setpgid (p, pgid);
1900 static inline int security_task_getpgid (struct task_struct *p)
1902 return security_ops->task_getpgid (p);
1905 static inline int security_task_getsid (struct task_struct *p)
1907 return security_ops->task_getsid (p);
1910 static inline void security_task_getsecid (struct task_struct *p, u32 *secid)
1912 security_ops->task_getsecid (p, secid);
1915 static inline int security_task_setgroups (struct group_info *group_info)
1917 return security_ops->task_setgroups (group_info);
1920 static inline int security_task_setnice (struct task_struct *p, int nice)
1922 return security_ops->task_setnice (p, nice);
1925 static inline int security_task_setioprio (struct task_struct *p, int ioprio)
1927 return security_ops->task_setioprio (p, ioprio);
1930 static inline int security_task_getioprio (struct task_struct *p)
1932 return security_ops->task_getioprio (p);
1935 static inline int security_task_setrlimit (unsigned int resource,
1936 struct rlimit *new_rlim)
1938 return security_ops->task_setrlimit (resource, new_rlim);
1941 static inline int security_task_setscheduler (struct task_struct *p,
1943 struct sched_param *lp)
1945 return security_ops->task_setscheduler (p, policy, lp);
1948 static inline int security_task_getscheduler (struct task_struct *p)
1950 return security_ops->task_getscheduler (p);
1953 static inline int security_task_movememory (struct task_struct *p)
1955 return security_ops->task_movememory (p);
1958 static inline int security_task_kill (struct task_struct *p,
1959 struct siginfo *info, int sig,
1962 return security_ops->task_kill (p, info, sig, secid);
1965 static inline int security_task_wait (struct task_struct *p)
1967 return security_ops->task_wait (p);
1970 static inline int security_task_prctl (int option, unsigned long arg2,
1975 return security_ops->task_prctl (option, arg2, arg3, arg4, arg5);
1978 static inline void security_task_reparent_to_init (struct task_struct *p)
1980 security_ops->task_reparent_to_init (p);
1983 static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
1985 security_ops->task_to_inode(p, inode);
1988 static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
1991 return security_ops->ipc_permission (ipcp, flag);
1994 static inline int security_msg_msg_alloc (struct msg_msg * msg)
1996 return security_ops->msg_msg_alloc_security (msg);
1999 static inline void security_msg_msg_free (struct msg_msg * msg)
2001 security_ops->msg_msg_free_security(msg);
2004 static inline int security_msg_queue_alloc (struct msg_queue *msq)
2006 return security_ops->msg_queue_alloc_security (msq);
2009 static inline void security_msg_queue_free (struct msg_queue *msq)
2011 security_ops->msg_queue_free_security (msq);
2014 static inline int security_msg_queue_associate (struct msg_queue * msq,
2017 return security_ops->msg_queue_associate (msq, msqflg);
2020 static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
2022 return security_ops->msg_queue_msgctl (msq, cmd);
2025 static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
2026 struct msg_msg * msg, int msqflg)
2028 return security_ops->msg_queue_msgsnd (msq, msg, msqflg);
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)
2036 return security_ops->msg_queue_msgrcv (msq, msg, target, type, mode);
2039 static inline int security_shm_alloc (struct shmid_kernel *shp)
2041 return security_ops->shm_alloc_security (shp);
2044 static inline void security_shm_free (struct shmid_kernel *shp)
2046 security_ops->shm_free_security (shp);
2049 static inline int security_shm_associate (struct shmid_kernel * shp,
2052 return security_ops->shm_associate(shp, shmflg);
2055 static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
2057 return security_ops->shm_shmctl (shp, cmd);
2060 static inline int security_shm_shmat (struct shmid_kernel * shp,
2061 char __user *shmaddr, int shmflg)
2063 return security_ops->shm_shmat(shp, shmaddr, shmflg);
2066 static inline int security_sem_alloc (struct sem_array *sma)
2068 return security_ops->sem_alloc_security (sma);
2071 static inline void security_sem_free (struct sem_array *sma)
2073 security_ops->sem_free_security (sma);
2076 static inline int security_sem_associate (struct sem_array * sma, int semflg)
2078 return security_ops->sem_associate (sma, semflg);
2081 static inline int security_sem_semctl (struct sem_array * sma, int cmd)
2083 return security_ops->sem_semctl(sma, cmd);
2086 static inline int security_sem_semop (struct sem_array * sma,
2087 struct sembuf * sops, unsigned nsops,
2090 return security_ops->sem_semop(sma, sops, nsops, alter);
2093 static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
2095 if (unlikely (inode && IS_PRIVATE (inode)))
2097 security_ops->d_instantiate (dentry, inode);
2100 static inline int security_getprocattr(struct task_struct *p, char *name, char **value)
2102 return security_ops->getprocattr(p, name, value);
2105 static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2107 return security_ops->setprocattr(p, name, value, size);
2110 static inline int security_netlink_send(struct sock *sk, struct sk_buff * skb)
2112 return security_ops->netlink_send(sk, skb);
2115 static inline int security_netlink_recv(struct sk_buff * skb, int cap)
2117 return security_ops->netlink_recv(skb, cap);
2120 static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
2122 return security_ops->secid_to_secctx(secid, secdata, seclen);
2125 static inline void security_release_secctx(char *secdata, u32 seclen)
2127 return security_ops->release_secctx(secdata, seclen);
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 const 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);
2143 #else /* CONFIG_SECURITY */
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.
2150 static inline int security_init(void)
2155 static inline int security_ptrace (struct task_struct *parent, struct task_struct * child)
2157 return cap_ptrace (parent, child);
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)
2165 return cap_capget (target, effective, inheritable, permitted);
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)
2173 return cap_capset_check (target, effective, inheritable, permitted);
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)
2181 cap_capset_set (target, effective, inheritable, permitted);
2184 static inline int security_capable(struct task_struct *tsk, int cap)
2186 return cap_capable(tsk, cap);
2189 static inline int security_acct (struct file *file)
2194 static inline int security_sysctl(struct ctl_table *table, int op)
2199 static inline int security_quotactl (int cmds, int type, int id,
2200 struct super_block * sb)
2205 static inline int security_quota_on (struct dentry * dentry)
2210 static inline int security_syslog(int type)
2212 return cap_syslog(type);
2215 static inline int security_settime(struct timespec *ts, struct timezone *tz)
2217 return cap_settime(ts, tz);
2220 static inline int security_vm_enough_memory(long pages)
2222 return cap_vm_enough_memory(pages);
2225 static inline int security_bprm_alloc (struct linux_binprm *bprm)
2230 static inline void security_bprm_free (struct linux_binprm *bprm)
2233 static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
2235 cap_bprm_apply_creds (bprm, unsafe);
2238 static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
2243 static inline int security_bprm_set (struct linux_binprm *bprm)
2245 return cap_bprm_set_security (bprm);
2248 static inline int security_bprm_check (struct linux_binprm *bprm)
2253 static inline int security_bprm_secureexec (struct linux_binprm *bprm)
2255 return cap_bprm_secureexec(bprm);
2258 static inline int security_sb_alloc (struct super_block *sb)
2263 static inline void security_sb_free (struct super_block *sb)
2266 static inline int security_sb_copy_data (struct file_system_type *type,
2267 void *orig, void *copy)
2272 static inline int security_sb_kern_mount (struct super_block *sb, void *data)
2277 static inline int security_sb_statfs (struct dentry *dentry)
2282 static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
2283 char *type, unsigned long flags,
2289 static inline int security_sb_check_sb (struct vfsmount *mnt,
2290 struct nameidata *nd)
2295 static inline int security_sb_umount (struct vfsmount *mnt, int flags)
2300 static inline void security_sb_umount_close (struct vfsmount *mnt)
2303 static inline void security_sb_umount_busy (struct vfsmount *mnt)
2306 static inline void security_sb_post_remount (struct vfsmount *mnt,
2307 unsigned long flags, void *data)
2310 static inline void security_sb_post_mountroot (void)
2313 static inline void security_sb_post_addmount (struct vfsmount *mnt,
2314 struct nameidata *mountpoint_nd)
2317 static inline int security_sb_pivotroot (struct nameidata *old_nd,
2318 struct nameidata *new_nd)
2323 static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
2324 struct nameidata *new_nd)
2327 static inline int security_inode_alloc (struct inode *inode)
2332 static inline void security_inode_free (struct inode *inode)
2335 static inline int security_inode_init_security (struct inode *inode,
2344 static inline int security_inode_create (struct inode *dir,
2345 struct dentry *dentry,
2351 static inline int security_inode_link (struct dentry *old_dentry,
2353 struct dentry *new_dentry)
2358 static inline int security_inode_unlink (struct inode *dir,
2359 struct dentry *dentry)
2364 static inline int security_inode_symlink (struct inode *dir,
2365 struct dentry *dentry,
2366 const char *old_name)
2371 static inline int security_inode_mkdir (struct inode *dir,
2372 struct dentry *dentry,
2378 static inline int security_inode_rmdir (struct inode *dir,
2379 struct dentry *dentry)
2384 static inline int security_inode_mknod (struct inode *dir,
2385 struct dentry *dentry,
2386 int mode, dev_t dev)
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)
2399 static inline int security_inode_readlink (struct dentry *dentry)
2404 static inline int security_inode_follow_link (struct dentry *dentry,
2405 struct nameidata *nd)
2410 static inline int security_inode_permission (struct inode *inode, int mask,
2411 struct nameidata *nd)
2416 static inline int security_inode_setattr (struct dentry *dentry,
2422 static inline int security_inode_getattr (struct vfsmount *mnt,
2423 struct dentry *dentry)
2428 static inline void security_inode_delete (struct inode *inode)
2431 static inline int security_inode_setxattr (struct dentry *dentry, char *name,
2432 void *value, size_t size, int flags)
2434 return cap_inode_setxattr(dentry, name, value, size, flags);
2437 static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
2438 void *value, size_t size, int flags)
2441 static inline int security_inode_getxattr (struct dentry *dentry, char *name)
2446 static inline int security_inode_listxattr (struct dentry *dentry)
2451 static inline int security_inode_removexattr (struct dentry *dentry, char *name)
2453 return cap_inode_removexattr(dentry, name);
2456 static inline const char *security_inode_xattr_getsuffix (void)
2461 static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void *buffer, size_t size, int err)
2466 static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
2471 static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
2476 static inline int security_file_permission (struct file *file, int mask)
2481 static inline int security_file_alloc (struct file *file)
2486 static inline void security_file_free (struct file *file)
2489 static inline int security_file_ioctl (struct file *file, unsigned int cmd,
2495 static inline int security_file_mmap (struct file *file, unsigned long reqprot,
2497 unsigned long flags,
2499 unsigned long addr_only)
2504 static inline int security_file_mprotect (struct vm_area_struct *vma,
2505 unsigned long reqprot,
2511 static inline int security_file_lock (struct file *file, unsigned int cmd)
2516 static inline int security_file_fcntl (struct file *file, unsigned int cmd,
2522 static inline int security_file_set_fowner (struct file *file)
2527 static inline int security_file_send_sigiotask (struct task_struct *tsk,
2528 struct fown_struct *fown,
2534 static inline int security_file_receive (struct file *file)
2539 static inline int security_task_create (unsigned long clone_flags)
2544 static inline int security_task_alloc (struct task_struct *p)
2549 static inline void security_task_free (struct task_struct *p)
2552 static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
2558 static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
2559 uid_t old_suid, int flags)
2561 return cap_task_post_setuid (old_ruid, old_euid, old_suid, flags);
2564 static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
2570 static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
2575 static inline int security_task_getpgid (struct task_struct *p)
2580 static inline int security_task_getsid (struct task_struct *p)
2585 static inline void security_task_getsecid (struct task_struct *p, u32 *secid)
2588 static inline int security_task_setgroups (struct group_info *group_info)
2593 static inline int security_task_setnice (struct task_struct *p, int nice)
2598 static inline int security_task_setioprio (struct task_struct *p, int ioprio)
2603 static inline int security_task_getioprio (struct task_struct *p)
2608 static inline int security_task_setrlimit (unsigned int resource,
2609 struct rlimit *new_rlim)
2614 static inline int security_task_setscheduler (struct task_struct *p,
2616 struct sched_param *lp)
2621 static inline int security_task_getscheduler (struct task_struct *p)
2626 static inline int security_task_movememory (struct task_struct *p)
2631 static inline int security_task_kill (struct task_struct *p,
2632 struct siginfo *info, int sig,
2638 static inline int security_task_wait (struct task_struct *p)
2643 static inline int security_task_prctl (int option, unsigned long arg2,
2651 static inline void security_task_reparent_to_init (struct task_struct *p)
2653 cap_task_reparent_to_init (p);
2656 static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
2659 static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
2665 static inline int security_msg_msg_alloc (struct msg_msg * msg)
2670 static inline void security_msg_msg_free (struct msg_msg * msg)
2673 static inline int security_msg_queue_alloc (struct msg_queue *msq)
2678 static inline void security_msg_queue_free (struct msg_queue *msq)
2681 static inline int security_msg_queue_associate (struct msg_queue * msq,
2687 static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
2692 static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
2693 struct msg_msg * msg, int msqflg)
2698 static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
2699 struct msg_msg * msg,
2700 struct task_struct * target,
2701 long type, int mode)
2706 static inline int security_shm_alloc (struct shmid_kernel *shp)
2711 static inline void security_shm_free (struct shmid_kernel *shp)
2714 static inline int security_shm_associate (struct shmid_kernel * shp,
2720 static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
2725 static inline int security_shm_shmat (struct shmid_kernel * shp,
2726 char __user *shmaddr, int shmflg)
2731 static inline int security_sem_alloc (struct sem_array *sma)
2736 static inline void security_sem_free (struct sem_array *sma)
2739 static inline int security_sem_associate (struct sem_array * sma, int semflg)
2744 static inline int security_sem_semctl (struct sem_array * sma, int cmd)
2749 static inline int security_sem_semop (struct sem_array * sma,
2750 struct sembuf * sops, unsigned nsops,
2756 static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
2759 static inline int security_getprocattr(struct task_struct *p, char *name, char **value)
2764 static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2769 static inline int security_netlink_send (struct sock *sk, struct sk_buff *skb)
2771 return cap_netlink_send (sk, skb);
2774 static inline int security_netlink_recv (struct sk_buff *skb, int cap)
2776 return cap_netlink_recv (skb, cap);
2779 static inline struct dentry *securityfs_create_dir(const char *name,
2780 struct dentry *parent)
2782 return ERR_PTR(-ENODEV);
2785 static inline struct dentry *securityfs_create_file(const char *name,
2787 struct dentry *parent,
2789 struct file_operations *fops)
2791 return ERR_PTR(-ENODEV);
2794 static inline void securityfs_remove(struct dentry *dentry)
2798 static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
2803 static inline void security_release_secctx(char *secdata, u32 seclen)
2806 #endif /* CONFIG_SECURITY */
2808 #ifdef CONFIG_SECURITY_NETWORK
2809 static inline int security_unix_stream_connect(struct socket * sock,
2810 struct socket * other,
2811 struct sock * newsk)
2813 return security_ops->unix_stream_connect(sock, other, newsk);
2817 static inline int security_unix_may_send(struct socket * sock,
2818 struct socket * other)
2820 return security_ops->unix_may_send(sock, other);
2823 static inline int security_socket_create (int family, int type,
2824 int protocol, int kern)
2826 return security_ops->socket_create(family, type, protocol, kern);
2829 static inline int security_socket_post_create(struct socket * sock,
2832 int protocol, int kern)
2834 return security_ops->socket_post_create(sock, family, type,
2838 static inline int security_socket_bind(struct socket * sock,
2839 struct sockaddr * address,
2842 return security_ops->socket_bind(sock, address, addrlen);
2845 static inline int security_socket_connect(struct socket * sock,
2846 struct sockaddr * address,
2849 return security_ops->socket_connect(sock, address, addrlen);
2852 static inline int security_socket_listen(struct socket * sock, int backlog)
2854 return security_ops->socket_listen(sock, backlog);
2857 static inline int security_socket_accept(struct socket * sock,
2858 struct socket * newsock)
2860 return security_ops->socket_accept(sock, newsock);
2863 static inline void security_socket_post_accept(struct socket * sock,
2864 struct socket * newsock)
2866 security_ops->socket_post_accept(sock, newsock);
2869 static inline int security_socket_sendmsg(struct socket * sock,
2870 struct msghdr * msg, int size)
2872 return security_ops->socket_sendmsg(sock, msg, size);
2875 static inline int security_socket_recvmsg(struct socket * sock,
2876 struct msghdr * msg, int size,
2879 return security_ops->socket_recvmsg(sock, msg, size, flags);
2882 static inline int security_socket_getsockname(struct socket * sock)
2884 return security_ops->socket_getsockname(sock);
2887 static inline int security_socket_getpeername(struct socket * sock)
2889 return security_ops->socket_getpeername(sock);
2892 static inline int security_socket_getsockopt(struct socket * sock,
2893 int level, int optname)
2895 return security_ops->socket_getsockopt(sock, level, optname);
2898 static inline int security_socket_setsockopt(struct socket * sock,
2899 int level, int optname)
2901 return security_ops->socket_setsockopt(sock, level, optname);
2904 static inline int security_socket_shutdown(struct socket * sock, int how)
2906 return security_ops->socket_shutdown(sock, how);
2909 static inline int security_sock_rcv_skb (struct sock * sk,
2910 struct sk_buff * skb)
2912 return security_ops->socket_sock_rcv_skb (sk, skb);
2915 static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2916 int __user *optlen, unsigned len)
2918 return security_ops->socket_getpeersec_stream(sock, optval, optlen, len);
2921 static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
2923 return security_ops->socket_getpeersec_dgram(sock, skb, secid);
2926 static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
2928 return security_ops->sk_alloc_security(sk, family, priority);
2931 static inline void security_sk_free(struct sock *sk)
2933 return security_ops->sk_free_security(sk);
2936 static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
2938 return security_ops->sk_clone_security(sk, newsk);
2941 static inline void security_sk_classify_flow(struct sock *sk, struct flowi *fl)
2943 security_ops->sk_getsecid(sk, &fl->secid);
2946 static inline void security_req_classify_flow(const struct request_sock *req, struct flowi *fl)
2948 security_ops->req_classify_flow(req, fl);
2951 static inline void security_sock_graft(struct sock* sk, struct socket *parent)
2953 security_ops->sock_graft(sk, parent);
2956 static inline int security_inet_conn_request(struct sock *sk,
2957 struct sk_buff *skb, struct request_sock *req)
2959 return security_ops->inet_conn_request(sk, skb, req);
2962 static inline void security_inet_csk_clone(struct sock *newsk,
2963 const struct request_sock *req)
2965 security_ops->inet_csk_clone(newsk, req);
2968 static inline void security_inet_conn_established(struct sock *sk,
2969 struct sk_buff *skb)
2971 security_ops->inet_conn_established(sk, skb);
2973 #else /* CONFIG_SECURITY_NETWORK */
2974 static inline int security_unix_stream_connect(struct socket * sock,
2975 struct socket * other,
2976 struct sock * newsk)
2981 static inline int security_unix_may_send(struct socket * sock,
2982 struct socket * other)
2987 static inline int security_socket_create (int family, int type,
2988 int protocol, int kern)
2993 static inline int security_socket_post_create(struct socket * sock,
2996 int protocol, int kern)
3001 static inline int security_socket_bind(struct socket * sock,
3002 struct sockaddr * address,
3008 static inline int security_socket_connect(struct socket * sock,
3009 struct sockaddr * address,
3015 static inline int security_socket_listen(struct socket * sock, int backlog)
3020 static inline int security_socket_accept(struct socket * sock,
3021 struct socket * newsock)
3026 static inline void security_socket_post_accept(struct socket * sock,
3027 struct socket * newsock)
3031 static inline int security_socket_sendmsg(struct socket * sock,
3032 struct msghdr * msg, int size)
3037 static inline int security_socket_recvmsg(struct socket * sock,
3038 struct msghdr * msg, int size,
3044 static inline int security_socket_getsockname(struct socket * sock)
3049 static inline int security_socket_getpeername(struct socket * sock)
3054 static inline int security_socket_getsockopt(struct socket * sock,
3055 int level, int optname)
3060 static inline int security_socket_setsockopt(struct socket * sock,
3061 int level, int optname)
3066 static inline int security_socket_shutdown(struct socket * sock, int how)
3070 static inline int security_sock_rcv_skb (struct sock * sk,
3071 struct sk_buff * skb)
3076 static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
3077 int __user *optlen, unsigned len)
3079 return -ENOPROTOOPT;
3082 static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
3084 return -ENOPROTOOPT;
3087 static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
3092 static inline void security_sk_free(struct sock *sk)
3096 static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
3100 static inline void security_sk_classify_flow(struct sock *sk, struct flowi *fl)
3104 static inline void security_req_classify_flow(const struct request_sock *req, struct flowi *fl)
3108 static inline void security_sock_graft(struct sock* sk, struct socket *parent)
3112 static inline int security_inet_conn_request(struct sock *sk,
3113 struct sk_buff *skb, struct request_sock *req)
3118 static inline void security_inet_csk_clone(struct sock *newsk,
3119 const struct request_sock *req)
3123 static inline void security_inet_conn_established(struct sock *sk,
3124 struct sk_buff *skb)
3127 #endif /* CONFIG_SECURITY_NETWORK */
3129 #ifdef CONFIG_SECURITY_NETWORK_XFRM
3130 static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx)
3132 return security_ops->xfrm_policy_alloc_security(xp, sec_ctx);
3135 static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
3137 return security_ops->xfrm_policy_clone_security(old, new);
3140 static inline void security_xfrm_policy_free(struct xfrm_policy *xp)
3142 security_ops->xfrm_policy_free_security(xp);
3145 static inline int security_xfrm_policy_delete(struct xfrm_policy *xp)
3147 return security_ops->xfrm_policy_delete_security(xp);
3150 static inline int security_xfrm_state_alloc(struct xfrm_state *x,
3151 struct xfrm_user_sec_ctx *sec_ctx)
3153 return security_ops->xfrm_state_alloc_security(x, sec_ctx, 0);
3156 static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
3157 struct xfrm_sec_ctx *polsec, u32 secid)
3162 * We want the context to be taken from secid which is usually
3165 return security_ops->xfrm_state_alloc_security(x, NULL, secid);
3168 static inline int security_xfrm_state_delete(struct xfrm_state *x)
3170 return security_ops->xfrm_state_delete_security(x);
3173 static inline void security_xfrm_state_free(struct xfrm_state *x)
3175 security_ops->xfrm_state_free_security(x);
3178 static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir)
3180 return security_ops->xfrm_policy_lookup(xp, fl_secid, dir);
3183 static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
3184 struct xfrm_policy *xp, struct flowi *fl)
3186 return security_ops->xfrm_state_pol_flow_match(x, xp, fl);
3189 static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
3191 return security_ops->xfrm_decode_session(skb, secid, 1);
3194 static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl)
3196 int rc = security_ops->xfrm_decode_session(skb, &fl->secid, 0);
3200 #else /* CONFIG_SECURITY_NETWORK_XFRM */
3201 static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx)
3206 static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
3211 static inline void security_xfrm_policy_free(struct xfrm_policy *xp)
3215 static inline int security_xfrm_policy_delete(struct xfrm_policy *xp)
3220 static inline int security_xfrm_state_alloc(struct xfrm_state *x,
3221 struct xfrm_user_sec_ctx *sec_ctx)
3226 static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
3227 struct xfrm_sec_ctx *polsec, u32 secid)
3232 static inline void security_xfrm_state_free(struct xfrm_state *x)
3236 static inline int security_xfrm_state_delete(struct xfrm_state *x)
3241 static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir)
3246 static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
3247 struct xfrm_policy *xp, struct flowi *fl)
3252 static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
3257 static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl)
3261 #endif /* CONFIG_SECURITY_NETWORK_XFRM */
3264 #ifdef CONFIG_SECURITY
3265 static inline int security_key_alloc(struct key *key,
3266 struct task_struct *tsk,
3267 unsigned long flags)
3269 return security_ops->key_alloc(key, tsk, flags);
3272 static inline void security_key_free(struct key *key)
3274 security_ops->key_free(key);
3277 static inline int security_key_permission(key_ref_t key_ref,
3278 struct task_struct *context,
3281 return security_ops->key_permission(key_ref, context, perm);
3286 static inline int security_key_alloc(struct key *key,
3287 struct task_struct *tsk,
3288 unsigned long flags)
3293 static inline void security_key_free(struct key *key)
3297 static inline int security_key_permission(key_ref_t key_ref,
3298 struct task_struct *context,
3305 #endif /* CONFIG_KEYS */
3307 #endif /* ! __LINUX_SECURITY_H */