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 (struct mm_struct *mm, 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 * @mm contains the mm struct it is being added to.
1129 * @pages contains the number of pages.
1130 * Return 0 if permission is granted.
1132 * @register_security:
1133 * allow module stacking.
1134 * @name contains the name of the security module being stacked.
1135 * @ops contains a pointer to the struct security_operations of the module to stack.
1136 * @unregister_security:
1137 * remove a stacked module.
1138 * @name contains the name of the security module being unstacked.
1139 * @ops contains a pointer to the struct security_operations of the module to unstack.
1142 * Convert secid to security context.
1143 * @secid contains the security ID.
1144 * @secdata contains the pointer that stores the converted security context.
1147 * Release the security context.
1148 * @secdata contains the security context.
1149 * @seclen contains the length of the security context.
1151 * This is the main security structure.
1153 struct security_operations {
1154 int (*ptrace) (struct task_struct * parent, struct task_struct * child);
1155 int (*capget) (struct task_struct * target,
1156 kernel_cap_t * effective,
1157 kernel_cap_t * inheritable, kernel_cap_t * permitted);
1158 int (*capset_check) (struct task_struct * target,
1159 kernel_cap_t * effective,
1160 kernel_cap_t * inheritable,
1161 kernel_cap_t * permitted);
1162 void (*capset_set) (struct task_struct * target,
1163 kernel_cap_t * effective,
1164 kernel_cap_t * inheritable,
1165 kernel_cap_t * permitted);
1166 int (*capable) (struct task_struct * tsk, int cap);
1167 int (*acct) (struct file * file);
1168 int (*sysctl) (struct ctl_table * table, int op);
1169 int (*quotactl) (int cmds, int type, int id, struct super_block * sb);
1170 int (*quota_on) (struct dentry * dentry);
1171 int (*syslog) (int type);
1172 int (*settime) (struct timespec *ts, struct timezone *tz);
1173 int (*vm_enough_memory) (struct mm_struct *mm, long pages);
1175 int (*bprm_alloc_security) (struct linux_binprm * bprm);
1176 void (*bprm_free_security) (struct linux_binprm * bprm);
1177 void (*bprm_apply_creds) (struct linux_binprm * bprm, int unsafe);
1178 void (*bprm_post_apply_creds) (struct linux_binprm * bprm);
1179 int (*bprm_set_security) (struct linux_binprm * bprm);
1180 int (*bprm_check_security) (struct linux_binprm * bprm);
1181 int (*bprm_secureexec) (struct linux_binprm * bprm);
1183 int (*sb_alloc_security) (struct super_block * sb);
1184 void (*sb_free_security) (struct super_block * sb);
1185 int (*sb_copy_data)(struct file_system_type *type,
1186 void *orig, void *copy);
1187 int (*sb_kern_mount) (struct super_block *sb, void *data);
1188 int (*sb_statfs) (struct dentry *dentry);
1189 int (*sb_mount) (char *dev_name, struct nameidata * nd,
1190 char *type, unsigned long flags, void *data);
1191 int (*sb_check_sb) (struct vfsmount * mnt, struct nameidata * nd);
1192 int (*sb_umount) (struct vfsmount * mnt, int flags);
1193 void (*sb_umount_close) (struct vfsmount * mnt);
1194 void (*sb_umount_busy) (struct vfsmount * mnt);
1195 void (*sb_post_remount) (struct vfsmount * mnt,
1196 unsigned long flags, void *data);
1197 void (*sb_post_mountroot) (void);
1198 void (*sb_post_addmount) (struct vfsmount * mnt,
1199 struct nameidata * mountpoint_nd);
1200 int (*sb_pivotroot) (struct nameidata * old_nd,
1201 struct nameidata * new_nd);
1202 void (*sb_post_pivotroot) (struct nameidata * old_nd,
1203 struct nameidata * new_nd);
1205 int (*inode_alloc_security) (struct inode *inode);
1206 void (*inode_free_security) (struct inode *inode);
1207 int (*inode_init_security) (struct inode *inode, struct inode *dir,
1208 char **name, void **value, size_t *len);
1209 int (*inode_create) (struct inode *dir,
1210 struct dentry *dentry, int mode);
1211 int (*inode_link) (struct dentry *old_dentry,
1212 struct inode *dir, struct dentry *new_dentry);
1213 int (*inode_unlink) (struct inode *dir, struct dentry *dentry);
1214 int (*inode_symlink) (struct inode *dir,
1215 struct dentry *dentry, const char *old_name);
1216 int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode);
1217 int (*inode_rmdir) (struct inode *dir, struct dentry *dentry);
1218 int (*inode_mknod) (struct inode *dir, struct dentry *dentry,
1219 int mode, dev_t dev);
1220 int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
1221 struct inode *new_dir, struct dentry *new_dentry);
1222 int (*inode_readlink) (struct dentry *dentry);
1223 int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
1224 int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd);
1225 int (*inode_setattr) (struct dentry *dentry, struct iattr *attr);
1226 int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
1227 void (*inode_delete) (struct inode *inode);
1228 int (*inode_setxattr) (struct dentry *dentry, char *name, void *value,
1229 size_t size, int flags);
1230 void (*inode_post_setxattr) (struct dentry *dentry, char *name, void *value,
1231 size_t size, int flags);
1232 int (*inode_getxattr) (struct dentry *dentry, char *name);
1233 int (*inode_listxattr) (struct dentry *dentry);
1234 int (*inode_removexattr) (struct dentry *dentry, char *name);
1235 const char *(*inode_xattr_getsuffix) (void);
1236 int (*inode_getsecurity)(const struct inode *inode, const char *name, void *buffer, size_t size, int err);
1237 int (*inode_setsecurity)(struct inode *inode, const char *name, const void *value, size_t size, int flags);
1238 int (*inode_listsecurity)(struct inode *inode, char *buffer, size_t buffer_size);
1240 int (*file_permission) (struct file * file, int mask);
1241 int (*file_alloc_security) (struct file * file);
1242 void (*file_free_security) (struct file * file);
1243 int (*file_ioctl) (struct file * file, unsigned int cmd,
1245 int (*file_mmap) (struct file * file,
1246 unsigned long reqprot, unsigned long prot,
1247 unsigned long flags, unsigned long addr,
1248 unsigned long addr_only);
1249 int (*file_mprotect) (struct vm_area_struct * vma,
1250 unsigned long reqprot,
1251 unsigned long prot);
1252 int (*file_lock) (struct file * file, unsigned int cmd);
1253 int (*file_fcntl) (struct file * file, unsigned int cmd,
1255 int (*file_set_fowner) (struct file * file);
1256 int (*file_send_sigiotask) (struct task_struct * tsk,
1257 struct fown_struct * fown, int sig);
1258 int (*file_receive) (struct file * file);
1260 int (*task_create) (unsigned long clone_flags);
1261 int (*task_alloc_security) (struct task_struct * p);
1262 void (*task_free_security) (struct task_struct * p);
1263 int (*task_setuid) (uid_t id0, uid_t id1, uid_t id2, int flags);
1264 int (*task_post_setuid) (uid_t old_ruid /* or fsuid */ ,
1265 uid_t old_euid, uid_t old_suid, int flags);
1266 int (*task_setgid) (gid_t id0, gid_t id1, gid_t id2, int flags);
1267 int (*task_setpgid) (struct task_struct * p, pid_t pgid);
1268 int (*task_getpgid) (struct task_struct * p);
1269 int (*task_getsid) (struct task_struct * p);
1270 void (*task_getsecid) (struct task_struct * p, u32 * secid);
1271 int (*task_setgroups) (struct group_info *group_info);
1272 int (*task_setnice) (struct task_struct * p, int nice);
1273 int (*task_setioprio) (struct task_struct * p, int ioprio);
1274 int (*task_getioprio) (struct task_struct * p);
1275 int (*task_setrlimit) (unsigned int resource, struct rlimit * new_rlim);
1276 int (*task_setscheduler) (struct task_struct * p, int policy,
1277 struct sched_param * lp);
1278 int (*task_getscheduler) (struct task_struct * p);
1279 int (*task_movememory) (struct task_struct * p);
1280 int (*task_kill) (struct task_struct * p,
1281 struct siginfo * info, int sig, u32 secid);
1282 int (*task_wait) (struct task_struct * p);
1283 int (*task_prctl) (int option, unsigned long arg2,
1284 unsigned long arg3, unsigned long arg4,
1285 unsigned long arg5);
1286 void (*task_reparent_to_init) (struct task_struct * p);
1287 void (*task_to_inode)(struct task_struct *p, struct inode *inode);
1289 int (*ipc_permission) (struct kern_ipc_perm * ipcp, short flag);
1291 int (*msg_msg_alloc_security) (struct msg_msg * msg);
1292 void (*msg_msg_free_security) (struct msg_msg * msg);
1294 int (*msg_queue_alloc_security) (struct msg_queue * msq);
1295 void (*msg_queue_free_security) (struct msg_queue * msq);
1296 int (*msg_queue_associate) (struct msg_queue * msq, int msqflg);
1297 int (*msg_queue_msgctl) (struct msg_queue * msq, int cmd);
1298 int (*msg_queue_msgsnd) (struct msg_queue * msq,
1299 struct msg_msg * msg, int msqflg);
1300 int (*msg_queue_msgrcv) (struct msg_queue * msq,
1301 struct msg_msg * msg,
1302 struct task_struct * target,
1303 long type, int mode);
1305 int (*shm_alloc_security) (struct shmid_kernel * shp);
1306 void (*shm_free_security) (struct shmid_kernel * shp);
1307 int (*shm_associate) (struct shmid_kernel * shp, int shmflg);
1308 int (*shm_shmctl) (struct shmid_kernel * shp, int cmd);
1309 int (*shm_shmat) (struct shmid_kernel * shp,
1310 char __user *shmaddr, int shmflg);
1312 int (*sem_alloc_security) (struct sem_array * sma);
1313 void (*sem_free_security) (struct sem_array * sma);
1314 int (*sem_associate) (struct sem_array * sma, int semflg);
1315 int (*sem_semctl) (struct sem_array * sma, int cmd);
1316 int (*sem_semop) (struct sem_array * sma,
1317 struct sembuf * sops, unsigned nsops, int alter);
1319 int (*netlink_send) (struct sock * sk, struct sk_buff * skb);
1320 int (*netlink_recv) (struct sk_buff * skb, int cap);
1322 /* allow module stacking */
1323 int (*register_security) (const char *name,
1324 struct security_operations *ops);
1325 int (*unregister_security) (const char *name,
1326 struct security_operations *ops);
1328 void (*d_instantiate) (struct dentry *dentry, struct inode *inode);
1330 int (*getprocattr)(struct task_struct *p, char *name, char **value);
1331 int (*setprocattr)(struct task_struct *p, char *name, void *value, size_t size);
1332 int (*secid_to_secctx)(u32 secid, char **secdata, u32 *seclen);
1333 void (*release_secctx)(char *secdata, u32 seclen);
1335 #ifdef CONFIG_SECURITY_NETWORK
1336 int (*unix_stream_connect) (struct socket * sock,
1337 struct socket * other, struct sock * newsk);
1338 int (*unix_may_send) (struct socket * sock, struct socket * other);
1340 int (*socket_create) (int family, int type, int protocol, int kern);
1341 int (*socket_post_create) (struct socket * sock, int family,
1342 int type, int protocol, int kern);
1343 int (*socket_bind) (struct socket * sock,
1344 struct sockaddr * address, int addrlen);
1345 int (*socket_connect) (struct socket * sock,
1346 struct sockaddr * address, int addrlen);
1347 int (*socket_listen) (struct socket * sock, int backlog);
1348 int (*socket_accept) (struct socket * sock, struct socket * newsock);
1349 void (*socket_post_accept) (struct socket * sock,
1350 struct socket * newsock);
1351 int (*socket_sendmsg) (struct socket * sock,
1352 struct msghdr * msg, int size);
1353 int (*socket_recvmsg) (struct socket * sock,
1354 struct msghdr * msg, int size, int flags);
1355 int (*socket_getsockname) (struct socket * sock);
1356 int (*socket_getpeername) (struct socket * sock);
1357 int (*socket_getsockopt) (struct socket * sock, int level, int optname);
1358 int (*socket_setsockopt) (struct socket * sock, int level, int optname);
1359 int (*socket_shutdown) (struct socket * sock, int how);
1360 int (*socket_sock_rcv_skb) (struct sock * sk, struct sk_buff * skb);
1361 int (*socket_getpeersec_stream) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len);
1362 int (*socket_getpeersec_dgram) (struct socket *sock, struct sk_buff *skb, u32 *secid);
1363 int (*sk_alloc_security) (struct sock *sk, int family, gfp_t priority);
1364 void (*sk_free_security) (struct sock *sk);
1365 void (*sk_clone_security) (const struct sock *sk, struct sock *newsk);
1366 void (*sk_getsecid) (struct sock *sk, u32 *secid);
1367 void (*sock_graft)(struct sock* sk, struct socket *parent);
1368 int (*inet_conn_request)(struct sock *sk, struct sk_buff *skb,
1369 struct request_sock *req);
1370 void (*inet_csk_clone)(struct sock *newsk, const struct request_sock *req);
1371 void (*inet_conn_established)(struct sock *sk, struct sk_buff *skb);
1372 void (*req_classify_flow)(const struct request_sock *req, struct flowi *fl);
1373 #endif /* CONFIG_SECURITY_NETWORK */
1375 #ifdef CONFIG_SECURITY_NETWORK_XFRM
1376 int (*xfrm_policy_alloc_security) (struct xfrm_policy *xp,
1377 struct xfrm_user_sec_ctx *sec_ctx);
1378 int (*xfrm_policy_clone_security) (struct xfrm_policy *old, struct xfrm_policy *new);
1379 void (*xfrm_policy_free_security) (struct xfrm_policy *xp);
1380 int (*xfrm_policy_delete_security) (struct xfrm_policy *xp);
1381 int (*xfrm_state_alloc_security) (struct xfrm_state *x,
1382 struct xfrm_user_sec_ctx *sec_ctx,
1384 void (*xfrm_state_free_security) (struct xfrm_state *x);
1385 int (*xfrm_state_delete_security) (struct xfrm_state *x);
1386 int (*xfrm_policy_lookup)(struct xfrm_policy *xp, u32 fl_secid, u8 dir);
1387 int (*xfrm_state_pol_flow_match)(struct xfrm_state *x,
1388 struct xfrm_policy *xp, struct flowi *fl);
1389 int (*xfrm_decode_session)(struct sk_buff *skb, u32 *secid, int ckall);
1390 #endif /* CONFIG_SECURITY_NETWORK_XFRM */
1392 /* key management security hooks */
1394 int (*key_alloc)(struct key *key, struct task_struct *tsk, unsigned long flags);
1395 void (*key_free)(struct key *key);
1396 int (*key_permission)(key_ref_t key_ref,
1397 struct task_struct *context,
1400 #endif /* CONFIG_KEYS */
1404 /* global variables */
1405 extern struct security_operations *security_ops;
1408 static inline int security_ptrace (struct task_struct * parent, struct task_struct * child)
1410 return security_ops->ptrace (parent, child);
1413 static inline int security_capget (struct task_struct *target,
1414 kernel_cap_t *effective,
1415 kernel_cap_t *inheritable,
1416 kernel_cap_t *permitted)
1418 return security_ops->capget (target, effective, inheritable, permitted);
1421 static inline int security_capset_check (struct task_struct *target,
1422 kernel_cap_t *effective,
1423 kernel_cap_t *inheritable,
1424 kernel_cap_t *permitted)
1426 return security_ops->capset_check (target, effective, inheritable, permitted);
1429 static inline void security_capset_set (struct task_struct *target,
1430 kernel_cap_t *effective,
1431 kernel_cap_t *inheritable,
1432 kernel_cap_t *permitted)
1434 security_ops->capset_set (target, effective, inheritable, permitted);
1437 static inline int security_capable(struct task_struct *tsk, int cap)
1439 return security_ops->capable(tsk, cap);
1442 static inline int security_acct (struct file *file)
1444 return security_ops->acct (file);
1447 static inline int security_sysctl(struct ctl_table *table, int op)
1449 return security_ops->sysctl(table, op);
1452 static inline int security_quotactl (int cmds, int type, int id,
1453 struct super_block *sb)
1455 return security_ops->quotactl (cmds, type, id, sb);
1458 static inline int security_quota_on (struct dentry * dentry)
1460 return security_ops->quota_on (dentry);
1463 static inline int security_syslog(int type)
1465 return security_ops->syslog(type);
1468 static inline int security_settime(struct timespec *ts, struct timezone *tz)
1470 return security_ops->settime(ts, tz);
1473 static inline int security_vm_enough_memory(long pages)
1475 return security_ops->vm_enough_memory(current->mm, pages);
1478 static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
1480 return security_ops->vm_enough_memory(mm, pages);
1483 static inline int security_bprm_alloc (struct linux_binprm *bprm)
1485 return security_ops->bprm_alloc_security (bprm);
1487 static inline void security_bprm_free (struct linux_binprm *bprm)
1489 security_ops->bprm_free_security (bprm);
1491 static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
1493 security_ops->bprm_apply_creds (bprm, unsafe);
1495 static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
1497 security_ops->bprm_post_apply_creds (bprm);
1499 static inline int security_bprm_set (struct linux_binprm *bprm)
1501 return security_ops->bprm_set_security (bprm);
1504 static inline int security_bprm_check (struct linux_binprm *bprm)
1506 return security_ops->bprm_check_security (bprm);
1509 static inline int security_bprm_secureexec (struct linux_binprm *bprm)
1511 return security_ops->bprm_secureexec (bprm);
1514 static inline int security_sb_alloc (struct super_block *sb)
1516 return security_ops->sb_alloc_security (sb);
1519 static inline void security_sb_free (struct super_block *sb)
1521 security_ops->sb_free_security (sb);
1524 static inline int security_sb_copy_data (struct file_system_type *type,
1525 void *orig, void *copy)
1527 return security_ops->sb_copy_data (type, orig, copy);
1530 static inline int security_sb_kern_mount (struct super_block *sb, void *data)
1532 return security_ops->sb_kern_mount (sb, data);
1535 static inline int security_sb_statfs (struct dentry *dentry)
1537 return security_ops->sb_statfs (dentry);
1540 static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
1541 char *type, unsigned long flags,
1544 return security_ops->sb_mount (dev_name, nd, type, flags, data);
1547 static inline int security_sb_check_sb (struct vfsmount *mnt,
1548 struct nameidata *nd)
1550 return security_ops->sb_check_sb (mnt, nd);
1553 static inline int security_sb_umount (struct vfsmount *mnt, int flags)
1555 return security_ops->sb_umount (mnt, flags);
1558 static inline void security_sb_umount_close (struct vfsmount *mnt)
1560 security_ops->sb_umount_close (mnt);
1563 static inline void security_sb_umount_busy (struct vfsmount *mnt)
1565 security_ops->sb_umount_busy (mnt);
1568 static inline void security_sb_post_remount (struct vfsmount *mnt,
1569 unsigned long flags, void *data)
1571 security_ops->sb_post_remount (mnt, flags, data);
1574 static inline void security_sb_post_mountroot (void)
1576 security_ops->sb_post_mountroot ();
1579 static inline void security_sb_post_addmount (struct vfsmount *mnt,
1580 struct nameidata *mountpoint_nd)
1582 security_ops->sb_post_addmount (mnt, mountpoint_nd);
1585 static inline int security_sb_pivotroot (struct nameidata *old_nd,
1586 struct nameidata *new_nd)
1588 return security_ops->sb_pivotroot (old_nd, new_nd);
1591 static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
1592 struct nameidata *new_nd)
1594 security_ops->sb_post_pivotroot (old_nd, new_nd);
1597 static inline int security_inode_alloc (struct inode *inode)
1599 inode->i_security = NULL;
1600 return security_ops->inode_alloc_security (inode);
1603 static inline void security_inode_free (struct inode *inode)
1605 security_ops->inode_free_security (inode);
1608 static inline int security_inode_init_security (struct inode *inode,
1614 if (unlikely (IS_PRIVATE (inode)))
1616 return security_ops->inode_init_security (inode, dir, name, value, len);
1619 static inline int security_inode_create (struct inode *dir,
1620 struct dentry *dentry,
1623 if (unlikely (IS_PRIVATE (dir)))
1625 return security_ops->inode_create (dir, dentry, mode);
1628 static inline int security_inode_link (struct dentry *old_dentry,
1630 struct dentry *new_dentry)
1632 if (unlikely (IS_PRIVATE (old_dentry->d_inode)))
1634 return security_ops->inode_link (old_dentry, dir, new_dentry);
1637 static inline int security_inode_unlink (struct inode *dir,
1638 struct dentry *dentry)
1640 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1642 return security_ops->inode_unlink (dir, dentry);
1645 static inline int security_inode_symlink (struct inode *dir,
1646 struct dentry *dentry,
1647 const char *old_name)
1649 if (unlikely (IS_PRIVATE (dir)))
1651 return security_ops->inode_symlink (dir, dentry, old_name);
1654 static inline int security_inode_mkdir (struct inode *dir,
1655 struct dentry *dentry,
1658 if (unlikely (IS_PRIVATE (dir)))
1660 return security_ops->inode_mkdir (dir, dentry, mode);
1663 static inline int security_inode_rmdir (struct inode *dir,
1664 struct dentry *dentry)
1666 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1668 return security_ops->inode_rmdir (dir, dentry);
1671 static inline int security_inode_mknod (struct inode *dir,
1672 struct dentry *dentry,
1673 int mode, dev_t dev)
1675 if (unlikely (IS_PRIVATE (dir)))
1677 return security_ops->inode_mknod (dir, dentry, mode, dev);
1680 static inline int security_inode_rename (struct inode *old_dir,
1681 struct dentry *old_dentry,
1682 struct inode *new_dir,
1683 struct dentry *new_dentry)
1685 if (unlikely (IS_PRIVATE (old_dentry->d_inode) ||
1686 (new_dentry->d_inode && IS_PRIVATE (new_dentry->d_inode))))
1688 return security_ops->inode_rename (old_dir, old_dentry,
1689 new_dir, new_dentry);
1692 static inline int security_inode_readlink (struct dentry *dentry)
1694 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1696 return security_ops->inode_readlink (dentry);
1699 static inline int security_inode_follow_link (struct dentry *dentry,
1700 struct nameidata *nd)
1702 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1704 return security_ops->inode_follow_link (dentry, nd);
1707 static inline int security_inode_permission (struct inode *inode, int mask,
1708 struct nameidata *nd)
1710 if (unlikely (IS_PRIVATE (inode)))
1712 return security_ops->inode_permission (inode, mask, nd);
1715 static inline int security_inode_setattr (struct dentry *dentry,
1718 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1720 return security_ops->inode_setattr (dentry, attr);
1723 static inline int security_inode_getattr (struct vfsmount *mnt,
1724 struct dentry *dentry)
1726 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1728 return security_ops->inode_getattr (mnt, dentry);
1731 static inline void security_inode_delete (struct inode *inode)
1733 if (unlikely (IS_PRIVATE (inode)))
1735 security_ops->inode_delete (inode);
1738 static inline int security_inode_setxattr (struct dentry *dentry, char *name,
1739 void *value, size_t size, int flags)
1741 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1743 return security_ops->inode_setxattr (dentry, name, value, size, flags);
1746 static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
1747 void *value, size_t size, int flags)
1749 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1751 security_ops->inode_post_setxattr (dentry, name, value, size, flags);
1754 static inline int security_inode_getxattr (struct dentry *dentry, char *name)
1756 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1758 return security_ops->inode_getxattr (dentry, name);
1761 static inline int security_inode_listxattr (struct dentry *dentry)
1763 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1765 return security_ops->inode_listxattr (dentry);
1768 static inline int security_inode_removexattr (struct dentry *dentry, char *name)
1770 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1772 return security_ops->inode_removexattr (dentry, name);
1775 static inline const char *security_inode_xattr_getsuffix(void)
1777 return security_ops->inode_xattr_getsuffix();
1780 static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void *buffer, size_t size, int err)
1782 if (unlikely (IS_PRIVATE (inode)))
1784 return security_ops->inode_getsecurity(inode, name, buffer, size, err);
1787 static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
1789 if (unlikely (IS_PRIVATE (inode)))
1791 return security_ops->inode_setsecurity(inode, name, value, size, flags);
1794 static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
1796 if (unlikely (IS_PRIVATE (inode)))
1798 return security_ops->inode_listsecurity(inode, buffer, buffer_size);
1801 static inline int security_file_permission (struct file *file, int mask)
1803 return security_ops->file_permission (file, mask);
1806 static inline int security_file_alloc (struct file *file)
1808 return security_ops->file_alloc_security (file);
1811 static inline void security_file_free (struct file *file)
1813 security_ops->file_free_security (file);
1816 static inline int security_file_ioctl (struct file *file, unsigned int cmd,
1819 return security_ops->file_ioctl (file, cmd, arg);
1822 static inline int security_file_mmap (struct file *file, unsigned long reqprot,
1824 unsigned long flags,
1826 unsigned long addr_only)
1828 return security_ops->file_mmap (file, reqprot, prot, flags, addr,
1832 static inline int security_file_mprotect (struct vm_area_struct *vma,
1833 unsigned long reqprot,
1836 return security_ops->file_mprotect (vma, reqprot, prot);
1839 static inline int security_file_lock (struct file *file, unsigned int cmd)
1841 return security_ops->file_lock (file, cmd);
1844 static inline int security_file_fcntl (struct file *file, unsigned int cmd,
1847 return security_ops->file_fcntl (file, cmd, arg);
1850 static inline int security_file_set_fowner (struct file *file)
1852 return security_ops->file_set_fowner (file);
1855 static inline int security_file_send_sigiotask (struct task_struct *tsk,
1856 struct fown_struct *fown,
1859 return security_ops->file_send_sigiotask (tsk, fown, sig);
1862 static inline int security_file_receive (struct file *file)
1864 return security_ops->file_receive (file);
1867 static inline int security_task_create (unsigned long clone_flags)
1869 return security_ops->task_create (clone_flags);
1872 static inline int security_task_alloc (struct task_struct *p)
1874 return security_ops->task_alloc_security (p);
1877 static inline void security_task_free (struct task_struct *p)
1879 security_ops->task_free_security (p);
1882 static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
1885 return security_ops->task_setuid (id0, id1, id2, flags);
1888 static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
1889 uid_t old_suid, int flags)
1891 return security_ops->task_post_setuid (old_ruid, old_euid, old_suid, flags);
1894 static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
1897 return security_ops->task_setgid (id0, id1, id2, flags);
1900 static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
1902 return security_ops->task_setpgid (p, pgid);
1905 static inline int security_task_getpgid (struct task_struct *p)
1907 return security_ops->task_getpgid (p);
1910 static inline int security_task_getsid (struct task_struct *p)
1912 return security_ops->task_getsid (p);
1915 static inline void security_task_getsecid (struct task_struct *p, u32 *secid)
1917 security_ops->task_getsecid (p, secid);
1920 static inline int security_task_setgroups (struct group_info *group_info)
1922 return security_ops->task_setgroups (group_info);
1925 static inline int security_task_setnice (struct task_struct *p, int nice)
1927 return security_ops->task_setnice (p, nice);
1930 static inline int security_task_setioprio (struct task_struct *p, int ioprio)
1932 return security_ops->task_setioprio (p, ioprio);
1935 static inline int security_task_getioprio (struct task_struct *p)
1937 return security_ops->task_getioprio (p);
1940 static inline int security_task_setrlimit (unsigned int resource,
1941 struct rlimit *new_rlim)
1943 return security_ops->task_setrlimit (resource, new_rlim);
1946 static inline int security_task_setscheduler (struct task_struct *p,
1948 struct sched_param *lp)
1950 return security_ops->task_setscheduler (p, policy, lp);
1953 static inline int security_task_getscheduler (struct task_struct *p)
1955 return security_ops->task_getscheduler (p);
1958 static inline int security_task_movememory (struct task_struct *p)
1960 return security_ops->task_movememory (p);
1963 static inline int security_task_kill (struct task_struct *p,
1964 struct siginfo *info, int sig,
1967 return security_ops->task_kill (p, info, sig, secid);
1970 static inline int security_task_wait (struct task_struct *p)
1972 return security_ops->task_wait (p);
1975 static inline int security_task_prctl (int option, unsigned long arg2,
1980 return security_ops->task_prctl (option, arg2, arg3, arg4, arg5);
1983 static inline void security_task_reparent_to_init (struct task_struct *p)
1985 security_ops->task_reparent_to_init (p);
1988 static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
1990 security_ops->task_to_inode(p, inode);
1993 static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
1996 return security_ops->ipc_permission (ipcp, flag);
1999 static inline int security_msg_msg_alloc (struct msg_msg * msg)
2001 return security_ops->msg_msg_alloc_security (msg);
2004 static inline void security_msg_msg_free (struct msg_msg * msg)
2006 security_ops->msg_msg_free_security(msg);
2009 static inline int security_msg_queue_alloc (struct msg_queue *msq)
2011 return security_ops->msg_queue_alloc_security (msq);
2014 static inline void security_msg_queue_free (struct msg_queue *msq)
2016 security_ops->msg_queue_free_security (msq);
2019 static inline int security_msg_queue_associate (struct msg_queue * msq,
2022 return security_ops->msg_queue_associate (msq, msqflg);
2025 static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
2027 return security_ops->msg_queue_msgctl (msq, cmd);
2030 static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
2031 struct msg_msg * msg, int msqflg)
2033 return security_ops->msg_queue_msgsnd (msq, msg, msqflg);
2036 static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
2037 struct msg_msg * msg,
2038 struct task_struct * target,
2039 long type, int mode)
2041 return security_ops->msg_queue_msgrcv (msq, msg, target, type, mode);
2044 static inline int security_shm_alloc (struct shmid_kernel *shp)
2046 return security_ops->shm_alloc_security (shp);
2049 static inline void security_shm_free (struct shmid_kernel *shp)
2051 security_ops->shm_free_security (shp);
2054 static inline int security_shm_associate (struct shmid_kernel * shp,
2057 return security_ops->shm_associate(shp, shmflg);
2060 static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
2062 return security_ops->shm_shmctl (shp, cmd);
2065 static inline int security_shm_shmat (struct shmid_kernel * shp,
2066 char __user *shmaddr, int shmflg)
2068 return security_ops->shm_shmat(shp, shmaddr, shmflg);
2071 static inline int security_sem_alloc (struct sem_array *sma)
2073 return security_ops->sem_alloc_security (sma);
2076 static inline void security_sem_free (struct sem_array *sma)
2078 security_ops->sem_free_security (sma);
2081 static inline int security_sem_associate (struct sem_array * sma, int semflg)
2083 return security_ops->sem_associate (sma, semflg);
2086 static inline int security_sem_semctl (struct sem_array * sma, int cmd)
2088 return security_ops->sem_semctl(sma, cmd);
2091 static inline int security_sem_semop (struct sem_array * sma,
2092 struct sembuf * sops, unsigned nsops,
2095 return security_ops->sem_semop(sma, sops, nsops, alter);
2098 static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
2100 if (unlikely (inode && IS_PRIVATE (inode)))
2102 security_ops->d_instantiate (dentry, inode);
2105 static inline int security_getprocattr(struct task_struct *p, char *name, char **value)
2107 return security_ops->getprocattr(p, name, value);
2110 static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2112 return security_ops->setprocattr(p, name, value, size);
2115 static inline int security_netlink_send(struct sock *sk, struct sk_buff * skb)
2117 return security_ops->netlink_send(sk, skb);
2120 static inline int security_netlink_recv(struct sk_buff * skb, int cap)
2122 return security_ops->netlink_recv(skb, cap);
2125 static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
2127 return security_ops->secid_to_secctx(secid, secdata, seclen);
2130 static inline void security_release_secctx(char *secdata, u32 seclen)
2132 return security_ops->release_secctx(secdata, seclen);
2136 extern int security_init (void);
2137 extern int register_security (struct security_operations *ops);
2138 extern int unregister_security (struct security_operations *ops);
2139 extern int mod_reg_security (const char *name, struct security_operations *ops);
2140 extern int mod_unreg_security (const char *name, struct security_operations *ops);
2141 extern struct dentry *securityfs_create_file(const char *name, mode_t mode,
2142 struct dentry *parent, void *data,
2143 const struct file_operations *fops);
2144 extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
2145 extern void securityfs_remove(struct dentry *dentry);
2148 #else /* CONFIG_SECURITY */
2151 * This is the default capabilities functionality. Most of these functions
2152 * are just stubbed out, but a few must call the proper capable code.
2155 static inline int security_init(void)
2160 static inline int security_ptrace (struct task_struct *parent, struct task_struct * child)
2162 return cap_ptrace (parent, child);
2165 static inline int security_capget (struct task_struct *target,
2166 kernel_cap_t *effective,
2167 kernel_cap_t *inheritable,
2168 kernel_cap_t *permitted)
2170 return cap_capget (target, effective, inheritable, permitted);
2173 static inline int security_capset_check (struct task_struct *target,
2174 kernel_cap_t *effective,
2175 kernel_cap_t *inheritable,
2176 kernel_cap_t *permitted)
2178 return cap_capset_check (target, effective, inheritable, permitted);
2181 static inline void security_capset_set (struct task_struct *target,
2182 kernel_cap_t *effective,
2183 kernel_cap_t *inheritable,
2184 kernel_cap_t *permitted)
2186 cap_capset_set (target, effective, inheritable, permitted);
2189 static inline int security_capable(struct task_struct *tsk, int cap)
2191 return cap_capable(tsk, cap);
2194 static inline int security_acct (struct file *file)
2199 static inline int security_sysctl(struct ctl_table *table, int op)
2204 static inline int security_quotactl (int cmds, int type, int id,
2205 struct super_block * sb)
2210 static inline int security_quota_on (struct dentry * dentry)
2215 static inline int security_syslog(int type)
2217 return cap_syslog(type);
2220 static inline int security_settime(struct timespec *ts, struct timezone *tz)
2222 return cap_settime(ts, tz);
2225 static inline int security_vm_enough_memory(long pages)
2227 return cap_vm_enough_memory(current->mm, pages);
2230 static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
2232 return cap_vm_enough_memory(mm, pages);
2235 static inline int security_bprm_alloc (struct linux_binprm *bprm)
2240 static inline void security_bprm_free (struct linux_binprm *bprm)
2243 static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
2245 cap_bprm_apply_creds (bprm, unsafe);
2248 static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
2253 static inline int security_bprm_set (struct linux_binprm *bprm)
2255 return cap_bprm_set_security (bprm);
2258 static inline int security_bprm_check (struct linux_binprm *bprm)
2263 static inline int security_bprm_secureexec (struct linux_binprm *bprm)
2265 return cap_bprm_secureexec(bprm);
2268 static inline int security_sb_alloc (struct super_block *sb)
2273 static inline void security_sb_free (struct super_block *sb)
2276 static inline int security_sb_copy_data (struct file_system_type *type,
2277 void *orig, void *copy)
2282 static inline int security_sb_kern_mount (struct super_block *sb, void *data)
2287 static inline int security_sb_statfs (struct dentry *dentry)
2292 static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
2293 char *type, unsigned long flags,
2299 static inline int security_sb_check_sb (struct vfsmount *mnt,
2300 struct nameidata *nd)
2305 static inline int security_sb_umount (struct vfsmount *mnt, int flags)
2310 static inline void security_sb_umount_close (struct vfsmount *mnt)
2313 static inline void security_sb_umount_busy (struct vfsmount *mnt)
2316 static inline void security_sb_post_remount (struct vfsmount *mnt,
2317 unsigned long flags, void *data)
2320 static inline void security_sb_post_mountroot (void)
2323 static inline void security_sb_post_addmount (struct vfsmount *mnt,
2324 struct nameidata *mountpoint_nd)
2327 static inline int security_sb_pivotroot (struct nameidata *old_nd,
2328 struct nameidata *new_nd)
2333 static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
2334 struct nameidata *new_nd)
2337 static inline int security_inode_alloc (struct inode *inode)
2342 static inline void security_inode_free (struct inode *inode)
2345 static inline int security_inode_init_security (struct inode *inode,
2354 static inline int security_inode_create (struct inode *dir,
2355 struct dentry *dentry,
2361 static inline int security_inode_link (struct dentry *old_dentry,
2363 struct dentry *new_dentry)
2368 static inline int security_inode_unlink (struct inode *dir,
2369 struct dentry *dentry)
2374 static inline int security_inode_symlink (struct inode *dir,
2375 struct dentry *dentry,
2376 const char *old_name)
2381 static inline int security_inode_mkdir (struct inode *dir,
2382 struct dentry *dentry,
2388 static inline int security_inode_rmdir (struct inode *dir,
2389 struct dentry *dentry)
2394 static inline int security_inode_mknod (struct inode *dir,
2395 struct dentry *dentry,
2396 int mode, dev_t dev)
2401 static inline int security_inode_rename (struct inode *old_dir,
2402 struct dentry *old_dentry,
2403 struct inode *new_dir,
2404 struct dentry *new_dentry)
2409 static inline int security_inode_readlink (struct dentry *dentry)
2414 static inline int security_inode_follow_link (struct dentry *dentry,
2415 struct nameidata *nd)
2420 static inline int security_inode_permission (struct inode *inode, int mask,
2421 struct nameidata *nd)
2426 static inline int security_inode_setattr (struct dentry *dentry,
2432 static inline int security_inode_getattr (struct vfsmount *mnt,
2433 struct dentry *dentry)
2438 static inline void security_inode_delete (struct inode *inode)
2441 static inline int security_inode_setxattr (struct dentry *dentry, char *name,
2442 void *value, size_t size, int flags)
2444 return cap_inode_setxattr(dentry, name, value, size, flags);
2447 static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
2448 void *value, size_t size, int flags)
2451 static inline int security_inode_getxattr (struct dentry *dentry, char *name)
2456 static inline int security_inode_listxattr (struct dentry *dentry)
2461 static inline int security_inode_removexattr (struct dentry *dentry, char *name)
2463 return cap_inode_removexattr(dentry, name);
2466 static inline const char *security_inode_xattr_getsuffix (void)
2471 static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void *buffer, size_t size, int err)
2476 static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
2481 static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
2486 static inline int security_file_permission (struct file *file, int mask)
2491 static inline int security_file_alloc (struct file *file)
2496 static inline void security_file_free (struct file *file)
2499 static inline int security_file_ioctl (struct file *file, unsigned int cmd,
2505 static inline int security_file_mmap (struct file *file, unsigned long reqprot,
2507 unsigned long flags,
2509 unsigned long addr_only)
2514 static inline int security_file_mprotect (struct vm_area_struct *vma,
2515 unsigned long reqprot,
2521 static inline int security_file_lock (struct file *file, unsigned int cmd)
2526 static inline int security_file_fcntl (struct file *file, unsigned int cmd,
2532 static inline int security_file_set_fowner (struct file *file)
2537 static inline int security_file_send_sigiotask (struct task_struct *tsk,
2538 struct fown_struct *fown,
2544 static inline int security_file_receive (struct file *file)
2549 static inline int security_task_create (unsigned long clone_flags)
2554 static inline int security_task_alloc (struct task_struct *p)
2559 static inline void security_task_free (struct task_struct *p)
2562 static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
2568 static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
2569 uid_t old_suid, int flags)
2571 return cap_task_post_setuid (old_ruid, old_euid, old_suid, flags);
2574 static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
2580 static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
2585 static inline int security_task_getpgid (struct task_struct *p)
2590 static inline int security_task_getsid (struct task_struct *p)
2595 static inline void security_task_getsecid (struct task_struct *p, u32 *secid)
2598 static inline int security_task_setgroups (struct group_info *group_info)
2603 static inline int security_task_setnice (struct task_struct *p, int nice)
2608 static inline int security_task_setioprio (struct task_struct *p, int ioprio)
2613 static inline int security_task_getioprio (struct task_struct *p)
2618 static inline int security_task_setrlimit (unsigned int resource,
2619 struct rlimit *new_rlim)
2624 static inline int security_task_setscheduler (struct task_struct *p,
2626 struct sched_param *lp)
2631 static inline int security_task_getscheduler (struct task_struct *p)
2636 static inline int security_task_movememory (struct task_struct *p)
2641 static inline int security_task_kill (struct task_struct *p,
2642 struct siginfo *info, int sig,
2648 static inline int security_task_wait (struct task_struct *p)
2653 static inline int security_task_prctl (int option, unsigned long arg2,
2661 static inline void security_task_reparent_to_init (struct task_struct *p)
2663 cap_task_reparent_to_init (p);
2666 static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
2669 static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
2675 static inline int security_msg_msg_alloc (struct msg_msg * msg)
2680 static inline void security_msg_msg_free (struct msg_msg * msg)
2683 static inline int security_msg_queue_alloc (struct msg_queue *msq)
2688 static inline void security_msg_queue_free (struct msg_queue *msq)
2691 static inline int security_msg_queue_associate (struct msg_queue * msq,
2697 static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
2702 static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
2703 struct msg_msg * msg, int msqflg)
2708 static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
2709 struct msg_msg * msg,
2710 struct task_struct * target,
2711 long type, int mode)
2716 static inline int security_shm_alloc (struct shmid_kernel *shp)
2721 static inline void security_shm_free (struct shmid_kernel *shp)
2724 static inline int security_shm_associate (struct shmid_kernel * shp,
2730 static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
2735 static inline int security_shm_shmat (struct shmid_kernel * shp,
2736 char __user *shmaddr, int shmflg)
2741 static inline int security_sem_alloc (struct sem_array *sma)
2746 static inline void security_sem_free (struct sem_array *sma)
2749 static inline int security_sem_associate (struct sem_array * sma, int semflg)
2754 static inline int security_sem_semctl (struct sem_array * sma, int cmd)
2759 static inline int security_sem_semop (struct sem_array * sma,
2760 struct sembuf * sops, unsigned nsops,
2766 static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
2769 static inline int security_getprocattr(struct task_struct *p, char *name, char **value)
2774 static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2779 static inline int security_netlink_send (struct sock *sk, struct sk_buff *skb)
2781 return cap_netlink_send (sk, skb);
2784 static inline int security_netlink_recv (struct sk_buff *skb, int cap)
2786 return cap_netlink_recv (skb, cap);
2789 static inline struct dentry *securityfs_create_dir(const char *name,
2790 struct dentry *parent)
2792 return ERR_PTR(-ENODEV);
2795 static inline struct dentry *securityfs_create_file(const char *name,
2797 struct dentry *parent,
2799 struct file_operations *fops)
2801 return ERR_PTR(-ENODEV);
2804 static inline void securityfs_remove(struct dentry *dentry)
2808 static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
2813 static inline void security_release_secctx(char *secdata, u32 seclen)
2816 #endif /* CONFIG_SECURITY */
2818 #ifdef CONFIG_SECURITY_NETWORK
2819 static inline int security_unix_stream_connect(struct socket * sock,
2820 struct socket * other,
2821 struct sock * newsk)
2823 return security_ops->unix_stream_connect(sock, other, newsk);
2827 static inline int security_unix_may_send(struct socket * sock,
2828 struct socket * other)
2830 return security_ops->unix_may_send(sock, other);
2833 static inline int security_socket_create (int family, int type,
2834 int protocol, int kern)
2836 return security_ops->socket_create(family, type, protocol, kern);
2839 static inline int security_socket_post_create(struct socket * sock,
2842 int protocol, int kern)
2844 return security_ops->socket_post_create(sock, family, type,
2848 static inline int security_socket_bind(struct socket * sock,
2849 struct sockaddr * address,
2852 return security_ops->socket_bind(sock, address, addrlen);
2855 static inline int security_socket_connect(struct socket * sock,
2856 struct sockaddr * address,
2859 return security_ops->socket_connect(sock, address, addrlen);
2862 static inline int security_socket_listen(struct socket * sock, int backlog)
2864 return security_ops->socket_listen(sock, backlog);
2867 static inline int security_socket_accept(struct socket * sock,
2868 struct socket * newsock)
2870 return security_ops->socket_accept(sock, newsock);
2873 static inline void security_socket_post_accept(struct socket * sock,
2874 struct socket * newsock)
2876 security_ops->socket_post_accept(sock, newsock);
2879 static inline int security_socket_sendmsg(struct socket * sock,
2880 struct msghdr * msg, int size)
2882 return security_ops->socket_sendmsg(sock, msg, size);
2885 static inline int security_socket_recvmsg(struct socket * sock,
2886 struct msghdr * msg, int size,
2889 return security_ops->socket_recvmsg(sock, msg, size, flags);
2892 static inline int security_socket_getsockname(struct socket * sock)
2894 return security_ops->socket_getsockname(sock);
2897 static inline int security_socket_getpeername(struct socket * sock)
2899 return security_ops->socket_getpeername(sock);
2902 static inline int security_socket_getsockopt(struct socket * sock,
2903 int level, int optname)
2905 return security_ops->socket_getsockopt(sock, level, optname);
2908 static inline int security_socket_setsockopt(struct socket * sock,
2909 int level, int optname)
2911 return security_ops->socket_setsockopt(sock, level, optname);
2914 static inline int security_socket_shutdown(struct socket * sock, int how)
2916 return security_ops->socket_shutdown(sock, how);
2919 static inline int security_sock_rcv_skb (struct sock * sk,
2920 struct sk_buff * skb)
2922 return security_ops->socket_sock_rcv_skb (sk, skb);
2925 static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2926 int __user *optlen, unsigned len)
2928 return security_ops->socket_getpeersec_stream(sock, optval, optlen, len);
2931 static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
2933 return security_ops->socket_getpeersec_dgram(sock, skb, secid);
2936 static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
2938 return security_ops->sk_alloc_security(sk, family, priority);
2941 static inline void security_sk_free(struct sock *sk)
2943 return security_ops->sk_free_security(sk);
2946 static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
2948 return security_ops->sk_clone_security(sk, newsk);
2951 static inline void security_sk_classify_flow(struct sock *sk, struct flowi *fl)
2953 security_ops->sk_getsecid(sk, &fl->secid);
2956 static inline void security_req_classify_flow(const struct request_sock *req, struct flowi *fl)
2958 security_ops->req_classify_flow(req, fl);
2961 static inline void security_sock_graft(struct sock* sk, struct socket *parent)
2963 security_ops->sock_graft(sk, parent);
2966 static inline int security_inet_conn_request(struct sock *sk,
2967 struct sk_buff *skb, struct request_sock *req)
2969 return security_ops->inet_conn_request(sk, skb, req);
2972 static inline void security_inet_csk_clone(struct sock *newsk,
2973 const struct request_sock *req)
2975 security_ops->inet_csk_clone(newsk, req);
2978 static inline void security_inet_conn_established(struct sock *sk,
2979 struct sk_buff *skb)
2981 security_ops->inet_conn_established(sk, skb);
2983 #else /* CONFIG_SECURITY_NETWORK */
2984 static inline int security_unix_stream_connect(struct socket * sock,
2985 struct socket * other,
2986 struct sock * newsk)
2991 static inline int security_unix_may_send(struct socket * sock,
2992 struct socket * other)
2997 static inline int security_socket_create (int family, int type,
2998 int protocol, int kern)
3003 static inline int security_socket_post_create(struct socket * sock,
3006 int protocol, int kern)
3011 static inline int security_socket_bind(struct socket * sock,
3012 struct sockaddr * address,
3018 static inline int security_socket_connect(struct socket * sock,
3019 struct sockaddr * address,
3025 static inline int security_socket_listen(struct socket * sock, int backlog)
3030 static inline int security_socket_accept(struct socket * sock,
3031 struct socket * newsock)
3036 static inline void security_socket_post_accept(struct socket * sock,
3037 struct socket * newsock)
3041 static inline int security_socket_sendmsg(struct socket * sock,
3042 struct msghdr * msg, int size)
3047 static inline int security_socket_recvmsg(struct socket * sock,
3048 struct msghdr * msg, int size,
3054 static inline int security_socket_getsockname(struct socket * sock)
3059 static inline int security_socket_getpeername(struct socket * sock)
3064 static inline int security_socket_getsockopt(struct socket * sock,
3065 int level, int optname)
3070 static inline int security_socket_setsockopt(struct socket * sock,
3071 int level, int optname)
3076 static inline int security_socket_shutdown(struct socket * sock, int how)
3080 static inline int security_sock_rcv_skb (struct sock * sk,
3081 struct sk_buff * skb)
3086 static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
3087 int __user *optlen, unsigned len)
3089 return -ENOPROTOOPT;
3092 static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
3094 return -ENOPROTOOPT;
3097 static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
3102 static inline void security_sk_free(struct sock *sk)
3106 static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
3110 static inline void security_sk_classify_flow(struct sock *sk, struct flowi *fl)
3114 static inline void security_req_classify_flow(const struct request_sock *req, struct flowi *fl)
3118 static inline void security_sock_graft(struct sock* sk, struct socket *parent)
3122 static inline int security_inet_conn_request(struct sock *sk,
3123 struct sk_buff *skb, struct request_sock *req)
3128 static inline void security_inet_csk_clone(struct sock *newsk,
3129 const struct request_sock *req)
3133 static inline void security_inet_conn_established(struct sock *sk,
3134 struct sk_buff *skb)
3137 #endif /* CONFIG_SECURITY_NETWORK */
3139 #ifdef CONFIG_SECURITY_NETWORK_XFRM
3140 static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx)
3142 return security_ops->xfrm_policy_alloc_security(xp, sec_ctx);
3145 static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
3147 return security_ops->xfrm_policy_clone_security(old, new);
3150 static inline void security_xfrm_policy_free(struct xfrm_policy *xp)
3152 security_ops->xfrm_policy_free_security(xp);
3155 static inline int security_xfrm_policy_delete(struct xfrm_policy *xp)
3157 return security_ops->xfrm_policy_delete_security(xp);
3160 static inline int security_xfrm_state_alloc(struct xfrm_state *x,
3161 struct xfrm_user_sec_ctx *sec_ctx)
3163 return security_ops->xfrm_state_alloc_security(x, sec_ctx, 0);
3166 static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
3167 struct xfrm_sec_ctx *polsec, u32 secid)
3172 * We want the context to be taken from secid which is usually
3175 return security_ops->xfrm_state_alloc_security(x, NULL, secid);
3178 static inline int security_xfrm_state_delete(struct xfrm_state *x)
3180 return security_ops->xfrm_state_delete_security(x);
3183 static inline void security_xfrm_state_free(struct xfrm_state *x)
3185 security_ops->xfrm_state_free_security(x);
3188 static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir)
3190 return security_ops->xfrm_policy_lookup(xp, fl_secid, dir);
3193 static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
3194 struct xfrm_policy *xp, struct flowi *fl)
3196 return security_ops->xfrm_state_pol_flow_match(x, xp, fl);
3199 static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
3201 return security_ops->xfrm_decode_session(skb, secid, 1);
3204 static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl)
3206 int rc = security_ops->xfrm_decode_session(skb, &fl->secid, 0);
3210 #else /* CONFIG_SECURITY_NETWORK_XFRM */
3211 static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx)
3216 static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
3221 static inline void security_xfrm_policy_free(struct xfrm_policy *xp)
3225 static inline int security_xfrm_policy_delete(struct xfrm_policy *xp)
3230 static inline int security_xfrm_state_alloc(struct xfrm_state *x,
3231 struct xfrm_user_sec_ctx *sec_ctx)
3236 static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
3237 struct xfrm_sec_ctx *polsec, u32 secid)
3242 static inline void security_xfrm_state_free(struct xfrm_state *x)
3246 static inline int security_xfrm_state_delete(struct xfrm_state *x)
3251 static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir)
3256 static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
3257 struct xfrm_policy *xp, struct flowi *fl)
3262 static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
3267 static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl)
3271 #endif /* CONFIG_SECURITY_NETWORK_XFRM */
3274 #ifdef CONFIG_SECURITY
3275 static inline int security_key_alloc(struct key *key,
3276 struct task_struct *tsk,
3277 unsigned long flags)
3279 return security_ops->key_alloc(key, tsk, flags);
3282 static inline void security_key_free(struct key *key)
3284 security_ops->key_free(key);
3287 static inline int security_key_permission(key_ref_t key_ref,
3288 struct task_struct *context,
3291 return security_ops->key_permission(key_ref, context, perm);
3296 static inline int security_key_alloc(struct key *key,
3297 struct task_struct *tsk,
3298 unsigned long flags)
3303 static inline void security_key_free(struct key *key)
3307 static inline int security_key_permission(key_ref_t key_ref,
3308 struct task_struct *context,
3315 #endif /* CONFIG_KEYS */
3317 #endif /* ! __LINUX_SECURITY_H */