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>
38 * These functions are in security/capability.c and are used
39 * as the default capabilities functions
41 extern int cap_capable (struct task_struct
*tsk
, int cap
);
42 extern int cap_settime (struct timespec
*ts
, struct timezone
*tz
);
43 extern int cap_ptrace (struct task_struct
*parent
, struct task_struct
*child
);
44 extern int cap_capget (struct task_struct
*target
, kernel_cap_t
*effective
, kernel_cap_t
*inheritable
, kernel_cap_t
*permitted
);
45 extern int cap_capset_check (struct task_struct
*target
, kernel_cap_t
*effective
, kernel_cap_t
*inheritable
, kernel_cap_t
*permitted
);
46 extern void cap_capset_set (struct task_struct
*target
, kernel_cap_t
*effective
, kernel_cap_t
*inheritable
, kernel_cap_t
*permitted
);
47 extern int cap_bprm_set_security (struct linux_binprm
*bprm
);
48 extern void cap_bprm_apply_creds (struct linux_binprm
*bprm
, int unsafe
);
49 extern int cap_bprm_secureexec(struct linux_binprm
*bprm
);
50 extern int cap_inode_setxattr(struct dentry
*dentry
, char *name
, void *value
, size_t size
, int flags
);
51 extern int cap_inode_removexattr(struct dentry
*dentry
, char *name
);
52 extern int cap_task_post_setuid (uid_t old_ruid
, uid_t old_euid
, uid_t old_suid
, int flags
);
53 extern void cap_task_reparent_to_init (struct task_struct
*p
);
54 extern int cap_syslog (int type
);
55 extern int cap_vm_enough_memory (long pages
);
67 struct xfrm_user_sec_ctx
;
69 extern int cap_netlink_send(struct sock
*sk
, struct sk_buff
*skb
);
70 extern int cap_netlink_recv(struct sk_buff
*skb
, int cap
);
73 * Values used in the task_security_ops calls
75 /* setuid or setgid, id0 == uid or gid */
76 #define LSM_SETID_ID 1
78 /* setreuid or setregid, id0 == real, id1 == eff */
79 #define LSM_SETID_RE 2
81 /* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
82 #define LSM_SETID_RES 4
84 /* setfsuid or setfsgid, id0 == fsuid or fsgid */
85 #define LSM_SETID_FS 8
87 /* forward declares to avoid warnings */
90 struct swap_info_struct
;
92 /* bprm_apply_creds unsafe reasons */
93 #define LSM_UNSAFE_SHARE 1
94 #define LSM_UNSAFE_PTRACE 2
95 #define LSM_UNSAFE_PTRACE_CAP 4
97 #ifdef CONFIG_SECURITY
100 * struct security_operations - main security structure
102 * Security hooks for program execution operations.
104 * @bprm_alloc_security:
105 * Allocate and attach a security structure to the @bprm->security field.
106 * The security field is initialized to NULL when the bprm structure is
108 * @bprm contains the linux_binprm structure to be modified.
109 * Return 0 if operation was successful.
110 * @bprm_free_security:
111 * @bprm contains the linux_binprm structure to be modified.
112 * Deallocate and clear the @bprm->security field.
114 * Compute and set the security attributes of a process being transformed
115 * by an execve operation based on the old attributes (current->security)
116 * and the information saved in @bprm->security by the set_security hook.
117 * Since this hook function (and its caller) are void, this hook can not
118 * return an error. However, it can leave the security attributes of the
119 * process unchanged if an access failure occurs at this point.
120 * bprm_apply_creds is called under task_lock. @unsafe indicates various
121 * reasons why it may be unsafe to change security state.
122 * @bprm contains the linux_binprm structure.
123 * @bprm_post_apply_creds:
124 * Runs after bprm_apply_creds with the task_lock dropped, so that
125 * functions which cannot be called safely under the task_lock can
126 * be used. This hook is a good place to perform state changes on
127 * the process such as closing open file descriptors to which access
128 * is no longer granted if the attributes were changed.
129 * Note that a security module might need to save state between
130 * bprm_apply_creds and bprm_post_apply_creds to store the decision
131 * on whether the process may proceed.
132 * @bprm contains the linux_binprm structure.
133 * @bprm_set_security:
134 * Save security information in the bprm->security field, typically based
135 * on information about the bprm->file, for later use by the apply_creds
136 * hook. This hook may also optionally check permissions (e.g. for
137 * transitions between security domains).
138 * This hook may be called multiple times during a single execve, e.g. for
139 * interpreters. The hook can tell whether it has already been called by
140 * checking to see if @bprm->security is non-NULL. If so, then the hook
141 * may decide either to retain the security information saved earlier or
143 * @bprm contains the linux_binprm structure.
144 * Return 0 if the hook is successful and permission is granted.
145 * @bprm_check_security:
146 * This hook mediates the point when a search for a binary handler will
147 * begin. It allows a check the @bprm->security value which is set in
148 * the preceding set_security call. The primary difference from
149 * set_security is that the argv list and envp list are reliably
150 * available in @bprm. This hook may be called multiple times
151 * during a single execve; and in each pass set_security is called
153 * @bprm contains the linux_binprm structure.
154 * Return 0 if the hook is successful and permission is granted.
156 * Return a boolean value (0 or 1) indicating whether a "secure exec"
157 * is required. The flag is passed in the auxiliary table
158 * on the initial stack to the ELF interpreter to indicate whether libc
159 * should enable secure mode.
160 * @bprm contains the linux_binprm structure.
162 * Security hooks for filesystem operations.
164 * @sb_alloc_security:
165 * Allocate and attach a security structure to the sb->s_security field.
166 * The s_security field is initialized to NULL when the structure is
168 * @sb contains the super_block structure to be modified.
169 * Return 0 if operation was successful.
171 * Deallocate and clear the sb->s_security field.
172 * @sb contains the super_block structure to be modified.
174 * Check permission before obtaining filesystem statistics for the @mnt
176 * @dentry is a handle on the superblock for the filesystem.
177 * Return 0 if permission is granted.
179 * Check permission before an object specified by @dev_name is mounted on
180 * the mount point named by @nd. For an ordinary mount, @dev_name
181 * identifies a device if the file system type requires a device. For a
182 * remount (@flags & MS_REMOUNT), @dev_name is irrelevant. For a
183 * loopback/bind mount (@flags & MS_BIND), @dev_name identifies the
184 * pathname of the object being mounted.
185 * @dev_name contains the name for object being mounted.
186 * @nd contains the nameidata structure for mount point object.
187 * @type contains the filesystem type.
188 * @flags contains the mount flags.
189 * @data contains the filesystem-specific data.
190 * Return 0 if permission is granted.
192 * Allow mount option data to be copied prior to parsing by the filesystem,
193 * so that the security module can extract security-specific mount
194 * options cleanly (a filesystem may modify the data e.g. with strsep()).
195 * This also allows the original mount data to be stripped of security-
196 * specific options to avoid having to make filesystems aware of them.
197 * @type the type of filesystem being mounted.
198 * @orig the original mount data copied from userspace.
199 * @copy copied data which will be passed to the security module.
200 * Returns 0 if the copy was successful.
202 * Check permission before the device with superblock @mnt->sb is mounted
203 * on the mount point named by @nd.
204 * @mnt contains the vfsmount for device being mounted.
205 * @nd contains the nameidata object for the mount point.
206 * Return 0 if permission is granted.
208 * Check permission before the @mnt file system is unmounted.
209 * @mnt contains the mounted file system.
210 * @flags contains the unmount flags, e.g. MNT_FORCE.
211 * Return 0 if permission is granted.
213 * Close any files in the @mnt mounted filesystem that are held open by
214 * the security module. This hook is called during an umount operation
215 * prior to checking whether the filesystem is still busy.
216 * @mnt contains the mounted filesystem.
218 * Handle a failed umount of the @mnt mounted filesystem, e.g. re-opening
219 * any files that were closed by umount_close. This hook is called during
220 * an umount operation if the umount fails after a call to the
222 * @mnt contains the mounted filesystem.
224 * Update the security module's state when a filesystem is remounted.
225 * This hook is only called if the remount was successful.
226 * @mnt contains the mounted file system.
227 * @flags contains the new filesystem flags.
228 * @data contains the filesystem-specific data.
229 * @sb_post_mountroot:
230 * Update the security module's state when the root filesystem is mounted.
231 * This hook is only called if the mount was successful.
233 * Update the security module's state when a filesystem is mounted.
234 * This hook is called any time a mount is successfully grafetd to
236 * @mnt contains the mounted filesystem.
237 * @mountpoint_nd contains the nameidata structure for the mount point.
239 * Check permission before pivoting the root filesystem.
240 * @old_nd contains the nameidata structure for the new location of the current root (put_old).
241 * @new_nd contains the nameidata structure for the new root (new_root).
242 * Return 0 if permission is granted.
243 * @sb_post_pivotroot:
244 * Update module state after a successful pivot.
245 * @old_nd contains the nameidata structure for the old root.
246 * @new_nd contains the nameidata structure for the new root.
248 * Security hooks for inode operations.
250 * @inode_alloc_security:
251 * Allocate and attach a security structure to @inode->i_security. The
252 * i_security field is initialized to NULL when the inode structure is
254 * @inode contains the inode structure.
255 * Return 0 if operation was successful.
256 * @inode_free_security:
257 * @inode contains the inode structure.
258 * Deallocate the inode security structure and set @inode->i_security to
260 * @inode_init_security:
261 * Obtain the security attribute name suffix and value to set on a newly
262 * created inode and set up the incore security field for the new inode.
263 * This hook is called by the fs code as part of the inode creation
264 * transaction and provides for atomic labeling of the inode, unlike
265 * the post_create/mkdir/... hooks called by the VFS. The hook function
266 * is expected to allocate the name and value via kmalloc, with the caller
267 * being responsible for calling kfree after using them.
268 * If the security module does not use security attributes or does
269 * not wish to put a security attribute on this particular inode,
270 * then it should return -EOPNOTSUPP to skip this processing.
271 * @inode contains the inode structure of the newly created inode.
272 * @dir contains the inode structure of the parent directory.
273 * @name will be set to the allocated name suffix (e.g. selinux).
274 * @value will be set to the allocated attribute value.
275 * @len will be set to the length of the value.
276 * Returns 0 if @name and @value have been successfully set,
277 * -EOPNOTSUPP if no security attribute is needed, or
278 * -ENOMEM on memory allocation failure.
280 * Check permission to create a regular file.
281 * @dir contains inode structure of the parent of the new file.
282 * @dentry contains the dentry structure for the file to be created.
283 * @mode contains the file mode of the file to be created.
284 * Return 0 if permission is granted.
286 * Check permission before creating a new hard link to a file.
287 * @old_dentry contains the dentry structure for an existing link to the file.
288 * @dir contains the inode structure of the parent directory of the new link.
289 * @new_dentry contains the dentry structure for the new link.
290 * Return 0 if permission is granted.
292 * Check the permission to remove a hard link to a file.
293 * @dir contains the inode structure of parent directory of the file.
294 * @dentry contains the dentry structure for file to be unlinked.
295 * Return 0 if permission is granted.
297 * Check the permission to create a symbolic link to a file.
298 * @dir contains the inode structure of parent directory of the symbolic link.
299 * @dentry contains the dentry structure of the symbolic link.
300 * @old_name contains the pathname of file.
301 * Return 0 if permission is granted.
303 * Check permissions to create a new directory in the existing directory
304 * associated with inode strcture @dir.
305 * @dir containst the inode structure of parent of the directory to be created.
306 * @dentry contains the dentry structure of new directory.
307 * @mode contains the mode of new directory.
308 * Return 0 if permission is granted.
310 * Check the permission to remove a directory.
311 * @dir contains the inode structure of parent of the directory to be removed.
312 * @dentry contains the dentry structure of directory to be removed.
313 * Return 0 if permission is granted.
315 * Check permissions when creating a special file (or a socket or a fifo
316 * file created via the mknod system call). Note that if mknod operation
317 * is being done for a regular file, then the create hook will be called
319 * @dir contains the inode structure of parent of the new file.
320 * @dentry contains the dentry structure of the new file.
321 * @mode contains the mode of the new file.
322 * @dev contains the the device number.
323 * Return 0 if permission is granted.
325 * Check for permission to rename a file or directory.
326 * @old_dir contains the inode structure for parent of the old link.
327 * @old_dentry contains the dentry structure of the old link.
328 * @new_dir contains the inode structure for parent of the new link.
329 * @new_dentry contains the dentry structure of the new link.
330 * Return 0 if permission is granted.
332 * Check the permission to read the symbolic link.
333 * @dentry contains the dentry structure for the file link.
334 * Return 0 if permission is granted.
335 * @inode_follow_link:
336 * Check permission to follow a symbolic link when looking up a pathname.
337 * @dentry contains the dentry structure for the link.
338 * @nd contains the nameidata structure for the parent directory.
339 * Return 0 if permission is granted.
341 * Check permission before accessing an inode. This hook is called by the
342 * existing Linux permission function, so a security module can use it to
343 * provide additional checking for existing Linux permission checks.
344 * Notice that this hook is called when a file is opened (as well as many
345 * other operations), whereas the file_security_ops permission hook is
346 * called when the actual read/write operations are performed.
347 * @inode contains the inode structure to check.
348 * @mask contains the permission mask.
349 * @nd contains the nameidata (may be NULL).
350 * Return 0 if permission is granted.
352 * Check permission before setting file attributes. Note that the kernel
353 * call to notify_change is performed from several locations, whenever
354 * file attributes change (such as when a file is truncated, chown/chmod
355 * operations, transferring disk quotas, etc).
356 * @dentry contains the dentry structure for the file.
357 * @attr is the iattr structure containing the new file attributes.
358 * Return 0 if permission is granted.
360 * Check permission before obtaining file attributes.
361 * @mnt is the vfsmount where the dentry was looked up
362 * @dentry contains the dentry structure for the file.
363 * Return 0 if permission is granted.
365 * @inode contains the inode structure for deleted inode.
366 * This hook is called when a deleted inode is released (i.e. an inode
367 * with no hard links has its use count drop to zero). A security module
368 * can use this hook to release any persistent label associated with the
371 * Check permission before setting the extended attributes
372 * @value identified by @name for @dentry.
373 * Return 0 if permission is granted.
374 * @inode_post_setxattr:
375 * Update inode security field after successful setxattr operation.
376 * @value identified by @name for @dentry.
378 * Check permission before obtaining the extended attributes
379 * identified by @name for @dentry.
380 * Return 0 if permission is granted.
382 * Check permission before obtaining the list of extended attribute
384 * Return 0 if permission is granted.
385 * @inode_removexattr:
386 * Check permission before removing the extended attribute
387 * identified by @name for @dentry.
388 * Return 0 if permission is granted.
389 * @inode_getsecurity:
390 * Copy the extended attribute representation of the security label
391 * associated with @name for @inode into @buffer. @buffer may be
392 * NULL to request the size of the buffer required. @size indicates
393 * the size of @buffer in bytes. Note that @name is the remainder
394 * of the attribute name after the security. prefix has been removed.
395 * @err is the return value from the preceding fs getxattr call,
396 * and can be used by the security module to determine whether it
397 * should try and canonicalize the attribute value.
398 * Return number of bytes used/required on success.
399 * @inode_setsecurity:
400 * Set the security label associated with @name for @inode from the
401 * extended attribute value @value. @size indicates the size of the
402 * @value in bytes. @flags may be XATTR_CREATE, XATTR_REPLACE, or 0.
403 * Note that @name is the remainder of the attribute name after the
404 * security. prefix has been removed.
405 * Return 0 on success.
406 * @inode_listsecurity:
407 * Copy the extended attribute names for the security labels
408 * associated with @inode into @buffer. The maximum size of @buffer
409 * is specified by @buffer_size. @buffer may be NULL to request
410 * the size of the buffer required.
411 * Returns number of bytes used/required on success.
413 * Security hooks for file operations
416 * Check file permissions before accessing an open file. This hook is
417 * called by various operations that read or write files. A security
418 * module can use this hook to perform additional checking on these
419 * operations, e.g. to revalidate permissions on use to support privilege
420 * bracketing or policy changes. Notice that this hook is used when the
421 * actual read/write operations are performed, whereas the
422 * inode_security_ops hook is called when a file is opened (as well as
423 * many other operations).
424 * Caveat: Although this hook can be used to revalidate permissions for
425 * various system call operations that read or write files, it does not
426 * address the revalidation of permissions for memory-mapped files.
427 * Security modules must handle this separately if they need such
429 * @file contains the file structure being accessed.
430 * @mask contains the requested permissions.
431 * Return 0 if permission is granted.
432 * @file_alloc_security:
433 * Allocate and attach a security structure to the file->f_security field.
434 * The security field is initialized to NULL when the structure is first
436 * @file contains the file structure to secure.
437 * Return 0 if the hook is successful and permission is granted.
438 * @file_free_security:
439 * Deallocate and free any security structures stored in file->f_security.
440 * @file contains the file structure being modified.
442 * @file contains the file structure.
443 * @cmd contains the operation to perform.
444 * @arg contains the operational arguments.
445 * Check permission for an ioctl operation on @file. Note that @arg can
446 * sometimes represents a user space pointer; in other cases, it may be a
447 * simple integer value. When @arg represents a user space pointer, it
448 * should never be used by the security module.
449 * Return 0 if permission is granted.
451 * Check permissions for a mmap operation. The @file may be NULL, e.g.
452 * if mapping anonymous memory.
453 * @file contains the file structure for file to map (may be NULL).
454 * @reqprot contains the protection requested by the application.
455 * @prot contains the protection that will be applied by the kernel.
456 * @flags contains the operational flags.
457 * Return 0 if permission is granted.
459 * Check permissions before changing memory access permissions.
460 * @vma contains the memory region to modify.
461 * @reqprot contains the protection requested by the application.
462 * @prot contains the protection that will be applied by the kernel.
463 * Return 0 if permission is granted.
465 * Check permission before performing file locking operations.
466 * Note: this hook mediates both flock and fcntl style locks.
467 * @file contains the file structure.
468 * @cmd contains the posix-translated lock operation to perform
469 * (e.g. F_RDLCK, F_WRLCK).
470 * Return 0 if permission is granted.
472 * Check permission before allowing the file operation specified by @cmd
473 * from being performed on the file @file. Note that @arg can sometimes
474 * represents a user space pointer; in other cases, it may be a simple
475 * integer value. When @arg represents a user space pointer, it should
476 * never be used by the security module.
477 * @file contains the file structure.
478 * @cmd contains the operation to be performed.
479 * @arg contains the operational arguments.
480 * Return 0 if permission is granted.
482 * Save owner security information (typically from current->security) in
483 * file->f_security for later use by the send_sigiotask hook.
484 * @file contains the file structure to update.
485 * Return 0 on success.
486 * @file_send_sigiotask:
487 * Check permission for the file owner @fown to send SIGIO or SIGURG to the
488 * process @tsk. Note that this hook is sometimes called from interrupt.
489 * Note that the fown_struct, @fown, is never outside the context of a
490 * struct file, so the file structure (and associated security information)
491 * can always be obtained:
492 * (struct file *)((long)fown - offsetof(struct file,f_owner));
493 * @tsk contains the structure of task receiving signal.
494 * @fown contains the file owner information.
495 * @sig is the signal that will be sent. When 0, kernel sends SIGIO.
496 * Return 0 if permission is granted.
498 * This hook allows security modules to control the ability of a process
499 * to receive an open file descriptor via socket IPC.
500 * @file contains the file structure being received.
501 * Return 0 if permission is granted.
503 * Security hooks for task operations.
506 * Check permission before creating a child process. See the clone(2)
507 * manual page for definitions of the @clone_flags.
508 * @clone_flags contains the flags indicating what should be shared.
509 * Return 0 if permission is granted.
510 * @task_alloc_security:
511 * @p contains the task_struct for child process.
512 * Allocate and attach a security structure to the p->security field. The
513 * security field is initialized to NULL when the task structure is
515 * Return 0 if operation was successful.
516 * @task_free_security:
517 * @p contains the task_struct for process.
518 * Deallocate and clear the p->security field.
520 * Check permission before setting one or more of the user identity
521 * attributes of the current process. The @flags parameter indicates
522 * which of the set*uid system calls invoked this hook and how to
523 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
524 * definitions at the beginning of this file for the @flags values and
526 * @id0 contains a uid.
527 * @id1 contains a uid.
528 * @id2 contains a uid.
529 * @flags contains one of the LSM_SETID_* values.
530 * Return 0 if permission is granted.
532 * Update the module's state after setting one or more of the user
533 * identity attributes of the current process. The @flags parameter
534 * indicates which of the set*uid system calls invoked this hook. If
535 * @flags is LSM_SETID_FS, then @old_ruid is the old fs uid and the other
536 * parameters are not used.
537 * @old_ruid contains the old real uid (or fs uid if LSM_SETID_FS).
538 * @old_euid contains the old effective uid (or -1 if LSM_SETID_FS).
539 * @old_suid contains the old saved uid (or -1 if LSM_SETID_FS).
540 * @flags contains one of the LSM_SETID_* values.
541 * Return 0 on success.
543 * Check permission before setting one or more of the group identity
544 * attributes of the current process. The @flags parameter indicates
545 * which of the set*gid system calls invoked this hook and how to
546 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
547 * definitions at the beginning of this file for the @flags values and
549 * @id0 contains a gid.
550 * @id1 contains a gid.
551 * @id2 contains a gid.
552 * @flags contains one of the LSM_SETID_* values.
553 * Return 0 if permission is granted.
555 * Check permission before setting the process group identifier of the
556 * process @p to @pgid.
557 * @p contains the task_struct for process being modified.
558 * @pgid contains the new pgid.
559 * Return 0 if permission is granted.
561 * Check permission before getting the process group identifier of the
563 * @p contains the task_struct for the process.
564 * Return 0 if permission is granted.
566 * Check permission before getting the session identifier of the process
568 * @p contains the task_struct for the process.
569 * Return 0 if permission is granted.
571 * Retrieve the security identifier of the process @p.
572 * @p contains the task_struct for the process and place is into @secid.
574 * Check permission before setting the supplementary group set of the
576 * @group_info contains the new group information.
577 * Return 0 if permission is granted.
579 * Check permission before setting the nice value of @p to @nice.
580 * @p contains the task_struct of process.
581 * @nice contains the new nice value.
582 * Return 0 if permission is granted.
584 * Check permission before setting the ioprio value of @p to @ioprio.
585 * @p contains the task_struct of process.
586 * @ioprio contains the new ioprio value
587 * Return 0 if permission is granted.
589 * Check permission before getting the ioprio value of @p.
590 * @p contains the task_struct of process.
591 * Return 0 if permission is granted.
593 * Check permission before setting the resource limits of the current
594 * process for @resource to @new_rlim. The old resource limit values can
595 * be examined by dereferencing (current->signal->rlim + resource).
596 * @resource contains the resource whose limit is being set.
597 * @new_rlim contains the new limits for @resource.
598 * Return 0 if permission is granted.
599 * @task_setscheduler:
600 * Check permission before setting scheduling policy and/or parameters of
601 * process @p based on @policy and @lp.
602 * @p contains the task_struct for process.
603 * @policy contains the scheduling policy.
604 * @lp contains the scheduling parameters.
605 * Return 0 if permission is granted.
606 * @task_getscheduler:
607 * Check permission before obtaining scheduling information for process
609 * @p contains the task_struct for process.
610 * Return 0 if permission is granted.
612 * Check permission before moving memory owned by process @p.
613 * @p contains the task_struct for process.
614 * Return 0 if permission is granted.
616 * Check permission before sending signal @sig to @p. @info can be NULL,
617 * the constant 1, or a pointer to a siginfo structure. If @info is 1 or
618 * SI_FROMKERNEL(info) is true, then the signal should be viewed as coming
619 * from the kernel and should typically be permitted.
620 * SIGIO signals are handled separately by the send_sigiotask hook in
622 * @p contains the task_struct for process.
623 * @info contains the signal information.
624 * @sig contains the signal value.
625 * @secid contains the sid of the process where the signal originated
626 * Return 0 if permission is granted.
628 * Check permission before allowing a process to reap a child process @p
629 * and collect its status information.
630 * @p contains the task_struct for process.
631 * Return 0 if permission is granted.
633 * Check permission before performing a process control operation on the
635 * @option contains the operation.
636 * @arg2 contains a argument.
637 * @arg3 contains a argument.
638 * @arg4 contains a argument.
639 * @arg5 contains a argument.
640 * Return 0 if permission is granted.
641 * @task_reparent_to_init:
642 * Set the security attributes in @p->security for a kernel thread that
643 * is being reparented to the init task.
644 * @p contains the task_struct for the kernel thread.
646 * Set the security attributes for an inode based on an associated task's
647 * security attributes, e.g. for /proc/pid inodes.
648 * @p contains the task_struct for the task.
649 * @inode contains the inode structure for the inode.
651 * Security hooks for Netlink messaging.
654 * Save security information for a netlink message so that permission
655 * checking can be performed when the message is processed. The security
656 * information can be saved using the eff_cap field of the
657 * netlink_skb_parms structure. Also may be used to provide fine
658 * grained control over message transmission.
659 * @sk associated sock of task sending the message.,
660 * @skb contains the sk_buff structure for the netlink message.
661 * Return 0 if the information was successfully saved and message
662 * is allowed to be transmitted.
664 * Check permission before processing the received netlink message in
666 * @skb contains the sk_buff structure for the netlink message.
667 * @cap indicates the capability required
668 * Return 0 if permission is granted.
670 * Security hooks for Unix domain networking.
672 * @unix_stream_connect:
673 * Check permissions before establishing a Unix domain stream connection
674 * between @sock and @other.
675 * @sock contains the socket structure.
676 * @other contains the peer socket structure.
677 * Return 0 if permission is granted.
679 * Check permissions before connecting or sending datagrams from @sock to
681 * @sock contains the socket structure.
682 * @sock contains the peer socket structure.
683 * Return 0 if permission is granted.
685 * The @unix_stream_connect and @unix_may_send hooks were necessary because
686 * Linux provides an alternative to the conventional file name space for Unix
687 * domain sockets. Whereas binding and connecting to sockets in the file name
688 * space is mediated by the typical file permissions (and caught by the mknod
689 * and permission hooks in inode_security_ops), binding and connecting to
690 * sockets in the abstract name space is completely unmediated. Sufficient
691 * control of Unix domain sockets in the abstract name space isn't possible
692 * using only the socket layer hooks, since we need to know the actual target
693 * socket, which is not looked up until we are inside the af_unix code.
695 * Security hooks for socket operations.
698 * Check permissions prior to creating a new socket.
699 * @family contains the requested protocol family.
700 * @type contains the requested communications type.
701 * @protocol contains the requested protocol.
702 * @kern set to 1 if a kernel socket.
703 * Return 0 if permission is granted.
704 * @socket_post_create:
705 * This hook allows a module to update or allocate a per-socket security
706 * structure. Note that the security field was not added directly to the
707 * socket structure, but rather, the socket security information is stored
708 * in the associated inode. Typically, the inode alloc_security hook will
709 * allocate and and attach security information to
710 * sock->inode->i_security. This hook may be used to update the
711 * sock->inode->i_security field with additional information that wasn't
712 * available when the inode was allocated.
713 * @sock contains the newly created socket structure.
714 * @family contains the requested protocol family.
715 * @type contains the requested communications type.
716 * @protocol contains the requested protocol.
717 * @kern set to 1 if a kernel socket.
719 * Check permission before socket protocol layer bind operation is
720 * performed and the socket @sock is bound to the address specified in the
721 * @address parameter.
722 * @sock contains the socket structure.
723 * @address contains the address to bind to.
724 * @addrlen contains the length of address.
725 * Return 0 if permission is granted.
727 * Check permission before socket protocol layer connect operation
728 * attempts to connect socket @sock to a remote address, @address.
729 * @sock contains the socket structure.
730 * @address contains the address of remote endpoint.
731 * @addrlen contains the length of address.
732 * Return 0 if permission is granted.
734 * Check permission before socket protocol layer listen operation.
735 * @sock contains the socket structure.
736 * @backlog contains the maximum length for the pending connection queue.
737 * Return 0 if permission is granted.
739 * Check permission before accepting a new connection. Note that the new
740 * socket, @newsock, has been created and some information copied to it,
741 * but the accept operation has not actually been performed.
742 * @sock contains the listening socket structure.
743 * @newsock contains the newly created server socket for connection.
744 * Return 0 if permission is granted.
745 * @socket_post_accept:
746 * This hook allows a security module to copy security
747 * information into the newly created socket's inode.
748 * @sock contains the listening socket structure.
749 * @newsock contains the newly created server socket for connection.
751 * Check permission before transmitting a message to another socket.
752 * @sock contains the socket structure.
753 * @msg contains the message to be transmitted.
754 * @size contains the size of message.
755 * Return 0 if permission is granted.
757 * Check permission before receiving a message from a socket.
758 * @sock contains the socket structure.
759 * @msg contains the message structure.
760 * @size contains the size of message structure.
761 * @flags contains the operational flags.
762 * Return 0 if permission is granted.
763 * @socket_getsockname:
764 * Check permission before the local address (name) of the socket object
765 * @sock is retrieved.
766 * @sock contains the socket structure.
767 * Return 0 if permission is granted.
768 * @socket_getpeername:
769 * Check permission before the remote address (name) of a socket object
770 * @sock is retrieved.
771 * @sock contains the socket structure.
772 * Return 0 if permission is granted.
773 * @socket_getsockopt:
774 * Check permissions before retrieving the options associated with socket
776 * @sock contains the socket structure.
777 * @level contains the protocol level to retrieve option from.
778 * @optname contains the name of option to retrieve.
779 * Return 0 if permission is granted.
780 * @socket_setsockopt:
781 * Check permissions before setting the options associated with socket
783 * @sock contains the socket structure.
784 * @level contains the protocol level to set options for.
785 * @optname contains the name of the option to set.
786 * Return 0 if permission is granted.
788 * Checks permission before all or part of a connection on the socket
789 * @sock is shut down.
790 * @sock contains the socket structure.
791 * @how contains the flag indicating how future sends and receives are handled.
792 * Return 0 if permission is granted.
793 * @socket_sock_rcv_skb:
794 * Check permissions on incoming network packets. This hook is distinct
795 * from Netfilter's IP input hooks since it is the first time that the
796 * incoming sk_buff @skb has been associated with a particular socket, @sk.
797 * @sk contains the sock (not socket) associated with the incoming sk_buff.
798 * @skb contains the incoming network data.
799 * @socket_getpeersec:
800 * This hook allows the security module to provide peer socket security
801 * state to userspace via getsockopt SO_GETPEERSEC.
802 * @sock is the local socket.
803 * @optval userspace memory where the security state is to be copied.
804 * @optlen userspace int where the module should copy the actual length
805 * of the security state.
806 * @len as input is the maximum length to copy to userspace provided
808 * Return 0 if all is well, otherwise, typical getsockopt return
810 * @sk_alloc_security:
811 * Allocate and attach a security structure to the sk->sk_security field,
812 * which is used to copy security attributes between local stream sockets.
814 * Deallocate security structure.
816 * Retrieve the LSM-specific sid for the sock to enable caching of network
819 * Security hooks for XFRM operations.
821 * @xfrm_policy_alloc_security:
822 * @xp contains the xfrm_policy being added to Security Policy Database
823 * used by the XFRM system.
824 * @sec_ctx contains the security context information being provided by
825 * the user-level policy update program (e.g., setkey).
826 * Allocate a security structure to the xp->security field.
827 * The security field is initialized to NULL when the xfrm_policy is
829 * Return 0 if operation was successful (memory to allocate, legal context)
830 * @xfrm_policy_clone_security:
831 * @old contains an existing xfrm_policy in the SPD.
832 * @new contains a new xfrm_policy being cloned from old.
833 * Allocate a security structure to the new->security field
834 * that contains the information from the old->security field.
835 * Return 0 if operation was successful (memory to allocate).
836 * @xfrm_policy_free_security:
837 * @xp contains the xfrm_policy
838 * Deallocate xp->security.
839 * @xfrm_policy_delete_security:
840 * @xp contains the xfrm_policy.
841 * Authorize deletion of xp->security.
842 * @xfrm_state_alloc_security:
843 * @x contains the xfrm_state being added to the Security Association
844 * Database by the XFRM system.
845 * @sec_ctx contains the security context information being provided by
846 * the user-level SA generation program (e.g., setkey or racoon).
847 * Allocate a security structure to the x->security field. The
848 * security field is initialized to NULL when the xfrm_state is
850 * Return 0 if operation was successful (memory to allocate, legal context).
851 * @xfrm_state_free_security:
852 * @x contains the xfrm_state.
853 * Deallocate x->security.
854 * @xfrm_state_delete_security:
855 * @x contains the xfrm_state.
856 * Authorize deletion of x->security.
857 * @xfrm_policy_lookup:
858 * @xp contains the xfrm_policy for which the access control is being
860 * @sk_sid contains the sock security label that is used to authorize
861 * access to the policy xp.
862 * @dir contains the direction of the flow (input or output).
863 * Check permission when a sock selects a xfrm_policy for processing
864 * XFRMs on a packet. The hook is called when selecting either a
865 * per-socket policy or a generic xfrm policy.
866 * Return 0 if permission is granted.
868 * Security hooks affecting all Key Management operations
871 * Permit allocation of a key and assign security data. Note that key does
872 * not have a serial number assigned at this point.
873 * @key points to the key.
874 * @flags is the allocation flags
875 * Return 0 if permission is granted, -ve error otherwise.
877 * Notification of destruction; free security data.
878 * @key points to the key.
881 * See whether a specific operational right is granted to a process on a
883 * @key_ref refers to the key (key pointer + possession attribute bit).
884 * @context points to the process to provide the context against which to
885 * evaluate the security data on the key.
886 * @perm describes the combination of permissions required of this key.
887 * Return 1 if permission granted, 0 if permission denied and -ve it the
888 * normal permissions model should be effected.
890 * Security hooks affecting all System V IPC operations.
893 * Check permissions for access to IPC
894 * @ipcp contains the kernel IPC permission structure
895 * @flag contains the desired (requested) permission set
896 * Return 0 if permission is granted.
898 * Security hooks for individual messages held in System V IPC message queues
899 * @msg_msg_alloc_security:
900 * Allocate and attach a security structure to the msg->security field.
901 * The security field is initialized to NULL when the structure is first
903 * @msg contains the message structure to be modified.
904 * Return 0 if operation was successful and permission is granted.
905 * @msg_msg_free_security:
906 * Deallocate the security structure for this message.
907 * @msg contains the message structure to be modified.
909 * Security hooks for System V IPC Message Queues
911 * @msg_queue_alloc_security:
912 * Allocate and attach a security structure to the
913 * msq->q_perm.security field. The security field is initialized to
914 * NULL when the structure is first created.
915 * @msq contains the message queue structure to be modified.
916 * Return 0 if operation was successful and permission is granted.
917 * @msg_queue_free_security:
918 * Deallocate security structure for this message queue.
919 * @msq contains the message queue structure to be modified.
920 * @msg_queue_associate:
921 * Check permission when a message queue is requested through the
922 * msgget system call. This hook is only called when returning the
923 * message queue identifier for an existing message queue, not when a
924 * new message queue is created.
925 * @msq contains the message queue to act upon.
926 * @msqflg contains the operation control flags.
927 * Return 0 if permission is granted.
929 * Check permission when a message control operation specified by @cmd
930 * is to be performed on the message queue @msq.
931 * The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO.
932 * @msq contains the message queue to act upon. May be NULL.
933 * @cmd contains the operation to be performed.
934 * Return 0 if permission is granted.
936 * Check permission before a message, @msg, is enqueued on the message
938 * @msq contains the message queue to send message to.
939 * @msg contains the message to be enqueued.
940 * @msqflg contains operational flags.
941 * Return 0 if permission is granted.
943 * Check permission before a message, @msg, is removed from the message
944 * queue, @msq. The @target task structure contains a pointer to the
945 * process that will be receiving the message (not equal to the current
946 * process when inline receives are being performed).
947 * @msq contains the message queue to retrieve message from.
948 * @msg contains the message destination.
949 * @target contains the task structure for recipient process.
950 * @type contains the type of message requested.
951 * @mode contains the operational flags.
952 * Return 0 if permission is granted.
954 * Security hooks for System V Shared Memory Segments
956 * @shm_alloc_security:
957 * Allocate and attach a security structure to the shp->shm_perm.security
958 * field. The security field is initialized to NULL when the structure is
960 * @shp contains the shared memory structure to be modified.
961 * Return 0 if operation was successful and permission is granted.
962 * @shm_free_security:
963 * Deallocate the security struct for this memory segment.
964 * @shp contains the shared memory structure to be modified.
966 * Check permission when a shared memory region is requested through the
967 * shmget system call. This hook is only called when returning the shared
968 * memory region identifier for an existing region, not when a new shared
969 * memory region is created.
970 * @shp contains the shared memory structure to be modified.
971 * @shmflg contains the operation control flags.
972 * Return 0 if permission is granted.
974 * Check permission when a shared memory control operation specified by
975 * @cmd is to be performed on the shared memory region @shp.
976 * The @shp may be NULL, e.g. for IPC_INFO or SHM_INFO.
977 * @shp contains shared memory structure to be modified.
978 * @cmd contains the operation to be performed.
979 * Return 0 if permission is granted.
981 * Check permissions prior to allowing the shmat system call to attach the
982 * shared memory segment @shp to the data segment of the calling process.
983 * The attaching address is specified by @shmaddr.
984 * @shp contains the shared memory structure to be modified.
985 * @shmaddr contains the address to attach memory region to.
986 * @shmflg contains the operational flags.
987 * Return 0 if permission is granted.
989 * Security hooks for System V Semaphores
991 * @sem_alloc_security:
992 * Allocate and attach a security structure to the sma->sem_perm.security
993 * field. The security field is initialized to NULL when the structure is
995 * @sma contains the semaphore structure
996 * Return 0 if operation was successful and permission is granted.
997 * @sem_free_security:
998 * deallocate security struct for this semaphore
999 * @sma contains the semaphore structure.
1001 * Check permission when a semaphore is requested through the semget
1002 * system call. This hook is only called when returning the semaphore
1003 * identifier for an existing semaphore, not when a new one must be
1005 * @sma contains the semaphore structure.
1006 * @semflg contains the operation control flags.
1007 * Return 0 if permission is granted.
1009 * Check permission when a semaphore operation specified by @cmd is to be
1010 * performed on the semaphore @sma. The @sma may be NULL, e.g. for
1011 * IPC_INFO or SEM_INFO.
1012 * @sma contains the semaphore structure. May be NULL.
1013 * @cmd contains the operation to be performed.
1014 * Return 0 if permission is granted.
1016 * Check permissions before performing operations on members of the
1017 * semaphore set @sma. If the @alter flag is nonzero, the semaphore set
1019 * @sma contains the semaphore structure.
1020 * @sops contains the operations to perform.
1021 * @nsops contains the number of operations to perform.
1022 * @alter contains the flag indicating whether changes are to be made.
1023 * Return 0 if permission is granted.
1026 * Check permission before allowing the @parent process to trace the
1028 * Security modules may also want to perform a process tracing check
1029 * during an execve in the set_security or apply_creds hooks of
1030 * binprm_security_ops if the process is being traced and its security
1031 * attributes would be changed by the execve.
1032 * @parent contains the task_struct structure for parent process.
1033 * @child contains the task_struct structure for child process.
1034 * Return 0 if permission is granted.
1036 * Get the @effective, @inheritable, and @permitted capability sets for
1037 * the @target process. The hook may also perform permission checking to
1038 * determine if the current process is allowed to see the capability sets
1039 * of the @target process.
1040 * @target contains the task_struct structure for target process.
1041 * @effective contains the effective capability set.
1042 * @inheritable contains the inheritable capability set.
1043 * @permitted contains the permitted capability set.
1044 * Return 0 if the capability sets were successfully obtained.
1046 * Check permission before setting the @effective, @inheritable, and
1047 * @permitted capability sets for the @target process.
1048 * Caveat: @target is also set to current if a set of processes is
1049 * specified (i.e. all processes other than current and init or a
1050 * particular process group). Hence, the capset_set hook may need to
1051 * revalidate permission to the actual target process.
1052 * @target contains the task_struct structure for target process.
1053 * @effective contains the effective capability set.
1054 * @inheritable contains the inheritable capability set.
1055 * @permitted contains the permitted capability set.
1056 * Return 0 if permission is granted.
1058 * Set the @effective, @inheritable, and @permitted capability sets for
1059 * the @target process. Since capset_check cannot always check permission
1060 * to the real @target process, this hook may also perform permission
1061 * checking to determine if the current process is allowed to set the
1062 * capability sets of the @target process. However, this hook has no way
1063 * of returning an error due to the structure of the sys_capset code.
1064 * @target contains the task_struct structure for target process.
1065 * @effective contains the effective capability set.
1066 * @inheritable contains the inheritable capability set.
1067 * @permitted contains the permitted capability set.
1069 * Check whether the @tsk process has the @cap capability.
1070 * @tsk contains the task_struct for the process.
1071 * @cap contains the capability <include/linux/capability.h>.
1072 * Return 0 if the capability is granted for @tsk.
1074 * Check permission before enabling or disabling process accounting. If
1075 * accounting is being enabled, then @file refers to the open file used to
1076 * store accounting records. If accounting is being disabled, then @file
1078 * @file contains the file structure for the accounting file (may be NULL).
1079 * Return 0 if permission is granted.
1081 * Check permission before accessing the @table sysctl variable in the
1082 * manner specified by @op.
1083 * @table contains the ctl_table structure for the sysctl variable.
1084 * @op contains the operation (001 = search, 002 = write, 004 = read).
1085 * Return 0 if permission is granted.
1087 * Check permission before accessing the kernel message ring or changing
1088 * logging to the console.
1089 * See the syslog(2) manual page for an explanation of the @type values.
1090 * @type contains the type of action.
1091 * Return 0 if permission is granted.
1093 * Check permission to change the system time.
1094 * struct timespec and timezone are defined in include/linux/time.h
1095 * @ts contains new time
1096 * @tz contains new timezone
1097 * Return 0 if permission is granted.
1098 * @vm_enough_memory:
1099 * Check permissions for allocating a new virtual mapping.
1100 * @pages contains the number of pages.
1101 * Return 0 if permission is granted.
1103 * @register_security:
1104 * allow module stacking.
1105 * @name contains the name of the security module being stacked.
1106 * @ops contains a pointer to the struct security_operations of the module to stack.
1107 * @unregister_security:
1108 * remove a stacked module.
1109 * @name contains the name of the security module being unstacked.
1110 * @ops contains a pointer to the struct security_operations of the module to unstack.
1112 * This is the main security structure.
1114 struct security_operations
{
1115 int (*ptrace
) (struct task_struct
* parent
, struct task_struct
* child
);
1116 int (*capget
) (struct task_struct
* target
,
1117 kernel_cap_t
* effective
,
1118 kernel_cap_t
* inheritable
, kernel_cap_t
* permitted
);
1119 int (*capset_check
) (struct task_struct
* target
,
1120 kernel_cap_t
* effective
,
1121 kernel_cap_t
* inheritable
,
1122 kernel_cap_t
* permitted
);
1123 void (*capset_set
) (struct task_struct
* target
,
1124 kernel_cap_t
* effective
,
1125 kernel_cap_t
* inheritable
,
1126 kernel_cap_t
* permitted
);
1127 int (*capable
) (struct task_struct
* tsk
, int cap
);
1128 int (*acct
) (struct file
* file
);
1129 int (*sysctl
) (struct ctl_table
* table
, int op
);
1130 int (*quotactl
) (int cmds
, int type
, int id
, struct super_block
* sb
);
1131 int (*quota_on
) (struct dentry
* dentry
);
1132 int (*syslog
) (int type
);
1133 int (*settime
) (struct timespec
*ts
, struct timezone
*tz
);
1134 int (*vm_enough_memory
) (long pages
);
1136 int (*bprm_alloc_security
) (struct linux_binprm
* bprm
);
1137 void (*bprm_free_security
) (struct linux_binprm
* bprm
);
1138 void (*bprm_apply_creds
) (struct linux_binprm
* bprm
, int unsafe
);
1139 void (*bprm_post_apply_creds
) (struct linux_binprm
* bprm
);
1140 int (*bprm_set_security
) (struct linux_binprm
* bprm
);
1141 int (*bprm_check_security
) (struct linux_binprm
* bprm
);
1142 int (*bprm_secureexec
) (struct linux_binprm
* bprm
);
1144 int (*sb_alloc_security
) (struct super_block
* sb
);
1145 void (*sb_free_security
) (struct super_block
* sb
);
1146 int (*sb_copy_data
)(struct file_system_type
*type
,
1147 void *orig
, void *copy
);
1148 int (*sb_kern_mount
) (struct super_block
*sb
, void *data
);
1149 int (*sb_statfs
) (struct dentry
*dentry
);
1150 int (*sb_mount
) (char *dev_name
, struct nameidata
* nd
,
1151 char *type
, unsigned long flags
, void *data
);
1152 int (*sb_check_sb
) (struct vfsmount
* mnt
, struct nameidata
* nd
);
1153 int (*sb_umount
) (struct vfsmount
* mnt
, int flags
);
1154 void (*sb_umount_close
) (struct vfsmount
* mnt
);
1155 void (*sb_umount_busy
) (struct vfsmount
* mnt
);
1156 void (*sb_post_remount
) (struct vfsmount
* mnt
,
1157 unsigned long flags
, void *data
);
1158 void (*sb_post_mountroot
) (void);
1159 void (*sb_post_addmount
) (struct vfsmount
* mnt
,
1160 struct nameidata
* mountpoint_nd
);
1161 int (*sb_pivotroot
) (struct nameidata
* old_nd
,
1162 struct nameidata
* new_nd
);
1163 void (*sb_post_pivotroot
) (struct nameidata
* old_nd
,
1164 struct nameidata
* new_nd
);
1166 int (*inode_alloc_security
) (struct inode
*inode
);
1167 void (*inode_free_security
) (struct inode
*inode
);
1168 int (*inode_init_security
) (struct inode
*inode
, struct inode
*dir
,
1169 char **name
, void **value
, size_t *len
);
1170 int (*inode_create
) (struct inode
*dir
,
1171 struct dentry
*dentry
, int mode
);
1172 int (*inode_link
) (struct dentry
*old_dentry
,
1173 struct inode
*dir
, struct dentry
*new_dentry
);
1174 int (*inode_unlink
) (struct inode
*dir
, struct dentry
*dentry
);
1175 int (*inode_symlink
) (struct inode
*dir
,
1176 struct dentry
*dentry
, const char *old_name
);
1177 int (*inode_mkdir
) (struct inode
*dir
, struct dentry
*dentry
, int mode
);
1178 int (*inode_rmdir
) (struct inode
*dir
, struct dentry
*dentry
);
1179 int (*inode_mknod
) (struct inode
*dir
, struct dentry
*dentry
,
1180 int mode
, dev_t dev
);
1181 int (*inode_rename
) (struct inode
*old_dir
, struct dentry
*old_dentry
,
1182 struct inode
*new_dir
, struct dentry
*new_dentry
);
1183 int (*inode_readlink
) (struct dentry
*dentry
);
1184 int (*inode_follow_link
) (struct dentry
*dentry
, struct nameidata
*nd
);
1185 int (*inode_permission
) (struct inode
*inode
, int mask
, struct nameidata
*nd
);
1186 int (*inode_setattr
) (struct dentry
*dentry
, struct iattr
*attr
);
1187 int (*inode_getattr
) (struct vfsmount
*mnt
, struct dentry
*dentry
);
1188 void (*inode_delete
) (struct inode
*inode
);
1189 int (*inode_setxattr
) (struct dentry
*dentry
, char *name
, void *value
,
1190 size_t size
, int flags
);
1191 void (*inode_post_setxattr
) (struct dentry
*dentry
, char *name
, void *value
,
1192 size_t size
, int flags
);
1193 int (*inode_getxattr
) (struct dentry
*dentry
, char *name
);
1194 int (*inode_listxattr
) (struct dentry
*dentry
);
1195 int (*inode_removexattr
) (struct dentry
*dentry
, char *name
);
1196 const char *(*inode_xattr_getsuffix
) (void);
1197 int (*inode_getsecurity
)(const struct inode
*inode
, const char *name
, void *buffer
, size_t size
, int err
);
1198 int (*inode_setsecurity
)(struct inode
*inode
, const char *name
, const void *value
, size_t size
, int flags
);
1199 int (*inode_listsecurity
)(struct inode
*inode
, char *buffer
, size_t buffer_size
);
1201 int (*file_permission
) (struct file
* file
, int mask
);
1202 int (*file_alloc_security
) (struct file
* file
);
1203 void (*file_free_security
) (struct file
* file
);
1204 int (*file_ioctl
) (struct file
* file
, unsigned int cmd
,
1206 int (*file_mmap
) (struct file
* file
,
1207 unsigned long reqprot
,
1208 unsigned long prot
, unsigned long flags
);
1209 int (*file_mprotect
) (struct vm_area_struct
* vma
,
1210 unsigned long reqprot
,
1211 unsigned long prot
);
1212 int (*file_lock
) (struct file
* file
, unsigned int cmd
);
1213 int (*file_fcntl
) (struct file
* file
, unsigned int cmd
,
1215 int (*file_set_fowner
) (struct file
* file
);
1216 int (*file_send_sigiotask
) (struct task_struct
* tsk
,
1217 struct fown_struct
* fown
, int sig
);
1218 int (*file_receive
) (struct file
* file
);
1220 int (*task_create
) (unsigned long clone_flags
);
1221 int (*task_alloc_security
) (struct task_struct
* p
);
1222 void (*task_free_security
) (struct task_struct
* p
);
1223 int (*task_setuid
) (uid_t id0
, uid_t id1
, uid_t id2
, int flags
);
1224 int (*task_post_setuid
) (uid_t old_ruid
/* or fsuid */ ,
1225 uid_t old_euid
, uid_t old_suid
, int flags
);
1226 int (*task_setgid
) (gid_t id0
, gid_t id1
, gid_t id2
, int flags
);
1227 int (*task_setpgid
) (struct task_struct
* p
, pid_t pgid
);
1228 int (*task_getpgid
) (struct task_struct
* p
);
1229 int (*task_getsid
) (struct task_struct
* p
);
1230 void (*task_getsecid
) (struct task_struct
* p
, u32
* secid
);
1231 int (*task_setgroups
) (struct group_info
*group_info
);
1232 int (*task_setnice
) (struct task_struct
* p
, int nice
);
1233 int (*task_setioprio
) (struct task_struct
* p
, int ioprio
);
1234 int (*task_getioprio
) (struct task_struct
* p
);
1235 int (*task_setrlimit
) (unsigned int resource
, struct rlimit
* new_rlim
);
1236 int (*task_setscheduler
) (struct task_struct
* p
, int policy
,
1237 struct sched_param
* lp
);
1238 int (*task_getscheduler
) (struct task_struct
* p
);
1239 int (*task_movememory
) (struct task_struct
* p
);
1240 int (*task_kill
) (struct task_struct
* p
,
1241 struct siginfo
* info
, int sig
, u32 secid
);
1242 int (*task_wait
) (struct task_struct
* p
);
1243 int (*task_prctl
) (int option
, unsigned long arg2
,
1244 unsigned long arg3
, unsigned long arg4
,
1245 unsigned long arg5
);
1246 void (*task_reparent_to_init
) (struct task_struct
* p
);
1247 void (*task_to_inode
)(struct task_struct
*p
, struct inode
*inode
);
1249 int (*ipc_permission
) (struct kern_ipc_perm
* ipcp
, short flag
);
1251 int (*msg_msg_alloc_security
) (struct msg_msg
* msg
);
1252 void (*msg_msg_free_security
) (struct msg_msg
* msg
);
1254 int (*msg_queue_alloc_security
) (struct msg_queue
* msq
);
1255 void (*msg_queue_free_security
) (struct msg_queue
* msq
);
1256 int (*msg_queue_associate
) (struct msg_queue
* msq
, int msqflg
);
1257 int (*msg_queue_msgctl
) (struct msg_queue
* msq
, int cmd
);
1258 int (*msg_queue_msgsnd
) (struct msg_queue
* msq
,
1259 struct msg_msg
* msg
, int msqflg
);
1260 int (*msg_queue_msgrcv
) (struct msg_queue
* msq
,
1261 struct msg_msg
* msg
,
1262 struct task_struct
* target
,
1263 long type
, int mode
);
1265 int (*shm_alloc_security
) (struct shmid_kernel
* shp
);
1266 void (*shm_free_security
) (struct shmid_kernel
* shp
);
1267 int (*shm_associate
) (struct shmid_kernel
* shp
, int shmflg
);
1268 int (*shm_shmctl
) (struct shmid_kernel
* shp
, int cmd
);
1269 int (*shm_shmat
) (struct shmid_kernel
* shp
,
1270 char __user
*shmaddr
, int shmflg
);
1272 int (*sem_alloc_security
) (struct sem_array
* sma
);
1273 void (*sem_free_security
) (struct sem_array
* sma
);
1274 int (*sem_associate
) (struct sem_array
* sma
, int semflg
);
1275 int (*sem_semctl
) (struct sem_array
* sma
, int cmd
);
1276 int (*sem_semop
) (struct sem_array
* sma
,
1277 struct sembuf
* sops
, unsigned nsops
, int alter
);
1279 int (*netlink_send
) (struct sock
* sk
, struct sk_buff
* skb
);
1280 int (*netlink_recv
) (struct sk_buff
* skb
, int cap
);
1282 /* allow module stacking */
1283 int (*register_security
) (const char *name
,
1284 struct security_operations
*ops
);
1285 int (*unregister_security
) (const char *name
,
1286 struct security_operations
*ops
);
1288 void (*d_instantiate
) (struct dentry
*dentry
, struct inode
*inode
);
1290 int (*getprocattr
)(struct task_struct
*p
, char *name
, void *value
, size_t size
);
1291 int (*setprocattr
)(struct task_struct
*p
, char *name
, void *value
, size_t size
);
1293 #ifdef CONFIG_SECURITY_NETWORK
1294 int (*unix_stream_connect
) (struct socket
* sock
,
1295 struct socket
* other
, struct sock
* newsk
);
1296 int (*unix_may_send
) (struct socket
* sock
, struct socket
* other
);
1298 int (*socket_create
) (int family
, int type
, int protocol
, int kern
);
1299 void (*socket_post_create
) (struct socket
* sock
, int family
,
1300 int type
, int protocol
, int kern
);
1301 int (*socket_bind
) (struct socket
* sock
,
1302 struct sockaddr
* address
, int addrlen
);
1303 int (*socket_connect
) (struct socket
* sock
,
1304 struct sockaddr
* address
, int addrlen
);
1305 int (*socket_listen
) (struct socket
* sock
, int backlog
);
1306 int (*socket_accept
) (struct socket
* sock
, struct socket
* newsock
);
1307 void (*socket_post_accept
) (struct socket
* sock
,
1308 struct socket
* newsock
);
1309 int (*socket_sendmsg
) (struct socket
* sock
,
1310 struct msghdr
* msg
, int size
);
1311 int (*socket_recvmsg
) (struct socket
* sock
,
1312 struct msghdr
* msg
, int size
, int flags
);
1313 int (*socket_getsockname
) (struct socket
* sock
);
1314 int (*socket_getpeername
) (struct socket
* sock
);
1315 int (*socket_getsockopt
) (struct socket
* sock
, int level
, int optname
);
1316 int (*socket_setsockopt
) (struct socket
* sock
, int level
, int optname
);
1317 int (*socket_shutdown
) (struct socket
* sock
, int how
);
1318 int (*socket_sock_rcv_skb
) (struct sock
* sk
, struct sk_buff
* skb
);
1319 int (*socket_getpeersec_stream
) (struct socket
*sock
, char __user
*optval
, int __user
*optlen
, unsigned len
);
1320 int (*socket_getpeersec_dgram
) (struct sk_buff
*skb
, char **secdata
, u32
*seclen
);
1321 int (*sk_alloc_security
) (struct sock
*sk
, int family
, gfp_t priority
);
1322 void (*sk_free_security
) (struct sock
*sk
);
1323 unsigned int (*sk_getsid
) (struct sock
*sk
, struct flowi
*fl
, u8 dir
);
1324 #endif /* CONFIG_SECURITY_NETWORK */
1326 #ifdef CONFIG_SECURITY_NETWORK_XFRM
1327 int (*xfrm_policy_alloc_security
) (struct xfrm_policy
*xp
, struct xfrm_user_sec_ctx
*sec_ctx
);
1328 int (*xfrm_policy_clone_security
) (struct xfrm_policy
*old
, struct xfrm_policy
*new);
1329 void (*xfrm_policy_free_security
) (struct xfrm_policy
*xp
);
1330 int (*xfrm_policy_delete_security
) (struct xfrm_policy
*xp
);
1331 int (*xfrm_state_alloc_security
) (struct xfrm_state
*x
, struct xfrm_user_sec_ctx
*sec_ctx
);
1332 void (*xfrm_state_free_security
) (struct xfrm_state
*x
);
1333 int (*xfrm_state_delete_security
) (struct xfrm_state
*x
);
1334 int (*xfrm_policy_lookup
)(struct xfrm_policy
*xp
, u32 sk_sid
, u8 dir
);
1335 #endif /* CONFIG_SECURITY_NETWORK_XFRM */
1337 /* key management security hooks */
1339 int (*key_alloc
)(struct key
*key
, struct task_struct
*tsk
, unsigned long flags
);
1340 void (*key_free
)(struct key
*key
);
1341 int (*key_permission
)(key_ref_t key_ref
,
1342 struct task_struct
*context
,
1345 #endif /* CONFIG_KEYS */
1349 /* global variables */
1350 extern struct security_operations
*security_ops
;
1353 static inline int security_ptrace (struct task_struct
* parent
, struct task_struct
* child
)
1355 return security_ops
->ptrace (parent
, child
);
1358 static inline int security_capget (struct task_struct
*target
,
1359 kernel_cap_t
*effective
,
1360 kernel_cap_t
*inheritable
,
1361 kernel_cap_t
*permitted
)
1363 return security_ops
->capget (target
, effective
, inheritable
, permitted
);
1366 static inline int security_capset_check (struct task_struct
*target
,
1367 kernel_cap_t
*effective
,
1368 kernel_cap_t
*inheritable
,
1369 kernel_cap_t
*permitted
)
1371 return security_ops
->capset_check (target
, effective
, inheritable
, permitted
);
1374 static inline void security_capset_set (struct task_struct
*target
,
1375 kernel_cap_t
*effective
,
1376 kernel_cap_t
*inheritable
,
1377 kernel_cap_t
*permitted
)
1379 security_ops
->capset_set (target
, effective
, inheritable
, permitted
);
1382 static inline int security_capable(struct task_struct
*tsk
, int cap
)
1384 return security_ops
->capable(tsk
, cap
);
1387 static inline int security_acct (struct file
*file
)
1389 return security_ops
->acct (file
);
1392 static inline int security_sysctl(struct ctl_table
*table
, int op
)
1394 return security_ops
->sysctl(table
, op
);
1397 static inline int security_quotactl (int cmds
, int type
, int id
,
1398 struct super_block
*sb
)
1400 return security_ops
->quotactl (cmds
, type
, id
, sb
);
1403 static inline int security_quota_on (struct dentry
* dentry
)
1405 return security_ops
->quota_on (dentry
);
1408 static inline int security_syslog(int type
)
1410 return security_ops
->syslog(type
);
1413 static inline int security_settime(struct timespec
*ts
, struct timezone
*tz
)
1415 return security_ops
->settime(ts
, tz
);
1419 static inline int security_vm_enough_memory(long pages
)
1421 return security_ops
->vm_enough_memory(pages
);
1424 static inline int security_bprm_alloc (struct linux_binprm
*bprm
)
1426 return security_ops
->bprm_alloc_security (bprm
);
1428 static inline void security_bprm_free (struct linux_binprm
*bprm
)
1430 security_ops
->bprm_free_security (bprm
);
1432 static inline void security_bprm_apply_creds (struct linux_binprm
*bprm
, int unsafe
)
1434 security_ops
->bprm_apply_creds (bprm
, unsafe
);
1436 static inline void security_bprm_post_apply_creds (struct linux_binprm
*bprm
)
1438 security_ops
->bprm_post_apply_creds (bprm
);
1440 static inline int security_bprm_set (struct linux_binprm
*bprm
)
1442 return security_ops
->bprm_set_security (bprm
);
1445 static inline int security_bprm_check (struct linux_binprm
*bprm
)
1447 return security_ops
->bprm_check_security (bprm
);
1450 static inline int security_bprm_secureexec (struct linux_binprm
*bprm
)
1452 return security_ops
->bprm_secureexec (bprm
);
1455 static inline int security_sb_alloc (struct super_block
*sb
)
1457 return security_ops
->sb_alloc_security (sb
);
1460 static inline void security_sb_free (struct super_block
*sb
)
1462 security_ops
->sb_free_security (sb
);
1465 static inline int security_sb_copy_data (struct file_system_type
*type
,
1466 void *orig
, void *copy
)
1468 return security_ops
->sb_copy_data (type
, orig
, copy
);
1471 static inline int security_sb_kern_mount (struct super_block
*sb
, void *data
)
1473 return security_ops
->sb_kern_mount (sb
, data
);
1476 static inline int security_sb_statfs (struct dentry
*dentry
)
1478 return security_ops
->sb_statfs (dentry
);
1481 static inline int security_sb_mount (char *dev_name
, struct nameidata
*nd
,
1482 char *type
, unsigned long flags
,
1485 return security_ops
->sb_mount (dev_name
, nd
, type
, flags
, data
);
1488 static inline int security_sb_check_sb (struct vfsmount
*mnt
,
1489 struct nameidata
*nd
)
1491 return security_ops
->sb_check_sb (mnt
, nd
);
1494 static inline int security_sb_umount (struct vfsmount
*mnt
, int flags
)
1496 return security_ops
->sb_umount (mnt
, flags
);
1499 static inline void security_sb_umount_close (struct vfsmount
*mnt
)
1501 security_ops
->sb_umount_close (mnt
);
1504 static inline void security_sb_umount_busy (struct vfsmount
*mnt
)
1506 security_ops
->sb_umount_busy (mnt
);
1509 static inline void security_sb_post_remount (struct vfsmount
*mnt
,
1510 unsigned long flags
, void *data
)
1512 security_ops
->sb_post_remount (mnt
, flags
, data
);
1515 static inline void security_sb_post_mountroot (void)
1517 security_ops
->sb_post_mountroot ();
1520 static inline void security_sb_post_addmount (struct vfsmount
*mnt
,
1521 struct nameidata
*mountpoint_nd
)
1523 security_ops
->sb_post_addmount (mnt
, mountpoint_nd
);
1526 static inline int security_sb_pivotroot (struct nameidata
*old_nd
,
1527 struct nameidata
*new_nd
)
1529 return security_ops
->sb_pivotroot (old_nd
, new_nd
);
1532 static inline void security_sb_post_pivotroot (struct nameidata
*old_nd
,
1533 struct nameidata
*new_nd
)
1535 security_ops
->sb_post_pivotroot (old_nd
, new_nd
);
1538 static inline int security_inode_alloc (struct inode
*inode
)
1540 return security_ops
->inode_alloc_security (inode
);
1543 static inline void security_inode_free (struct inode
*inode
)
1545 security_ops
->inode_free_security (inode
);
1548 static inline int security_inode_init_security (struct inode
*inode
,
1554 if (unlikely (IS_PRIVATE (inode
)))
1556 return security_ops
->inode_init_security (inode
, dir
, name
, value
, len
);
1559 static inline int security_inode_create (struct inode
*dir
,
1560 struct dentry
*dentry
,
1563 if (unlikely (IS_PRIVATE (dir
)))
1565 return security_ops
->inode_create (dir
, dentry
, mode
);
1568 static inline int security_inode_link (struct dentry
*old_dentry
,
1570 struct dentry
*new_dentry
)
1572 if (unlikely (IS_PRIVATE (old_dentry
->d_inode
)))
1574 return security_ops
->inode_link (old_dentry
, dir
, new_dentry
);
1577 static inline int security_inode_unlink (struct inode
*dir
,
1578 struct dentry
*dentry
)
1580 if (unlikely (IS_PRIVATE (dentry
->d_inode
)))
1582 return security_ops
->inode_unlink (dir
, dentry
);
1585 static inline int security_inode_symlink (struct inode
*dir
,
1586 struct dentry
*dentry
,
1587 const char *old_name
)
1589 if (unlikely (IS_PRIVATE (dir
)))
1591 return security_ops
->inode_symlink (dir
, dentry
, old_name
);
1594 static inline int security_inode_mkdir (struct inode
*dir
,
1595 struct dentry
*dentry
,
1598 if (unlikely (IS_PRIVATE (dir
)))
1600 return security_ops
->inode_mkdir (dir
, dentry
, mode
);
1603 static inline int security_inode_rmdir (struct inode
*dir
,
1604 struct dentry
*dentry
)
1606 if (unlikely (IS_PRIVATE (dentry
->d_inode
)))
1608 return security_ops
->inode_rmdir (dir
, dentry
);
1611 static inline int security_inode_mknod (struct inode
*dir
,
1612 struct dentry
*dentry
,
1613 int mode
, dev_t dev
)
1615 if (unlikely (IS_PRIVATE (dir
)))
1617 return security_ops
->inode_mknod (dir
, dentry
, mode
, dev
);
1620 static inline int security_inode_rename (struct inode
*old_dir
,
1621 struct dentry
*old_dentry
,
1622 struct inode
*new_dir
,
1623 struct dentry
*new_dentry
)
1625 if (unlikely (IS_PRIVATE (old_dentry
->d_inode
) ||
1626 (new_dentry
->d_inode
&& IS_PRIVATE (new_dentry
->d_inode
))))
1628 return security_ops
->inode_rename (old_dir
, old_dentry
,
1629 new_dir
, new_dentry
);
1632 static inline int security_inode_readlink (struct dentry
*dentry
)
1634 if (unlikely (IS_PRIVATE (dentry
->d_inode
)))
1636 return security_ops
->inode_readlink (dentry
);
1639 static inline int security_inode_follow_link (struct dentry
*dentry
,
1640 struct nameidata
*nd
)
1642 if (unlikely (IS_PRIVATE (dentry
->d_inode
)))
1644 return security_ops
->inode_follow_link (dentry
, nd
);
1647 static inline int security_inode_permission (struct inode
*inode
, int mask
,
1648 struct nameidata
*nd
)
1650 if (unlikely (IS_PRIVATE (inode
)))
1652 return security_ops
->inode_permission (inode
, mask
, nd
);
1655 static inline int security_inode_setattr (struct dentry
*dentry
,
1658 if (unlikely (IS_PRIVATE (dentry
->d_inode
)))
1660 return security_ops
->inode_setattr (dentry
, attr
);
1663 static inline int security_inode_getattr (struct vfsmount
*mnt
,
1664 struct dentry
*dentry
)
1666 if (unlikely (IS_PRIVATE (dentry
->d_inode
)))
1668 return security_ops
->inode_getattr (mnt
, dentry
);
1671 static inline void security_inode_delete (struct inode
*inode
)
1673 if (unlikely (IS_PRIVATE (inode
)))
1675 security_ops
->inode_delete (inode
);
1678 static inline int security_inode_setxattr (struct dentry
*dentry
, char *name
,
1679 void *value
, size_t size
, int flags
)
1681 if (unlikely (IS_PRIVATE (dentry
->d_inode
)))
1683 return security_ops
->inode_setxattr (dentry
, name
, value
, size
, flags
);
1686 static inline void security_inode_post_setxattr (struct dentry
*dentry
, char *name
,
1687 void *value
, size_t size
, int flags
)
1689 if (unlikely (IS_PRIVATE (dentry
->d_inode
)))
1691 security_ops
->inode_post_setxattr (dentry
, name
, value
, size
, flags
);
1694 static inline int security_inode_getxattr (struct dentry
*dentry
, char *name
)
1696 if (unlikely (IS_PRIVATE (dentry
->d_inode
)))
1698 return security_ops
->inode_getxattr (dentry
, name
);
1701 static inline int security_inode_listxattr (struct dentry
*dentry
)
1703 if (unlikely (IS_PRIVATE (dentry
->d_inode
)))
1705 return security_ops
->inode_listxattr (dentry
);
1708 static inline int security_inode_removexattr (struct dentry
*dentry
, char *name
)
1710 if (unlikely (IS_PRIVATE (dentry
->d_inode
)))
1712 return security_ops
->inode_removexattr (dentry
, name
);
1715 static inline const char *security_inode_xattr_getsuffix(void)
1717 return security_ops
->inode_xattr_getsuffix();
1720 static inline int security_inode_getsecurity(const struct inode
*inode
, const char *name
, void *buffer
, size_t size
, int err
)
1722 if (unlikely (IS_PRIVATE (inode
)))
1724 return security_ops
->inode_getsecurity(inode
, name
, buffer
, size
, err
);
1727 static inline int security_inode_setsecurity(struct inode
*inode
, const char *name
, const void *value
, size_t size
, int flags
)
1729 if (unlikely (IS_PRIVATE (inode
)))
1731 return security_ops
->inode_setsecurity(inode
, name
, value
, size
, flags
);
1734 static inline int security_inode_listsecurity(struct inode
*inode
, char *buffer
, size_t buffer_size
)
1736 if (unlikely (IS_PRIVATE (inode
)))
1738 return security_ops
->inode_listsecurity(inode
, buffer
, buffer_size
);
1741 static inline int security_file_permission (struct file
*file
, int mask
)
1743 return security_ops
->file_permission (file
, mask
);
1746 static inline int security_file_alloc (struct file
*file
)
1748 return security_ops
->file_alloc_security (file
);
1751 static inline void security_file_free (struct file
*file
)
1753 security_ops
->file_free_security (file
);
1756 static inline int security_file_ioctl (struct file
*file
, unsigned int cmd
,
1759 return security_ops
->file_ioctl (file
, cmd
, arg
);
1762 static inline int security_file_mmap (struct file
*file
, unsigned long reqprot
,
1764 unsigned long flags
)
1766 return security_ops
->file_mmap (file
, reqprot
, prot
, flags
);
1769 static inline int security_file_mprotect (struct vm_area_struct
*vma
,
1770 unsigned long reqprot
,
1773 return security_ops
->file_mprotect (vma
, reqprot
, prot
);
1776 static inline int security_file_lock (struct file
*file
, unsigned int cmd
)
1778 return security_ops
->file_lock (file
, cmd
);
1781 static inline int security_file_fcntl (struct file
*file
, unsigned int cmd
,
1784 return security_ops
->file_fcntl (file
, cmd
, arg
);
1787 static inline int security_file_set_fowner (struct file
*file
)
1789 return security_ops
->file_set_fowner (file
);
1792 static inline int security_file_send_sigiotask (struct task_struct
*tsk
,
1793 struct fown_struct
*fown
,
1796 return security_ops
->file_send_sigiotask (tsk
, fown
, sig
);
1799 static inline int security_file_receive (struct file
*file
)
1801 return security_ops
->file_receive (file
);
1804 static inline int security_task_create (unsigned long clone_flags
)
1806 return security_ops
->task_create (clone_flags
);
1809 static inline int security_task_alloc (struct task_struct
*p
)
1811 return security_ops
->task_alloc_security (p
);
1814 static inline void security_task_free (struct task_struct
*p
)
1816 security_ops
->task_free_security (p
);
1819 static inline int security_task_setuid (uid_t id0
, uid_t id1
, uid_t id2
,
1822 return security_ops
->task_setuid (id0
, id1
, id2
, flags
);
1825 static inline int security_task_post_setuid (uid_t old_ruid
, uid_t old_euid
,
1826 uid_t old_suid
, int flags
)
1828 return security_ops
->task_post_setuid (old_ruid
, old_euid
, old_suid
, flags
);
1831 static inline int security_task_setgid (gid_t id0
, gid_t id1
, gid_t id2
,
1834 return security_ops
->task_setgid (id0
, id1
, id2
, flags
);
1837 static inline int security_task_setpgid (struct task_struct
*p
, pid_t pgid
)
1839 return security_ops
->task_setpgid (p
, pgid
);
1842 static inline int security_task_getpgid (struct task_struct
*p
)
1844 return security_ops
->task_getpgid (p
);
1847 static inline int security_task_getsid (struct task_struct
*p
)
1849 return security_ops
->task_getsid (p
);
1852 static inline void security_task_getsecid (struct task_struct
*p
, u32
*secid
)
1854 security_ops
->task_getsecid (p
, secid
);
1857 static inline int security_task_setgroups (struct group_info
*group_info
)
1859 return security_ops
->task_setgroups (group_info
);
1862 static inline int security_task_setnice (struct task_struct
*p
, int nice
)
1864 return security_ops
->task_setnice (p
, nice
);
1867 static inline int security_task_setioprio (struct task_struct
*p
, int ioprio
)
1869 return security_ops
->task_setioprio (p
, ioprio
);
1872 static inline int security_task_getioprio (struct task_struct
*p
)
1874 return security_ops
->task_getioprio (p
);
1877 static inline int security_task_setrlimit (unsigned int resource
,
1878 struct rlimit
*new_rlim
)
1880 return security_ops
->task_setrlimit (resource
, new_rlim
);
1883 static inline int security_task_setscheduler (struct task_struct
*p
,
1885 struct sched_param
*lp
)
1887 return security_ops
->task_setscheduler (p
, policy
, lp
);
1890 static inline int security_task_getscheduler (struct task_struct
*p
)
1892 return security_ops
->task_getscheduler (p
);
1895 static inline int security_task_movememory (struct task_struct
*p
)
1897 return security_ops
->task_movememory (p
);
1900 static inline int security_task_kill (struct task_struct
*p
,
1901 struct siginfo
*info
, int sig
,
1904 return security_ops
->task_kill (p
, info
, sig
, secid
);
1907 static inline int security_task_wait (struct task_struct
*p
)
1909 return security_ops
->task_wait (p
);
1912 static inline int security_task_prctl (int option
, unsigned long arg2
,
1917 return security_ops
->task_prctl (option
, arg2
, arg3
, arg4
, arg5
);
1920 static inline void security_task_reparent_to_init (struct task_struct
*p
)
1922 security_ops
->task_reparent_to_init (p
);
1925 static inline void security_task_to_inode(struct task_struct
*p
, struct inode
*inode
)
1927 security_ops
->task_to_inode(p
, inode
);
1930 static inline int security_ipc_permission (struct kern_ipc_perm
*ipcp
,
1933 return security_ops
->ipc_permission (ipcp
, flag
);
1936 static inline int security_msg_msg_alloc (struct msg_msg
* msg
)
1938 return security_ops
->msg_msg_alloc_security (msg
);
1941 static inline void security_msg_msg_free (struct msg_msg
* msg
)
1943 security_ops
->msg_msg_free_security(msg
);
1946 static inline int security_msg_queue_alloc (struct msg_queue
*msq
)
1948 return security_ops
->msg_queue_alloc_security (msq
);
1951 static inline void security_msg_queue_free (struct msg_queue
*msq
)
1953 security_ops
->msg_queue_free_security (msq
);
1956 static inline int security_msg_queue_associate (struct msg_queue
* msq
,
1959 return security_ops
->msg_queue_associate (msq
, msqflg
);
1962 static inline int security_msg_queue_msgctl (struct msg_queue
* msq
, int cmd
)
1964 return security_ops
->msg_queue_msgctl (msq
, cmd
);
1967 static inline int security_msg_queue_msgsnd (struct msg_queue
* msq
,
1968 struct msg_msg
* msg
, int msqflg
)
1970 return security_ops
->msg_queue_msgsnd (msq
, msg
, msqflg
);
1973 static inline int security_msg_queue_msgrcv (struct msg_queue
* msq
,
1974 struct msg_msg
* msg
,
1975 struct task_struct
* target
,
1976 long type
, int mode
)
1978 return security_ops
->msg_queue_msgrcv (msq
, msg
, target
, type
, mode
);
1981 static inline int security_shm_alloc (struct shmid_kernel
*shp
)
1983 return security_ops
->shm_alloc_security (shp
);
1986 static inline void security_shm_free (struct shmid_kernel
*shp
)
1988 security_ops
->shm_free_security (shp
);
1991 static inline int security_shm_associate (struct shmid_kernel
* shp
,
1994 return security_ops
->shm_associate(shp
, shmflg
);
1997 static inline int security_shm_shmctl (struct shmid_kernel
* shp
, int cmd
)
1999 return security_ops
->shm_shmctl (shp
, cmd
);
2002 static inline int security_shm_shmat (struct shmid_kernel
* shp
,
2003 char __user
*shmaddr
, int shmflg
)
2005 return security_ops
->shm_shmat(shp
, shmaddr
, shmflg
);
2008 static inline int security_sem_alloc (struct sem_array
*sma
)
2010 return security_ops
->sem_alloc_security (sma
);
2013 static inline void security_sem_free (struct sem_array
*sma
)
2015 security_ops
->sem_free_security (sma
);
2018 static inline int security_sem_associate (struct sem_array
* sma
, int semflg
)
2020 return security_ops
->sem_associate (sma
, semflg
);
2023 static inline int security_sem_semctl (struct sem_array
* sma
, int cmd
)
2025 return security_ops
->sem_semctl(sma
, cmd
);
2028 static inline int security_sem_semop (struct sem_array
* sma
,
2029 struct sembuf
* sops
, unsigned nsops
,
2032 return security_ops
->sem_semop(sma
, sops
, nsops
, alter
);
2035 static inline void security_d_instantiate (struct dentry
*dentry
, struct inode
*inode
)
2037 if (unlikely (inode
&& IS_PRIVATE (inode
)))
2039 security_ops
->d_instantiate (dentry
, inode
);
2042 static inline int security_getprocattr(struct task_struct
*p
, char *name
, void *value
, size_t size
)
2044 return security_ops
->getprocattr(p
, name
, value
, size
);
2047 static inline int security_setprocattr(struct task_struct
*p
, char *name
, void *value
, size_t size
)
2049 return security_ops
->setprocattr(p
, name
, value
, size
);
2052 static inline int security_netlink_send(struct sock
*sk
, struct sk_buff
* skb
)
2054 return security_ops
->netlink_send(sk
, skb
);
2057 static inline int security_netlink_recv(struct sk_buff
* skb
, int cap
)
2059 return security_ops
->netlink_recv(skb
, cap
);
2063 extern int security_init (void);
2064 extern int register_security (struct security_operations
*ops
);
2065 extern int unregister_security (struct security_operations
*ops
);
2066 extern int mod_reg_security (const char *name
, struct security_operations
*ops
);
2067 extern int mod_unreg_security (const char *name
, struct security_operations
*ops
);
2068 extern struct dentry
*securityfs_create_file(const char *name
, mode_t mode
,
2069 struct dentry
*parent
, void *data
,
2070 struct file_operations
*fops
);
2071 extern struct dentry
*securityfs_create_dir(const char *name
, struct dentry
*parent
);
2072 extern void securityfs_remove(struct dentry
*dentry
);
2075 #else /* CONFIG_SECURITY */
2078 * This is the default capabilities functionality. Most of these functions
2079 * are just stubbed out, but a few must call the proper capable code.
2082 static inline int security_init(void)
2087 static inline int security_ptrace (struct task_struct
*parent
, struct task_struct
* child
)
2089 return cap_ptrace (parent
, child
);
2092 static inline int security_capget (struct task_struct
*target
,
2093 kernel_cap_t
*effective
,
2094 kernel_cap_t
*inheritable
,
2095 kernel_cap_t
*permitted
)
2097 return cap_capget (target
, effective
, inheritable
, permitted
);
2100 static inline int security_capset_check (struct task_struct
*target
,
2101 kernel_cap_t
*effective
,
2102 kernel_cap_t
*inheritable
,
2103 kernel_cap_t
*permitted
)
2105 return cap_capset_check (target
, effective
, inheritable
, permitted
);
2108 static inline void security_capset_set (struct task_struct
*target
,
2109 kernel_cap_t
*effective
,
2110 kernel_cap_t
*inheritable
,
2111 kernel_cap_t
*permitted
)
2113 cap_capset_set (target
, effective
, inheritable
, permitted
);
2116 static inline int security_capable(struct task_struct
*tsk
, int cap
)
2118 return cap_capable(tsk
, cap
);
2121 static inline int security_acct (struct file
*file
)
2126 static inline int security_sysctl(struct ctl_table
*table
, int op
)
2131 static inline int security_quotactl (int cmds
, int type
, int id
,
2132 struct super_block
* sb
)
2137 static inline int security_quota_on (struct dentry
* dentry
)
2142 static inline int security_syslog(int type
)
2144 return cap_syslog(type
);
2147 static inline int security_settime(struct timespec
*ts
, struct timezone
*tz
)
2149 return cap_settime(ts
, tz
);
2152 static inline int security_vm_enough_memory(long pages
)
2154 return cap_vm_enough_memory(pages
);
2157 static inline int security_bprm_alloc (struct linux_binprm
*bprm
)
2162 static inline void security_bprm_free (struct linux_binprm
*bprm
)
2165 static inline void security_bprm_apply_creds (struct linux_binprm
*bprm
, int unsafe
)
2167 cap_bprm_apply_creds (bprm
, unsafe
);
2170 static inline void security_bprm_post_apply_creds (struct linux_binprm
*bprm
)
2175 static inline int security_bprm_set (struct linux_binprm
*bprm
)
2177 return cap_bprm_set_security (bprm
);
2180 static inline int security_bprm_check (struct linux_binprm
*bprm
)
2185 static inline int security_bprm_secureexec (struct linux_binprm
*bprm
)
2187 return cap_bprm_secureexec(bprm
);
2190 static inline int security_sb_alloc (struct super_block
*sb
)
2195 static inline void security_sb_free (struct super_block
*sb
)
2198 static inline int security_sb_copy_data (struct file_system_type
*type
,
2199 void *orig
, void *copy
)
2204 static inline int security_sb_kern_mount (struct super_block
*sb
, void *data
)
2209 static inline int security_sb_statfs (struct dentry
*dentry
)
2214 static inline int security_sb_mount (char *dev_name
, struct nameidata
*nd
,
2215 char *type
, unsigned long flags
,
2221 static inline int security_sb_check_sb (struct vfsmount
*mnt
,
2222 struct nameidata
*nd
)
2227 static inline int security_sb_umount (struct vfsmount
*mnt
, int flags
)
2232 static inline void security_sb_umount_close (struct vfsmount
*mnt
)
2235 static inline void security_sb_umount_busy (struct vfsmount
*mnt
)
2238 static inline void security_sb_post_remount (struct vfsmount
*mnt
,
2239 unsigned long flags
, void *data
)
2242 static inline void security_sb_post_mountroot (void)
2245 static inline void security_sb_post_addmount (struct vfsmount
*mnt
,
2246 struct nameidata
*mountpoint_nd
)
2249 static inline int security_sb_pivotroot (struct nameidata
*old_nd
,
2250 struct nameidata
*new_nd
)
2255 static inline void security_sb_post_pivotroot (struct nameidata
*old_nd
,
2256 struct nameidata
*new_nd
)
2259 static inline int security_inode_alloc (struct inode
*inode
)
2264 static inline void security_inode_free (struct inode
*inode
)
2267 static inline int security_inode_init_security (struct inode
*inode
,
2276 static inline int security_inode_create (struct inode
*dir
,
2277 struct dentry
*dentry
,
2283 static inline int security_inode_link (struct dentry
*old_dentry
,
2285 struct dentry
*new_dentry
)
2290 static inline int security_inode_unlink (struct inode
*dir
,
2291 struct dentry
*dentry
)
2296 static inline int security_inode_symlink (struct inode
*dir
,
2297 struct dentry
*dentry
,
2298 const char *old_name
)
2303 static inline int security_inode_mkdir (struct inode
*dir
,
2304 struct dentry
*dentry
,
2310 static inline int security_inode_rmdir (struct inode
*dir
,
2311 struct dentry
*dentry
)
2316 static inline int security_inode_mknod (struct inode
*dir
,
2317 struct dentry
*dentry
,
2318 int mode
, dev_t dev
)
2323 static inline int security_inode_rename (struct inode
*old_dir
,
2324 struct dentry
*old_dentry
,
2325 struct inode
*new_dir
,
2326 struct dentry
*new_dentry
)
2331 static inline int security_inode_readlink (struct dentry
*dentry
)
2336 static inline int security_inode_follow_link (struct dentry
*dentry
,
2337 struct nameidata
*nd
)
2342 static inline int security_inode_permission (struct inode
*inode
, int mask
,
2343 struct nameidata
*nd
)
2348 static inline int security_inode_setattr (struct dentry
*dentry
,
2354 static inline int security_inode_getattr (struct vfsmount
*mnt
,
2355 struct dentry
*dentry
)
2360 static inline void security_inode_delete (struct inode
*inode
)
2363 static inline int security_inode_setxattr (struct dentry
*dentry
, char *name
,
2364 void *value
, size_t size
, int flags
)
2366 return cap_inode_setxattr(dentry
, name
, value
, size
, flags
);
2369 static inline void security_inode_post_setxattr (struct dentry
*dentry
, char *name
,
2370 void *value
, size_t size
, int flags
)
2373 static inline int security_inode_getxattr (struct dentry
*dentry
, char *name
)
2378 static inline int security_inode_listxattr (struct dentry
*dentry
)
2383 static inline int security_inode_removexattr (struct dentry
*dentry
, char *name
)
2385 return cap_inode_removexattr(dentry
, name
);
2388 static inline const char *security_inode_xattr_getsuffix (void)
2393 static inline int security_inode_getsecurity(const struct inode
*inode
, const char *name
, void *buffer
, size_t size
, int err
)
2398 static inline int security_inode_setsecurity(struct inode
*inode
, const char *name
, const void *value
, size_t size
, int flags
)
2403 static inline int security_inode_listsecurity(struct inode
*inode
, char *buffer
, size_t buffer_size
)
2408 static inline int security_file_permission (struct file
*file
, int mask
)
2413 static inline int security_file_alloc (struct file
*file
)
2418 static inline void security_file_free (struct file
*file
)
2421 static inline int security_file_ioctl (struct file
*file
, unsigned int cmd
,
2427 static inline int security_file_mmap (struct file
*file
, unsigned long reqprot
,
2429 unsigned long flags
)
2434 static inline int security_file_mprotect (struct vm_area_struct
*vma
,
2435 unsigned long reqprot
,
2441 static inline int security_file_lock (struct file
*file
, unsigned int cmd
)
2446 static inline int security_file_fcntl (struct file
*file
, unsigned int cmd
,
2452 static inline int security_file_set_fowner (struct file
*file
)
2457 static inline int security_file_send_sigiotask (struct task_struct
*tsk
,
2458 struct fown_struct
*fown
,
2464 static inline int security_file_receive (struct file
*file
)
2469 static inline int security_task_create (unsigned long clone_flags
)
2474 static inline int security_task_alloc (struct task_struct
*p
)
2479 static inline void security_task_free (struct task_struct
*p
)
2482 static inline int security_task_setuid (uid_t id0
, uid_t id1
, uid_t id2
,
2488 static inline int security_task_post_setuid (uid_t old_ruid
, uid_t old_euid
,
2489 uid_t old_suid
, int flags
)
2491 return cap_task_post_setuid (old_ruid
, old_euid
, old_suid
, flags
);
2494 static inline int security_task_setgid (gid_t id0
, gid_t id1
, gid_t id2
,
2500 static inline int security_task_setpgid (struct task_struct
*p
, pid_t pgid
)
2505 static inline int security_task_getpgid (struct task_struct
*p
)
2510 static inline int security_task_getsid (struct task_struct
*p
)
2515 static inline void security_task_getsecid (struct task_struct
*p
, u32
*secid
)
2518 static inline int security_task_setgroups (struct group_info
*group_info
)
2523 static inline int security_task_setnice (struct task_struct
*p
, int nice
)
2528 static inline int security_task_setioprio (struct task_struct
*p
, int ioprio
)
2533 static inline int security_task_getioprio (struct task_struct
*p
)
2538 static inline int security_task_setrlimit (unsigned int resource
,
2539 struct rlimit
*new_rlim
)
2544 static inline int security_task_setscheduler (struct task_struct
*p
,
2546 struct sched_param
*lp
)
2551 static inline int security_task_getscheduler (struct task_struct
*p
)
2556 static inline int security_task_movememory (struct task_struct
*p
)
2561 static inline int security_task_kill (struct task_struct
*p
,
2562 struct siginfo
*info
, int sig
,
2568 static inline int security_task_wait (struct task_struct
*p
)
2573 static inline int security_task_prctl (int option
, unsigned long arg2
,
2581 static inline void security_task_reparent_to_init (struct task_struct
*p
)
2583 cap_task_reparent_to_init (p
);
2586 static inline void security_task_to_inode(struct task_struct
*p
, struct inode
*inode
)
2589 static inline int security_ipc_permission (struct kern_ipc_perm
*ipcp
,
2595 static inline int security_msg_msg_alloc (struct msg_msg
* msg
)
2600 static inline void security_msg_msg_free (struct msg_msg
* msg
)
2603 static inline int security_msg_queue_alloc (struct msg_queue
*msq
)
2608 static inline void security_msg_queue_free (struct msg_queue
*msq
)
2611 static inline int security_msg_queue_associate (struct msg_queue
* msq
,
2617 static inline int security_msg_queue_msgctl (struct msg_queue
* msq
, int cmd
)
2622 static inline int security_msg_queue_msgsnd (struct msg_queue
* msq
,
2623 struct msg_msg
* msg
, int msqflg
)
2628 static inline int security_msg_queue_msgrcv (struct msg_queue
* msq
,
2629 struct msg_msg
* msg
,
2630 struct task_struct
* target
,
2631 long type
, int mode
)
2636 static inline int security_shm_alloc (struct shmid_kernel
*shp
)
2641 static inline void security_shm_free (struct shmid_kernel
*shp
)
2644 static inline int security_shm_associate (struct shmid_kernel
* shp
,
2650 static inline int security_shm_shmctl (struct shmid_kernel
* shp
, int cmd
)
2655 static inline int security_shm_shmat (struct shmid_kernel
* shp
,
2656 char __user
*shmaddr
, int shmflg
)
2661 static inline int security_sem_alloc (struct sem_array
*sma
)
2666 static inline void security_sem_free (struct sem_array
*sma
)
2669 static inline int security_sem_associate (struct sem_array
* sma
, int semflg
)
2674 static inline int security_sem_semctl (struct sem_array
* sma
, int cmd
)
2679 static inline int security_sem_semop (struct sem_array
* sma
,
2680 struct sembuf
* sops
, unsigned nsops
,
2686 static inline void security_d_instantiate (struct dentry
*dentry
, struct inode
*inode
)
2689 static inline int security_getprocattr(struct task_struct
*p
, char *name
, void *value
, size_t size
)
2694 static inline int security_setprocattr(struct task_struct
*p
, char *name
, void *value
, size_t size
)
2699 static inline int security_netlink_send (struct sock
*sk
, struct sk_buff
*skb
)
2701 return cap_netlink_send (sk
, skb
);
2704 static inline int security_netlink_recv (struct sk_buff
*skb
, int cap
)
2706 return cap_netlink_recv (skb
, cap
);
2709 static inline struct dentry
*securityfs_create_dir(const char *name
,
2710 struct dentry
*parent
)
2712 return ERR_PTR(-ENODEV
);
2715 static inline struct dentry
*securityfs_create_file(const char *name
,
2717 struct dentry
*parent
,
2719 struct file_operations
*fops
)
2721 return ERR_PTR(-ENODEV
);
2724 static inline void securityfs_remove(struct dentry
*dentry
)
2728 #endif /* CONFIG_SECURITY */
2730 #ifdef CONFIG_SECURITY_NETWORK
2731 static inline int security_unix_stream_connect(struct socket
* sock
,
2732 struct socket
* other
,
2733 struct sock
* newsk
)
2735 return security_ops
->unix_stream_connect(sock
, other
, newsk
);
2739 static inline int security_unix_may_send(struct socket
* sock
,
2740 struct socket
* other
)
2742 return security_ops
->unix_may_send(sock
, other
);
2745 static inline int security_socket_create (int family
, int type
,
2746 int protocol
, int kern
)
2748 return security_ops
->socket_create(family
, type
, protocol
, kern
);
2751 static inline void security_socket_post_create(struct socket
* sock
,
2754 int protocol
, int kern
)
2756 security_ops
->socket_post_create(sock
, family
, type
,
2760 static inline int security_socket_bind(struct socket
* sock
,
2761 struct sockaddr
* address
,
2764 return security_ops
->socket_bind(sock
, address
, addrlen
);
2767 static inline int security_socket_connect(struct socket
* sock
,
2768 struct sockaddr
* address
,
2771 return security_ops
->socket_connect(sock
, address
, addrlen
);
2774 static inline int security_socket_listen(struct socket
* sock
, int backlog
)
2776 return security_ops
->socket_listen(sock
, backlog
);
2779 static inline int security_socket_accept(struct socket
* sock
,
2780 struct socket
* newsock
)
2782 return security_ops
->socket_accept(sock
, newsock
);
2785 static inline void security_socket_post_accept(struct socket
* sock
,
2786 struct socket
* newsock
)
2788 security_ops
->socket_post_accept(sock
, newsock
);
2791 static inline int security_socket_sendmsg(struct socket
* sock
,
2792 struct msghdr
* msg
, int size
)
2794 return security_ops
->socket_sendmsg(sock
, msg
, size
);
2797 static inline int security_socket_recvmsg(struct socket
* sock
,
2798 struct msghdr
* msg
, int size
,
2801 return security_ops
->socket_recvmsg(sock
, msg
, size
, flags
);
2804 static inline int security_socket_getsockname(struct socket
* sock
)
2806 return security_ops
->socket_getsockname(sock
);
2809 static inline int security_socket_getpeername(struct socket
* sock
)
2811 return security_ops
->socket_getpeername(sock
);
2814 static inline int security_socket_getsockopt(struct socket
* sock
,
2815 int level
, int optname
)
2817 return security_ops
->socket_getsockopt(sock
, level
, optname
);
2820 static inline int security_socket_setsockopt(struct socket
* sock
,
2821 int level
, int optname
)
2823 return security_ops
->socket_setsockopt(sock
, level
, optname
);
2826 static inline int security_socket_shutdown(struct socket
* sock
, int how
)
2828 return security_ops
->socket_shutdown(sock
, how
);
2831 static inline int security_sock_rcv_skb (struct sock
* sk
,
2832 struct sk_buff
* skb
)
2834 return security_ops
->socket_sock_rcv_skb (sk
, skb
);
2837 static inline int security_socket_getpeersec_stream(struct socket
*sock
, char __user
*optval
,
2838 int __user
*optlen
, unsigned len
)
2840 return security_ops
->socket_getpeersec_stream(sock
, optval
, optlen
, len
);
2843 static inline int security_socket_getpeersec_dgram(struct sk_buff
*skb
, char **secdata
,
2846 return security_ops
->socket_getpeersec_dgram(skb
, secdata
, seclen
);
2849 static inline int security_sk_alloc(struct sock
*sk
, int family
, gfp_t priority
)
2851 return security_ops
->sk_alloc_security(sk
, family
, priority
);
2854 static inline void security_sk_free(struct sock
*sk
)
2856 return security_ops
->sk_free_security(sk
);
2859 static inline unsigned int security_sk_sid(struct sock
*sk
, struct flowi
*fl
, u8 dir
)
2861 return security_ops
->sk_getsid(sk
, fl
, dir
);
2863 #else /* CONFIG_SECURITY_NETWORK */
2864 static inline int security_unix_stream_connect(struct socket
* sock
,
2865 struct socket
* other
,
2866 struct sock
* newsk
)
2871 static inline int security_unix_may_send(struct socket
* sock
,
2872 struct socket
* other
)
2877 static inline int security_socket_create (int family
, int type
,
2878 int protocol
, int kern
)
2883 static inline void security_socket_post_create(struct socket
* sock
,
2886 int protocol
, int kern
)
2890 static inline int security_socket_bind(struct socket
* sock
,
2891 struct sockaddr
* address
,
2897 static inline int security_socket_connect(struct socket
* sock
,
2898 struct sockaddr
* address
,
2904 static inline int security_socket_listen(struct socket
* sock
, int backlog
)
2909 static inline int security_socket_accept(struct socket
* sock
,
2910 struct socket
* newsock
)
2915 static inline void security_socket_post_accept(struct socket
* sock
,
2916 struct socket
* newsock
)
2920 static inline int security_socket_sendmsg(struct socket
* sock
,
2921 struct msghdr
* msg
, int size
)
2926 static inline int security_socket_recvmsg(struct socket
* sock
,
2927 struct msghdr
* msg
, int size
,
2933 static inline int security_socket_getsockname(struct socket
* sock
)
2938 static inline int security_socket_getpeername(struct socket
* sock
)
2943 static inline int security_socket_getsockopt(struct socket
* sock
,
2944 int level
, int optname
)
2949 static inline int security_socket_setsockopt(struct socket
* sock
,
2950 int level
, int optname
)
2955 static inline int security_socket_shutdown(struct socket
* sock
, int how
)
2959 static inline int security_sock_rcv_skb (struct sock
* sk
,
2960 struct sk_buff
* skb
)
2965 static inline int security_socket_getpeersec_stream(struct socket
*sock
, char __user
*optval
,
2966 int __user
*optlen
, unsigned len
)
2968 return -ENOPROTOOPT
;
2971 static inline int security_socket_getpeersec_dgram(struct sk_buff
*skb
, char **secdata
,
2974 return -ENOPROTOOPT
;
2977 static inline int security_sk_alloc(struct sock
*sk
, int family
, gfp_t priority
)
2982 static inline void security_sk_free(struct sock
*sk
)
2986 static inline unsigned int security_sk_sid(struct sock
*sk
, struct flowi
*fl
, u8 dir
)
2990 #endif /* CONFIG_SECURITY_NETWORK */
2992 #ifdef CONFIG_SECURITY_NETWORK_XFRM
2993 static inline int security_xfrm_policy_alloc(struct xfrm_policy
*xp
, struct xfrm_user_sec_ctx
*sec_ctx
)
2995 return security_ops
->xfrm_policy_alloc_security(xp
, sec_ctx
);
2998 static inline int security_xfrm_policy_clone(struct xfrm_policy
*old
, struct xfrm_policy
*new)
3000 return security_ops
->xfrm_policy_clone_security(old
, new);
3003 static inline void security_xfrm_policy_free(struct xfrm_policy
*xp
)
3005 security_ops
->xfrm_policy_free_security(xp
);
3008 static inline int security_xfrm_policy_delete(struct xfrm_policy
*xp
)
3010 return security_ops
->xfrm_policy_delete_security(xp
);
3013 static inline int security_xfrm_state_alloc(struct xfrm_state
*x
, struct xfrm_user_sec_ctx
*sec_ctx
)
3015 return security_ops
->xfrm_state_alloc_security(x
, sec_ctx
);
3018 static inline int security_xfrm_state_delete(struct xfrm_state
*x
)
3020 return security_ops
->xfrm_state_delete_security(x
);
3023 static inline void security_xfrm_state_free(struct xfrm_state
*x
)
3025 security_ops
->xfrm_state_free_security(x
);
3028 static inline int security_xfrm_policy_lookup(struct xfrm_policy
*xp
, u32 sk_sid
, u8 dir
)
3030 return security_ops
->xfrm_policy_lookup(xp
, sk_sid
, dir
);
3032 #else /* CONFIG_SECURITY_NETWORK_XFRM */
3033 static inline int security_xfrm_policy_alloc(struct xfrm_policy
*xp
, struct xfrm_user_sec_ctx
*sec_ctx
)
3038 static inline int security_xfrm_policy_clone(struct xfrm_policy
*old
, struct xfrm_policy
*new)
3043 static inline void security_xfrm_policy_free(struct xfrm_policy
*xp
)
3047 static inline int security_xfrm_policy_delete(struct xfrm_policy
*xp
)
3052 static inline int security_xfrm_state_alloc(struct xfrm_state
*x
, struct xfrm_user_sec_ctx
*sec_ctx
)
3057 static inline void security_xfrm_state_free(struct xfrm_state
*x
)
3061 static inline int security_xfrm_state_delete(struct xfrm_state
*x
)
3066 static inline int security_xfrm_policy_lookup(struct xfrm_policy
*xp
, u32 sk_sid
, u8 dir
)
3070 #endif /* CONFIG_SECURITY_NETWORK_XFRM */
3073 #ifdef CONFIG_SECURITY
3074 static inline int security_key_alloc(struct key
*key
,
3075 struct task_struct
*tsk
,
3076 unsigned long flags
)
3078 return security_ops
->key_alloc(key
, tsk
, flags
);
3081 static inline void security_key_free(struct key
*key
)
3083 security_ops
->key_free(key
);
3086 static inline int security_key_permission(key_ref_t key_ref
,
3087 struct task_struct
*context
,
3090 return security_ops
->key_permission(key_ref
, context
, perm
);
3095 static inline int security_key_alloc(struct key
*key
,
3096 struct task_struct
*tsk
,
3097 unsigned long flags
)
3102 static inline void security_key_free(struct key
*key
)
3106 static inline int security_key_permission(key_ref_t key_ref
,
3107 struct task_struct
*context
,
3114 #endif /* CONFIG_KEYS */
3116 #endif /* ! __LINUX_SECURITY_H */