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>
39 * These functions are in security/capability.c and are used
40 * as the default capabilities functions
42 extern int cap_capable (struct task_struct *tsk, int cap);
43 extern int cap_settime (struct timespec *ts, struct timezone *tz);
44 extern int cap_ptrace (struct task_struct *parent, struct task_struct *child);
45 extern int cap_capget (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
46 extern int cap_capset_check (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
47 extern void cap_capset_set (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
48 extern int cap_bprm_set_security (struct linux_binprm *bprm);
49 extern void cap_bprm_apply_creds (struct linux_binprm *bprm, int unsafe);
50 extern int cap_bprm_secureexec(struct linux_binprm *bprm);
51 extern int cap_inode_setxattr(struct dentry *dentry, char *name, void *value, size_t size, int flags);
52 extern int cap_inode_removexattr(struct dentry *dentry, char *name);
53 extern int cap_task_post_setuid (uid_t old_ruid, uid_t old_euid, uid_t old_suid, int flags);
54 extern void cap_task_reparent_to_init (struct task_struct *p);
55 extern int cap_syslog (int type);
56 extern int cap_vm_enough_memory (long pages);
68 struct xfrm_user_sec_ctx;
70 extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
71 extern int cap_netlink_recv(struct sk_buff *skb, int cap);
74 * Values used in the task_security_ops calls
76 /* setuid or setgid, id0 == uid or gid */
77 #define LSM_SETID_ID 1
79 /* setreuid or setregid, id0 == real, id1 == eff */
80 #define LSM_SETID_RE 2
82 /* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
83 #define LSM_SETID_RES 4
85 /* setfsuid or setfsgid, id0 == fsuid or fsgid */
86 #define LSM_SETID_FS 8
88 /* forward declares to avoid warnings */
91 struct swap_info_struct;
93 /* bprm_apply_creds unsafe reasons */
94 #define LSM_UNSAFE_SHARE 1
95 #define LSM_UNSAFE_PTRACE 2
96 #define LSM_UNSAFE_PTRACE_CAP 4
98 #ifdef CONFIG_SECURITY
101 * struct security_operations - main security structure
103 * Security hooks for program execution operations.
105 * @bprm_alloc_security:
106 * Allocate and attach a security structure to the @bprm->security field.
107 * The security field is initialized to NULL when the bprm structure is
109 * @bprm contains the linux_binprm structure to be modified.
110 * Return 0 if operation was successful.
111 * @bprm_free_security:
112 * @bprm contains the linux_binprm structure to be modified.
113 * Deallocate and clear the @bprm->security field.
115 * Compute and set the security attributes of a process being transformed
116 * by an execve operation based on the old attributes (current->security)
117 * and the information saved in @bprm->security by the set_security hook.
118 * Since this hook function (and its caller) are void, this hook can not
119 * return an error. However, it can leave the security attributes of the
120 * process unchanged if an access failure occurs at this point.
121 * bprm_apply_creds is called under task_lock. @unsafe indicates various
122 * reasons why it may be unsafe to change security state.
123 * @bprm contains the linux_binprm structure.
124 * @bprm_post_apply_creds:
125 * Runs after bprm_apply_creds with the task_lock dropped, so that
126 * functions which cannot be called safely under the task_lock can
127 * be used. This hook is a good place to perform state changes on
128 * the process such as closing open file descriptors to which access
129 * is no longer granted if the attributes were changed.
130 * Note that a security module might need to save state between
131 * bprm_apply_creds and bprm_post_apply_creds to store the decision
132 * on whether the process may proceed.
133 * @bprm contains the linux_binprm structure.
134 * @bprm_set_security:
135 * Save security information in the bprm->security field, typically based
136 * on information about the bprm->file, for later use by the apply_creds
137 * hook. This hook may also optionally check permissions (e.g. for
138 * transitions between security domains).
139 * This hook may be called multiple times during a single execve, e.g. for
140 * interpreters. The hook can tell whether it has already been called by
141 * checking to see if @bprm->security is non-NULL. If so, then the hook
142 * may decide either to retain the security information saved earlier or
144 * @bprm contains the linux_binprm structure.
145 * Return 0 if the hook is successful and permission is granted.
146 * @bprm_check_security:
147 * This hook mediates the point when a search for a binary handler will
148 * begin. It allows a check the @bprm->security value which is set in
149 * the preceding set_security call. The primary difference from
150 * set_security is that the argv list and envp list are reliably
151 * available in @bprm. This hook may be called multiple times
152 * during a single execve; and in each pass set_security is called
154 * @bprm contains the linux_binprm structure.
155 * Return 0 if the hook is successful and permission is granted.
157 * Return a boolean value (0 or 1) indicating whether a "secure exec"
158 * is required. The flag is passed in the auxiliary table
159 * on the initial stack to the ELF interpreter to indicate whether libc
160 * should enable secure mode.
161 * @bprm contains the linux_binprm structure.
163 * Security hooks for filesystem operations.
165 * @sb_alloc_security:
166 * Allocate and attach a security structure to the sb->s_security field.
167 * The s_security field is initialized to NULL when the structure is
169 * @sb contains the super_block structure to be modified.
170 * Return 0 if operation was successful.
172 * Deallocate and clear the sb->s_security field.
173 * @sb contains the super_block structure to be modified.
175 * Check permission before obtaining filesystem statistics for the @mnt
177 * @dentry is a handle on the superblock for the filesystem.
178 * Return 0 if permission is granted.
180 * Check permission before an object specified by @dev_name is mounted on
181 * the mount point named by @nd. For an ordinary mount, @dev_name
182 * identifies a device if the file system type requires a device. For a
183 * remount (@flags & MS_REMOUNT), @dev_name is irrelevant. For a
184 * loopback/bind mount (@flags & MS_BIND), @dev_name identifies the
185 * pathname of the object being mounted.
186 * @dev_name contains the name for object being mounted.
187 * @nd contains the nameidata structure for mount point object.
188 * @type contains the filesystem type.
189 * @flags contains the mount flags.
190 * @data contains the filesystem-specific data.
191 * Return 0 if permission is granted.
193 * Allow mount option data to be copied prior to parsing by the filesystem,
194 * so that the security module can extract security-specific mount
195 * options cleanly (a filesystem may modify the data e.g. with strsep()).
196 * This also allows the original mount data to be stripped of security-
197 * specific options to avoid having to make filesystems aware of them.
198 * @type the type of filesystem being mounted.
199 * @orig the original mount data copied from userspace.
200 * @copy copied data which will be passed to the security module.
201 * Returns 0 if the copy was successful.
203 * Check permission before the device with superblock @mnt->sb is mounted
204 * on the mount point named by @nd.
205 * @mnt contains the vfsmount for device being mounted.
206 * @nd contains the nameidata object for the mount point.
207 * Return 0 if permission is granted.
209 * Check permission before the @mnt file system is unmounted.
210 * @mnt contains the mounted file system.
211 * @flags contains the unmount flags, e.g. MNT_FORCE.
212 * Return 0 if permission is granted.
214 * Close any files in the @mnt mounted filesystem that are held open by
215 * the security module. This hook is called during an umount operation
216 * prior to checking whether the filesystem is still busy.
217 * @mnt contains the mounted filesystem.
219 * Handle a failed umount of the @mnt mounted filesystem, e.g. re-opening
220 * any files that were closed by umount_close. This hook is called during
221 * an umount operation if the umount fails after a call to the
223 * @mnt contains the mounted filesystem.
225 * Update the security module's state when a filesystem is remounted.
226 * This hook is only called if the remount was successful.
227 * @mnt contains the mounted file system.
228 * @flags contains the new filesystem flags.
229 * @data contains the filesystem-specific data.
230 * @sb_post_mountroot:
231 * Update the security module's state when the root filesystem is mounted.
232 * This hook is only called if the mount was successful.
234 * Update the security module's state when a filesystem is mounted.
235 * This hook is called any time a mount is successfully grafetd to
237 * @mnt contains the mounted filesystem.
238 * @mountpoint_nd contains the nameidata structure for the mount point.
240 * Check permission before pivoting the root filesystem.
241 * @old_nd contains the nameidata structure for the new location of the current root (put_old).
242 * @new_nd contains the nameidata structure for the new root (new_root).
243 * Return 0 if permission is granted.
244 * @sb_post_pivotroot:
245 * Update module state after a successful pivot.
246 * @old_nd contains the nameidata structure for the old root.
247 * @new_nd contains the nameidata structure for the new root.
249 * Security hooks for inode operations.
251 * @inode_alloc_security:
252 * Allocate and attach a security structure to @inode->i_security. The
253 * i_security field is initialized to NULL when the inode structure is
255 * @inode contains the inode structure.
256 * Return 0 if operation was successful.
257 * @inode_free_security:
258 * @inode contains the inode structure.
259 * Deallocate the inode security structure and set @inode->i_security to
261 * @inode_init_security:
262 * Obtain the security attribute name suffix and value to set on a newly
263 * created inode and set up the incore security field for the new inode.
264 * This hook is called by the fs code as part of the inode creation
265 * transaction and provides for atomic labeling of the inode, unlike
266 * the post_create/mkdir/... hooks called by the VFS. The hook function
267 * is expected to allocate the name and value via kmalloc, with the caller
268 * being responsible for calling kfree after using them.
269 * If the security module does not use security attributes or does
270 * not wish to put a security attribute on this particular inode,
271 * then it should return -EOPNOTSUPP to skip this processing.
272 * @inode contains the inode structure of the newly created inode.
273 * @dir contains the inode structure of the parent directory.
274 * @name will be set to the allocated name suffix (e.g. selinux).
275 * @value will be set to the allocated attribute value.
276 * @len will be set to the length of the value.
277 * Returns 0 if @name and @value have been successfully set,
278 * -EOPNOTSUPP if no security attribute is needed, or
279 * -ENOMEM on memory allocation failure.
281 * Check permission to create a regular file.
282 * @dir contains inode structure of the parent of the new file.
283 * @dentry contains the dentry structure for the file to be created.
284 * @mode contains the file mode of the file to be created.
285 * Return 0 if permission is granted.
287 * Check permission before creating a new hard link to a file.
288 * @old_dentry contains the dentry structure for an existing link to the file.
289 * @dir contains the inode structure of the parent directory of the new link.
290 * @new_dentry contains the dentry structure for the new link.
291 * Return 0 if permission is granted.
293 * Check the permission to remove a hard link to a file.
294 * @dir contains the inode structure of parent directory of the file.
295 * @dentry contains the dentry structure for file to be unlinked.
296 * Return 0 if permission is granted.
298 * Check the permission to create a symbolic link to a file.
299 * @dir contains the inode structure of parent directory of the symbolic link.
300 * @dentry contains the dentry structure of the symbolic link.
301 * @old_name contains the pathname of file.
302 * Return 0 if permission is granted.
304 * Check permissions to create a new directory in the existing directory
305 * associated with inode strcture @dir.
306 * @dir containst the inode structure of parent of the directory to be created.
307 * @dentry contains the dentry structure of new directory.
308 * @mode contains the mode of new directory.
309 * Return 0 if permission is granted.
311 * Check the permission to remove a directory.
312 * @dir contains the inode structure of parent of the directory to be removed.
313 * @dentry contains the dentry structure of directory to be removed.
314 * Return 0 if permission is granted.
316 * Check permissions when creating a special file (or a socket or a fifo
317 * file created via the mknod system call). Note that if mknod operation
318 * is being done for a regular file, then the create hook will be called
320 * @dir contains the inode structure of parent of the new file.
321 * @dentry contains the dentry structure of the new file.
322 * @mode contains the mode of the new file.
323 * @dev contains the the device number.
324 * Return 0 if permission is granted.
326 * Check for permission to rename a file or directory.
327 * @old_dir contains the inode structure for parent of the old link.
328 * @old_dentry contains the dentry structure of the old link.
329 * @new_dir contains the inode structure for parent of the new link.
330 * @new_dentry contains the dentry structure of the new link.
331 * Return 0 if permission is granted.
333 * Check the permission to read the symbolic link.
334 * @dentry contains the dentry structure for the file link.
335 * Return 0 if permission is granted.
336 * @inode_follow_link:
337 * Check permission to follow a symbolic link when looking up a pathname.
338 * @dentry contains the dentry structure for the link.
339 * @nd contains the nameidata structure for the parent directory.
340 * Return 0 if permission is granted.
342 * Check permission before accessing an inode. This hook is called by the
343 * existing Linux permission function, so a security module can use it to
344 * provide additional checking for existing Linux permission checks.
345 * Notice that this hook is called when a file is opened (as well as many
346 * other operations), whereas the file_security_ops permission hook is
347 * called when the actual read/write operations are performed.
348 * @inode contains the inode structure to check.
349 * @mask contains the permission mask.
350 * @nd contains the nameidata (may be NULL).
351 * Return 0 if permission is granted.
353 * Check permission before setting file attributes. Note that the kernel
354 * call to notify_change is performed from several locations, whenever
355 * file attributes change (such as when a file is truncated, chown/chmod
356 * operations, transferring disk quotas, etc).
357 * @dentry contains the dentry structure for the file.
358 * @attr is the iattr structure containing the new file attributes.
359 * Return 0 if permission is granted.
361 * Check permission before obtaining file attributes.
362 * @mnt is the vfsmount where the dentry was looked up
363 * @dentry contains the dentry structure for the file.
364 * Return 0 if permission is granted.
366 * @inode contains the inode structure for deleted inode.
367 * This hook is called when a deleted inode is released (i.e. an inode
368 * with no hard links has its use count drop to zero). A security module
369 * can use this hook to release any persistent label associated with the
372 * Check permission before setting the extended attributes
373 * @value identified by @name for @dentry.
374 * Return 0 if permission is granted.
375 * @inode_post_setxattr:
376 * Update inode security field after successful setxattr operation.
377 * @value identified by @name for @dentry.
379 * Check permission before obtaining the extended attributes
380 * identified by @name for @dentry.
381 * Return 0 if permission is granted.
383 * Check permission before obtaining the list of extended attribute
385 * Return 0 if permission is granted.
386 * @inode_removexattr:
387 * Check permission before removing the extended attribute
388 * identified by @name for @dentry.
389 * Return 0 if permission is granted.
390 * @inode_getsecurity:
391 * Copy the extended attribute representation of the security label
392 * associated with @name for @inode into @buffer. @buffer may be
393 * NULL to request the size of the buffer required. @size indicates
394 * the size of @buffer in bytes. Note that @name is the remainder
395 * of the attribute name after the security. prefix has been removed.
396 * @err is the return value from the preceding fs getxattr call,
397 * and can be used by the security module to determine whether it
398 * should try and canonicalize the attribute value.
399 * Return number of bytes used/required on success.
400 * @inode_setsecurity:
401 * Set the security label associated with @name for @inode from the
402 * extended attribute value @value. @size indicates the size of the
403 * @value in bytes. @flags may be XATTR_CREATE, XATTR_REPLACE, or 0.
404 * Note that @name is the remainder of the attribute name after the
405 * security. prefix has been removed.
406 * Return 0 on success.
407 * @inode_listsecurity:
408 * Copy the extended attribute names for the security labels
409 * associated with @inode into @buffer. The maximum size of @buffer
410 * is specified by @buffer_size. @buffer may be NULL to request
411 * the size of the buffer required.
412 * Returns number of bytes used/required on success.
414 * Security hooks for file operations
417 * Check file permissions before accessing an open file. This hook is
418 * called by various operations that read or write files. A security
419 * module can use this hook to perform additional checking on these
420 * operations, e.g. to revalidate permissions on use to support privilege
421 * bracketing or policy changes. Notice that this hook is used when the
422 * actual read/write operations are performed, whereas the
423 * inode_security_ops hook is called when a file is opened (as well as
424 * many other operations).
425 * Caveat: Although this hook can be used to revalidate permissions for
426 * various system call operations that read or write files, it does not
427 * address the revalidation of permissions for memory-mapped files.
428 * Security modules must handle this separately if they need such
430 * @file contains the file structure being accessed.
431 * @mask contains the requested permissions.
432 * Return 0 if permission is granted.
433 * @file_alloc_security:
434 * Allocate and attach a security structure to the file->f_security field.
435 * The security field is initialized to NULL when the structure is first
437 * @file contains the file structure to secure.
438 * Return 0 if the hook is successful and permission is granted.
439 * @file_free_security:
440 * Deallocate and free any security structures stored in file->f_security.
441 * @file contains the file structure being modified.
443 * @file contains the file structure.
444 * @cmd contains the operation to perform.
445 * @arg contains the operational arguments.
446 * Check permission for an ioctl operation on @file. Note that @arg can
447 * sometimes represents a user space pointer; in other cases, it may be a
448 * simple integer value. When @arg represents a user space pointer, it
449 * should never be used by the security module.
450 * Return 0 if permission is granted.
452 * Check permissions for a mmap operation. The @file may be NULL, e.g.
453 * if mapping anonymous memory.
454 * @file contains the file structure for file to map (may be NULL).
455 * @reqprot contains the protection requested by the application.
456 * @prot contains the protection that will be applied by the kernel.
457 * @flags contains the operational flags.
458 * Return 0 if permission is granted.
460 * Check permissions before changing memory access permissions.
461 * @vma contains the memory region to modify.
462 * @reqprot contains the protection requested by the application.
463 * @prot contains the protection that will be applied by the kernel.
464 * Return 0 if permission is granted.
466 * Check permission before performing file locking operations.
467 * Note: this hook mediates both flock and fcntl style locks.
468 * @file contains the file structure.
469 * @cmd contains the posix-translated lock operation to perform
470 * (e.g. F_RDLCK, F_WRLCK).
471 * Return 0 if permission is granted.
473 * Check permission before allowing the file operation specified by @cmd
474 * from being performed on the file @file. Note that @arg can sometimes
475 * represents a user space pointer; in other cases, it may be a simple
476 * integer value. When @arg represents a user space pointer, it should
477 * never be used by the security module.
478 * @file contains the file structure.
479 * @cmd contains the operation to be performed.
480 * @arg contains the operational arguments.
481 * Return 0 if permission is granted.
483 * Save owner security information (typically from current->security) in
484 * file->f_security for later use by the send_sigiotask hook.
485 * @file contains the file structure to update.
486 * Return 0 on success.
487 * @file_send_sigiotask:
488 * Check permission for the file owner @fown to send SIGIO or SIGURG to the
489 * process @tsk. Note that this hook is sometimes called from interrupt.
490 * Note that the fown_struct, @fown, is never outside the context of a
491 * struct file, so the file structure (and associated security information)
492 * can always be obtained:
493 * (struct file *)((long)fown - offsetof(struct file,f_owner));
494 * @tsk contains the structure of task receiving signal.
495 * @fown contains the file owner information.
496 * @sig is the signal that will be sent. When 0, kernel sends SIGIO.
497 * Return 0 if permission is granted.
499 * This hook allows security modules to control the ability of a process
500 * to receive an open file descriptor via socket IPC.
501 * @file contains the file structure being received.
502 * Return 0 if permission is granted.
504 * Security hooks for task operations.
507 * Check permission before creating a child process. See the clone(2)
508 * manual page for definitions of the @clone_flags.
509 * @clone_flags contains the flags indicating what should be shared.
510 * Return 0 if permission is granted.
511 * @task_alloc_security:
512 * @p contains the task_struct for child process.
513 * Allocate and attach a security structure to the p->security field. The
514 * security field is initialized to NULL when the task structure is
516 * Return 0 if operation was successful.
517 * @task_free_security:
518 * @p contains the task_struct for process.
519 * Deallocate and clear the p->security field.
521 * Check permission before setting one or more of the user identity
522 * attributes of the current process. The @flags parameter indicates
523 * which of the set*uid system calls invoked this hook and how to
524 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
525 * definitions at the beginning of this file for the @flags values and
527 * @id0 contains a uid.
528 * @id1 contains a uid.
529 * @id2 contains a uid.
530 * @flags contains one of the LSM_SETID_* values.
531 * Return 0 if permission is granted.
533 * Update the module's state after setting one or more of the user
534 * identity attributes of the current process. The @flags parameter
535 * indicates which of the set*uid system calls invoked this hook. If
536 * @flags is LSM_SETID_FS, then @old_ruid is the old fs uid and the other
537 * parameters are not used.
538 * @old_ruid contains the old real uid (or fs uid if LSM_SETID_FS).
539 * @old_euid contains the old effective uid (or -1 if LSM_SETID_FS).
540 * @old_suid contains the old saved uid (or -1 if LSM_SETID_FS).
541 * @flags contains one of the LSM_SETID_* values.
542 * Return 0 on success.
544 * Check permission before setting one or more of the group identity
545 * attributes of the current process. The @flags parameter indicates
546 * which of the set*gid system calls invoked this hook and how to
547 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
548 * definitions at the beginning of this file for the @flags values and
550 * @id0 contains a gid.
551 * @id1 contains a gid.
552 * @id2 contains a gid.
553 * @flags contains one of the LSM_SETID_* values.
554 * Return 0 if permission is granted.
556 * Check permission before setting the process group identifier of the
557 * process @p to @pgid.
558 * @p contains the task_struct for process being modified.
559 * @pgid contains the new pgid.
560 * Return 0 if permission is granted.
562 * Check permission before getting the process group identifier of the
564 * @p contains the task_struct for the process.
565 * Return 0 if permission is granted.
567 * Check permission before getting the session identifier of the process
569 * @p contains the task_struct for the process.
570 * Return 0 if permission is granted.
572 * Retrieve the security identifier of the process @p.
573 * @p contains the task_struct for the process and place is into @secid.
575 * Check permission before setting the supplementary group set of the
577 * @group_info contains the new group information.
578 * Return 0 if permission is granted.
580 * Check permission before setting the nice value of @p to @nice.
581 * @p contains the task_struct of process.
582 * @nice contains the new nice value.
583 * Return 0 if permission is granted.
585 * Check permission before setting the ioprio value of @p to @ioprio.
586 * @p contains the task_struct of process.
587 * @ioprio contains the new ioprio value
588 * Return 0 if permission is granted.
590 * Check permission before getting the ioprio value of @p.
591 * @p contains the task_struct of process.
592 * Return 0 if permission is granted.
594 * Check permission before setting the resource limits of the current
595 * process for @resource to @new_rlim. The old resource limit values can
596 * be examined by dereferencing (current->signal->rlim + resource).
597 * @resource contains the resource whose limit is being set.
598 * @new_rlim contains the new limits for @resource.
599 * Return 0 if permission is granted.
600 * @task_setscheduler:
601 * Check permission before setting scheduling policy and/or parameters of
602 * process @p based on @policy and @lp.
603 * @p contains the task_struct for process.
604 * @policy contains the scheduling policy.
605 * @lp contains the scheduling parameters.
606 * Return 0 if permission is granted.
607 * @task_getscheduler:
608 * Check permission before obtaining scheduling information for process
610 * @p contains the task_struct for process.
611 * Return 0 if permission is granted.
613 * Check permission before moving memory owned by process @p.
614 * @p contains the task_struct for process.
615 * Return 0 if permission is granted.
617 * Check permission before sending signal @sig to @p. @info can be NULL,
618 * the constant 1, or a pointer to a siginfo structure. If @info is 1 or
619 * SI_FROMKERNEL(info) is true, then the signal should be viewed as coming
620 * from the kernel and should typically be permitted.
621 * SIGIO signals are handled separately by the send_sigiotask hook in
623 * @p contains the task_struct for process.
624 * @info contains the signal information.
625 * @sig contains the signal value.
626 * @secid contains the sid of the process where the signal originated
627 * Return 0 if permission is granted.
629 * Check permission before allowing a process to reap a child process @p
630 * and collect its status information.
631 * @p contains the task_struct for process.
632 * Return 0 if permission is granted.
634 * Check permission before performing a process control operation on the
636 * @option contains the operation.
637 * @arg2 contains a argument.
638 * @arg3 contains a argument.
639 * @arg4 contains a argument.
640 * @arg5 contains a argument.
641 * Return 0 if permission is granted.
642 * @task_reparent_to_init:
643 * Set the security attributes in @p->security for a kernel thread that
644 * is being reparented to the init task.
645 * @p contains the task_struct for the kernel thread.
647 * Set the security attributes for an inode based on an associated task's
648 * security attributes, e.g. for /proc/pid inodes.
649 * @p contains the task_struct for the task.
650 * @inode contains the inode structure for the inode.
652 * Security hooks for Netlink messaging.
655 * Save security information for a netlink message so that permission
656 * checking can be performed when the message is processed. The security
657 * information can be saved using the eff_cap field of the
658 * netlink_skb_parms structure. Also may be used to provide fine
659 * grained control over message transmission.
660 * @sk associated sock of task sending the message.,
661 * @skb contains the sk_buff structure for the netlink message.
662 * Return 0 if the information was successfully saved and message
663 * is allowed to be transmitted.
665 * Check permission before processing the received netlink message in
667 * @skb contains the sk_buff structure for the netlink message.
668 * @cap indicates the capability required
669 * Return 0 if permission is granted.
671 * Security hooks for Unix domain networking.
673 * @unix_stream_connect:
674 * Check permissions before establishing a Unix domain stream connection
675 * between @sock and @other.
676 * @sock contains the socket structure.
677 * @other contains the peer socket structure.
678 * Return 0 if permission is granted.
680 * Check permissions before connecting or sending datagrams from @sock to
682 * @sock contains the socket structure.
683 * @sock contains the peer socket structure.
684 * Return 0 if permission is granted.
686 * The @unix_stream_connect and @unix_may_send hooks were necessary because
687 * Linux provides an alternative to the conventional file name space for Unix
688 * domain sockets. Whereas binding and connecting to sockets in the file name
689 * space is mediated by the typical file permissions (and caught by the mknod
690 * and permission hooks in inode_security_ops), binding and connecting to
691 * sockets in the abstract name space is completely unmediated. Sufficient
692 * control of Unix domain sockets in the abstract name space isn't possible
693 * using only the socket layer hooks, since we need to know the actual target
694 * socket, which is not looked up until we are inside the af_unix code.
696 * Security hooks for socket operations.
699 * Check permissions prior to creating a new socket.
700 * @family contains the requested protocol family.
701 * @type contains the requested communications type.
702 * @protocol contains the requested protocol.
703 * @kern set to 1 if a kernel socket.
704 * Return 0 if permission is granted.
705 * @socket_post_create:
706 * This hook allows a module to update or allocate a per-socket security
707 * structure. Note that the security field was not added directly to the
708 * socket structure, but rather, the socket security information is stored
709 * in the associated inode. Typically, the inode alloc_security hook will
710 * allocate and and attach security information to
711 * sock->inode->i_security. This hook may be used to update the
712 * sock->inode->i_security field with additional information that wasn't
713 * available when the inode was allocated.
714 * @sock contains the newly created socket structure.
715 * @family contains the requested protocol family.
716 * @type contains the requested communications type.
717 * @protocol contains the requested protocol.
718 * @kern set to 1 if a kernel socket.
720 * Check permission before socket protocol layer bind operation is
721 * performed and the socket @sock is bound to the address specified in the
722 * @address parameter.
723 * @sock contains the socket structure.
724 * @address contains the address to bind to.
725 * @addrlen contains the length of address.
726 * Return 0 if permission is granted.
728 * Check permission before socket protocol layer connect operation
729 * attempts to connect socket @sock to a remote address, @address.
730 * @sock contains the socket structure.
731 * @address contains the address of remote endpoint.
732 * @addrlen contains the length of address.
733 * Return 0 if permission is granted.
735 * Check permission before socket protocol layer listen operation.
736 * @sock contains the socket structure.
737 * @backlog contains the maximum length for the pending connection queue.
738 * Return 0 if permission is granted.
740 * Check permission before accepting a new connection. Note that the new
741 * socket, @newsock, has been created and some information copied to it,
742 * but the accept operation has not actually been performed.
743 * @sock contains the listening socket structure.
744 * @newsock contains the newly created server socket for connection.
745 * Return 0 if permission is granted.
746 * @socket_post_accept:
747 * This hook allows a security module to copy security
748 * information into the newly created socket's inode.
749 * @sock contains the listening socket structure.
750 * @newsock contains the newly created server socket for connection.
752 * Check permission before transmitting a message to another socket.
753 * @sock contains the socket structure.
754 * @msg contains the message to be transmitted.
755 * @size contains the size of message.
756 * Return 0 if permission is granted.
758 * Check permission before receiving a message from a socket.
759 * @sock contains the socket structure.
760 * @msg contains the message structure.
761 * @size contains the size of message structure.
762 * @flags contains the operational flags.
763 * Return 0 if permission is granted.
764 * @socket_getsockname:
765 * Check permission before the local address (name) of the socket object
766 * @sock is retrieved.
767 * @sock contains the socket structure.
768 * Return 0 if permission is granted.
769 * @socket_getpeername:
770 * Check permission before the remote address (name) of a socket object
771 * @sock is retrieved.
772 * @sock contains the socket structure.
773 * Return 0 if permission is granted.
774 * @socket_getsockopt:
775 * Check permissions before retrieving the options associated with socket
777 * @sock contains the socket structure.
778 * @level contains the protocol level to retrieve option from.
779 * @optname contains the name of option to retrieve.
780 * Return 0 if permission is granted.
781 * @socket_setsockopt:
782 * Check permissions before setting the options associated with socket
784 * @sock contains the socket structure.
785 * @level contains the protocol level to set options for.
786 * @optname contains the name of the option to set.
787 * Return 0 if permission is granted.
789 * Checks permission before all or part of a connection on the socket
790 * @sock is shut down.
791 * @sock contains the socket structure.
792 * @how contains the flag indicating how future sends and receives are handled.
793 * Return 0 if permission is granted.
794 * @socket_sock_rcv_skb:
795 * Check permissions on incoming network packets. This hook is distinct
796 * from Netfilter's IP input hooks since it is the first time that the
797 * incoming sk_buff @skb has been associated with a particular socket, @sk.
798 * @sk contains the sock (not socket) associated with the incoming sk_buff.
799 * @skb contains the incoming network data.
800 * @socket_getpeersec:
801 * This hook allows the security module to provide peer socket security
802 * state to userspace via getsockopt SO_GETPEERSEC.
803 * @sock is the local socket.
804 * @optval userspace memory where the security state is to be copied.
805 * @optlen userspace int where the module should copy the actual length
806 * of the security state.
807 * @len as input is the maximum length to copy to userspace provided
809 * Return 0 if all is well, otherwise, typical getsockopt return
811 * @sk_alloc_security:
812 * Allocate and attach a security structure to the sk->sk_security field,
813 * which is used to copy security attributes between local stream sockets.
815 * Deallocate security structure.
816 * @sk_clone_security:
817 * Clone/copy security structure.
819 * Retrieve the LSM-specific sid for the sock to enable caching of network
822 * Security hooks for XFRM operations.
824 * @xfrm_policy_alloc_security:
825 * @xp contains the xfrm_policy being added to Security Policy Database
826 * used by the XFRM system.
827 * @sec_ctx contains the security context information being provided by
828 * the user-level policy update program (e.g., setkey).
829 * Allocate a security structure to the xp->security field; the security
830 * field is initialized to NULL when the xfrm_policy is allocated.
831 * Return 0 if operation was successful (memory to allocate, legal context)
832 * @xfrm_policy_clone_security:
833 * @old contains an existing xfrm_policy in the SPD.
834 * @new contains a new xfrm_policy being cloned from old.
835 * Allocate a security structure to the new->security field
836 * that contains the information from the old->security field.
837 * Return 0 if operation was successful (memory to allocate).
838 * @xfrm_policy_free_security:
839 * @xp contains the xfrm_policy
840 * Deallocate xp->security.
841 * @xfrm_policy_delete_security:
842 * @xp contains the xfrm_policy.
843 * Authorize deletion of xp->security.
844 * @xfrm_state_alloc_security:
845 * @x contains the xfrm_state being added to the Security Association
846 * Database by the XFRM system.
847 * @sec_ctx contains the security context information being provided by
848 * the user-level SA generation program (e.g., setkey or racoon).
849 * @polsec contains the security context information associated with a xfrm
850 * policy rule from which to take the base context. polsec must be NULL
851 * when sec_ctx is specified.
852 * @secid contains the secid from which to take the mls portion of the context.
853 * Allocate a security structure to the x->security field; the security
854 * field is initialized to NULL when the xfrm_state is allocated. Set the
855 * context to correspond to either sec_ctx or polsec, with the mls portion
856 * taken from secid in the latter case.
857 * Return 0 if operation was successful (memory to allocate, legal context).
858 * @xfrm_state_free_security:
859 * @x contains the xfrm_state.
860 * Deallocate x->security.
861 * @xfrm_state_delete_security:
862 * @x contains the xfrm_state.
863 * Authorize deletion of x->security.
864 * @xfrm_policy_lookup:
865 * @xp contains the xfrm_policy for which the access control is being
867 * @fl_secid contains the flow security label that is used to authorize
868 * access to the policy xp.
869 * @dir contains the direction of the flow (input or output).
870 * Check permission when a flow selects a xfrm_policy for processing
871 * XFRMs on a packet. The hook is called when selecting either a
872 * per-socket policy or a generic xfrm policy.
873 * Return 0 if permission is granted.
874 * @xfrm_state_pol_flow_match:
875 * @x contains the state to match.
876 * @xp contains the policy to check for a match.
877 * @fl contains the flow to check for a match.
878 * Return 1 if there is a match.
879 * @xfrm_flow_state_match:
880 * @fl contains the flow key to match.
881 * @xfrm points to the xfrm_state to match.
882 * Return 1 if there is a match.
883 * @xfrm_decode_session:
884 * @skb points to skb to decode.
885 * @fl points to the flow key to set.
886 * Return 0 if successful decoding.
888 * Security hooks affecting all Key Management operations
891 * Permit allocation of a key and assign security data. Note that key does
892 * not have a serial number assigned at this point.
893 * @key points to the key.
894 * @flags is the allocation flags
895 * Return 0 if permission is granted, -ve error otherwise.
897 * Notification of destruction; free security data.
898 * @key points to the key.
901 * See whether a specific operational right is granted to a process on a
903 * @key_ref refers to the key (key pointer + possession attribute bit).
904 * @context points to the process to provide the context against which to
905 * evaluate the security data on the key.
906 * @perm describes the combination of permissions required of this key.
907 * Return 1 if permission granted, 0 if permission denied and -ve it the
908 * normal permissions model should be effected.
910 * Security hooks affecting all System V IPC operations.
913 * Check permissions for access to IPC
914 * @ipcp contains the kernel IPC permission structure
915 * @flag contains the desired (requested) permission set
916 * Return 0 if permission is granted.
918 * Security hooks for individual messages held in System V IPC message queues
919 * @msg_msg_alloc_security:
920 * Allocate and attach a security structure to the msg->security field.
921 * The security field is initialized to NULL when the structure is first
923 * @msg contains the message structure to be modified.
924 * Return 0 if operation was successful and permission is granted.
925 * @msg_msg_free_security:
926 * Deallocate the security structure for this message.
927 * @msg contains the message structure to be modified.
929 * Security hooks for System V IPC Message Queues
931 * @msg_queue_alloc_security:
932 * Allocate and attach a security structure to the
933 * msq->q_perm.security field. The security field is initialized to
934 * NULL when the structure is first created.
935 * @msq contains the message queue structure to be modified.
936 * Return 0 if operation was successful and permission is granted.
937 * @msg_queue_free_security:
938 * Deallocate security structure for this message queue.
939 * @msq contains the message queue structure to be modified.
940 * @msg_queue_associate:
941 * Check permission when a message queue is requested through the
942 * msgget system call. This hook is only called when returning the
943 * message queue identifier for an existing message queue, not when a
944 * new message queue is created.
945 * @msq contains the message queue to act upon.
946 * @msqflg contains the operation control flags.
947 * Return 0 if permission is granted.
949 * Check permission when a message control operation specified by @cmd
950 * is to be performed on the message queue @msq.
951 * The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO.
952 * @msq contains the message queue to act upon. May be NULL.
953 * @cmd contains the operation to be performed.
954 * Return 0 if permission is granted.
956 * Check permission before a message, @msg, is enqueued on the message
958 * @msq contains the message queue to send message to.
959 * @msg contains the message to be enqueued.
960 * @msqflg contains operational flags.
961 * Return 0 if permission is granted.
963 * Check permission before a message, @msg, is removed from the message
964 * queue, @msq. The @target task structure contains a pointer to the
965 * process that will be receiving the message (not equal to the current
966 * process when inline receives are being performed).
967 * @msq contains the message queue to retrieve message from.
968 * @msg contains the message destination.
969 * @target contains the task structure for recipient process.
970 * @type contains the type of message requested.
971 * @mode contains the operational flags.
972 * Return 0 if permission is granted.
974 * Security hooks for System V Shared Memory Segments
976 * @shm_alloc_security:
977 * Allocate and attach a security structure to the shp->shm_perm.security
978 * field. The security field is initialized to NULL when the structure is
980 * @shp contains the shared memory structure to be modified.
981 * Return 0 if operation was successful and permission is granted.
982 * @shm_free_security:
983 * Deallocate the security struct for this memory segment.
984 * @shp contains the shared memory structure to be modified.
986 * Check permission when a shared memory region is requested through the
987 * shmget system call. This hook is only called when returning the shared
988 * memory region identifier for an existing region, not when a new shared
989 * memory region is created.
990 * @shp contains the shared memory structure to be modified.
991 * @shmflg contains the operation control flags.
992 * Return 0 if permission is granted.
994 * Check permission when a shared memory control operation specified by
995 * @cmd is to be performed on the shared memory region @shp.
996 * The @shp may be NULL, e.g. for IPC_INFO or SHM_INFO.
997 * @shp contains shared memory structure to be modified.
998 * @cmd contains the operation to be performed.
999 * Return 0 if permission is granted.
1001 * Check permissions prior to allowing the shmat system call to attach the
1002 * shared memory segment @shp to the data segment of the calling process.
1003 * The attaching address is specified by @shmaddr.
1004 * @shp contains the shared memory structure to be modified.
1005 * @shmaddr contains the address to attach memory region to.
1006 * @shmflg contains the operational flags.
1007 * Return 0 if permission is granted.
1009 * Security hooks for System V Semaphores
1011 * @sem_alloc_security:
1012 * Allocate and attach a security structure to the sma->sem_perm.security
1013 * field. The security field is initialized to NULL when the structure is
1015 * @sma contains the semaphore structure
1016 * Return 0 if operation was successful and permission is granted.
1017 * @sem_free_security:
1018 * deallocate security struct for this semaphore
1019 * @sma contains the semaphore structure.
1021 * Check permission when a semaphore is requested through the semget
1022 * system call. This hook is only called when returning the semaphore
1023 * identifier for an existing semaphore, not when a new one must be
1025 * @sma contains the semaphore structure.
1026 * @semflg contains the operation control flags.
1027 * Return 0 if permission is granted.
1029 * Check permission when a semaphore operation specified by @cmd is to be
1030 * performed on the semaphore @sma. The @sma may be NULL, e.g. for
1031 * IPC_INFO or SEM_INFO.
1032 * @sma contains the semaphore structure. May be NULL.
1033 * @cmd contains the operation to be performed.
1034 * Return 0 if permission is granted.
1036 * Check permissions before performing operations on members of the
1037 * semaphore set @sma. If the @alter flag is nonzero, the semaphore set
1039 * @sma contains the semaphore structure.
1040 * @sops contains the operations to perform.
1041 * @nsops contains the number of operations to perform.
1042 * @alter contains the flag indicating whether changes are to be made.
1043 * Return 0 if permission is granted.
1046 * Check permission before allowing the @parent process to trace the
1048 * Security modules may also want to perform a process tracing check
1049 * during an execve in the set_security or apply_creds hooks of
1050 * binprm_security_ops if the process is being traced and its security
1051 * attributes would be changed by the execve.
1052 * @parent contains the task_struct structure for parent process.
1053 * @child contains the task_struct structure for child process.
1054 * Return 0 if permission is granted.
1056 * Get the @effective, @inheritable, and @permitted capability sets for
1057 * the @target process. The hook may also perform permission checking to
1058 * determine if the current process is allowed to see the capability sets
1059 * of the @target process.
1060 * @target contains the task_struct structure for target process.
1061 * @effective contains the effective capability set.
1062 * @inheritable contains the inheritable capability set.
1063 * @permitted contains the permitted capability set.
1064 * Return 0 if the capability sets were successfully obtained.
1066 * Check permission before setting the @effective, @inheritable, and
1067 * @permitted capability sets for the @target process.
1068 * Caveat: @target is also set to current if a set of processes is
1069 * specified (i.e. all processes other than current and init or a
1070 * particular process group). Hence, the capset_set hook may need to
1071 * revalidate permission to the actual target process.
1072 * @target contains the task_struct structure for target process.
1073 * @effective contains the effective capability set.
1074 * @inheritable contains the inheritable capability set.
1075 * @permitted contains the permitted capability set.
1076 * Return 0 if permission is granted.
1078 * Set the @effective, @inheritable, and @permitted capability sets for
1079 * the @target process. Since capset_check cannot always check permission
1080 * to the real @target process, this hook may also perform permission
1081 * checking to determine if the current process is allowed to set the
1082 * capability sets of the @target process. However, this hook has no way
1083 * of returning an error due to the structure of the sys_capset code.
1084 * @target contains the task_struct structure for target process.
1085 * @effective contains the effective capability set.
1086 * @inheritable contains the inheritable capability set.
1087 * @permitted contains the permitted capability set.
1089 * Check whether the @tsk process has the @cap capability.
1090 * @tsk contains the task_struct for the process.
1091 * @cap contains the capability <include/linux/capability.h>.
1092 * Return 0 if the capability is granted for @tsk.
1094 * Check permission before enabling or disabling process accounting. If
1095 * accounting is being enabled, then @file refers to the open file used to
1096 * store accounting records. If accounting is being disabled, then @file
1098 * @file contains the file structure for the accounting file (may be NULL).
1099 * Return 0 if permission is granted.
1101 * Check permission before accessing the @table sysctl variable in the
1102 * manner specified by @op.
1103 * @table contains the ctl_table structure for the sysctl variable.
1104 * @op contains the operation (001 = search, 002 = write, 004 = read).
1105 * Return 0 if permission is granted.
1107 * Check permission before accessing the kernel message ring or changing
1108 * logging to the console.
1109 * See the syslog(2) manual page for an explanation of the @type values.
1110 * @type contains the type of action.
1111 * Return 0 if permission is granted.
1113 * Check permission to change the system time.
1114 * struct timespec and timezone are defined in include/linux/time.h
1115 * @ts contains new time
1116 * @tz contains new timezone
1117 * Return 0 if permission is granted.
1118 * @vm_enough_memory:
1119 * Check permissions for allocating a new virtual mapping.
1120 * @pages contains the number of pages.
1121 * Return 0 if permission is granted.
1123 * @register_security:
1124 * allow module stacking.
1125 * @name contains the name of the security module being stacked.
1126 * @ops contains a pointer to the struct security_operations of the module to stack.
1127 * @unregister_security:
1128 * remove a stacked module.
1129 * @name contains the name of the security module being unstacked.
1130 * @ops contains a pointer to the struct security_operations of the module to unstack.
1133 * Convert secid to security context.
1134 * @secid contains the security ID.
1135 * @secdata contains the pointer that stores the converted security context.
1138 * Release the security context.
1139 * @secdata contains the security context.
1140 * @seclen contains the length of the security context.
1142 * This is the main security structure.
1144 struct security_operations {
1145 int (*ptrace) (struct task_struct * parent, struct task_struct * child);
1146 int (*capget) (struct task_struct * target,
1147 kernel_cap_t * effective,
1148 kernel_cap_t * inheritable, kernel_cap_t * permitted);
1149 int (*capset_check) (struct task_struct * target,
1150 kernel_cap_t * effective,
1151 kernel_cap_t * inheritable,
1152 kernel_cap_t * permitted);
1153 void (*capset_set) (struct task_struct * target,
1154 kernel_cap_t * effective,
1155 kernel_cap_t * inheritable,
1156 kernel_cap_t * permitted);
1157 int (*capable) (struct task_struct * tsk, int cap);
1158 int (*acct) (struct file * file);
1159 int (*sysctl) (struct ctl_table * table, int op);
1160 int (*quotactl) (int cmds, int type, int id, struct super_block * sb);
1161 int (*quota_on) (struct dentry * dentry);
1162 int (*syslog) (int type);
1163 int (*settime) (struct timespec *ts, struct timezone *tz);
1164 int (*vm_enough_memory) (long pages);
1166 int (*bprm_alloc_security) (struct linux_binprm * bprm);
1167 void (*bprm_free_security) (struct linux_binprm * bprm);
1168 void (*bprm_apply_creds) (struct linux_binprm * bprm, int unsafe);
1169 void (*bprm_post_apply_creds) (struct linux_binprm * bprm);
1170 int (*bprm_set_security) (struct linux_binprm * bprm);
1171 int (*bprm_check_security) (struct linux_binprm * bprm);
1172 int (*bprm_secureexec) (struct linux_binprm * bprm);
1174 int (*sb_alloc_security) (struct super_block * sb);
1175 void (*sb_free_security) (struct super_block * sb);
1176 int (*sb_copy_data)(struct file_system_type *type,
1177 void *orig, void *copy);
1178 int (*sb_kern_mount) (struct super_block *sb, void *data);
1179 int (*sb_statfs) (struct dentry *dentry);
1180 int (*sb_mount) (char *dev_name, struct nameidata * nd,
1181 char *type, unsigned long flags, void *data);
1182 int (*sb_check_sb) (struct vfsmount * mnt, struct nameidata * nd);
1183 int (*sb_umount) (struct vfsmount * mnt, int flags);
1184 void (*sb_umount_close) (struct vfsmount * mnt);
1185 void (*sb_umount_busy) (struct vfsmount * mnt);
1186 void (*sb_post_remount) (struct vfsmount * mnt,
1187 unsigned long flags, void *data);
1188 void (*sb_post_mountroot) (void);
1189 void (*sb_post_addmount) (struct vfsmount * mnt,
1190 struct nameidata * mountpoint_nd);
1191 int (*sb_pivotroot) (struct nameidata * old_nd,
1192 struct nameidata * new_nd);
1193 void (*sb_post_pivotroot) (struct nameidata * old_nd,
1194 struct nameidata * new_nd);
1196 int (*inode_alloc_security) (struct inode *inode);
1197 void (*inode_free_security) (struct inode *inode);
1198 int (*inode_init_security) (struct inode *inode, struct inode *dir,
1199 char **name, void **value, size_t *len);
1200 int (*inode_create) (struct inode *dir,
1201 struct dentry *dentry, int mode);
1202 int (*inode_link) (struct dentry *old_dentry,
1203 struct inode *dir, struct dentry *new_dentry);
1204 int (*inode_unlink) (struct inode *dir, struct dentry *dentry);
1205 int (*inode_symlink) (struct inode *dir,
1206 struct dentry *dentry, const char *old_name);
1207 int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode);
1208 int (*inode_rmdir) (struct inode *dir, struct dentry *dentry);
1209 int (*inode_mknod) (struct inode *dir, struct dentry *dentry,
1210 int mode, dev_t dev);
1211 int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
1212 struct inode *new_dir, struct dentry *new_dentry);
1213 int (*inode_readlink) (struct dentry *dentry);
1214 int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
1215 int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd);
1216 int (*inode_setattr) (struct dentry *dentry, struct iattr *attr);
1217 int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
1218 void (*inode_delete) (struct inode *inode);
1219 int (*inode_setxattr) (struct dentry *dentry, char *name, void *value,
1220 size_t size, int flags);
1221 void (*inode_post_setxattr) (struct dentry *dentry, char *name, void *value,
1222 size_t size, int flags);
1223 int (*inode_getxattr) (struct dentry *dentry, char *name);
1224 int (*inode_listxattr) (struct dentry *dentry);
1225 int (*inode_removexattr) (struct dentry *dentry, char *name);
1226 const char *(*inode_xattr_getsuffix) (void);
1227 int (*inode_getsecurity)(const struct inode *inode, const char *name, void *buffer, size_t size, int err);
1228 int (*inode_setsecurity)(struct inode *inode, const char *name, const void *value, size_t size, int flags);
1229 int (*inode_listsecurity)(struct inode *inode, char *buffer, size_t buffer_size);
1231 int (*file_permission) (struct file * file, int mask);
1232 int (*file_alloc_security) (struct file * file);
1233 void (*file_free_security) (struct file * file);
1234 int (*file_ioctl) (struct file * file, unsigned int cmd,
1236 int (*file_mmap) (struct file * file,
1237 unsigned long reqprot,
1238 unsigned long prot, unsigned long flags);
1239 int (*file_mprotect) (struct vm_area_struct * vma,
1240 unsigned long reqprot,
1241 unsigned long prot);
1242 int (*file_lock) (struct file * file, unsigned int cmd);
1243 int (*file_fcntl) (struct file * file, unsigned int cmd,
1245 int (*file_set_fowner) (struct file * file);
1246 int (*file_send_sigiotask) (struct task_struct * tsk,
1247 struct fown_struct * fown, int sig);
1248 int (*file_receive) (struct file * file);
1250 int (*task_create) (unsigned long clone_flags);
1251 int (*task_alloc_security) (struct task_struct * p);
1252 void (*task_free_security) (struct task_struct * p);
1253 int (*task_setuid) (uid_t id0, uid_t id1, uid_t id2, int flags);
1254 int (*task_post_setuid) (uid_t old_ruid /* or fsuid */ ,
1255 uid_t old_euid, uid_t old_suid, int flags);
1256 int (*task_setgid) (gid_t id0, gid_t id1, gid_t id2, int flags);
1257 int (*task_setpgid) (struct task_struct * p, pid_t pgid);
1258 int (*task_getpgid) (struct task_struct * p);
1259 int (*task_getsid) (struct task_struct * p);
1260 void (*task_getsecid) (struct task_struct * p, u32 * secid);
1261 int (*task_setgroups) (struct group_info *group_info);
1262 int (*task_setnice) (struct task_struct * p, int nice);
1263 int (*task_setioprio) (struct task_struct * p, int ioprio);
1264 int (*task_getioprio) (struct task_struct * p);
1265 int (*task_setrlimit) (unsigned int resource, struct rlimit * new_rlim);
1266 int (*task_setscheduler) (struct task_struct * p, int policy,
1267 struct sched_param * lp);
1268 int (*task_getscheduler) (struct task_struct * p);
1269 int (*task_movememory) (struct task_struct * p);
1270 int (*task_kill) (struct task_struct * p,
1271 struct siginfo * info, int sig, u32 secid);
1272 int (*task_wait) (struct task_struct * p);
1273 int (*task_prctl) (int option, unsigned long arg2,
1274 unsigned long arg3, unsigned long arg4,
1275 unsigned long arg5);
1276 void (*task_reparent_to_init) (struct task_struct * p);
1277 void (*task_to_inode)(struct task_struct *p, struct inode *inode);
1279 int (*ipc_permission) (struct kern_ipc_perm * ipcp, short flag);
1281 int (*msg_msg_alloc_security) (struct msg_msg * msg);
1282 void (*msg_msg_free_security) (struct msg_msg * msg);
1284 int (*msg_queue_alloc_security) (struct msg_queue * msq);
1285 void (*msg_queue_free_security) (struct msg_queue * msq);
1286 int (*msg_queue_associate) (struct msg_queue * msq, int msqflg);
1287 int (*msg_queue_msgctl) (struct msg_queue * msq, int cmd);
1288 int (*msg_queue_msgsnd) (struct msg_queue * msq,
1289 struct msg_msg * msg, int msqflg);
1290 int (*msg_queue_msgrcv) (struct msg_queue * msq,
1291 struct msg_msg * msg,
1292 struct task_struct * target,
1293 long type, int mode);
1295 int (*shm_alloc_security) (struct shmid_kernel * shp);
1296 void (*shm_free_security) (struct shmid_kernel * shp);
1297 int (*shm_associate) (struct shmid_kernel * shp, int shmflg);
1298 int (*shm_shmctl) (struct shmid_kernel * shp, int cmd);
1299 int (*shm_shmat) (struct shmid_kernel * shp,
1300 char __user *shmaddr, int shmflg);
1302 int (*sem_alloc_security) (struct sem_array * sma);
1303 void (*sem_free_security) (struct sem_array * sma);
1304 int (*sem_associate) (struct sem_array * sma, int semflg);
1305 int (*sem_semctl) (struct sem_array * sma, int cmd);
1306 int (*sem_semop) (struct sem_array * sma,
1307 struct sembuf * sops, unsigned nsops, int alter);
1309 int (*netlink_send) (struct sock * sk, struct sk_buff * skb);
1310 int (*netlink_recv) (struct sk_buff * skb, int cap);
1312 /* allow module stacking */
1313 int (*register_security) (const char *name,
1314 struct security_operations *ops);
1315 int (*unregister_security) (const char *name,
1316 struct security_operations *ops);
1318 void (*d_instantiate) (struct dentry *dentry, struct inode *inode);
1320 int (*getprocattr)(struct task_struct *p, char *name, void *value, size_t size);
1321 int (*setprocattr)(struct task_struct *p, char *name, void *value, size_t size);
1322 int (*secid_to_secctx)(u32 secid, char **secdata, u32 *seclen);
1323 void (*release_secctx)(char *secdata, u32 seclen);
1325 #ifdef CONFIG_SECURITY_NETWORK
1326 int (*unix_stream_connect) (struct socket * sock,
1327 struct socket * other, struct sock * newsk);
1328 int (*unix_may_send) (struct socket * sock, struct socket * other);
1330 int (*socket_create) (int family, int type, int protocol, int kern);
1331 void (*socket_post_create) (struct socket * sock, int family,
1332 int type, int protocol, int kern);
1333 int (*socket_bind) (struct socket * sock,
1334 struct sockaddr * address, int addrlen);
1335 int (*socket_connect) (struct socket * sock,
1336 struct sockaddr * address, int addrlen);
1337 int (*socket_listen) (struct socket * sock, int backlog);
1338 int (*socket_accept) (struct socket * sock, struct socket * newsock);
1339 void (*socket_post_accept) (struct socket * sock,
1340 struct socket * newsock);
1341 int (*socket_sendmsg) (struct socket * sock,
1342 struct msghdr * msg, int size);
1343 int (*socket_recvmsg) (struct socket * sock,
1344 struct msghdr * msg, int size, int flags);
1345 int (*socket_getsockname) (struct socket * sock);
1346 int (*socket_getpeername) (struct socket * sock);
1347 int (*socket_getsockopt) (struct socket * sock, int level, int optname);
1348 int (*socket_setsockopt) (struct socket * sock, int level, int optname);
1349 int (*socket_shutdown) (struct socket * sock, int how);
1350 int (*socket_sock_rcv_skb) (struct sock * sk, struct sk_buff * skb);
1351 int (*socket_getpeersec_stream) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len);
1352 int (*socket_getpeersec_dgram) (struct socket *sock, struct sk_buff *skb, u32 *secid);
1353 int (*sk_alloc_security) (struct sock *sk, int family, gfp_t priority);
1354 void (*sk_free_security) (struct sock *sk);
1355 void (*sk_clone_security) (const struct sock *sk, struct sock *newsk);
1356 unsigned int (*sk_getsid) (struct sock *sk, struct flowi *fl, u8 dir);
1357 #endif /* CONFIG_SECURITY_NETWORK */
1359 #ifdef CONFIG_SECURITY_NETWORK_XFRM
1360 int (*xfrm_policy_alloc_security) (struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx);
1361 int (*xfrm_policy_clone_security) (struct xfrm_policy *old, struct xfrm_policy *new);
1362 void (*xfrm_policy_free_security) (struct xfrm_policy *xp);
1363 int (*xfrm_policy_delete_security) (struct xfrm_policy *xp);
1364 int (*xfrm_state_alloc_security) (struct xfrm_state *x,
1365 struct xfrm_user_sec_ctx *sec_ctx, struct xfrm_sec_ctx *polsec,
1367 void (*xfrm_state_free_security) (struct xfrm_state *x);
1368 int (*xfrm_state_delete_security) (struct xfrm_state *x);
1369 int (*xfrm_policy_lookup)(struct xfrm_policy *xp, u32 fl_secid, u8 dir);
1370 int (*xfrm_state_pol_flow_match)(struct xfrm_state *x,
1371 struct xfrm_policy *xp, struct flowi *fl);
1372 int (*xfrm_flow_state_match)(struct flowi *fl, struct xfrm_state *xfrm);
1373 int (*xfrm_decode_session)(struct sk_buff *skb, struct flowi *fl);
1374 #endif /* CONFIG_SECURITY_NETWORK_XFRM */
1376 /* key management security hooks */
1378 int (*key_alloc)(struct key *key, struct task_struct *tsk, unsigned long flags);
1379 void (*key_free)(struct key *key);
1380 int (*key_permission)(key_ref_t key_ref,
1381 struct task_struct *context,
1384 #endif /* CONFIG_KEYS */
1388 /* global variables */
1389 extern struct security_operations *security_ops;
1392 static inline int security_ptrace (struct task_struct * parent, struct task_struct * child)
1394 return security_ops->ptrace (parent, child);
1397 static inline int security_capget (struct task_struct *target,
1398 kernel_cap_t *effective,
1399 kernel_cap_t *inheritable,
1400 kernel_cap_t *permitted)
1402 return security_ops->capget (target, effective, inheritable, permitted);
1405 static inline int security_capset_check (struct task_struct *target,
1406 kernel_cap_t *effective,
1407 kernel_cap_t *inheritable,
1408 kernel_cap_t *permitted)
1410 return security_ops->capset_check (target, effective, inheritable, permitted);
1413 static inline void security_capset_set (struct task_struct *target,
1414 kernel_cap_t *effective,
1415 kernel_cap_t *inheritable,
1416 kernel_cap_t *permitted)
1418 security_ops->capset_set (target, effective, inheritable, permitted);
1421 static inline int security_capable(struct task_struct *tsk, int cap)
1423 return security_ops->capable(tsk, cap);
1426 static inline int security_acct (struct file *file)
1428 return security_ops->acct (file);
1431 static inline int security_sysctl(struct ctl_table *table, int op)
1433 return security_ops->sysctl(table, op);
1436 static inline int security_quotactl (int cmds, int type, int id,
1437 struct super_block *sb)
1439 return security_ops->quotactl (cmds, type, id, sb);
1442 static inline int security_quota_on (struct dentry * dentry)
1444 return security_ops->quota_on (dentry);
1447 static inline int security_syslog(int type)
1449 return security_ops->syslog(type);
1452 static inline int security_settime(struct timespec *ts, struct timezone *tz)
1454 return security_ops->settime(ts, tz);
1458 static inline int security_vm_enough_memory(long pages)
1460 return security_ops->vm_enough_memory(pages);
1463 static inline int security_bprm_alloc (struct linux_binprm *bprm)
1465 return security_ops->bprm_alloc_security (bprm);
1467 static inline void security_bprm_free (struct linux_binprm *bprm)
1469 security_ops->bprm_free_security (bprm);
1471 static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
1473 security_ops->bprm_apply_creds (bprm, unsafe);
1475 static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
1477 security_ops->bprm_post_apply_creds (bprm);
1479 static inline int security_bprm_set (struct linux_binprm *bprm)
1481 return security_ops->bprm_set_security (bprm);
1484 static inline int security_bprm_check (struct linux_binprm *bprm)
1486 return security_ops->bprm_check_security (bprm);
1489 static inline int security_bprm_secureexec (struct linux_binprm *bprm)
1491 return security_ops->bprm_secureexec (bprm);
1494 static inline int security_sb_alloc (struct super_block *sb)
1496 return security_ops->sb_alloc_security (sb);
1499 static inline void security_sb_free (struct super_block *sb)
1501 security_ops->sb_free_security (sb);
1504 static inline int security_sb_copy_data (struct file_system_type *type,
1505 void *orig, void *copy)
1507 return security_ops->sb_copy_data (type, orig, copy);
1510 static inline int security_sb_kern_mount (struct super_block *sb, void *data)
1512 return security_ops->sb_kern_mount (sb, data);
1515 static inline int security_sb_statfs (struct dentry *dentry)
1517 return security_ops->sb_statfs (dentry);
1520 static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
1521 char *type, unsigned long flags,
1524 return security_ops->sb_mount (dev_name, nd, type, flags, data);
1527 static inline int security_sb_check_sb (struct vfsmount *mnt,
1528 struct nameidata *nd)
1530 return security_ops->sb_check_sb (mnt, nd);
1533 static inline int security_sb_umount (struct vfsmount *mnt, int flags)
1535 return security_ops->sb_umount (mnt, flags);
1538 static inline void security_sb_umount_close (struct vfsmount *mnt)
1540 security_ops->sb_umount_close (mnt);
1543 static inline void security_sb_umount_busy (struct vfsmount *mnt)
1545 security_ops->sb_umount_busy (mnt);
1548 static inline void security_sb_post_remount (struct vfsmount *mnt,
1549 unsigned long flags, void *data)
1551 security_ops->sb_post_remount (mnt, flags, data);
1554 static inline void security_sb_post_mountroot (void)
1556 security_ops->sb_post_mountroot ();
1559 static inline void security_sb_post_addmount (struct vfsmount *mnt,
1560 struct nameidata *mountpoint_nd)
1562 security_ops->sb_post_addmount (mnt, mountpoint_nd);
1565 static inline int security_sb_pivotroot (struct nameidata *old_nd,
1566 struct nameidata *new_nd)
1568 return security_ops->sb_pivotroot (old_nd, new_nd);
1571 static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
1572 struct nameidata *new_nd)
1574 security_ops->sb_post_pivotroot (old_nd, new_nd);
1577 static inline int security_inode_alloc (struct inode *inode)
1579 return security_ops->inode_alloc_security (inode);
1582 static inline void security_inode_free (struct inode *inode)
1584 security_ops->inode_free_security (inode);
1587 static inline int security_inode_init_security (struct inode *inode,
1593 if (unlikely (IS_PRIVATE (inode)))
1595 return security_ops->inode_init_security (inode, dir, name, value, len);
1598 static inline int security_inode_create (struct inode *dir,
1599 struct dentry *dentry,
1602 if (unlikely (IS_PRIVATE (dir)))
1604 return security_ops->inode_create (dir, dentry, mode);
1607 static inline int security_inode_link (struct dentry *old_dentry,
1609 struct dentry *new_dentry)
1611 if (unlikely (IS_PRIVATE (old_dentry->d_inode)))
1613 return security_ops->inode_link (old_dentry, dir, new_dentry);
1616 static inline int security_inode_unlink (struct inode *dir,
1617 struct dentry *dentry)
1619 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1621 return security_ops->inode_unlink (dir, dentry);
1624 static inline int security_inode_symlink (struct inode *dir,
1625 struct dentry *dentry,
1626 const char *old_name)
1628 if (unlikely (IS_PRIVATE (dir)))
1630 return security_ops->inode_symlink (dir, dentry, old_name);
1633 static inline int security_inode_mkdir (struct inode *dir,
1634 struct dentry *dentry,
1637 if (unlikely (IS_PRIVATE (dir)))
1639 return security_ops->inode_mkdir (dir, dentry, mode);
1642 static inline int security_inode_rmdir (struct inode *dir,
1643 struct dentry *dentry)
1645 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1647 return security_ops->inode_rmdir (dir, dentry);
1650 static inline int security_inode_mknod (struct inode *dir,
1651 struct dentry *dentry,
1652 int mode, dev_t dev)
1654 if (unlikely (IS_PRIVATE (dir)))
1656 return security_ops->inode_mknod (dir, dentry, mode, dev);
1659 static inline int security_inode_rename (struct inode *old_dir,
1660 struct dentry *old_dentry,
1661 struct inode *new_dir,
1662 struct dentry *new_dentry)
1664 if (unlikely (IS_PRIVATE (old_dentry->d_inode) ||
1665 (new_dentry->d_inode && IS_PRIVATE (new_dentry->d_inode))))
1667 return security_ops->inode_rename (old_dir, old_dentry,
1668 new_dir, new_dentry);
1671 static inline int security_inode_readlink (struct dentry *dentry)
1673 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1675 return security_ops->inode_readlink (dentry);
1678 static inline int security_inode_follow_link (struct dentry *dentry,
1679 struct nameidata *nd)
1681 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1683 return security_ops->inode_follow_link (dentry, nd);
1686 static inline int security_inode_permission (struct inode *inode, int mask,
1687 struct nameidata *nd)
1689 if (unlikely (IS_PRIVATE (inode)))
1691 return security_ops->inode_permission (inode, mask, nd);
1694 static inline int security_inode_setattr (struct dentry *dentry,
1697 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1699 return security_ops->inode_setattr (dentry, attr);
1702 static inline int security_inode_getattr (struct vfsmount *mnt,
1703 struct dentry *dentry)
1705 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1707 return security_ops->inode_getattr (mnt, dentry);
1710 static inline void security_inode_delete (struct inode *inode)
1712 if (unlikely (IS_PRIVATE (inode)))
1714 security_ops->inode_delete (inode);
1717 static inline int security_inode_setxattr (struct dentry *dentry, char *name,
1718 void *value, size_t size, int flags)
1720 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1722 return security_ops->inode_setxattr (dentry, name, value, size, flags);
1725 static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
1726 void *value, size_t size, int flags)
1728 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1730 security_ops->inode_post_setxattr (dentry, name, value, size, flags);
1733 static inline int security_inode_getxattr (struct dentry *dentry, char *name)
1735 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1737 return security_ops->inode_getxattr (dentry, name);
1740 static inline int security_inode_listxattr (struct dentry *dentry)
1742 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1744 return security_ops->inode_listxattr (dentry);
1747 static inline int security_inode_removexattr (struct dentry *dentry, char *name)
1749 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1751 return security_ops->inode_removexattr (dentry, name);
1754 static inline const char *security_inode_xattr_getsuffix(void)
1756 return security_ops->inode_xattr_getsuffix();
1759 static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void *buffer, size_t size, int err)
1761 if (unlikely (IS_PRIVATE (inode)))
1763 return security_ops->inode_getsecurity(inode, name, buffer, size, err);
1766 static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
1768 if (unlikely (IS_PRIVATE (inode)))
1770 return security_ops->inode_setsecurity(inode, name, value, size, flags);
1773 static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
1775 if (unlikely (IS_PRIVATE (inode)))
1777 return security_ops->inode_listsecurity(inode, buffer, buffer_size);
1780 static inline int security_file_permission (struct file *file, int mask)
1782 return security_ops->file_permission (file, mask);
1785 static inline int security_file_alloc (struct file *file)
1787 return security_ops->file_alloc_security (file);
1790 static inline void security_file_free (struct file *file)
1792 security_ops->file_free_security (file);
1795 static inline int security_file_ioctl (struct file *file, unsigned int cmd,
1798 return security_ops->file_ioctl (file, cmd, arg);
1801 static inline int security_file_mmap (struct file *file, unsigned long reqprot,
1803 unsigned long flags)
1805 return security_ops->file_mmap (file, reqprot, prot, flags);
1808 static inline int security_file_mprotect (struct vm_area_struct *vma,
1809 unsigned long reqprot,
1812 return security_ops->file_mprotect (vma, reqprot, prot);
1815 static inline int security_file_lock (struct file *file, unsigned int cmd)
1817 return security_ops->file_lock (file, cmd);
1820 static inline int security_file_fcntl (struct file *file, unsigned int cmd,
1823 return security_ops->file_fcntl (file, cmd, arg);
1826 static inline int security_file_set_fowner (struct file *file)
1828 return security_ops->file_set_fowner (file);
1831 static inline int security_file_send_sigiotask (struct task_struct *tsk,
1832 struct fown_struct *fown,
1835 return security_ops->file_send_sigiotask (tsk, fown, sig);
1838 static inline int security_file_receive (struct file *file)
1840 return security_ops->file_receive (file);
1843 static inline int security_task_create (unsigned long clone_flags)
1845 return security_ops->task_create (clone_flags);
1848 static inline int security_task_alloc (struct task_struct *p)
1850 return security_ops->task_alloc_security (p);
1853 static inline void security_task_free (struct task_struct *p)
1855 security_ops->task_free_security (p);
1858 static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
1861 return security_ops->task_setuid (id0, id1, id2, flags);
1864 static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
1865 uid_t old_suid, int flags)
1867 return security_ops->task_post_setuid (old_ruid, old_euid, old_suid, flags);
1870 static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
1873 return security_ops->task_setgid (id0, id1, id2, flags);
1876 static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
1878 return security_ops->task_setpgid (p, pgid);
1881 static inline int security_task_getpgid (struct task_struct *p)
1883 return security_ops->task_getpgid (p);
1886 static inline int security_task_getsid (struct task_struct *p)
1888 return security_ops->task_getsid (p);
1891 static inline void security_task_getsecid (struct task_struct *p, u32 *secid)
1893 security_ops->task_getsecid (p, secid);
1896 static inline int security_task_setgroups (struct group_info *group_info)
1898 return security_ops->task_setgroups (group_info);
1901 static inline int security_task_setnice (struct task_struct *p, int nice)
1903 return security_ops->task_setnice (p, nice);
1906 static inline int security_task_setioprio (struct task_struct *p, int ioprio)
1908 return security_ops->task_setioprio (p, ioprio);
1911 static inline int security_task_getioprio (struct task_struct *p)
1913 return security_ops->task_getioprio (p);
1916 static inline int security_task_setrlimit (unsigned int resource,
1917 struct rlimit *new_rlim)
1919 return security_ops->task_setrlimit (resource, new_rlim);
1922 static inline int security_task_setscheduler (struct task_struct *p,
1924 struct sched_param *lp)
1926 return security_ops->task_setscheduler (p, policy, lp);
1929 static inline int security_task_getscheduler (struct task_struct *p)
1931 return security_ops->task_getscheduler (p);
1934 static inline int security_task_movememory (struct task_struct *p)
1936 return security_ops->task_movememory (p);
1939 static inline int security_task_kill (struct task_struct *p,
1940 struct siginfo *info, int sig,
1943 return security_ops->task_kill (p, info, sig, secid);
1946 static inline int security_task_wait (struct task_struct *p)
1948 return security_ops->task_wait (p);
1951 static inline int security_task_prctl (int option, unsigned long arg2,
1956 return security_ops->task_prctl (option, arg2, arg3, arg4, arg5);
1959 static inline void security_task_reparent_to_init (struct task_struct *p)
1961 security_ops->task_reparent_to_init (p);
1964 static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
1966 security_ops->task_to_inode(p, inode);
1969 static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
1972 return security_ops->ipc_permission (ipcp, flag);
1975 static inline int security_msg_msg_alloc (struct msg_msg * msg)
1977 return security_ops->msg_msg_alloc_security (msg);
1980 static inline void security_msg_msg_free (struct msg_msg * msg)
1982 security_ops->msg_msg_free_security(msg);
1985 static inline int security_msg_queue_alloc (struct msg_queue *msq)
1987 return security_ops->msg_queue_alloc_security (msq);
1990 static inline void security_msg_queue_free (struct msg_queue *msq)
1992 security_ops->msg_queue_free_security (msq);
1995 static inline int security_msg_queue_associate (struct msg_queue * msq,
1998 return security_ops->msg_queue_associate (msq, msqflg);
2001 static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
2003 return security_ops->msg_queue_msgctl (msq, cmd);
2006 static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
2007 struct msg_msg * msg, int msqflg)
2009 return security_ops->msg_queue_msgsnd (msq, msg, msqflg);
2012 static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
2013 struct msg_msg * msg,
2014 struct task_struct * target,
2015 long type, int mode)
2017 return security_ops->msg_queue_msgrcv (msq, msg, target, type, mode);
2020 static inline int security_shm_alloc (struct shmid_kernel *shp)
2022 return security_ops->shm_alloc_security (shp);
2025 static inline void security_shm_free (struct shmid_kernel *shp)
2027 security_ops->shm_free_security (shp);
2030 static inline int security_shm_associate (struct shmid_kernel * shp,
2033 return security_ops->shm_associate(shp, shmflg);
2036 static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
2038 return security_ops->shm_shmctl (shp, cmd);
2041 static inline int security_shm_shmat (struct shmid_kernel * shp,
2042 char __user *shmaddr, int shmflg)
2044 return security_ops->shm_shmat(shp, shmaddr, shmflg);
2047 static inline int security_sem_alloc (struct sem_array *sma)
2049 return security_ops->sem_alloc_security (sma);
2052 static inline void security_sem_free (struct sem_array *sma)
2054 security_ops->sem_free_security (sma);
2057 static inline int security_sem_associate (struct sem_array * sma, int semflg)
2059 return security_ops->sem_associate (sma, semflg);
2062 static inline int security_sem_semctl (struct sem_array * sma, int cmd)
2064 return security_ops->sem_semctl(sma, cmd);
2067 static inline int security_sem_semop (struct sem_array * sma,
2068 struct sembuf * sops, unsigned nsops,
2071 return security_ops->sem_semop(sma, sops, nsops, alter);
2074 static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
2076 if (unlikely (inode && IS_PRIVATE (inode)))
2078 security_ops->d_instantiate (dentry, inode);
2081 static inline int security_getprocattr(struct task_struct *p, char *name, void *value, size_t size)
2083 return security_ops->getprocattr(p, name, value, size);
2086 static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2088 return security_ops->setprocattr(p, name, value, size);
2091 static inline int security_netlink_send(struct sock *sk, struct sk_buff * skb)
2093 return security_ops->netlink_send(sk, skb);
2096 static inline int security_netlink_recv(struct sk_buff * skb, int cap)
2098 return security_ops->netlink_recv(skb, cap);
2101 static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
2103 return security_ops->secid_to_secctx(secid, secdata, seclen);
2106 static inline void security_release_secctx(char *secdata, u32 seclen)
2108 return security_ops->release_secctx(secdata, seclen);
2112 extern int security_init (void);
2113 extern int register_security (struct security_operations *ops);
2114 extern int unregister_security (struct security_operations *ops);
2115 extern int mod_reg_security (const char *name, struct security_operations *ops);
2116 extern int mod_unreg_security (const char *name, struct security_operations *ops);
2117 extern struct dentry *securityfs_create_file(const char *name, mode_t mode,
2118 struct dentry *parent, void *data,
2119 struct file_operations *fops);
2120 extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
2121 extern void securityfs_remove(struct dentry *dentry);
2124 #else /* CONFIG_SECURITY */
2127 * This is the default capabilities functionality. Most of these functions
2128 * are just stubbed out, but a few must call the proper capable code.
2131 static inline int security_init(void)
2136 static inline int security_ptrace (struct task_struct *parent, struct task_struct * child)
2138 return cap_ptrace (parent, child);
2141 static inline int security_capget (struct task_struct *target,
2142 kernel_cap_t *effective,
2143 kernel_cap_t *inheritable,
2144 kernel_cap_t *permitted)
2146 return cap_capget (target, effective, inheritable, permitted);
2149 static inline int security_capset_check (struct task_struct *target,
2150 kernel_cap_t *effective,
2151 kernel_cap_t *inheritable,
2152 kernel_cap_t *permitted)
2154 return cap_capset_check (target, effective, inheritable, permitted);
2157 static inline void security_capset_set (struct task_struct *target,
2158 kernel_cap_t *effective,
2159 kernel_cap_t *inheritable,
2160 kernel_cap_t *permitted)
2162 cap_capset_set (target, effective, inheritable, permitted);
2165 static inline int security_capable(struct task_struct *tsk, int cap)
2167 return cap_capable(tsk, cap);
2170 static inline int security_acct (struct file *file)
2175 static inline int security_sysctl(struct ctl_table *table, int op)
2180 static inline int security_quotactl (int cmds, int type, int id,
2181 struct super_block * sb)
2186 static inline int security_quota_on (struct dentry * dentry)
2191 static inline int security_syslog(int type)
2193 return cap_syslog(type);
2196 static inline int security_settime(struct timespec *ts, struct timezone *tz)
2198 return cap_settime(ts, tz);
2201 static inline int security_vm_enough_memory(long pages)
2203 return cap_vm_enough_memory(pages);
2206 static inline int security_bprm_alloc (struct linux_binprm *bprm)
2211 static inline void security_bprm_free (struct linux_binprm *bprm)
2214 static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
2216 cap_bprm_apply_creds (bprm, unsafe);
2219 static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
2224 static inline int security_bprm_set (struct linux_binprm *bprm)
2226 return cap_bprm_set_security (bprm);
2229 static inline int security_bprm_check (struct linux_binprm *bprm)
2234 static inline int security_bprm_secureexec (struct linux_binprm *bprm)
2236 return cap_bprm_secureexec(bprm);
2239 static inline int security_sb_alloc (struct super_block *sb)
2244 static inline void security_sb_free (struct super_block *sb)
2247 static inline int security_sb_copy_data (struct file_system_type *type,
2248 void *orig, void *copy)
2253 static inline int security_sb_kern_mount (struct super_block *sb, void *data)
2258 static inline int security_sb_statfs (struct dentry *dentry)
2263 static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
2264 char *type, unsigned long flags,
2270 static inline int security_sb_check_sb (struct vfsmount *mnt,
2271 struct nameidata *nd)
2276 static inline int security_sb_umount (struct vfsmount *mnt, int flags)
2281 static inline void security_sb_umount_close (struct vfsmount *mnt)
2284 static inline void security_sb_umount_busy (struct vfsmount *mnt)
2287 static inline void security_sb_post_remount (struct vfsmount *mnt,
2288 unsigned long flags, void *data)
2291 static inline void security_sb_post_mountroot (void)
2294 static inline void security_sb_post_addmount (struct vfsmount *mnt,
2295 struct nameidata *mountpoint_nd)
2298 static inline int security_sb_pivotroot (struct nameidata *old_nd,
2299 struct nameidata *new_nd)
2304 static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
2305 struct nameidata *new_nd)
2308 static inline int security_inode_alloc (struct inode *inode)
2313 static inline void security_inode_free (struct inode *inode)
2316 static inline int security_inode_init_security (struct inode *inode,
2325 static inline int security_inode_create (struct inode *dir,
2326 struct dentry *dentry,
2332 static inline int security_inode_link (struct dentry *old_dentry,
2334 struct dentry *new_dentry)
2339 static inline int security_inode_unlink (struct inode *dir,
2340 struct dentry *dentry)
2345 static inline int security_inode_symlink (struct inode *dir,
2346 struct dentry *dentry,
2347 const char *old_name)
2352 static inline int security_inode_mkdir (struct inode *dir,
2353 struct dentry *dentry,
2359 static inline int security_inode_rmdir (struct inode *dir,
2360 struct dentry *dentry)
2365 static inline int security_inode_mknod (struct inode *dir,
2366 struct dentry *dentry,
2367 int mode, dev_t dev)
2372 static inline int security_inode_rename (struct inode *old_dir,
2373 struct dentry *old_dentry,
2374 struct inode *new_dir,
2375 struct dentry *new_dentry)
2380 static inline int security_inode_readlink (struct dentry *dentry)
2385 static inline int security_inode_follow_link (struct dentry *dentry,
2386 struct nameidata *nd)
2391 static inline int security_inode_permission (struct inode *inode, int mask,
2392 struct nameidata *nd)
2397 static inline int security_inode_setattr (struct dentry *dentry,
2403 static inline int security_inode_getattr (struct vfsmount *mnt,
2404 struct dentry *dentry)
2409 static inline void security_inode_delete (struct inode *inode)
2412 static inline int security_inode_setxattr (struct dentry *dentry, char *name,
2413 void *value, size_t size, int flags)
2415 return cap_inode_setxattr(dentry, name, value, size, flags);
2418 static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
2419 void *value, size_t size, int flags)
2422 static inline int security_inode_getxattr (struct dentry *dentry, char *name)
2427 static inline int security_inode_listxattr (struct dentry *dentry)
2432 static inline int security_inode_removexattr (struct dentry *dentry, char *name)
2434 return cap_inode_removexattr(dentry, name);
2437 static inline const char *security_inode_xattr_getsuffix (void)
2442 static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void *buffer, size_t size, int err)
2447 static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
2452 static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
2457 static inline int security_file_permission (struct file *file, int mask)
2462 static inline int security_file_alloc (struct file *file)
2467 static inline void security_file_free (struct file *file)
2470 static inline int security_file_ioctl (struct file *file, unsigned int cmd,
2476 static inline int security_file_mmap (struct file *file, unsigned long reqprot,
2478 unsigned long flags)
2483 static inline int security_file_mprotect (struct vm_area_struct *vma,
2484 unsigned long reqprot,
2490 static inline int security_file_lock (struct file *file, unsigned int cmd)
2495 static inline int security_file_fcntl (struct file *file, unsigned int cmd,
2501 static inline int security_file_set_fowner (struct file *file)
2506 static inline int security_file_send_sigiotask (struct task_struct *tsk,
2507 struct fown_struct *fown,
2513 static inline int security_file_receive (struct file *file)
2518 static inline int security_task_create (unsigned long clone_flags)
2523 static inline int security_task_alloc (struct task_struct *p)
2528 static inline void security_task_free (struct task_struct *p)
2531 static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
2537 static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
2538 uid_t old_suid, int flags)
2540 return cap_task_post_setuid (old_ruid, old_euid, old_suid, flags);
2543 static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
2549 static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
2554 static inline int security_task_getpgid (struct task_struct *p)
2559 static inline int security_task_getsid (struct task_struct *p)
2564 static inline void security_task_getsecid (struct task_struct *p, u32 *secid)
2567 static inline int security_task_setgroups (struct group_info *group_info)
2572 static inline int security_task_setnice (struct task_struct *p, int nice)
2577 static inline int security_task_setioprio (struct task_struct *p, int ioprio)
2582 static inline int security_task_getioprio (struct task_struct *p)
2587 static inline int security_task_setrlimit (unsigned int resource,
2588 struct rlimit *new_rlim)
2593 static inline int security_task_setscheduler (struct task_struct *p,
2595 struct sched_param *lp)
2600 static inline int security_task_getscheduler (struct task_struct *p)
2605 static inline int security_task_movememory (struct task_struct *p)
2610 static inline int security_task_kill (struct task_struct *p,
2611 struct siginfo *info, int sig,
2617 static inline int security_task_wait (struct task_struct *p)
2622 static inline int security_task_prctl (int option, unsigned long arg2,
2630 static inline void security_task_reparent_to_init (struct task_struct *p)
2632 cap_task_reparent_to_init (p);
2635 static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
2638 static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
2644 static inline int security_msg_msg_alloc (struct msg_msg * msg)
2649 static inline void security_msg_msg_free (struct msg_msg * msg)
2652 static inline int security_msg_queue_alloc (struct msg_queue *msq)
2657 static inline void security_msg_queue_free (struct msg_queue *msq)
2660 static inline int security_msg_queue_associate (struct msg_queue * msq,
2666 static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
2671 static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
2672 struct msg_msg * msg, int msqflg)
2677 static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
2678 struct msg_msg * msg,
2679 struct task_struct * target,
2680 long type, int mode)
2685 static inline int security_shm_alloc (struct shmid_kernel *shp)
2690 static inline void security_shm_free (struct shmid_kernel *shp)
2693 static inline int security_shm_associate (struct shmid_kernel * shp,
2699 static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
2704 static inline int security_shm_shmat (struct shmid_kernel * shp,
2705 char __user *shmaddr, int shmflg)
2710 static inline int security_sem_alloc (struct sem_array *sma)
2715 static inline void security_sem_free (struct sem_array *sma)
2718 static inline int security_sem_associate (struct sem_array * sma, int semflg)
2723 static inline int security_sem_semctl (struct sem_array * sma, int cmd)
2728 static inline int security_sem_semop (struct sem_array * sma,
2729 struct sembuf * sops, unsigned nsops,
2735 static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
2738 static inline int security_getprocattr(struct task_struct *p, char *name, void *value, size_t size)
2743 static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2748 static inline int security_netlink_send (struct sock *sk, struct sk_buff *skb)
2750 return cap_netlink_send (sk, skb);
2753 static inline int security_netlink_recv (struct sk_buff *skb, int cap)
2755 return cap_netlink_recv (skb, cap);
2758 static inline struct dentry *securityfs_create_dir(const char *name,
2759 struct dentry *parent)
2761 return ERR_PTR(-ENODEV);
2764 static inline struct dentry *securityfs_create_file(const char *name,
2766 struct dentry *parent,
2768 struct file_operations *fops)
2770 return ERR_PTR(-ENODEV);
2773 static inline void securityfs_remove(struct dentry *dentry)
2777 static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
2782 static inline void security_release_secctx(char *secdata, u32 seclen)
2785 #endif /* CONFIG_SECURITY */
2787 #ifdef CONFIG_SECURITY_NETWORK
2788 static inline int security_unix_stream_connect(struct socket * sock,
2789 struct socket * other,
2790 struct sock * newsk)
2792 return security_ops->unix_stream_connect(sock, other, newsk);
2796 static inline int security_unix_may_send(struct socket * sock,
2797 struct socket * other)
2799 return security_ops->unix_may_send(sock, other);
2802 static inline int security_socket_create (int family, int type,
2803 int protocol, int kern)
2805 return security_ops->socket_create(family, type, protocol, kern);
2808 static inline void security_socket_post_create(struct socket * sock,
2811 int protocol, int kern)
2813 security_ops->socket_post_create(sock, family, type,
2817 static inline int security_socket_bind(struct socket * sock,
2818 struct sockaddr * address,
2821 return security_ops->socket_bind(sock, address, addrlen);
2824 static inline int security_socket_connect(struct socket * sock,
2825 struct sockaddr * address,
2828 return security_ops->socket_connect(sock, address, addrlen);
2831 static inline int security_socket_listen(struct socket * sock, int backlog)
2833 return security_ops->socket_listen(sock, backlog);
2836 static inline int security_socket_accept(struct socket * sock,
2837 struct socket * newsock)
2839 return security_ops->socket_accept(sock, newsock);
2842 static inline void security_socket_post_accept(struct socket * sock,
2843 struct socket * newsock)
2845 security_ops->socket_post_accept(sock, newsock);
2848 static inline int security_socket_sendmsg(struct socket * sock,
2849 struct msghdr * msg, int size)
2851 return security_ops->socket_sendmsg(sock, msg, size);
2854 static inline int security_socket_recvmsg(struct socket * sock,
2855 struct msghdr * msg, int size,
2858 return security_ops->socket_recvmsg(sock, msg, size, flags);
2861 static inline int security_socket_getsockname(struct socket * sock)
2863 return security_ops->socket_getsockname(sock);
2866 static inline int security_socket_getpeername(struct socket * sock)
2868 return security_ops->socket_getpeername(sock);
2871 static inline int security_socket_getsockopt(struct socket * sock,
2872 int level, int optname)
2874 return security_ops->socket_getsockopt(sock, level, optname);
2877 static inline int security_socket_setsockopt(struct socket * sock,
2878 int level, int optname)
2880 return security_ops->socket_setsockopt(sock, level, optname);
2883 static inline int security_socket_shutdown(struct socket * sock, int how)
2885 return security_ops->socket_shutdown(sock, how);
2888 static inline int security_sock_rcv_skb (struct sock * sk,
2889 struct sk_buff * skb)
2891 return security_ops->socket_sock_rcv_skb (sk, skb);
2894 static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2895 int __user *optlen, unsigned len)
2897 return security_ops->socket_getpeersec_stream(sock, optval, optlen, len);
2900 static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
2902 return security_ops->socket_getpeersec_dgram(sock, skb, secid);
2905 static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
2907 return security_ops->sk_alloc_security(sk, family, priority);
2910 static inline void security_sk_free(struct sock *sk)
2912 return security_ops->sk_free_security(sk);
2915 static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
2917 return security_ops->sk_clone_security(sk, newsk);
2920 static inline unsigned int security_sk_sid(struct sock *sk, struct flowi *fl, u8 dir)
2922 return security_ops->sk_getsid(sk, fl, dir);
2924 #else /* CONFIG_SECURITY_NETWORK */
2925 static inline int security_unix_stream_connect(struct socket * sock,
2926 struct socket * other,
2927 struct sock * newsk)
2932 static inline int security_unix_may_send(struct socket * sock,
2933 struct socket * other)
2938 static inline int security_socket_create (int family, int type,
2939 int protocol, int kern)
2944 static inline void security_socket_post_create(struct socket * sock,
2947 int protocol, int kern)
2951 static inline int security_socket_bind(struct socket * sock,
2952 struct sockaddr * address,
2958 static inline int security_socket_connect(struct socket * sock,
2959 struct sockaddr * address,
2965 static inline int security_socket_listen(struct socket * sock, int backlog)
2970 static inline int security_socket_accept(struct socket * sock,
2971 struct socket * newsock)
2976 static inline void security_socket_post_accept(struct socket * sock,
2977 struct socket * newsock)
2981 static inline int security_socket_sendmsg(struct socket * sock,
2982 struct msghdr * msg, int size)
2987 static inline int security_socket_recvmsg(struct socket * sock,
2988 struct msghdr * msg, int size,
2994 static inline int security_socket_getsockname(struct socket * sock)
2999 static inline int security_socket_getpeername(struct socket * sock)
3004 static inline int security_socket_getsockopt(struct socket * sock,
3005 int level, int optname)
3010 static inline int security_socket_setsockopt(struct socket * sock,
3011 int level, int optname)
3016 static inline int security_socket_shutdown(struct socket * sock, int how)
3020 static inline int security_sock_rcv_skb (struct sock * sk,
3021 struct sk_buff * skb)
3026 static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
3027 int __user *optlen, unsigned len)
3029 return -ENOPROTOOPT;
3032 static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
3034 return -ENOPROTOOPT;
3037 static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
3042 static inline void security_sk_free(struct sock *sk)
3046 static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
3050 static inline unsigned int security_sk_sid(struct sock *sk, struct flowi *fl, u8 dir)
3054 #endif /* CONFIG_SECURITY_NETWORK */
3056 #ifdef CONFIG_SECURITY_NETWORK_XFRM
3057 static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx)
3059 return security_ops->xfrm_policy_alloc_security(xp, sec_ctx);
3062 static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
3064 return security_ops->xfrm_policy_clone_security(old, new);
3067 static inline void security_xfrm_policy_free(struct xfrm_policy *xp)
3069 security_ops->xfrm_policy_free_security(xp);
3072 static inline int security_xfrm_policy_delete(struct xfrm_policy *xp)
3074 return security_ops->xfrm_policy_delete_security(xp);
3077 static inline int security_xfrm_state_alloc(struct xfrm_state *x,
3078 struct xfrm_user_sec_ctx *sec_ctx)
3080 return security_ops->xfrm_state_alloc_security(x, sec_ctx, NULL, 0);
3083 static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
3084 struct xfrm_sec_ctx *polsec, u32 secid)
3088 return security_ops->xfrm_state_alloc_security(x, NULL, polsec, secid);
3091 static inline int security_xfrm_state_delete(struct xfrm_state *x)
3093 return security_ops->xfrm_state_delete_security(x);
3096 static inline void security_xfrm_state_free(struct xfrm_state *x)
3098 security_ops->xfrm_state_free_security(x);
3101 static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir)
3103 return security_ops->xfrm_policy_lookup(xp, fl_secid, dir);
3106 static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
3107 struct xfrm_policy *xp, struct flowi *fl)
3109 return security_ops->xfrm_state_pol_flow_match(x, xp, fl);
3112 static inline int security_xfrm_flow_state_match(struct flowi *fl, struct xfrm_state *xfrm)
3114 return security_ops->xfrm_flow_state_match(fl, xfrm);
3117 static inline int security_xfrm_decode_session(struct sk_buff *skb, struct flowi *fl)
3119 return security_ops->xfrm_decode_session(skb, fl);
3121 #else /* CONFIG_SECURITY_NETWORK_XFRM */
3122 static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx)
3127 static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
3132 static inline void security_xfrm_policy_free(struct xfrm_policy *xp)
3136 static inline int security_xfrm_policy_delete(struct xfrm_policy *xp)
3141 static inline int security_xfrm_state_alloc(struct xfrm_state *x,
3142 struct xfrm_user_sec_ctx *sec_ctx)
3147 static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
3148 struct xfrm_sec_ctx *polsec, u32 secid)
3153 static inline void security_xfrm_state_free(struct xfrm_state *x)
3157 static inline int security_xfrm_state_delete(struct xfrm_state *x)
3162 static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir)
3167 static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
3168 struct xfrm_policy *xp, struct flowi *fl)
3173 static inline int security_xfrm_flow_state_match(struct flowi *fl,
3174 struct xfrm_state *xfrm)
3179 static inline int security_xfrm_decode_session(struct sk_buff *skb, struct flowi *fl)
3184 #endif /* CONFIG_SECURITY_NETWORK_XFRM */
3187 #ifdef CONFIG_SECURITY
3188 static inline int security_key_alloc(struct key *key,
3189 struct task_struct *tsk,
3190 unsigned long flags)
3192 return security_ops->key_alloc(key, tsk, flags);
3195 static inline void security_key_free(struct key *key)
3197 security_ops->key_free(key);
3200 static inline int security_key_permission(key_ref_t key_ref,
3201 struct task_struct *context,
3204 return security_ops->key_permission(key_ref, context, perm);
3209 static inline int security_key_alloc(struct key *key,
3210 struct task_struct *tsk,
3211 unsigned long flags)
3216 static inline void security_key_free(struct key *key)
3220 static inline int security_key_permission(key_ref_t key_ref,
3221 struct task_struct *context,
3228 #endif /* CONFIG_KEYS */
3230 #endif /* ! __LINUX_SECURITY_H */