4 * Copyright (C) 2001 WireX Communications, Inc <chris@wirex.com>
5 * Copyright (C) 2001 Greg Kroah-Hartman <greg@kroah.com>
6 * Copyright (C) 2001 Networks Associates Technology, Inc <ssmalley@nai.com>
7 * Copyright (C) 2001 James Morris <jmorris@intercode.com.au>
8 * Copyright (C) 2001 Silicon Graphics, Inc. (Trust Technology Group)
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * Due to this file being licensed under the GPL there is controversy over
16 * whether this permits you to write a module that #includes this file
17 * without placing your module under the GPL. Please consult a lawyer for
18 * advice before doing this.
22 #ifndef __LINUX_SECURITY_H
23 #define __LINUX_SECURITY_H
26 #include <linux/binfmts.h>
27 #include <linux/signal.h>
28 #include <linux/resource.h>
29 #include <linux/sem.h>
30 #include <linux/shm.h>
31 #include <linux/msg.h>
32 #include <linux/sched.h>
33 #include <linux/key.h>
34 #include <linux/xfrm.h>
40 * These functions are in security/capability.c and are used
41 * as the default capabilities functions
43 extern int cap_capable (struct task_struct *tsk, int cap);
44 extern int cap_settime (struct timespec *ts, struct timezone *tz);
45 extern int cap_ptrace (struct task_struct *parent, struct task_struct *child);
46 extern int cap_capget (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
47 extern int cap_capset_check (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
48 extern void cap_capset_set (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
49 extern int cap_bprm_set_security (struct linux_binprm *bprm);
50 extern void cap_bprm_apply_creds (struct linux_binprm *bprm, int unsafe);
51 extern int cap_bprm_secureexec(struct linux_binprm *bprm);
52 extern int cap_inode_setxattr(struct dentry *dentry, char *name, void *value, size_t size, int flags);
53 extern int cap_inode_removexattr(struct dentry *dentry, char *name);
54 extern int cap_task_post_setuid (uid_t old_ruid, uid_t old_euid, uid_t old_suid, int flags);
55 extern void cap_task_reparent_to_init (struct task_struct *p);
56 extern int cap_syslog (int type);
57 extern int cap_vm_enough_memory (struct mm_struct *mm, long pages);
69 struct xfrm_user_sec_ctx;
71 extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
72 extern int cap_netlink_recv(struct sk_buff *skb, int cap);
74 extern unsigned long mmap_min_addr;
76 * Values used in the task_security_ops calls
78 /* setuid or setgid, id0 == uid or gid */
79 #define LSM_SETID_ID 1
81 /* setreuid or setregid, id0 == real, id1 == eff */
82 #define LSM_SETID_RE 2
84 /* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
85 #define LSM_SETID_RES 4
87 /* setfsuid or setfsgid, id0 == fsuid or fsgid */
88 #define LSM_SETID_FS 8
90 /* forward declares to avoid warnings */
93 struct swap_info_struct;
96 /* bprm_apply_creds unsafe reasons */
97 #define LSM_UNSAFE_SHARE 1
98 #define LSM_UNSAFE_PTRACE 2
99 #define LSM_UNSAFE_PTRACE_CAP 4
101 #ifdef CONFIG_SECURITY
104 * struct security_operations - main security structure
106 * Security hooks for program execution operations.
108 * @bprm_alloc_security:
109 * Allocate and attach a security structure to the @bprm->security field.
110 * The security field is initialized to NULL when the bprm structure is
112 * @bprm contains the linux_binprm structure to be modified.
113 * Return 0 if operation was successful.
114 * @bprm_free_security:
115 * @bprm contains the linux_binprm structure to be modified.
116 * Deallocate and clear the @bprm->security field.
118 * Compute and set the security attributes of a process being transformed
119 * by an execve operation based on the old attributes (current->security)
120 * and the information saved in @bprm->security by the set_security hook.
121 * Since this hook function (and its caller) are void, this hook can not
122 * return an error. However, it can leave the security attributes of the
123 * process unchanged if an access failure occurs at this point.
124 * bprm_apply_creds is called under task_lock. @unsafe indicates various
125 * reasons why it may be unsafe to change security state.
126 * @bprm contains the linux_binprm structure.
127 * @bprm_post_apply_creds:
128 * Runs after bprm_apply_creds with the task_lock dropped, so that
129 * functions which cannot be called safely under the task_lock can
130 * be used. This hook is a good place to perform state changes on
131 * the process such as closing open file descriptors to which access
132 * is no longer granted if the attributes were changed.
133 * Note that a security module might need to save state between
134 * bprm_apply_creds and bprm_post_apply_creds to store the decision
135 * on whether the process may proceed.
136 * @bprm contains the linux_binprm structure.
137 * @bprm_set_security:
138 * Save security information in the bprm->security field, typically based
139 * on information about the bprm->file, for later use by the apply_creds
140 * hook. This hook may also optionally check permissions (e.g. for
141 * transitions between security domains).
142 * This hook may be called multiple times during a single execve, e.g. for
143 * interpreters. The hook can tell whether it has already been called by
144 * checking to see if @bprm->security is non-NULL. If so, then the hook
145 * may decide either to retain the security information saved earlier or
147 * @bprm contains the linux_binprm structure.
148 * Return 0 if the hook is successful and permission is granted.
149 * @bprm_check_security:
150 * This hook mediates the point when a search for a binary handler will
151 * begin. It allows a check the @bprm->security value which is set in
152 * the preceding set_security call. The primary difference from
153 * set_security is that the argv list and envp list are reliably
154 * available in @bprm. This hook may be called multiple times
155 * during a single execve; and in each pass set_security is called
157 * @bprm contains the linux_binprm structure.
158 * Return 0 if the hook is successful and permission is granted.
160 * Return a boolean value (0 or 1) indicating whether a "secure exec"
161 * is required. The flag is passed in the auxiliary table
162 * on the initial stack to the ELF interpreter to indicate whether libc
163 * should enable secure mode.
164 * @bprm contains the linux_binprm structure.
166 * Security hooks for filesystem operations.
168 * @sb_alloc_security:
169 * Allocate and attach a security structure to the sb->s_security field.
170 * The s_security field is initialized to NULL when the structure is
172 * @sb contains the super_block structure to be modified.
173 * Return 0 if operation was successful.
175 * Deallocate and clear the sb->s_security field.
176 * @sb contains the super_block structure to be modified.
178 * Check permission before obtaining filesystem statistics for the @mnt
180 * @dentry is a handle on the superblock for the filesystem.
181 * Return 0 if permission is granted.
183 * Check permission before an object specified by @dev_name is mounted on
184 * the mount point named by @nd. For an ordinary mount, @dev_name
185 * identifies a device if the file system type requires a device. For a
186 * remount (@flags & MS_REMOUNT), @dev_name is irrelevant. For a
187 * loopback/bind mount (@flags & MS_BIND), @dev_name identifies the
188 * pathname of the object being mounted.
189 * @dev_name contains the name for object being mounted.
190 * @nd contains the nameidata structure for mount point object.
191 * @type contains the filesystem type.
192 * @flags contains the mount flags.
193 * @data contains the filesystem-specific data.
194 * Return 0 if permission is granted.
196 * Allow mount option data to be copied prior to parsing by the filesystem,
197 * so that the security module can extract security-specific mount
198 * options cleanly (a filesystem may modify the data e.g. with strsep()).
199 * This also allows the original mount data to be stripped of security-
200 * specific options to avoid having to make filesystems aware of them.
201 * @type the type of filesystem being mounted.
202 * @orig the original mount data copied from userspace.
203 * @copy copied data which will be passed to the security module.
204 * Returns 0 if the copy was successful.
206 * Check permission before the device with superblock @mnt->sb is mounted
207 * on the mount point named by @nd.
208 * @mnt contains the vfsmount for device being mounted.
209 * @nd contains the nameidata object for the mount point.
210 * Return 0 if permission is granted.
212 * Check permission before the @mnt file system is unmounted.
213 * @mnt contains the mounted file system.
214 * @flags contains the unmount flags, e.g. MNT_FORCE.
215 * Return 0 if permission is granted.
217 * Close any files in the @mnt mounted filesystem that are held open by
218 * the security module. This hook is called during an umount operation
219 * prior to checking whether the filesystem is still busy.
220 * @mnt contains the mounted filesystem.
222 * Handle a failed umount of the @mnt mounted filesystem, e.g. re-opening
223 * any files that were closed by umount_close. This hook is called during
224 * an umount operation if the umount fails after a call to the
226 * @mnt contains the mounted filesystem.
228 * Update the security module's state when a filesystem is remounted.
229 * This hook is only called if the remount was successful.
230 * @mnt contains the mounted file system.
231 * @flags contains the new filesystem flags.
232 * @data contains the filesystem-specific data.
233 * @sb_post_mountroot:
234 * Update the security module's state when the root filesystem is mounted.
235 * This hook is only called if the mount was successful.
237 * Update the security module's state when a filesystem is mounted.
238 * This hook is called any time a mount is successfully grafetd to
240 * @mnt contains the mounted filesystem.
241 * @mountpoint_nd contains the nameidata structure for the mount point.
243 * Check permission before pivoting the root filesystem.
244 * @old_nd contains the nameidata structure for the new location of the current root (put_old).
245 * @new_nd contains the nameidata structure for the new root (new_root).
246 * Return 0 if permission is granted.
247 * @sb_post_pivotroot:
248 * Update module state after a successful pivot.
249 * @old_nd contains the nameidata structure for the old root.
250 * @new_nd contains the nameidata structure for the new root.
252 * Security hooks for inode operations.
254 * @inode_alloc_security:
255 * Allocate and attach a security structure to @inode->i_security. The
256 * i_security field is initialized to NULL when the inode structure is
258 * @inode contains the inode structure.
259 * Return 0 if operation was successful.
260 * @inode_free_security:
261 * @inode contains the inode structure.
262 * Deallocate the inode security structure and set @inode->i_security to
264 * @inode_init_security:
265 * Obtain the security attribute name suffix and value to set on a newly
266 * created inode and set up the incore security field for the new inode.
267 * This hook is called by the fs code as part of the inode creation
268 * transaction and provides for atomic labeling of the inode, unlike
269 * the post_create/mkdir/... hooks called by the VFS. The hook function
270 * is expected to allocate the name and value via kmalloc, with the caller
271 * being responsible for calling kfree after using them.
272 * If the security module does not use security attributes or does
273 * not wish to put a security attribute on this particular inode,
274 * then it should return -EOPNOTSUPP to skip this processing.
275 * @inode contains the inode structure of the newly created inode.
276 * @dir contains the inode structure of the parent directory.
277 * @name will be set to the allocated name suffix (e.g. selinux).
278 * @value will be set to the allocated attribute value.
279 * @len will be set to the length of the value.
280 * Returns 0 if @name and @value have been successfully set,
281 * -EOPNOTSUPP if no security attribute is needed, or
282 * -ENOMEM on memory allocation failure.
284 * Check permission to create a regular file.
285 * @dir contains inode structure of the parent of the new file.
286 * @dentry contains the dentry structure for the file to be created.
287 * @mode contains the file mode of the file to be created.
288 * Return 0 if permission is granted.
290 * Check permission before creating a new hard link to a file.
291 * @old_dentry contains the dentry structure for an existing link to the file.
292 * @dir contains the inode structure of the parent directory of the new link.
293 * @new_dentry contains the dentry structure for the new link.
294 * Return 0 if permission is granted.
296 * Check the permission to remove a hard link to a file.
297 * @dir contains the inode structure of parent directory of the file.
298 * @dentry contains the dentry structure for file to be unlinked.
299 * Return 0 if permission is granted.
301 * Check the permission to create a symbolic link to a file.
302 * @dir contains the inode structure of parent directory of the symbolic link.
303 * @dentry contains the dentry structure of the symbolic link.
304 * @old_name contains the pathname of file.
305 * Return 0 if permission is granted.
307 * Check permissions to create a new directory in the existing directory
308 * associated with inode strcture @dir.
309 * @dir containst the inode structure of parent of the directory to be created.
310 * @dentry contains the dentry structure of new directory.
311 * @mode contains the mode of new directory.
312 * Return 0 if permission is granted.
314 * Check the permission to remove a directory.
315 * @dir contains the inode structure of parent of the directory to be removed.
316 * @dentry contains the dentry structure of directory to be removed.
317 * Return 0 if permission is granted.
319 * Check permissions when creating a special file (or a socket or a fifo
320 * file created via the mknod system call). Note that if mknod operation
321 * is being done for a regular file, then the create hook will be called
323 * @dir contains the inode structure of parent of the new file.
324 * @dentry contains the dentry structure of the new file.
325 * @mode contains the mode of the new file.
326 * @dev contains the device number.
327 * Return 0 if permission is granted.
329 * Check for permission to rename a file or directory.
330 * @old_dir contains the inode structure for parent of the old link.
331 * @old_dentry contains the dentry structure of the old link.
332 * @new_dir contains the inode structure for parent of the new link.
333 * @new_dentry contains the dentry structure of the new link.
334 * Return 0 if permission is granted.
336 * Check the permission to read the symbolic link.
337 * @dentry contains the dentry structure for the file link.
338 * Return 0 if permission is granted.
339 * @inode_follow_link:
340 * Check permission to follow a symbolic link when looking up a pathname.
341 * @dentry contains the dentry structure for the link.
342 * @nd contains the nameidata structure for the parent directory.
343 * Return 0 if permission is granted.
345 * Check permission before accessing an inode. This hook is called by the
346 * existing Linux permission function, so a security module can use it to
347 * provide additional checking for existing Linux permission checks.
348 * Notice that this hook is called when a file is opened (as well as many
349 * other operations), whereas the file_security_ops permission hook is
350 * called when the actual read/write operations are performed.
351 * @inode contains the inode structure to check.
352 * @mask contains the permission mask.
353 * @nd contains the nameidata (may be NULL).
354 * Return 0 if permission is granted.
356 * Check permission before setting file attributes. Note that the kernel
357 * call to notify_change is performed from several locations, whenever
358 * file attributes change (such as when a file is truncated, chown/chmod
359 * operations, transferring disk quotas, etc).
360 * @dentry contains the dentry structure for the file.
361 * @attr is the iattr structure containing the new file attributes.
362 * Return 0 if permission is granted.
364 * Check permission before obtaining file attributes.
365 * @mnt is the vfsmount where the dentry was looked up
366 * @dentry contains the dentry structure for the file.
367 * Return 0 if permission is granted.
369 * @inode contains the inode structure for deleted inode.
370 * This hook is called when a deleted inode is released (i.e. an inode
371 * with no hard links has its use count drop to zero). A security module
372 * can use this hook to release any persistent label associated with the
375 * Check permission before setting the extended attributes
376 * @value identified by @name for @dentry.
377 * Return 0 if permission is granted.
378 * @inode_post_setxattr:
379 * Update inode security field after successful setxattr operation.
380 * @value identified by @name for @dentry.
382 * Check permission before obtaining the extended attributes
383 * identified by @name for @dentry.
384 * Return 0 if permission is granted.
386 * Check permission before obtaining the list of extended attribute
388 * Return 0 if permission is granted.
389 * @inode_removexattr:
390 * Check permission before removing the extended attribute
391 * identified by @name for @dentry.
392 * Return 0 if permission is granted.
393 * @inode_getsecurity:
394 * Copy the extended attribute representation of the security label
395 * associated with @name for @inode into @buffer. @buffer may be
396 * NULL to request the size of the buffer required. @size indicates
397 * the size of @buffer in bytes. Note that @name is the remainder
398 * of the attribute name after the security. prefix has been removed.
399 * @err is the return value from the preceding fs getxattr call,
400 * and can be used by the security module to determine whether it
401 * should try and canonicalize the attribute value.
402 * Return number of bytes used/required on success.
403 * @inode_setsecurity:
404 * Set the security label associated with @name for @inode from the
405 * extended attribute value @value. @size indicates the size of the
406 * @value in bytes. @flags may be XATTR_CREATE, XATTR_REPLACE, or 0.
407 * Note that @name is the remainder of the attribute name after the
408 * security. prefix has been removed.
409 * Return 0 on success.
410 * @inode_listsecurity:
411 * Copy the extended attribute names for the security labels
412 * associated with @inode into @buffer. The maximum size of @buffer
413 * is specified by @buffer_size. @buffer may be NULL to request
414 * the size of the buffer required.
415 * Returns number of bytes used/required on success.
417 * Security hooks for file operations
420 * Check file permissions before accessing an open file. This hook is
421 * called by various operations that read or write files. A security
422 * module can use this hook to perform additional checking on these
423 * operations, e.g. to revalidate permissions on use to support privilege
424 * bracketing or policy changes. Notice that this hook is used when the
425 * actual read/write operations are performed, whereas the
426 * inode_security_ops hook is called when a file is opened (as well as
427 * many other operations).
428 * Caveat: Although this hook can be used to revalidate permissions for
429 * various system call operations that read or write files, it does not
430 * address the revalidation of permissions for memory-mapped files.
431 * Security modules must handle this separately if they need such
433 * @file contains the file structure being accessed.
434 * @mask contains the requested permissions.
435 * Return 0 if permission is granted.
436 * @file_alloc_security:
437 * Allocate and attach a security structure to the file->f_security field.
438 * The security field is initialized to NULL when the structure is first
440 * @file contains the file structure to secure.
441 * Return 0 if the hook is successful and permission is granted.
442 * @file_free_security:
443 * Deallocate and free any security structures stored in file->f_security.
444 * @file contains the file structure being modified.
446 * @file contains the file structure.
447 * @cmd contains the operation to perform.
448 * @arg contains the operational arguments.
449 * Check permission for an ioctl operation on @file. Note that @arg can
450 * sometimes represents a user space pointer; in other cases, it may be a
451 * simple integer value. When @arg represents a user space pointer, it
452 * should never be used by the security module.
453 * Return 0 if permission is granted.
455 * Check permissions for a mmap operation. The @file may be NULL, e.g.
456 * if mapping anonymous memory.
457 * @file contains the file structure for file to map (may be NULL).
458 * @reqprot contains the protection requested by the application.
459 * @prot contains the protection that will be applied by the kernel.
460 * @flags contains the operational flags.
461 * Return 0 if permission is granted.
463 * Check permissions before changing memory access permissions.
464 * @vma contains the memory region to modify.
465 * @reqprot contains the protection requested by the application.
466 * @prot contains the protection that will be applied by the kernel.
467 * Return 0 if permission is granted.
469 * Check permission before performing file locking operations.
470 * Note: this hook mediates both flock and fcntl style locks.
471 * @file contains the file structure.
472 * @cmd contains the posix-translated lock operation to perform
473 * (e.g. F_RDLCK, F_WRLCK).
474 * Return 0 if permission is granted.
476 * Check permission before allowing the file operation specified by @cmd
477 * from being performed on the file @file. Note that @arg can sometimes
478 * represents a user space pointer; in other cases, it may be a simple
479 * integer value. When @arg represents a user space pointer, it should
480 * never be used by the security module.
481 * @file contains the file structure.
482 * @cmd contains the operation to be performed.
483 * @arg contains the operational arguments.
484 * Return 0 if permission is granted.
486 * Save owner security information (typically from current->security) in
487 * file->f_security for later use by the send_sigiotask hook.
488 * @file contains the file structure to update.
489 * Return 0 on success.
490 * @file_send_sigiotask:
491 * Check permission for the file owner @fown to send SIGIO or SIGURG to the
492 * process @tsk. Note that this hook is sometimes called from interrupt.
493 * Note that the fown_struct, @fown, is never outside the context of a
494 * struct file, so the file structure (and associated security information)
495 * can always be obtained:
496 * container_of(fown, struct file, f_owner)
497 * @tsk contains the structure of task receiving signal.
498 * @fown contains the file owner information.
499 * @sig is the signal that will be sent. When 0, kernel sends SIGIO.
500 * Return 0 if permission is granted.
502 * This hook allows security modules to control the ability of a process
503 * to receive an open file descriptor via socket IPC.
504 * @file contains the file structure being received.
505 * Return 0 if permission is granted.
507 * Security hook for dentry
510 * Save open-time permission checking state for later use upon
511 * file_permission, and recheck access if anything has changed
512 * since inode_permission.
514 * Security hooks for task operations.
517 * Check permission before creating a child process. See the clone(2)
518 * manual page for definitions of the @clone_flags.
519 * @clone_flags contains the flags indicating what should be shared.
520 * Return 0 if permission is granted.
521 * @task_alloc_security:
522 * @p contains the task_struct for child process.
523 * Allocate and attach a security structure to the p->security field. The
524 * security field is initialized to NULL when the task structure is
526 * Return 0 if operation was successful.
527 * @task_free_security:
528 * @p contains the task_struct for process.
529 * Deallocate and clear the p->security field.
531 * Check permission before setting one or more of the user identity
532 * attributes of the current process. The @flags parameter indicates
533 * which of the set*uid system calls invoked this hook and how to
534 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
535 * definitions at the beginning of this file for the @flags values and
537 * @id0 contains a uid.
538 * @id1 contains a uid.
539 * @id2 contains a uid.
540 * @flags contains one of the LSM_SETID_* values.
541 * Return 0 if permission is granted.
543 * Update the module's state after setting one or more of the user
544 * identity attributes of the current process. The @flags parameter
545 * indicates which of the set*uid system calls invoked this hook. If
546 * @flags is LSM_SETID_FS, then @old_ruid is the old fs uid and the other
547 * parameters are not used.
548 * @old_ruid contains the old real uid (or fs uid if LSM_SETID_FS).
549 * @old_euid contains the old effective uid (or -1 if LSM_SETID_FS).
550 * @old_suid contains the old saved uid (or -1 if LSM_SETID_FS).
551 * @flags contains one of the LSM_SETID_* values.
552 * Return 0 on success.
554 * Check permission before setting one or more of the group identity
555 * attributes of the current process. The @flags parameter indicates
556 * which of the set*gid system calls invoked this hook and how to
557 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
558 * definitions at the beginning of this file for the @flags values and
560 * @id0 contains a gid.
561 * @id1 contains a gid.
562 * @id2 contains a gid.
563 * @flags contains one of the LSM_SETID_* values.
564 * Return 0 if permission is granted.
566 * Check permission before setting the process group identifier of the
567 * process @p to @pgid.
568 * @p contains the task_struct for process being modified.
569 * @pgid contains the new pgid.
570 * Return 0 if permission is granted.
572 * Check permission before getting the process group identifier of the
574 * @p contains the task_struct for the process.
575 * Return 0 if permission is granted.
577 * Check permission before getting the session identifier of the process
579 * @p contains the task_struct for the process.
580 * Return 0 if permission is granted.
582 * Retrieve the security identifier of the process @p.
583 * @p contains the task_struct for the process and place is into @secid.
585 * Check permission before setting the supplementary group set of the
587 * @group_info contains the new group information.
588 * Return 0 if permission is granted.
590 * Check permission before setting the nice value of @p to @nice.
591 * @p contains the task_struct of process.
592 * @nice contains the new nice value.
593 * Return 0 if permission is granted.
595 * Check permission before setting the ioprio value of @p to @ioprio.
596 * @p contains the task_struct of process.
597 * @ioprio contains the new ioprio value
598 * Return 0 if permission is granted.
600 * Check permission before getting the ioprio value of @p.
601 * @p contains the task_struct of process.
602 * Return 0 if permission is granted.
604 * Check permission before setting the resource limits of the current
605 * process for @resource to @new_rlim. The old resource limit values can
606 * be examined by dereferencing (current->signal->rlim + resource).
607 * @resource contains the resource whose limit is being set.
608 * @new_rlim contains the new limits for @resource.
609 * Return 0 if permission is granted.
610 * @task_setscheduler:
611 * Check permission before setting scheduling policy and/or parameters of
612 * process @p based on @policy and @lp.
613 * @p contains the task_struct for process.
614 * @policy contains the scheduling policy.
615 * @lp contains the scheduling parameters.
616 * Return 0 if permission is granted.
617 * @task_getscheduler:
618 * Check permission before obtaining scheduling information for process
620 * @p contains the task_struct for process.
621 * Return 0 if permission is granted.
623 * Check permission before moving memory owned by process @p.
624 * @p contains the task_struct for process.
625 * Return 0 if permission is granted.
627 * Check permission before sending signal @sig to @p. @info can be NULL,
628 * the constant 1, or a pointer to a siginfo structure. If @info is 1 or
629 * SI_FROMKERNEL(info) is true, then the signal should be viewed as coming
630 * from the kernel and should typically be permitted.
631 * SIGIO signals are handled separately by the send_sigiotask hook in
633 * @p contains the task_struct for process.
634 * @info contains the signal information.
635 * @sig contains the signal value.
636 * @secid contains the sid of the process where the signal originated
637 * Return 0 if permission is granted.
639 * Check permission before allowing a process to reap a child process @p
640 * and collect its status information.
641 * @p contains the task_struct for process.
642 * Return 0 if permission is granted.
644 * Check permission before performing a process control operation on the
646 * @option contains the operation.
647 * @arg2 contains a argument.
648 * @arg3 contains a argument.
649 * @arg4 contains a argument.
650 * @arg5 contains a argument.
651 * Return 0 if permission is granted.
652 * @task_reparent_to_init:
653 * Set the security attributes in @p->security for a kernel thread that
654 * is being reparented to the init task.
655 * @p contains the task_struct for the kernel thread.
657 * Set the security attributes for an inode based on an associated task's
658 * security attributes, e.g. for /proc/pid inodes.
659 * @p contains the task_struct for the task.
660 * @inode contains the inode structure for the inode.
662 * Security hooks for Netlink messaging.
665 * Save security information for a netlink message so that permission
666 * checking can be performed when the message is processed. The security
667 * information can be saved using the eff_cap field of the
668 * netlink_skb_parms structure. Also may be used to provide fine
669 * grained control over message transmission.
670 * @sk associated sock of task sending the message.,
671 * @skb contains the sk_buff structure for the netlink message.
672 * Return 0 if the information was successfully saved and message
673 * is allowed to be transmitted.
675 * Check permission before processing the received netlink message in
677 * @skb contains the sk_buff structure for the netlink message.
678 * @cap indicates the capability required
679 * Return 0 if permission is granted.
681 * Security hooks for Unix domain networking.
683 * @unix_stream_connect:
684 * Check permissions before establishing a Unix domain stream connection
685 * between @sock and @other.
686 * @sock contains the socket structure.
687 * @other contains the peer socket structure.
688 * Return 0 if permission is granted.
690 * Check permissions before connecting or sending datagrams from @sock to
692 * @sock contains the socket structure.
693 * @sock contains the peer socket structure.
694 * Return 0 if permission is granted.
696 * The @unix_stream_connect and @unix_may_send hooks were necessary because
697 * Linux provides an alternative to the conventional file name space for Unix
698 * domain sockets. Whereas binding and connecting to sockets in the file name
699 * space is mediated by the typical file permissions (and caught by the mknod
700 * and permission hooks in inode_security_ops), binding and connecting to
701 * sockets in the abstract name space is completely unmediated. Sufficient
702 * control of Unix domain sockets in the abstract name space isn't possible
703 * using only the socket layer hooks, since we need to know the actual target
704 * socket, which is not looked up until we are inside the af_unix code.
706 * Security hooks for socket operations.
709 * Check permissions prior to creating a new socket.
710 * @family contains the requested protocol family.
711 * @type contains the requested communications type.
712 * @protocol contains the requested protocol.
713 * @kern set to 1 if a kernel socket.
714 * Return 0 if permission is granted.
715 * @socket_post_create:
716 * This hook allows a module to update or allocate a per-socket security
717 * structure. Note that the security field was not added directly to the
718 * socket structure, but rather, the socket security information is stored
719 * in the associated inode. Typically, the inode alloc_security hook will
720 * allocate and and attach security information to
721 * sock->inode->i_security. This hook may be used to update the
722 * sock->inode->i_security field with additional information that wasn't
723 * available when the inode was allocated.
724 * @sock contains the newly created socket structure.
725 * @family contains the requested protocol family.
726 * @type contains the requested communications type.
727 * @protocol contains the requested protocol.
728 * @kern set to 1 if a kernel socket.
730 * Check permission before socket protocol layer bind operation is
731 * performed and the socket @sock is bound to the address specified in the
732 * @address parameter.
733 * @sock contains the socket structure.
734 * @address contains the address to bind to.
735 * @addrlen contains the length of address.
736 * Return 0 if permission is granted.
738 * Check permission before socket protocol layer connect operation
739 * attempts to connect socket @sock to a remote address, @address.
740 * @sock contains the socket structure.
741 * @address contains the address of remote endpoint.
742 * @addrlen contains the length of address.
743 * Return 0 if permission is granted.
745 * Check permission before socket protocol layer listen operation.
746 * @sock contains the socket structure.
747 * @backlog contains the maximum length for the pending connection queue.
748 * Return 0 if permission is granted.
750 * Check permission before accepting a new connection. Note that the new
751 * socket, @newsock, has been created and some information copied to it,
752 * but the accept operation has not actually been performed.
753 * @sock contains the listening socket structure.
754 * @newsock contains the newly created server socket for connection.
755 * Return 0 if permission is granted.
756 * @socket_post_accept:
757 * This hook allows a security module to copy security
758 * information into the newly created socket's inode.
759 * @sock contains the listening socket structure.
760 * @newsock contains the newly created server socket for connection.
762 * Check permission before transmitting a message to another socket.
763 * @sock contains the socket structure.
764 * @msg contains the message to be transmitted.
765 * @size contains the size of message.
766 * Return 0 if permission is granted.
768 * Check permission before receiving a message from a socket.
769 * @sock contains the socket structure.
770 * @msg contains the message structure.
771 * @size contains the size of message structure.
772 * @flags contains the operational flags.
773 * Return 0 if permission is granted.
774 * @socket_getsockname:
775 * Check permission before the local address (name) of the socket object
776 * @sock is retrieved.
777 * @sock contains the socket structure.
778 * Return 0 if permission is granted.
779 * @socket_getpeername:
780 * Check permission before the remote address (name) of a socket object
781 * @sock is retrieved.
782 * @sock contains the socket structure.
783 * Return 0 if permission is granted.
784 * @socket_getsockopt:
785 * Check permissions before retrieving the options associated with socket
787 * @sock contains the socket structure.
788 * @level contains the protocol level to retrieve option from.
789 * @optname contains the name of option to retrieve.
790 * Return 0 if permission is granted.
791 * @socket_setsockopt:
792 * Check permissions before setting the options associated with socket
794 * @sock contains the socket structure.
795 * @level contains the protocol level to set options for.
796 * @optname contains the name of the option to set.
797 * Return 0 if permission is granted.
799 * Checks permission before all or part of a connection on the socket
800 * @sock is shut down.
801 * @sock contains the socket structure.
802 * @how contains the flag indicating how future sends and receives are handled.
803 * Return 0 if permission is granted.
804 * @socket_sock_rcv_skb:
805 * Check permissions on incoming network packets. This hook is distinct
806 * from Netfilter's IP input hooks since it is the first time that the
807 * incoming sk_buff @skb has been associated with a particular socket, @sk.
808 * @sk contains the sock (not socket) associated with the incoming sk_buff.
809 * @skb contains the incoming network data.
810 * @socket_getpeersec:
811 * This hook allows the security module to provide peer socket security
812 * state to userspace via getsockopt SO_GETPEERSEC.
813 * @sock is the local socket.
814 * @optval userspace memory where the security state is to be copied.
815 * @optlen userspace int where the module should copy the actual length
816 * of the security state.
817 * @len as input is the maximum length to copy to userspace provided
819 * Return 0 if all is well, otherwise, typical getsockopt return
821 * @sk_alloc_security:
822 * Allocate and attach a security structure to the sk->sk_security field,
823 * which is used to copy security attributes between local stream sockets.
825 * Deallocate security structure.
826 * @sk_clone_security:
827 * Clone/copy security structure.
829 * Retrieve the LSM-specific secid for the sock to enable caching of network
832 * Sets the socket's isec sid to the sock's sid.
833 * @inet_conn_request:
834 * Sets the openreq's sid to socket's sid with MLS portion taken from peer sid.
836 * Sets the new child socket's sid to the openreq sid.
837 * @inet_conn_established:
838 * Sets the connection's peersid to the secmark on skb.
839 * @req_classify_flow:
840 * Sets the flow's sid to the openreq sid.
842 * Security hooks for XFRM operations.
844 * @xfrm_policy_alloc_security:
845 * @xp contains the xfrm_policy being added to Security Policy Database
846 * used by the XFRM system.
847 * @sec_ctx contains the security context information being provided by
848 * the user-level policy update program (e.g., setkey).
849 * Allocate a security structure to the xp->security field; the security
850 * field is initialized to NULL when the xfrm_policy is allocated.
851 * Return 0 if operation was successful (memory to allocate, legal context)
852 * @xfrm_policy_clone_security:
853 * @old contains an existing xfrm_policy in the SPD.
854 * @new contains a new xfrm_policy being cloned from old.
855 * Allocate a security structure to the new->security field
856 * that contains the information from the old->security field.
857 * Return 0 if operation was successful (memory to allocate).
858 * @xfrm_policy_free_security:
859 * @xp contains the xfrm_policy
860 * Deallocate xp->security.
861 * @xfrm_policy_delete_security:
862 * @xp contains the xfrm_policy.
863 * Authorize deletion of xp->security.
864 * @xfrm_state_alloc_security:
865 * @x contains the xfrm_state being added to the Security Association
866 * Database by the XFRM system.
867 * @sec_ctx contains the security context information being provided by
868 * the user-level SA generation program (e.g., setkey or racoon).
869 * @secid contains the secid from which to take the mls portion of the context.
870 * Allocate a security structure to the x->security field; the security
871 * field is initialized to NULL when the xfrm_state is allocated. Set the
872 * context to correspond to either sec_ctx or polsec, with the mls portion
873 * taken from secid in the latter case.
874 * Return 0 if operation was successful (memory to allocate, legal context).
875 * @xfrm_state_free_security:
876 * @x contains the xfrm_state.
877 * Deallocate x->security.
878 * @xfrm_state_delete_security:
879 * @x contains the xfrm_state.
880 * Authorize deletion of x->security.
881 * @xfrm_policy_lookup:
882 * @xp contains the xfrm_policy for which the access control is being
884 * @fl_secid contains the flow security label that is used to authorize
885 * access to the policy xp.
886 * @dir contains the direction of the flow (input or output).
887 * Check permission when a flow selects a xfrm_policy for processing
888 * XFRMs on a packet. The hook is called when selecting either a
889 * per-socket policy or a generic xfrm policy.
890 * Return 0 if permission is granted, -ESRCH otherwise, or -errno
892 * @xfrm_state_pol_flow_match:
893 * @x contains the state to match.
894 * @xp contains the policy to check for a match.
895 * @fl contains the flow to check for a match.
896 * Return 1 if there is a match.
897 * @xfrm_decode_session:
898 * @skb points to skb to decode.
899 * @secid points to the flow key secid to set.
900 * @ckall says if all xfrms used should be checked for same secid.
901 * Return 0 if ckall is zero or all xfrms used have the same secid.
903 * Security hooks affecting all Key Management operations
906 * Permit allocation of a key and assign security data. Note that key does
907 * not have a serial number assigned at this point.
908 * @key points to the key.
909 * @flags is the allocation flags
910 * Return 0 if permission is granted, -ve error otherwise.
912 * Notification of destruction; free security data.
913 * @key points to the key.
916 * See whether a specific operational right is granted to a process on a
918 * @key_ref refers to the key (key pointer + possession attribute bit).
919 * @context points to the process to provide the context against which to
920 * evaluate the security data on the key.
921 * @perm describes the combination of permissions required of this key.
922 * Return 1 if permission granted, 0 if permission denied and -ve it the
923 * normal permissions model should be effected.
925 * Security hooks affecting all System V IPC operations.
928 * Check permissions for access to IPC
929 * @ipcp contains the kernel IPC permission structure
930 * @flag contains the desired (requested) permission set
931 * Return 0 if permission is granted.
933 * Security hooks for individual messages held in System V IPC message queues
934 * @msg_msg_alloc_security:
935 * Allocate and attach a security structure to the msg->security field.
936 * The security field is initialized to NULL when the structure is first
938 * @msg contains the message structure to be modified.
939 * Return 0 if operation was successful and permission is granted.
940 * @msg_msg_free_security:
941 * Deallocate the security structure for this message.
942 * @msg contains the message structure to be modified.
944 * Security hooks for System V IPC Message Queues
946 * @msg_queue_alloc_security:
947 * Allocate and attach a security structure to the
948 * msq->q_perm.security field. The security field is initialized to
949 * NULL when the structure is first created.
950 * @msq contains the message queue structure to be modified.
951 * Return 0 if operation was successful and permission is granted.
952 * @msg_queue_free_security:
953 * Deallocate security structure for this message queue.
954 * @msq contains the message queue structure to be modified.
955 * @msg_queue_associate:
956 * Check permission when a message queue is requested through the
957 * msgget system call. This hook is only called when returning the
958 * message queue identifier for an existing message queue, not when a
959 * new message queue is created.
960 * @msq contains the message queue to act upon.
961 * @msqflg contains the operation control flags.
962 * Return 0 if permission is granted.
964 * Check permission when a message control operation specified by @cmd
965 * is to be performed on the message queue @msq.
966 * The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO.
967 * @msq contains the message queue to act upon. May be NULL.
968 * @cmd contains the operation to be performed.
969 * Return 0 if permission is granted.
971 * Check permission before a message, @msg, is enqueued on the message
973 * @msq contains the message queue to send message to.
974 * @msg contains the message to be enqueued.
975 * @msqflg contains operational flags.
976 * Return 0 if permission is granted.
978 * Check permission before a message, @msg, is removed from the message
979 * queue, @msq. The @target task structure contains a pointer to the
980 * process that will be receiving the message (not equal to the current
981 * process when inline receives are being performed).
982 * @msq contains the message queue to retrieve message from.
983 * @msg contains the message destination.
984 * @target contains the task structure for recipient process.
985 * @type contains the type of message requested.
986 * @mode contains the operational flags.
987 * Return 0 if permission is granted.
989 * Security hooks for System V Shared Memory Segments
991 * @shm_alloc_security:
992 * Allocate and attach a security structure to the shp->shm_perm.security
993 * field. The security field is initialized to NULL when the structure is
995 * @shp contains the shared memory structure to be modified.
996 * Return 0 if operation was successful and permission is granted.
997 * @shm_free_security:
998 * Deallocate the security struct for this memory segment.
999 * @shp contains the shared memory structure to be modified.
1001 * Check permission when a shared memory region is requested through the
1002 * shmget system call. This hook is only called when returning the shared
1003 * memory region identifier for an existing region, not when a new shared
1004 * memory region is created.
1005 * @shp contains the shared memory structure to be modified.
1006 * @shmflg contains the operation control flags.
1007 * Return 0 if permission is granted.
1009 * Check permission when a shared memory control operation specified by
1010 * @cmd is to be performed on the shared memory region @shp.
1011 * The @shp may be NULL, e.g. for IPC_INFO or SHM_INFO.
1012 * @shp contains shared memory structure to be modified.
1013 * @cmd contains the operation to be performed.
1014 * Return 0 if permission is granted.
1016 * Check permissions prior to allowing the shmat system call to attach the
1017 * shared memory segment @shp to the data segment of the calling process.
1018 * The attaching address is specified by @shmaddr.
1019 * @shp contains the shared memory structure to be modified.
1020 * @shmaddr contains the address to attach memory region to.
1021 * @shmflg contains the operational flags.
1022 * Return 0 if permission is granted.
1024 * Security hooks for System V Semaphores
1026 * @sem_alloc_security:
1027 * Allocate and attach a security structure to the sma->sem_perm.security
1028 * field. The security field is initialized to NULL when the structure is
1030 * @sma contains the semaphore structure
1031 * Return 0 if operation was successful and permission is granted.
1032 * @sem_free_security:
1033 * deallocate security struct for this semaphore
1034 * @sma contains the semaphore structure.
1036 * Check permission when a semaphore is requested through the semget
1037 * system call. This hook is only called when returning the semaphore
1038 * identifier for an existing semaphore, not when a new one must be
1040 * @sma contains the semaphore structure.
1041 * @semflg contains the operation control flags.
1042 * Return 0 if permission is granted.
1044 * Check permission when a semaphore operation specified by @cmd is to be
1045 * performed on the semaphore @sma. The @sma may be NULL, e.g. for
1046 * IPC_INFO or SEM_INFO.
1047 * @sma contains the semaphore structure. May be NULL.
1048 * @cmd contains the operation to be performed.
1049 * Return 0 if permission is granted.
1051 * Check permissions before performing operations on members of the
1052 * semaphore set @sma. If the @alter flag is nonzero, the semaphore set
1054 * @sma contains the semaphore structure.
1055 * @sops contains the operations to perform.
1056 * @nsops contains the number of operations to perform.
1057 * @alter contains the flag indicating whether changes are to be made.
1058 * Return 0 if permission is granted.
1061 * Check permission before allowing the @parent process to trace the
1063 * Security modules may also want to perform a process tracing check
1064 * during an execve in the set_security or apply_creds hooks of
1065 * binprm_security_ops if the process is being traced and its security
1066 * attributes would be changed by the execve.
1067 * @parent contains the task_struct structure for parent process.
1068 * @child contains the task_struct structure for child process.
1069 * Return 0 if permission is granted.
1071 * Get the @effective, @inheritable, and @permitted capability sets for
1072 * the @target process. The hook may also perform permission checking to
1073 * determine if the current process is allowed to see the capability sets
1074 * of the @target process.
1075 * @target contains the task_struct structure for target process.
1076 * @effective contains the effective capability set.
1077 * @inheritable contains the inheritable capability set.
1078 * @permitted contains the permitted capability set.
1079 * Return 0 if the capability sets were successfully obtained.
1081 * Check permission before setting the @effective, @inheritable, and
1082 * @permitted capability sets for the @target process.
1083 * Caveat: @target is also set to current if a set of processes is
1084 * specified (i.e. all processes other than current and init or a
1085 * particular process group). Hence, the capset_set hook may need to
1086 * revalidate permission to the actual target process.
1087 * @target contains the task_struct structure for target process.
1088 * @effective contains the effective capability set.
1089 * @inheritable contains the inheritable capability set.
1090 * @permitted contains the permitted capability set.
1091 * Return 0 if permission is granted.
1093 * Set the @effective, @inheritable, and @permitted capability sets for
1094 * the @target process. Since capset_check cannot always check permission
1095 * to the real @target process, this hook may also perform permission
1096 * checking to determine if the current process is allowed to set the
1097 * capability sets of the @target process. However, this hook has no way
1098 * of returning an error due to the structure of the sys_capset code.
1099 * @target contains the task_struct structure for target process.
1100 * @effective contains the effective capability set.
1101 * @inheritable contains the inheritable capability set.
1102 * @permitted contains the permitted capability set.
1104 * Check whether the @tsk process has the @cap capability.
1105 * @tsk contains the task_struct for the process.
1106 * @cap contains the capability <include/linux/capability.h>.
1107 * Return 0 if the capability is granted for @tsk.
1109 * Check permission before enabling or disabling process accounting. If
1110 * accounting is being enabled, then @file refers to the open file used to
1111 * store accounting records. If accounting is being disabled, then @file
1113 * @file contains the file structure for the accounting file (may be NULL).
1114 * Return 0 if permission is granted.
1116 * Check permission before accessing the @table sysctl variable in the
1117 * manner specified by @op.
1118 * @table contains the ctl_table structure for the sysctl variable.
1119 * @op contains the operation (001 = search, 002 = write, 004 = read).
1120 * Return 0 if permission is granted.
1122 * Check permission before accessing the kernel message ring or changing
1123 * logging to the console.
1124 * See the syslog(2) manual page for an explanation of the @type values.
1125 * @type contains the type of action.
1126 * Return 0 if permission is granted.
1128 * Check permission to change the system time.
1129 * struct timespec and timezone are defined in include/linux/time.h
1130 * @ts contains new time
1131 * @tz contains new timezone
1132 * Return 0 if permission is granted.
1133 * @vm_enough_memory:
1134 * Check permissions for allocating a new virtual mapping.
1135 * @mm contains the mm struct it is being added to.
1136 * @pages contains the number of pages.
1137 * Return 0 if permission is granted.
1139 * @register_security:
1140 * allow module stacking.
1141 * @name contains the name of the security module being stacked.
1142 * @ops contains a pointer to the struct security_operations of the module to stack.
1143 * @unregister_security:
1144 * remove a stacked module.
1145 * @name contains the name of the security module being unstacked.
1146 * @ops contains a pointer to the struct security_operations of the module to unstack.
1149 * Convert secid to security context.
1150 * @secid contains the security ID.
1151 * @secdata contains the pointer that stores the converted security context.
1154 * Release the security context.
1155 * @secdata contains the security context.
1156 * @seclen contains the length of the security context.
1158 * This is the main security structure.
1160 struct security_operations {
1161 int (*ptrace) (struct task_struct * parent, struct task_struct * child);
1162 int (*capget) (struct task_struct * target,
1163 kernel_cap_t * effective,
1164 kernel_cap_t * inheritable, kernel_cap_t * permitted);
1165 int (*capset_check) (struct task_struct * target,
1166 kernel_cap_t * effective,
1167 kernel_cap_t * inheritable,
1168 kernel_cap_t * permitted);
1169 void (*capset_set) (struct task_struct * target,
1170 kernel_cap_t * effective,
1171 kernel_cap_t * inheritable,
1172 kernel_cap_t * permitted);
1173 int (*capable) (struct task_struct * tsk, int cap);
1174 int (*acct) (struct file * file);
1175 int (*sysctl) (struct ctl_table * table, int op);
1176 int (*quotactl) (int cmds, int type, int id, struct super_block * sb);
1177 int (*quota_on) (struct dentry * dentry);
1178 int (*syslog) (int type);
1179 int (*settime) (struct timespec *ts, struct timezone *tz);
1180 int (*vm_enough_memory) (struct mm_struct *mm, long pages);
1182 int (*bprm_alloc_security) (struct linux_binprm * bprm);
1183 void (*bprm_free_security) (struct linux_binprm * bprm);
1184 void (*bprm_apply_creds) (struct linux_binprm * bprm, int unsafe);
1185 void (*bprm_post_apply_creds) (struct linux_binprm * bprm);
1186 int (*bprm_set_security) (struct linux_binprm * bprm);
1187 int (*bprm_check_security) (struct linux_binprm * bprm);
1188 int (*bprm_secureexec) (struct linux_binprm * bprm);
1190 int (*sb_alloc_security) (struct super_block * sb);
1191 void (*sb_free_security) (struct super_block * sb);
1192 int (*sb_copy_data)(struct file_system_type *type,
1193 void *orig, void *copy);
1194 int (*sb_kern_mount) (struct super_block *sb, void *data);
1195 int (*sb_statfs) (struct dentry *dentry);
1196 int (*sb_mount) (char *dev_name, struct nameidata * nd,
1197 char *type, unsigned long flags, void *data);
1198 int (*sb_check_sb) (struct vfsmount * mnt, struct nameidata * nd);
1199 int (*sb_umount) (struct vfsmount * mnt, int flags);
1200 void (*sb_umount_close) (struct vfsmount * mnt);
1201 void (*sb_umount_busy) (struct vfsmount * mnt);
1202 void (*sb_post_remount) (struct vfsmount * mnt,
1203 unsigned long flags, void *data);
1204 void (*sb_post_mountroot) (void);
1205 void (*sb_post_addmount) (struct vfsmount * mnt,
1206 struct nameidata * mountpoint_nd);
1207 int (*sb_pivotroot) (struct nameidata * old_nd,
1208 struct nameidata * new_nd);
1209 void (*sb_post_pivotroot) (struct nameidata * old_nd,
1210 struct nameidata * new_nd);
1212 int (*inode_alloc_security) (struct inode *inode);
1213 void (*inode_free_security) (struct inode *inode);
1214 int (*inode_init_security) (struct inode *inode, struct inode *dir,
1215 char **name, void **value, size_t *len);
1216 int (*inode_create) (struct inode *dir,
1217 struct dentry *dentry, int mode);
1218 int (*inode_link) (struct dentry *old_dentry,
1219 struct inode *dir, struct dentry *new_dentry);
1220 int (*inode_unlink) (struct inode *dir, struct dentry *dentry);
1221 int (*inode_symlink) (struct inode *dir,
1222 struct dentry *dentry, const char *old_name);
1223 int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode);
1224 int (*inode_rmdir) (struct inode *dir, struct dentry *dentry);
1225 int (*inode_mknod) (struct inode *dir, struct dentry *dentry,
1226 int mode, dev_t dev);
1227 int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
1228 struct inode *new_dir, struct dentry *new_dentry);
1229 int (*inode_readlink) (struct dentry *dentry);
1230 int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
1231 int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd);
1232 int (*inode_setattr) (struct dentry *dentry, struct iattr *attr);
1233 int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
1234 void (*inode_delete) (struct inode *inode);
1235 int (*inode_setxattr) (struct dentry *dentry, char *name, void *value,
1236 size_t size, int flags);
1237 void (*inode_post_setxattr) (struct dentry *dentry, char *name, void *value,
1238 size_t size, int flags);
1239 int (*inode_getxattr) (struct dentry *dentry, char *name);
1240 int (*inode_listxattr) (struct dentry *dentry);
1241 int (*inode_removexattr) (struct dentry *dentry, char *name);
1242 const char *(*inode_xattr_getsuffix) (void);
1243 int (*inode_getsecurity)(const struct inode *inode, const char *name, void *buffer, size_t size, int err);
1244 int (*inode_setsecurity)(struct inode *inode, const char *name, const void *value, size_t size, int flags);
1245 int (*inode_listsecurity)(struct inode *inode, char *buffer, size_t buffer_size);
1247 int (*file_permission) (struct file * file, int mask);
1248 int (*file_alloc_security) (struct file * file);
1249 void (*file_free_security) (struct file * file);
1250 int (*file_ioctl) (struct file * file, unsigned int cmd,
1252 int (*file_mmap) (struct file * file,
1253 unsigned long reqprot, unsigned long prot,
1254 unsigned long flags, unsigned long addr,
1255 unsigned long addr_only);
1256 int (*file_mprotect) (struct vm_area_struct * vma,
1257 unsigned long reqprot,
1258 unsigned long prot);
1259 int (*file_lock) (struct file * file, unsigned int cmd);
1260 int (*file_fcntl) (struct file * file, unsigned int cmd,
1262 int (*file_set_fowner) (struct file * file);
1263 int (*file_send_sigiotask) (struct task_struct * tsk,
1264 struct fown_struct * fown, int sig);
1265 int (*file_receive) (struct file * file);
1266 int (*dentry_open) (struct file *file);
1268 int (*task_create) (unsigned long clone_flags);
1269 int (*task_alloc_security) (struct task_struct * p);
1270 void (*task_free_security) (struct task_struct * p);
1271 int (*task_setuid) (uid_t id0, uid_t id1, uid_t id2, int flags);
1272 int (*task_post_setuid) (uid_t old_ruid /* or fsuid */ ,
1273 uid_t old_euid, uid_t old_suid, int flags);
1274 int (*task_setgid) (gid_t id0, gid_t id1, gid_t id2, int flags);
1275 int (*task_setpgid) (struct task_struct * p, pid_t pgid);
1276 int (*task_getpgid) (struct task_struct * p);
1277 int (*task_getsid) (struct task_struct * p);
1278 void (*task_getsecid) (struct task_struct * p, u32 * secid);
1279 int (*task_setgroups) (struct group_info *group_info);
1280 int (*task_setnice) (struct task_struct * p, int nice);
1281 int (*task_setioprio) (struct task_struct * p, int ioprio);
1282 int (*task_getioprio) (struct task_struct * p);
1283 int (*task_setrlimit) (unsigned int resource, struct rlimit * new_rlim);
1284 int (*task_setscheduler) (struct task_struct * p, int policy,
1285 struct sched_param * lp);
1286 int (*task_getscheduler) (struct task_struct * p);
1287 int (*task_movememory) (struct task_struct * p);
1288 int (*task_kill) (struct task_struct * p,
1289 struct siginfo * info, int sig, u32 secid);
1290 int (*task_wait) (struct task_struct * p);
1291 int (*task_prctl) (int option, unsigned long arg2,
1292 unsigned long arg3, unsigned long arg4,
1293 unsigned long arg5);
1294 void (*task_reparent_to_init) (struct task_struct * p);
1295 void (*task_to_inode)(struct task_struct *p, struct inode *inode);
1297 int (*ipc_permission) (struct kern_ipc_perm * ipcp, short flag);
1299 int (*msg_msg_alloc_security) (struct msg_msg * msg);
1300 void (*msg_msg_free_security) (struct msg_msg * msg);
1302 int (*msg_queue_alloc_security) (struct msg_queue * msq);
1303 void (*msg_queue_free_security) (struct msg_queue * msq);
1304 int (*msg_queue_associate) (struct msg_queue * msq, int msqflg);
1305 int (*msg_queue_msgctl) (struct msg_queue * msq, int cmd);
1306 int (*msg_queue_msgsnd) (struct msg_queue * msq,
1307 struct msg_msg * msg, int msqflg);
1308 int (*msg_queue_msgrcv) (struct msg_queue * msq,
1309 struct msg_msg * msg,
1310 struct task_struct * target,
1311 long type, int mode);
1313 int (*shm_alloc_security) (struct shmid_kernel * shp);
1314 void (*shm_free_security) (struct shmid_kernel * shp);
1315 int (*shm_associate) (struct shmid_kernel * shp, int shmflg);
1316 int (*shm_shmctl) (struct shmid_kernel * shp, int cmd);
1317 int (*shm_shmat) (struct shmid_kernel * shp,
1318 char __user *shmaddr, int shmflg);
1320 int (*sem_alloc_security) (struct sem_array * sma);
1321 void (*sem_free_security) (struct sem_array * sma);
1322 int (*sem_associate) (struct sem_array * sma, int semflg);
1323 int (*sem_semctl) (struct sem_array * sma, int cmd);
1324 int (*sem_semop) (struct sem_array * sma,
1325 struct sembuf * sops, unsigned nsops, int alter);
1327 int (*netlink_send) (struct sock * sk, struct sk_buff * skb);
1328 int (*netlink_recv) (struct sk_buff * skb, int cap);
1330 /* allow module stacking */
1331 int (*register_security) (const char *name,
1332 struct security_operations *ops);
1333 int (*unregister_security) (const char *name,
1334 struct security_operations *ops);
1336 void (*d_instantiate) (struct dentry *dentry, struct inode *inode);
1338 int (*getprocattr)(struct task_struct *p, char *name, char **value);
1339 int (*setprocattr)(struct task_struct *p, char *name, void *value, size_t size);
1340 int (*secid_to_secctx)(u32 secid, char **secdata, u32 *seclen);
1341 void (*release_secctx)(char *secdata, u32 seclen);
1343 #ifdef CONFIG_SECURITY_NETWORK
1344 int (*unix_stream_connect) (struct socket * sock,
1345 struct socket * other, struct sock * newsk);
1346 int (*unix_may_send) (struct socket * sock, struct socket * other);
1348 int (*socket_create) (int family, int type, int protocol, int kern);
1349 int (*socket_post_create) (struct socket * sock, int family,
1350 int type, int protocol, int kern);
1351 int (*socket_bind) (struct socket * sock,
1352 struct sockaddr * address, int addrlen);
1353 int (*socket_connect) (struct socket * sock,
1354 struct sockaddr * address, int addrlen);
1355 int (*socket_listen) (struct socket * sock, int backlog);
1356 int (*socket_accept) (struct socket * sock, struct socket * newsock);
1357 void (*socket_post_accept) (struct socket * sock,
1358 struct socket * newsock);
1359 int (*socket_sendmsg) (struct socket * sock,
1360 struct msghdr * msg, int size);
1361 int (*socket_recvmsg) (struct socket * sock,
1362 struct msghdr * msg, int size, int flags);
1363 int (*socket_getsockname) (struct socket * sock);
1364 int (*socket_getpeername) (struct socket * sock);
1365 int (*socket_getsockopt) (struct socket * sock, int level, int optname);
1366 int (*socket_setsockopt) (struct socket * sock, int level, int optname);
1367 int (*socket_shutdown) (struct socket * sock, int how);
1368 int (*socket_sock_rcv_skb) (struct sock * sk, struct sk_buff * skb);
1369 int (*socket_getpeersec_stream) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len);
1370 int (*socket_getpeersec_dgram) (struct socket *sock, struct sk_buff *skb, u32 *secid);
1371 int (*sk_alloc_security) (struct sock *sk, int family, gfp_t priority);
1372 void (*sk_free_security) (struct sock *sk);
1373 void (*sk_clone_security) (const struct sock *sk, struct sock *newsk);
1374 void (*sk_getsecid) (struct sock *sk, u32 *secid);
1375 void (*sock_graft)(struct sock* sk, struct socket *parent);
1376 int (*inet_conn_request)(struct sock *sk, struct sk_buff *skb,
1377 struct request_sock *req);
1378 void (*inet_csk_clone)(struct sock *newsk, const struct request_sock *req);
1379 void (*inet_conn_established)(struct sock *sk, struct sk_buff *skb);
1380 void (*req_classify_flow)(const struct request_sock *req, struct flowi *fl);
1381 #endif /* CONFIG_SECURITY_NETWORK */
1383 #ifdef CONFIG_SECURITY_NETWORK_XFRM
1384 int (*xfrm_policy_alloc_security) (struct xfrm_policy *xp,
1385 struct xfrm_user_sec_ctx *sec_ctx);
1386 int (*xfrm_policy_clone_security) (struct xfrm_policy *old, struct xfrm_policy *new);
1387 void (*xfrm_policy_free_security) (struct xfrm_policy *xp);
1388 int (*xfrm_policy_delete_security) (struct xfrm_policy *xp);
1389 int (*xfrm_state_alloc_security) (struct xfrm_state *x,
1390 struct xfrm_user_sec_ctx *sec_ctx,
1392 void (*xfrm_state_free_security) (struct xfrm_state *x);
1393 int (*xfrm_state_delete_security) (struct xfrm_state *x);
1394 int (*xfrm_policy_lookup)(struct xfrm_policy *xp, u32 fl_secid, u8 dir);
1395 int (*xfrm_state_pol_flow_match)(struct xfrm_state *x,
1396 struct xfrm_policy *xp, struct flowi *fl);
1397 int (*xfrm_decode_session)(struct sk_buff *skb, u32 *secid, int ckall);
1398 #endif /* CONFIG_SECURITY_NETWORK_XFRM */
1400 /* key management security hooks */
1402 int (*key_alloc)(struct key *key, struct task_struct *tsk, unsigned long flags);
1403 void (*key_free)(struct key *key);
1404 int (*key_permission)(key_ref_t key_ref,
1405 struct task_struct *context,
1408 #endif /* CONFIG_KEYS */
1412 /* global variables */
1413 extern struct security_operations *security_ops;
1416 static inline int security_ptrace (struct task_struct * parent, struct task_struct * child)
1418 return security_ops->ptrace (parent, child);
1421 static inline int security_capget (struct task_struct *target,
1422 kernel_cap_t *effective,
1423 kernel_cap_t *inheritable,
1424 kernel_cap_t *permitted)
1426 return security_ops->capget (target, effective, inheritable, permitted);
1429 static inline int security_capset_check (struct task_struct *target,
1430 kernel_cap_t *effective,
1431 kernel_cap_t *inheritable,
1432 kernel_cap_t *permitted)
1434 return security_ops->capset_check (target, effective, inheritable, permitted);
1437 static inline void security_capset_set (struct task_struct *target,
1438 kernel_cap_t *effective,
1439 kernel_cap_t *inheritable,
1440 kernel_cap_t *permitted)
1442 security_ops->capset_set (target, effective, inheritable, permitted);
1445 static inline int security_capable(struct task_struct *tsk, int cap)
1447 return security_ops->capable(tsk, cap);
1450 static inline int security_acct (struct file *file)
1452 return security_ops->acct (file);
1455 static inline int security_sysctl(struct ctl_table *table, int op)
1457 return security_ops->sysctl(table, op);
1460 static inline int security_quotactl (int cmds, int type, int id,
1461 struct super_block *sb)
1463 return security_ops->quotactl (cmds, type, id, sb);
1466 static inline int security_quota_on (struct dentry * dentry)
1468 return security_ops->quota_on (dentry);
1471 static inline int security_syslog(int type)
1473 return security_ops->syslog(type);
1476 static inline int security_settime(struct timespec *ts, struct timezone *tz)
1478 return security_ops->settime(ts, tz);
1481 static inline int security_vm_enough_memory(long pages)
1483 return security_ops->vm_enough_memory(current->mm, pages);
1486 static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
1488 return security_ops->vm_enough_memory(mm, pages);
1491 static inline int security_bprm_alloc (struct linux_binprm *bprm)
1493 return security_ops->bprm_alloc_security (bprm);
1495 static inline void security_bprm_free (struct linux_binprm *bprm)
1497 security_ops->bprm_free_security (bprm);
1499 static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
1501 security_ops->bprm_apply_creds (bprm, unsafe);
1503 static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
1505 security_ops->bprm_post_apply_creds (bprm);
1507 static inline int security_bprm_set (struct linux_binprm *bprm)
1509 return security_ops->bprm_set_security (bprm);
1512 static inline int security_bprm_check (struct linux_binprm *bprm)
1514 return security_ops->bprm_check_security (bprm);
1517 static inline int security_bprm_secureexec (struct linux_binprm *bprm)
1519 return security_ops->bprm_secureexec (bprm);
1522 static inline int security_sb_alloc (struct super_block *sb)
1524 return security_ops->sb_alloc_security (sb);
1527 static inline void security_sb_free (struct super_block *sb)
1529 security_ops->sb_free_security (sb);
1532 static inline int security_sb_copy_data (struct file_system_type *type,
1533 void *orig, void *copy)
1535 return security_ops->sb_copy_data (type, orig, copy);
1538 static inline int security_sb_kern_mount (struct super_block *sb, void *data)
1540 return security_ops->sb_kern_mount (sb, data);
1543 static inline int security_sb_statfs (struct dentry *dentry)
1545 return security_ops->sb_statfs (dentry);
1548 static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
1549 char *type, unsigned long flags,
1552 return security_ops->sb_mount (dev_name, nd, type, flags, data);
1555 static inline int security_sb_check_sb (struct vfsmount *mnt,
1556 struct nameidata *nd)
1558 return security_ops->sb_check_sb (mnt, nd);
1561 static inline int security_sb_umount (struct vfsmount *mnt, int flags)
1563 return security_ops->sb_umount (mnt, flags);
1566 static inline void security_sb_umount_close (struct vfsmount *mnt)
1568 security_ops->sb_umount_close (mnt);
1571 static inline void security_sb_umount_busy (struct vfsmount *mnt)
1573 security_ops->sb_umount_busy (mnt);
1576 static inline void security_sb_post_remount (struct vfsmount *mnt,
1577 unsigned long flags, void *data)
1579 security_ops->sb_post_remount (mnt, flags, data);
1582 static inline void security_sb_post_mountroot (void)
1584 security_ops->sb_post_mountroot ();
1587 static inline void security_sb_post_addmount (struct vfsmount *mnt,
1588 struct nameidata *mountpoint_nd)
1590 security_ops->sb_post_addmount (mnt, mountpoint_nd);
1593 static inline int security_sb_pivotroot (struct nameidata *old_nd,
1594 struct nameidata *new_nd)
1596 return security_ops->sb_pivotroot (old_nd, new_nd);
1599 static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
1600 struct nameidata *new_nd)
1602 security_ops->sb_post_pivotroot (old_nd, new_nd);
1605 static inline int security_inode_alloc (struct inode *inode)
1607 inode->i_security = NULL;
1608 return security_ops->inode_alloc_security (inode);
1611 static inline void security_inode_free (struct inode *inode)
1613 security_ops->inode_free_security (inode);
1616 static inline int security_inode_init_security (struct inode *inode,
1622 if (unlikely (IS_PRIVATE (inode)))
1624 return security_ops->inode_init_security (inode, dir, name, value, len);
1627 static inline int security_inode_create (struct inode *dir,
1628 struct dentry *dentry,
1631 if (unlikely (IS_PRIVATE (dir)))
1633 return security_ops->inode_create (dir, dentry, mode);
1636 static inline int security_inode_link (struct dentry *old_dentry,
1638 struct dentry *new_dentry)
1640 if (unlikely (IS_PRIVATE (old_dentry->d_inode)))
1642 return security_ops->inode_link (old_dentry, dir, new_dentry);
1645 static inline int security_inode_unlink (struct inode *dir,
1646 struct dentry *dentry)
1648 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1650 return security_ops->inode_unlink (dir, dentry);
1653 static inline int security_inode_symlink (struct inode *dir,
1654 struct dentry *dentry,
1655 const char *old_name)
1657 if (unlikely (IS_PRIVATE (dir)))
1659 return security_ops->inode_symlink (dir, dentry, old_name);
1662 static inline int security_inode_mkdir (struct inode *dir,
1663 struct dentry *dentry,
1666 if (unlikely (IS_PRIVATE (dir)))
1668 return security_ops->inode_mkdir (dir, dentry, mode);
1671 static inline int security_inode_rmdir (struct inode *dir,
1672 struct dentry *dentry)
1674 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1676 return security_ops->inode_rmdir (dir, dentry);
1679 static inline int security_inode_mknod (struct inode *dir,
1680 struct dentry *dentry,
1681 int mode, dev_t dev)
1683 if (unlikely (IS_PRIVATE (dir)))
1685 return security_ops->inode_mknod (dir, dentry, mode, dev);
1688 static inline int security_inode_rename (struct inode *old_dir,
1689 struct dentry *old_dentry,
1690 struct inode *new_dir,
1691 struct dentry *new_dentry)
1693 if (unlikely (IS_PRIVATE (old_dentry->d_inode) ||
1694 (new_dentry->d_inode && IS_PRIVATE (new_dentry->d_inode))))
1696 return security_ops->inode_rename (old_dir, old_dentry,
1697 new_dir, new_dentry);
1700 static inline int security_inode_readlink (struct dentry *dentry)
1702 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1704 return security_ops->inode_readlink (dentry);
1707 static inline int security_inode_follow_link (struct dentry *dentry,
1708 struct nameidata *nd)
1710 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1712 return security_ops->inode_follow_link (dentry, nd);
1715 static inline int security_inode_permission (struct inode *inode, int mask,
1716 struct nameidata *nd)
1718 if (unlikely (IS_PRIVATE (inode)))
1720 return security_ops->inode_permission (inode, mask, nd);
1723 static inline int security_inode_setattr (struct dentry *dentry,
1726 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1728 return security_ops->inode_setattr (dentry, attr);
1731 static inline int security_inode_getattr (struct vfsmount *mnt,
1732 struct dentry *dentry)
1734 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1736 return security_ops->inode_getattr (mnt, dentry);
1739 static inline void security_inode_delete (struct inode *inode)
1741 if (unlikely (IS_PRIVATE (inode)))
1743 security_ops->inode_delete (inode);
1746 static inline int security_inode_setxattr (struct dentry *dentry, char *name,
1747 void *value, size_t size, int flags)
1749 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1751 return security_ops->inode_setxattr (dentry, name, value, size, flags);
1754 static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
1755 void *value, size_t size, int flags)
1757 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1759 security_ops->inode_post_setxattr (dentry, name, value, size, flags);
1762 static inline int security_inode_getxattr (struct dentry *dentry, char *name)
1764 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1766 return security_ops->inode_getxattr (dentry, name);
1769 static inline int security_inode_listxattr (struct dentry *dentry)
1771 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1773 return security_ops->inode_listxattr (dentry);
1776 static inline int security_inode_removexattr (struct dentry *dentry, char *name)
1778 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1780 return security_ops->inode_removexattr (dentry, name);
1783 static inline const char *security_inode_xattr_getsuffix(void)
1785 return security_ops->inode_xattr_getsuffix();
1788 static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void *buffer, size_t size, int err)
1790 if (unlikely (IS_PRIVATE (inode)))
1792 return security_ops->inode_getsecurity(inode, name, buffer, size, err);
1795 static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
1797 if (unlikely (IS_PRIVATE (inode)))
1799 return security_ops->inode_setsecurity(inode, name, value, size, flags);
1802 static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
1804 if (unlikely (IS_PRIVATE (inode)))
1806 return security_ops->inode_listsecurity(inode, buffer, buffer_size);
1809 static inline int security_file_permission (struct file *file, int mask)
1811 return security_ops->file_permission (file, mask);
1814 static inline int security_file_alloc (struct file *file)
1816 return security_ops->file_alloc_security (file);
1819 static inline void security_file_free (struct file *file)
1821 security_ops->file_free_security (file);
1824 static inline int security_file_ioctl (struct file *file, unsigned int cmd,
1827 return security_ops->file_ioctl (file, cmd, arg);
1830 static inline int security_file_mmap (struct file *file, unsigned long reqprot,
1832 unsigned long flags,
1834 unsigned long addr_only)
1836 return security_ops->file_mmap (file, reqprot, prot, flags, addr,
1840 static inline int security_file_mprotect (struct vm_area_struct *vma,
1841 unsigned long reqprot,
1844 return security_ops->file_mprotect (vma, reqprot, prot);
1847 static inline int security_file_lock (struct file *file, unsigned int cmd)
1849 return security_ops->file_lock (file, cmd);
1852 static inline int security_file_fcntl (struct file *file, unsigned int cmd,
1855 return security_ops->file_fcntl (file, cmd, arg);
1858 static inline int security_file_set_fowner (struct file *file)
1860 return security_ops->file_set_fowner (file);
1863 static inline int security_file_send_sigiotask (struct task_struct *tsk,
1864 struct fown_struct *fown,
1867 return security_ops->file_send_sigiotask (tsk, fown, sig);
1870 static inline int security_file_receive (struct file *file)
1872 return security_ops->file_receive (file);
1875 static inline int security_dentry_open (struct file *file)
1877 return security_ops->dentry_open (file);
1880 static inline int security_task_create (unsigned long clone_flags)
1882 return security_ops->task_create (clone_flags);
1885 static inline int security_task_alloc (struct task_struct *p)
1887 return security_ops->task_alloc_security (p);
1890 static inline void security_task_free (struct task_struct *p)
1892 security_ops->task_free_security (p);
1895 static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
1898 return security_ops->task_setuid (id0, id1, id2, flags);
1901 static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
1902 uid_t old_suid, int flags)
1904 return security_ops->task_post_setuid (old_ruid, old_euid, old_suid, flags);
1907 static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
1910 return security_ops->task_setgid (id0, id1, id2, flags);
1913 static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
1915 return security_ops->task_setpgid (p, pgid);
1918 static inline int security_task_getpgid (struct task_struct *p)
1920 return security_ops->task_getpgid (p);
1923 static inline int security_task_getsid (struct task_struct *p)
1925 return security_ops->task_getsid (p);
1928 static inline void security_task_getsecid (struct task_struct *p, u32 *secid)
1930 security_ops->task_getsecid (p, secid);
1933 static inline int security_task_setgroups (struct group_info *group_info)
1935 return security_ops->task_setgroups (group_info);
1938 static inline int security_task_setnice (struct task_struct *p, int nice)
1940 return security_ops->task_setnice (p, nice);
1943 static inline int security_task_setioprio (struct task_struct *p, int ioprio)
1945 return security_ops->task_setioprio (p, ioprio);
1948 static inline int security_task_getioprio (struct task_struct *p)
1950 return security_ops->task_getioprio (p);
1953 static inline int security_task_setrlimit (unsigned int resource,
1954 struct rlimit *new_rlim)
1956 return security_ops->task_setrlimit (resource, new_rlim);
1959 static inline int security_task_setscheduler (struct task_struct *p,
1961 struct sched_param *lp)
1963 return security_ops->task_setscheduler (p, policy, lp);
1966 static inline int security_task_getscheduler (struct task_struct *p)
1968 return security_ops->task_getscheduler (p);
1971 static inline int security_task_movememory (struct task_struct *p)
1973 return security_ops->task_movememory (p);
1976 static inline int security_task_kill (struct task_struct *p,
1977 struct siginfo *info, int sig,
1980 return security_ops->task_kill (p, info, sig, secid);
1983 static inline int security_task_wait (struct task_struct *p)
1985 return security_ops->task_wait (p);
1988 static inline int security_task_prctl (int option, unsigned long arg2,
1993 return security_ops->task_prctl (option, arg2, arg3, arg4, arg5);
1996 static inline void security_task_reparent_to_init (struct task_struct *p)
1998 security_ops->task_reparent_to_init (p);
2001 static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
2003 security_ops->task_to_inode(p, inode);
2006 static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
2009 return security_ops->ipc_permission (ipcp, flag);
2012 static inline int security_msg_msg_alloc (struct msg_msg * msg)
2014 return security_ops->msg_msg_alloc_security (msg);
2017 static inline void security_msg_msg_free (struct msg_msg * msg)
2019 security_ops->msg_msg_free_security(msg);
2022 static inline int security_msg_queue_alloc (struct msg_queue *msq)
2024 return security_ops->msg_queue_alloc_security (msq);
2027 static inline void security_msg_queue_free (struct msg_queue *msq)
2029 security_ops->msg_queue_free_security (msq);
2032 static inline int security_msg_queue_associate (struct msg_queue * msq,
2035 return security_ops->msg_queue_associate (msq, msqflg);
2038 static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
2040 return security_ops->msg_queue_msgctl (msq, cmd);
2043 static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
2044 struct msg_msg * msg, int msqflg)
2046 return security_ops->msg_queue_msgsnd (msq, msg, msqflg);
2049 static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
2050 struct msg_msg * msg,
2051 struct task_struct * target,
2052 long type, int mode)
2054 return security_ops->msg_queue_msgrcv (msq, msg, target, type, mode);
2057 static inline int security_shm_alloc (struct shmid_kernel *shp)
2059 return security_ops->shm_alloc_security (shp);
2062 static inline void security_shm_free (struct shmid_kernel *shp)
2064 security_ops->shm_free_security (shp);
2067 static inline int security_shm_associate (struct shmid_kernel * shp,
2070 return security_ops->shm_associate(shp, shmflg);
2073 static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
2075 return security_ops->shm_shmctl (shp, cmd);
2078 static inline int security_shm_shmat (struct shmid_kernel * shp,
2079 char __user *shmaddr, int shmflg)
2081 return security_ops->shm_shmat(shp, shmaddr, shmflg);
2084 static inline int security_sem_alloc (struct sem_array *sma)
2086 return security_ops->sem_alloc_security (sma);
2089 static inline void security_sem_free (struct sem_array *sma)
2091 security_ops->sem_free_security (sma);
2094 static inline int security_sem_associate (struct sem_array * sma, int semflg)
2096 return security_ops->sem_associate (sma, semflg);
2099 static inline int security_sem_semctl (struct sem_array * sma, int cmd)
2101 return security_ops->sem_semctl(sma, cmd);
2104 static inline int security_sem_semop (struct sem_array * sma,
2105 struct sembuf * sops, unsigned nsops,
2108 return security_ops->sem_semop(sma, sops, nsops, alter);
2111 static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
2113 if (unlikely (inode && IS_PRIVATE (inode)))
2115 security_ops->d_instantiate (dentry, inode);
2118 static inline int security_getprocattr(struct task_struct *p, char *name, char **value)
2120 return security_ops->getprocattr(p, name, value);
2123 static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2125 return security_ops->setprocattr(p, name, value, size);
2128 static inline int security_netlink_send(struct sock *sk, struct sk_buff * skb)
2130 return security_ops->netlink_send(sk, skb);
2133 static inline int security_netlink_recv(struct sk_buff * skb, int cap)
2135 return security_ops->netlink_recv(skb, cap);
2138 static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
2140 return security_ops->secid_to_secctx(secid, secdata, seclen);
2143 static inline void security_release_secctx(char *secdata, u32 seclen)
2145 return security_ops->release_secctx(secdata, seclen);
2149 extern int security_init (void);
2150 extern int register_security (struct security_operations *ops);
2151 extern int unregister_security (struct security_operations *ops);
2152 extern int mod_reg_security (const char *name, struct security_operations *ops);
2153 extern int mod_unreg_security (const char *name, struct security_operations *ops);
2154 extern struct dentry *securityfs_create_file(const char *name, mode_t mode,
2155 struct dentry *parent, void *data,
2156 const struct file_operations *fops);
2157 extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
2158 extern void securityfs_remove(struct dentry *dentry);
2161 #else /* CONFIG_SECURITY */
2164 * This is the default capabilities functionality. Most of these functions
2165 * are just stubbed out, but a few must call the proper capable code.
2168 static inline int security_init(void)
2173 static inline int security_ptrace (struct task_struct *parent, struct task_struct * child)
2175 return cap_ptrace (parent, child);
2178 static inline int security_capget (struct task_struct *target,
2179 kernel_cap_t *effective,
2180 kernel_cap_t *inheritable,
2181 kernel_cap_t *permitted)
2183 return cap_capget (target, effective, inheritable, permitted);
2186 static inline int security_capset_check (struct task_struct *target,
2187 kernel_cap_t *effective,
2188 kernel_cap_t *inheritable,
2189 kernel_cap_t *permitted)
2191 return cap_capset_check (target, effective, inheritable, permitted);
2194 static inline void security_capset_set (struct task_struct *target,
2195 kernel_cap_t *effective,
2196 kernel_cap_t *inheritable,
2197 kernel_cap_t *permitted)
2199 cap_capset_set (target, effective, inheritable, permitted);
2202 static inline int security_capable(struct task_struct *tsk, int cap)
2204 return cap_capable(tsk, cap);
2207 static inline int security_acct (struct file *file)
2212 static inline int security_sysctl(struct ctl_table *table, int op)
2217 static inline int security_quotactl (int cmds, int type, int id,
2218 struct super_block * sb)
2223 static inline int security_quota_on (struct dentry * dentry)
2228 static inline int security_syslog(int type)
2230 return cap_syslog(type);
2233 static inline int security_settime(struct timespec *ts, struct timezone *tz)
2235 return cap_settime(ts, tz);
2238 static inline int security_vm_enough_memory(long pages)
2240 return cap_vm_enough_memory(current->mm, pages);
2243 static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
2245 return cap_vm_enough_memory(mm, pages);
2248 static inline int security_bprm_alloc (struct linux_binprm *bprm)
2253 static inline void security_bprm_free (struct linux_binprm *bprm)
2256 static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
2258 cap_bprm_apply_creds (bprm, unsafe);
2261 static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
2266 static inline int security_bprm_set (struct linux_binprm *bprm)
2268 return cap_bprm_set_security (bprm);
2271 static inline int security_bprm_check (struct linux_binprm *bprm)
2276 static inline int security_bprm_secureexec (struct linux_binprm *bprm)
2278 return cap_bprm_secureexec(bprm);
2281 static inline int security_sb_alloc (struct super_block *sb)
2286 static inline void security_sb_free (struct super_block *sb)
2289 static inline int security_sb_copy_data (struct file_system_type *type,
2290 void *orig, void *copy)
2295 static inline int security_sb_kern_mount (struct super_block *sb, void *data)
2300 static inline int security_sb_statfs (struct dentry *dentry)
2305 static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
2306 char *type, unsigned long flags,
2312 static inline int security_sb_check_sb (struct vfsmount *mnt,
2313 struct nameidata *nd)
2318 static inline int security_sb_umount (struct vfsmount *mnt, int flags)
2323 static inline void security_sb_umount_close (struct vfsmount *mnt)
2326 static inline void security_sb_umount_busy (struct vfsmount *mnt)
2329 static inline void security_sb_post_remount (struct vfsmount *mnt,
2330 unsigned long flags, void *data)
2333 static inline void security_sb_post_mountroot (void)
2336 static inline void security_sb_post_addmount (struct vfsmount *mnt,
2337 struct nameidata *mountpoint_nd)
2340 static inline int security_sb_pivotroot (struct nameidata *old_nd,
2341 struct nameidata *new_nd)
2346 static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
2347 struct nameidata *new_nd)
2350 static inline int security_inode_alloc (struct inode *inode)
2355 static inline void security_inode_free (struct inode *inode)
2358 static inline int security_inode_init_security (struct inode *inode,
2367 static inline int security_inode_create (struct inode *dir,
2368 struct dentry *dentry,
2374 static inline int security_inode_link (struct dentry *old_dentry,
2376 struct dentry *new_dentry)
2381 static inline int security_inode_unlink (struct inode *dir,
2382 struct dentry *dentry)
2387 static inline int security_inode_symlink (struct inode *dir,
2388 struct dentry *dentry,
2389 const char *old_name)
2394 static inline int security_inode_mkdir (struct inode *dir,
2395 struct dentry *dentry,
2401 static inline int security_inode_rmdir (struct inode *dir,
2402 struct dentry *dentry)
2407 static inline int security_inode_mknod (struct inode *dir,
2408 struct dentry *dentry,
2409 int mode, dev_t dev)
2414 static inline int security_inode_rename (struct inode *old_dir,
2415 struct dentry *old_dentry,
2416 struct inode *new_dir,
2417 struct dentry *new_dentry)
2422 static inline int security_inode_readlink (struct dentry *dentry)
2427 static inline int security_inode_follow_link (struct dentry *dentry,
2428 struct nameidata *nd)
2433 static inline int security_inode_permission (struct inode *inode, int mask,
2434 struct nameidata *nd)
2439 static inline int security_inode_setattr (struct dentry *dentry,
2445 static inline int security_inode_getattr (struct vfsmount *mnt,
2446 struct dentry *dentry)
2451 static inline void security_inode_delete (struct inode *inode)
2454 static inline int security_inode_setxattr (struct dentry *dentry, char *name,
2455 void *value, size_t size, int flags)
2457 return cap_inode_setxattr(dentry, name, value, size, flags);
2460 static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
2461 void *value, size_t size, int flags)
2464 static inline int security_inode_getxattr (struct dentry *dentry, char *name)
2469 static inline int security_inode_listxattr (struct dentry *dentry)
2474 static inline int security_inode_removexattr (struct dentry *dentry, char *name)
2476 return cap_inode_removexattr(dentry, name);
2479 static inline const char *security_inode_xattr_getsuffix (void)
2484 static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void *buffer, size_t size, int err)
2489 static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
2494 static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
2499 static inline int security_file_permission (struct file *file, int mask)
2504 static inline int security_file_alloc (struct file *file)
2509 static inline void security_file_free (struct file *file)
2512 static inline int security_file_ioctl (struct file *file, unsigned int cmd,
2518 static inline int security_file_mmap (struct file *file, unsigned long reqprot,
2520 unsigned long flags,
2522 unsigned long addr_only)
2527 static inline int security_file_mprotect (struct vm_area_struct *vma,
2528 unsigned long reqprot,
2534 static inline int security_file_lock (struct file *file, unsigned int cmd)
2539 static inline int security_file_fcntl (struct file *file, unsigned int cmd,
2545 static inline int security_file_set_fowner (struct file *file)
2550 static inline int security_file_send_sigiotask (struct task_struct *tsk,
2551 struct fown_struct *fown,
2557 static inline int security_file_receive (struct file *file)
2562 static inline int security_dentry_open (struct file *file)
2567 static inline int security_task_create (unsigned long clone_flags)
2572 static inline int security_task_alloc (struct task_struct *p)
2577 static inline void security_task_free (struct task_struct *p)
2580 static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
2586 static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
2587 uid_t old_suid, int flags)
2589 return cap_task_post_setuid (old_ruid, old_euid, old_suid, flags);
2592 static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
2598 static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
2603 static inline int security_task_getpgid (struct task_struct *p)
2608 static inline int security_task_getsid (struct task_struct *p)
2613 static inline void security_task_getsecid (struct task_struct *p, u32 *secid)
2616 static inline int security_task_setgroups (struct group_info *group_info)
2621 static inline int security_task_setnice (struct task_struct *p, int nice)
2626 static inline int security_task_setioprio (struct task_struct *p, int ioprio)
2631 static inline int security_task_getioprio (struct task_struct *p)
2636 static inline int security_task_setrlimit (unsigned int resource,
2637 struct rlimit *new_rlim)
2642 static inline int security_task_setscheduler (struct task_struct *p,
2644 struct sched_param *lp)
2649 static inline int security_task_getscheduler (struct task_struct *p)
2654 static inline int security_task_movememory (struct task_struct *p)
2659 static inline int security_task_kill (struct task_struct *p,
2660 struct siginfo *info, int sig,
2666 static inline int security_task_wait (struct task_struct *p)
2671 static inline int security_task_prctl (int option, unsigned long arg2,
2679 static inline void security_task_reparent_to_init (struct task_struct *p)
2681 cap_task_reparent_to_init (p);
2684 static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
2687 static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
2693 static inline int security_msg_msg_alloc (struct msg_msg * msg)
2698 static inline void security_msg_msg_free (struct msg_msg * msg)
2701 static inline int security_msg_queue_alloc (struct msg_queue *msq)
2706 static inline void security_msg_queue_free (struct msg_queue *msq)
2709 static inline int security_msg_queue_associate (struct msg_queue * msq,
2715 static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
2720 static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
2721 struct msg_msg * msg, int msqflg)
2726 static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
2727 struct msg_msg * msg,
2728 struct task_struct * target,
2729 long type, int mode)
2734 static inline int security_shm_alloc (struct shmid_kernel *shp)
2739 static inline void security_shm_free (struct shmid_kernel *shp)
2742 static inline int security_shm_associate (struct shmid_kernel * shp,
2748 static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
2753 static inline int security_shm_shmat (struct shmid_kernel * shp,
2754 char __user *shmaddr, int shmflg)
2759 static inline int security_sem_alloc (struct sem_array *sma)
2764 static inline void security_sem_free (struct sem_array *sma)
2767 static inline int security_sem_associate (struct sem_array * sma, int semflg)
2772 static inline int security_sem_semctl (struct sem_array * sma, int cmd)
2777 static inline int security_sem_semop (struct sem_array * sma,
2778 struct sembuf * sops, unsigned nsops,
2784 static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
2787 static inline int security_getprocattr(struct task_struct *p, char *name, char **value)
2792 static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2797 static inline int security_netlink_send (struct sock *sk, struct sk_buff *skb)
2799 return cap_netlink_send (sk, skb);
2802 static inline int security_netlink_recv (struct sk_buff *skb, int cap)
2804 return cap_netlink_recv (skb, cap);
2807 static inline struct dentry *securityfs_create_dir(const char *name,
2808 struct dentry *parent)
2810 return ERR_PTR(-ENODEV);
2813 static inline struct dentry *securityfs_create_file(const char *name,
2815 struct dentry *parent,
2817 struct file_operations *fops)
2819 return ERR_PTR(-ENODEV);
2822 static inline void securityfs_remove(struct dentry *dentry)
2826 static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
2831 static inline void security_release_secctx(char *secdata, u32 seclen)
2834 #endif /* CONFIG_SECURITY */
2836 #ifdef CONFIG_SECURITY_NETWORK
2837 static inline int security_unix_stream_connect(struct socket * sock,
2838 struct socket * other,
2839 struct sock * newsk)
2841 return security_ops->unix_stream_connect(sock, other, newsk);
2845 static inline int security_unix_may_send(struct socket * sock,
2846 struct socket * other)
2848 return security_ops->unix_may_send(sock, other);
2851 static inline int security_socket_create (int family, int type,
2852 int protocol, int kern)
2854 return security_ops->socket_create(family, type, protocol, kern);
2857 static inline int security_socket_post_create(struct socket * sock,
2860 int protocol, int kern)
2862 return security_ops->socket_post_create(sock, family, type,
2866 static inline int security_socket_bind(struct socket * sock,
2867 struct sockaddr * address,
2870 return security_ops->socket_bind(sock, address, addrlen);
2873 static inline int security_socket_connect(struct socket * sock,
2874 struct sockaddr * address,
2877 return security_ops->socket_connect(sock, address, addrlen);
2880 static inline int security_socket_listen(struct socket * sock, int backlog)
2882 return security_ops->socket_listen(sock, backlog);
2885 static inline int security_socket_accept(struct socket * sock,
2886 struct socket * newsock)
2888 return security_ops->socket_accept(sock, newsock);
2891 static inline void security_socket_post_accept(struct socket * sock,
2892 struct socket * newsock)
2894 security_ops->socket_post_accept(sock, newsock);
2897 static inline int security_socket_sendmsg(struct socket * sock,
2898 struct msghdr * msg, int size)
2900 return security_ops->socket_sendmsg(sock, msg, size);
2903 static inline int security_socket_recvmsg(struct socket * sock,
2904 struct msghdr * msg, int size,
2907 return security_ops->socket_recvmsg(sock, msg, size, flags);
2910 static inline int security_socket_getsockname(struct socket * sock)
2912 return security_ops->socket_getsockname(sock);
2915 static inline int security_socket_getpeername(struct socket * sock)
2917 return security_ops->socket_getpeername(sock);
2920 static inline int security_socket_getsockopt(struct socket * sock,
2921 int level, int optname)
2923 return security_ops->socket_getsockopt(sock, level, optname);
2926 static inline int security_socket_setsockopt(struct socket * sock,
2927 int level, int optname)
2929 return security_ops->socket_setsockopt(sock, level, optname);
2932 static inline int security_socket_shutdown(struct socket * sock, int how)
2934 return security_ops->socket_shutdown(sock, how);
2937 static inline int security_sock_rcv_skb (struct sock * sk,
2938 struct sk_buff * skb)
2940 return security_ops->socket_sock_rcv_skb (sk, skb);
2943 static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2944 int __user *optlen, unsigned len)
2946 return security_ops->socket_getpeersec_stream(sock, optval, optlen, len);
2949 static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
2951 return security_ops->socket_getpeersec_dgram(sock, skb, secid);
2954 static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
2956 return security_ops->sk_alloc_security(sk, family, priority);
2959 static inline void security_sk_free(struct sock *sk)
2961 return security_ops->sk_free_security(sk);
2964 static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
2966 return security_ops->sk_clone_security(sk, newsk);
2969 static inline void security_sk_classify_flow(struct sock *sk, struct flowi *fl)
2971 security_ops->sk_getsecid(sk, &fl->secid);
2974 static inline void security_req_classify_flow(const struct request_sock *req, struct flowi *fl)
2976 security_ops->req_classify_flow(req, fl);
2979 static inline void security_sock_graft(struct sock* sk, struct socket *parent)
2981 security_ops->sock_graft(sk, parent);
2984 static inline int security_inet_conn_request(struct sock *sk,
2985 struct sk_buff *skb, struct request_sock *req)
2987 return security_ops->inet_conn_request(sk, skb, req);
2990 static inline void security_inet_csk_clone(struct sock *newsk,
2991 const struct request_sock *req)
2993 security_ops->inet_csk_clone(newsk, req);
2996 static inline void security_inet_conn_established(struct sock *sk,
2997 struct sk_buff *skb)
2999 security_ops->inet_conn_established(sk, skb);
3001 #else /* CONFIG_SECURITY_NETWORK */
3002 static inline int security_unix_stream_connect(struct socket * sock,
3003 struct socket * other,
3004 struct sock * newsk)
3009 static inline int security_unix_may_send(struct socket * sock,
3010 struct socket * other)
3015 static inline int security_socket_create (int family, int type,
3016 int protocol, int kern)
3021 static inline int security_socket_post_create(struct socket * sock,
3024 int protocol, int kern)
3029 static inline int security_socket_bind(struct socket * sock,
3030 struct sockaddr * address,
3036 static inline int security_socket_connect(struct socket * sock,
3037 struct sockaddr * address,
3043 static inline int security_socket_listen(struct socket * sock, int backlog)
3048 static inline int security_socket_accept(struct socket * sock,
3049 struct socket * newsock)
3054 static inline void security_socket_post_accept(struct socket * sock,
3055 struct socket * newsock)
3059 static inline int security_socket_sendmsg(struct socket * sock,
3060 struct msghdr * msg, int size)
3065 static inline int security_socket_recvmsg(struct socket * sock,
3066 struct msghdr * msg, int size,
3072 static inline int security_socket_getsockname(struct socket * sock)
3077 static inline int security_socket_getpeername(struct socket * sock)
3082 static inline int security_socket_getsockopt(struct socket * sock,
3083 int level, int optname)
3088 static inline int security_socket_setsockopt(struct socket * sock,
3089 int level, int optname)
3094 static inline int security_socket_shutdown(struct socket * sock, int how)
3098 static inline int security_sock_rcv_skb (struct sock * sk,
3099 struct sk_buff * skb)
3104 static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
3105 int __user *optlen, unsigned len)
3107 return -ENOPROTOOPT;
3110 static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
3112 return -ENOPROTOOPT;
3115 static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
3120 static inline void security_sk_free(struct sock *sk)
3124 static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
3128 static inline void security_sk_classify_flow(struct sock *sk, struct flowi *fl)
3132 static inline void security_req_classify_flow(const struct request_sock *req, struct flowi *fl)
3136 static inline void security_sock_graft(struct sock* sk, struct socket *parent)
3140 static inline int security_inet_conn_request(struct sock *sk,
3141 struct sk_buff *skb, struct request_sock *req)
3146 static inline void security_inet_csk_clone(struct sock *newsk,
3147 const struct request_sock *req)
3151 static inline void security_inet_conn_established(struct sock *sk,
3152 struct sk_buff *skb)
3155 #endif /* CONFIG_SECURITY_NETWORK */
3157 #ifdef CONFIG_SECURITY_NETWORK_XFRM
3158 static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx)
3160 return security_ops->xfrm_policy_alloc_security(xp, sec_ctx);
3163 static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
3165 return security_ops->xfrm_policy_clone_security(old, new);
3168 static inline void security_xfrm_policy_free(struct xfrm_policy *xp)
3170 security_ops->xfrm_policy_free_security(xp);
3173 static inline int security_xfrm_policy_delete(struct xfrm_policy *xp)
3175 return security_ops->xfrm_policy_delete_security(xp);
3178 static inline int security_xfrm_state_alloc(struct xfrm_state *x,
3179 struct xfrm_user_sec_ctx *sec_ctx)
3181 return security_ops->xfrm_state_alloc_security(x, sec_ctx, 0);
3184 static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
3185 struct xfrm_sec_ctx *polsec, u32 secid)
3190 * We want the context to be taken from secid which is usually
3193 return security_ops->xfrm_state_alloc_security(x, NULL, secid);
3196 static inline int security_xfrm_state_delete(struct xfrm_state *x)
3198 return security_ops->xfrm_state_delete_security(x);
3201 static inline void security_xfrm_state_free(struct xfrm_state *x)
3203 security_ops->xfrm_state_free_security(x);
3206 static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir)
3208 return security_ops->xfrm_policy_lookup(xp, fl_secid, dir);
3211 static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
3212 struct xfrm_policy *xp, struct flowi *fl)
3214 return security_ops->xfrm_state_pol_flow_match(x, xp, fl);
3217 static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
3219 return security_ops->xfrm_decode_session(skb, secid, 1);
3222 static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl)
3224 int rc = security_ops->xfrm_decode_session(skb, &fl->secid, 0);
3228 #else /* CONFIG_SECURITY_NETWORK_XFRM */
3229 static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx)
3234 static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
3239 static inline void security_xfrm_policy_free(struct xfrm_policy *xp)
3243 static inline int security_xfrm_policy_delete(struct xfrm_policy *xp)
3248 static inline int security_xfrm_state_alloc(struct xfrm_state *x,
3249 struct xfrm_user_sec_ctx *sec_ctx)
3254 static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
3255 struct xfrm_sec_ctx *polsec, u32 secid)
3260 static inline void security_xfrm_state_free(struct xfrm_state *x)
3264 static inline int security_xfrm_state_delete(struct xfrm_state *x)
3269 static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir)
3274 static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
3275 struct xfrm_policy *xp, struct flowi *fl)
3280 static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
3285 static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl)
3289 #endif /* CONFIG_SECURITY_NETWORK_XFRM */
3292 #ifdef CONFIG_SECURITY
3293 static inline int security_key_alloc(struct key *key,
3294 struct task_struct *tsk,
3295 unsigned long flags)
3297 return security_ops->key_alloc(key, tsk, flags);
3300 static inline void security_key_free(struct key *key)
3302 security_ops->key_free(key);
3305 static inline int security_key_permission(key_ref_t key_ref,
3306 struct task_struct *context,
3309 return security_ops->key_permission(key_ref, context, perm);
3314 static inline int security_key_alloc(struct key *key,
3315 struct task_struct *tsk,
3316 unsigned long flags)
3321 static inline void security_key_free(struct key *key)
3325 static inline int security_key_permission(key_ref_t key_ref,
3326 struct task_struct *context,
3333 #endif /* CONFIG_KEYS */
3335 #endif /* ! __LINUX_SECURITY_H */