4 * Copyright (C) 2001 WireX Communications, Inc <chris@wirex.com>
5 * Copyright (C) 2001 Greg Kroah-Hartman <greg@kroah.com>
6 * Copyright (C) 2001 Networks Associates Technology, Inc <ssmalley@nai.com>
7 * Copyright (C) 2001 James Morris <jmorris@intercode.com.au>
8 * Copyright (C) 2001 Silicon Graphics, Inc. (Trust Technology Group)
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * Due to this file being licensed under the GPL there is controversy over
16 * whether this permits you to write a module that #includes this file
17 * without placing your module under the GPL. Please consult a lawyer for
18 * advice before doing this.
22 #ifndef __LINUX_SECURITY_H
23 #define __LINUX_SECURITY_H
26 #include <linux/binfmts.h>
27 #include <linux/signal.h>
28 #include <linux/resource.h>
29 #include <linux/sem.h>
30 #include <linux/shm.h>
31 #include <linux/msg.h>
32 #include <linux/sched.h>
33 #include <linux/key.h>
34 #include <linux/xfrm.h>
40 * These functions are in security/capability.c and are used
41 * as the default capabilities functions
43 extern int cap_capable (struct task_struct
*tsk
, int cap
);
44 extern int cap_settime (struct timespec
*ts
, struct timezone
*tz
);
45 extern int cap_ptrace (struct task_struct
*parent
, struct task_struct
*child
);
46 extern int cap_capget (struct task_struct
*target
, kernel_cap_t
*effective
, kernel_cap_t
*inheritable
, kernel_cap_t
*permitted
);
47 extern int cap_capset_check (struct task_struct
*target
, kernel_cap_t
*effective
, kernel_cap_t
*inheritable
, kernel_cap_t
*permitted
);
48 extern void cap_capset_set (struct task_struct
*target
, kernel_cap_t
*effective
, kernel_cap_t
*inheritable
, kernel_cap_t
*permitted
);
49 extern int cap_bprm_set_security (struct linux_binprm
*bprm
);
50 extern void cap_bprm_apply_creds (struct linux_binprm
*bprm
, int unsafe
);
51 extern int cap_bprm_secureexec(struct linux_binprm
*bprm
);
52 extern int cap_inode_setxattr(struct dentry
*dentry
, char *name
, void *value
, size_t size
, int flags
);
53 extern int cap_inode_removexattr(struct dentry
*dentry
, char *name
);
54 extern int cap_task_post_setuid (uid_t old_ruid
, uid_t old_euid
, uid_t old_suid
, int flags
);
55 extern void cap_task_reparent_to_init (struct task_struct
*p
);
56 extern int cap_syslog (int type
);
57 extern int cap_vm_enough_memory (long pages
);
69 struct xfrm_user_sec_ctx
;
71 extern int cap_netlink_send(struct sock
*sk
, struct sk_buff
*skb
);
72 extern int cap_netlink_recv(struct sk_buff
*skb
, int cap
);
75 * Values used in the task_security_ops calls
77 /* setuid or setgid, id0 == uid or gid */
78 #define LSM_SETID_ID 1
80 /* setreuid or setregid, id0 == real, id1 == eff */
81 #define LSM_SETID_RE 2
83 /* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
84 #define LSM_SETID_RES 4
86 /* setfsuid or setfsgid, id0 == fsuid or fsgid */
87 #define LSM_SETID_FS 8
89 /* forward declares to avoid warnings */
92 struct swap_info_struct
;
94 /* bprm_apply_creds unsafe reasons */
95 #define LSM_UNSAFE_SHARE 1
96 #define LSM_UNSAFE_PTRACE 2
97 #define LSM_UNSAFE_PTRACE_CAP 4
99 #ifdef CONFIG_SECURITY
102 * struct security_operations - main security structure
104 * Security hooks for program execution operations.
106 * @bprm_alloc_security:
107 * Allocate and attach a security structure to the @bprm->security field.
108 * The security field is initialized to NULL when the bprm structure is
110 * @bprm contains the linux_binprm structure to be modified.
111 * Return 0 if operation was successful.
112 * @bprm_free_security:
113 * @bprm contains the linux_binprm structure to be modified.
114 * Deallocate and clear the @bprm->security field.
116 * Compute and set the security attributes of a process being transformed
117 * by an execve operation based on the old attributes (current->security)
118 * and the information saved in @bprm->security by the set_security hook.
119 * Since this hook function (and its caller) are void, this hook can not
120 * return an error. However, it can leave the security attributes of the
121 * process unchanged if an access failure occurs at this point.
122 * bprm_apply_creds is called under task_lock. @unsafe indicates various
123 * reasons why it may be unsafe to change security state.
124 * @bprm contains the linux_binprm structure.
125 * @bprm_post_apply_creds:
126 * Runs after bprm_apply_creds with the task_lock dropped, so that
127 * functions which cannot be called safely under the task_lock can
128 * be used. This hook is a good place to perform state changes on
129 * the process such as closing open file descriptors to which access
130 * is no longer granted if the attributes were changed.
131 * Note that a security module might need to save state between
132 * bprm_apply_creds and bprm_post_apply_creds to store the decision
133 * on whether the process may proceed.
134 * @bprm contains the linux_binprm structure.
135 * @bprm_set_security:
136 * Save security information in the bprm->security field, typically based
137 * on information about the bprm->file, for later use by the apply_creds
138 * hook. This hook may also optionally check permissions (e.g. for
139 * transitions between security domains).
140 * This hook may be called multiple times during a single execve, e.g. for
141 * interpreters. The hook can tell whether it has already been called by
142 * checking to see if @bprm->security is non-NULL. If so, then the hook
143 * may decide either to retain the security information saved earlier or
145 * @bprm contains the linux_binprm structure.
146 * Return 0 if the hook is successful and permission is granted.
147 * @bprm_check_security:
148 * This hook mediates the point when a search for a binary handler will
149 * begin. It allows a check the @bprm->security value which is set in
150 * the preceding set_security call. The primary difference from
151 * set_security is that the argv list and envp list are reliably
152 * available in @bprm. This hook may be called multiple times
153 * during a single execve; and in each pass set_security is called
155 * @bprm contains the linux_binprm structure.
156 * Return 0 if the hook is successful and permission is granted.
158 * Return a boolean value (0 or 1) indicating whether a "secure exec"
159 * is required. The flag is passed in the auxiliary table
160 * on the initial stack to the ELF interpreter to indicate whether libc
161 * should enable secure mode.
162 * @bprm contains the linux_binprm structure.
164 * Security hooks for filesystem operations.
166 * @sb_alloc_security:
167 * Allocate and attach a security structure to the sb->s_security field.
168 * The s_security field is initialized to NULL when the structure is
170 * @sb contains the super_block structure to be modified.
171 * Return 0 if operation was successful.
173 * Deallocate and clear the sb->s_security field.
174 * @sb contains the super_block structure to be modified.
176 * Check permission before obtaining filesystem statistics for the @mnt
178 * @dentry is a handle on the superblock for the filesystem.
179 * Return 0 if permission is granted.
181 * Check permission before an object specified by @dev_name is mounted on
182 * the mount point named by @nd. For an ordinary mount, @dev_name
183 * identifies a device if the file system type requires a device. For a
184 * remount (@flags & MS_REMOUNT), @dev_name is irrelevant. For a
185 * loopback/bind mount (@flags & MS_BIND), @dev_name identifies the
186 * pathname of the object being mounted.
187 * @dev_name contains the name for object being mounted.
188 * @nd contains the nameidata structure for mount point object.
189 * @type contains the filesystem type.
190 * @flags contains the mount flags.
191 * @data contains the filesystem-specific data.
192 * Return 0 if permission is granted.
194 * Allow mount option data to be copied prior to parsing by the filesystem,
195 * so that the security module can extract security-specific mount
196 * options cleanly (a filesystem may modify the data e.g. with strsep()).
197 * This also allows the original mount data to be stripped of security-
198 * specific options to avoid having to make filesystems aware of them.
199 * @type the type of filesystem being mounted.
200 * @orig the original mount data copied from userspace.
201 * @copy copied data which will be passed to the security module.
202 * Returns 0 if the copy was successful.
204 * Check permission before the device with superblock @mnt->sb is mounted
205 * on the mount point named by @nd.
206 * @mnt contains the vfsmount for device being mounted.
207 * @nd contains the nameidata object for the mount point.
208 * Return 0 if permission is granted.
210 * Check permission before the @mnt file system is unmounted.
211 * @mnt contains the mounted file system.
212 * @flags contains the unmount flags, e.g. MNT_FORCE.
213 * Return 0 if permission is granted.
215 * Close any files in the @mnt mounted filesystem that are held open by
216 * the security module. This hook is called during an umount operation
217 * prior to checking whether the filesystem is still busy.
218 * @mnt contains the mounted filesystem.
220 * Handle a failed umount of the @mnt mounted filesystem, e.g. re-opening
221 * any files that were closed by umount_close. This hook is called during
222 * an umount operation if the umount fails after a call to the
224 * @mnt contains the mounted filesystem.
226 * Update the security module's state when a filesystem is remounted.
227 * This hook is only called if the remount was successful.
228 * @mnt contains the mounted file system.
229 * @flags contains the new filesystem flags.
230 * @data contains the filesystem-specific data.
231 * @sb_post_mountroot:
232 * Update the security module's state when the root filesystem is mounted.
233 * This hook is only called if the mount was successful.
235 * Update the security module's state when a filesystem is mounted.
236 * This hook is called any time a mount is successfully grafetd to
238 * @mnt contains the mounted filesystem.
239 * @mountpoint_nd contains the nameidata structure for the mount point.
241 * Check permission before pivoting the root filesystem.
242 * @old_nd contains the nameidata structure for the new location of the current root (put_old).
243 * @new_nd contains the nameidata structure for the new root (new_root).
244 * Return 0 if permission is granted.
245 * @sb_post_pivotroot:
246 * Update module state after a successful pivot.
247 * @old_nd contains the nameidata structure for the old root.
248 * @new_nd contains the nameidata structure for the new root.
250 * Security hooks for inode operations.
252 * @inode_alloc_security:
253 * Allocate and attach a security structure to @inode->i_security. The
254 * i_security field is initialized to NULL when the inode structure is
256 * @inode contains the inode structure.
257 * Return 0 if operation was successful.
258 * @inode_free_security:
259 * @inode contains the inode structure.
260 * Deallocate the inode security structure and set @inode->i_security to
262 * @inode_init_security:
263 * Obtain the security attribute name suffix and value to set on a newly
264 * created inode and set up the incore security field for the new inode.
265 * This hook is called by the fs code as part of the inode creation
266 * transaction and provides for atomic labeling of the inode, unlike
267 * the post_create/mkdir/... hooks called by the VFS. The hook function
268 * is expected to allocate the name and value via kmalloc, with the caller
269 * being responsible for calling kfree after using them.
270 * If the security module does not use security attributes or does
271 * not wish to put a security attribute on this particular inode,
272 * then it should return -EOPNOTSUPP to skip this processing.
273 * @inode contains the inode structure of the newly created inode.
274 * @dir contains the inode structure of the parent directory.
275 * @name will be set to the allocated name suffix (e.g. selinux).
276 * @value will be set to the allocated attribute value.
277 * @len will be set to the length of the value.
278 * Returns 0 if @name and @value have been successfully set,
279 * -EOPNOTSUPP if no security attribute is needed, or
280 * -ENOMEM on memory allocation failure.
282 * Check permission to create a regular file.
283 * @dir contains inode structure of the parent of the new file.
284 * @dentry contains the dentry structure for the file to be created.
285 * @mode contains the file mode of the file to be created.
286 * Return 0 if permission is granted.
288 * Check permission before creating a new hard link to a file.
289 * @old_dentry contains the dentry structure for an existing link to the file.
290 * @dir contains the inode structure of the parent directory of the new link.
291 * @new_dentry contains the dentry structure for the new link.
292 * Return 0 if permission is granted.
294 * Check the permission to remove a hard link to a file.
295 * @dir contains the inode structure of parent directory of the file.
296 * @dentry contains the dentry structure for file to be unlinked.
297 * Return 0 if permission is granted.
299 * Check the permission to create a symbolic link to a file.
300 * @dir contains the inode structure of parent directory of the symbolic link.
301 * @dentry contains the dentry structure of the symbolic link.
302 * @old_name contains the pathname of file.
303 * Return 0 if permission is granted.
305 * Check permissions to create a new directory in the existing directory
306 * associated with inode strcture @dir.
307 * @dir containst the inode structure of parent of the directory to be created.
308 * @dentry contains the dentry structure of new directory.
309 * @mode contains the mode of new directory.
310 * Return 0 if permission is granted.
312 * Check the permission to remove a directory.
313 * @dir contains the inode structure of parent of the directory to be removed.
314 * @dentry contains the dentry structure of directory to be removed.
315 * Return 0 if permission is granted.
317 * Check permissions when creating a special file (or a socket or a fifo
318 * file created via the mknod system call). Note that if mknod operation
319 * is being done for a regular file, then the create hook will be called
321 * @dir contains the inode structure of parent of the new file.
322 * @dentry contains the dentry structure of the new file.
323 * @mode contains the mode of the new file.
324 * @dev contains the the device number.
325 * Return 0 if permission is granted.
327 * Check for permission to rename a file or directory.
328 * @old_dir contains the inode structure for parent of the old link.
329 * @old_dentry contains the dentry structure of the old link.
330 * @new_dir contains the inode structure for parent of the new link.
331 * @new_dentry contains the dentry structure of the new link.
332 * Return 0 if permission is granted.
334 * Check the permission to read the symbolic link.
335 * @dentry contains the dentry structure for the file link.
336 * Return 0 if permission is granted.
337 * @inode_follow_link:
338 * Check permission to follow a symbolic link when looking up a pathname.
339 * @dentry contains the dentry structure for the link.
340 * @nd contains the nameidata structure for the parent directory.
341 * Return 0 if permission is granted.
343 * Check permission before accessing an inode. This hook is called by the
344 * existing Linux permission function, so a security module can use it to
345 * provide additional checking for existing Linux permission checks.
346 * Notice that this hook is called when a file is opened (as well as many
347 * other operations), whereas the file_security_ops permission hook is
348 * called when the actual read/write operations are performed.
349 * @inode contains the inode structure to check.
350 * @mask contains the permission mask.
351 * @nd contains the nameidata (may be NULL).
352 * Return 0 if permission is granted.
354 * Check permission before setting file attributes. Note that the kernel
355 * call to notify_change is performed from several locations, whenever
356 * file attributes change (such as when a file is truncated, chown/chmod
357 * operations, transferring disk quotas, etc).
358 * @dentry contains the dentry structure for the file.
359 * @attr is the iattr structure containing the new file attributes.
360 * Return 0 if permission is granted.
362 * Check permission before obtaining file attributes.
363 * @mnt is the vfsmount where the dentry was looked up
364 * @dentry contains the dentry structure for the file.
365 * Return 0 if permission is granted.
367 * @inode contains the inode structure for deleted inode.
368 * This hook is called when a deleted inode is released (i.e. an inode
369 * with no hard links has its use count drop to zero). A security module
370 * can use this hook to release any persistent label associated with the
373 * Check permission before setting the extended attributes
374 * @value identified by @name for @dentry.
375 * Return 0 if permission is granted.
376 * @inode_post_setxattr:
377 * Update inode security field after successful setxattr operation.
378 * @value identified by @name for @dentry.
380 * Check permission before obtaining the extended attributes
381 * identified by @name for @dentry.
382 * Return 0 if permission is granted.
384 * Check permission before obtaining the list of extended attribute
386 * Return 0 if permission is granted.
387 * @inode_removexattr:
388 * Check permission before removing the extended attribute
389 * identified by @name for @dentry.
390 * Return 0 if permission is granted.
391 * @inode_getsecurity:
392 * Copy the extended attribute representation of the security label
393 * associated with @name for @inode into @buffer. @buffer may be
394 * NULL to request the size of the buffer required. @size indicates
395 * the size of @buffer in bytes. Note that @name is the remainder
396 * of the attribute name after the security. prefix has been removed.
397 * @err is the return value from the preceding fs getxattr call,
398 * and can be used by the security module to determine whether it
399 * should try and canonicalize the attribute value.
400 * Return number of bytes used/required on success.
401 * @inode_setsecurity:
402 * Set the security label associated with @name for @inode from the
403 * extended attribute value @value. @size indicates the size of the
404 * @value in bytes. @flags may be XATTR_CREATE, XATTR_REPLACE, or 0.
405 * Note that @name is the remainder of the attribute name after the
406 * security. prefix has been removed.
407 * Return 0 on success.
408 * @inode_listsecurity:
409 * Copy the extended attribute names for the security labels
410 * associated with @inode into @buffer. The maximum size of @buffer
411 * is specified by @buffer_size. @buffer may be NULL to request
412 * the size of the buffer required.
413 * Returns number of bytes used/required on success.
415 * Security hooks for file operations
418 * Check file permissions before accessing an open file. This hook is
419 * called by various operations that read or write files. A security
420 * module can use this hook to perform additional checking on these
421 * operations, e.g. to revalidate permissions on use to support privilege
422 * bracketing or policy changes. Notice that this hook is used when the
423 * actual read/write operations are performed, whereas the
424 * inode_security_ops hook is called when a file is opened (as well as
425 * many other operations).
426 * Caveat: Although this hook can be used to revalidate permissions for
427 * various system call operations that read or write files, it does not
428 * address the revalidation of permissions for memory-mapped files.
429 * Security modules must handle this separately if they need such
431 * @file contains the file structure being accessed.
432 * @mask contains the requested permissions.
433 * Return 0 if permission is granted.
434 * @file_alloc_security:
435 * Allocate and attach a security structure to the file->f_security field.
436 * The security field is initialized to NULL when the structure is first
438 * @file contains the file structure to secure.
439 * Return 0 if the hook is successful and permission is granted.
440 * @file_free_security:
441 * Deallocate and free any security structures stored in file->f_security.
442 * @file contains the file structure being modified.
444 * @file contains the file structure.
445 * @cmd contains the operation to perform.
446 * @arg contains the operational arguments.
447 * Check permission for an ioctl operation on @file. Note that @arg can
448 * sometimes represents a user space pointer; in other cases, it may be a
449 * simple integer value. When @arg represents a user space pointer, it
450 * should never be used by the security module.
451 * Return 0 if permission is granted.
453 * Check permissions for a mmap operation. The @file may be NULL, e.g.
454 * if mapping anonymous memory.
455 * @file contains the file structure for file to map (may be NULL).
456 * @reqprot contains the protection requested by the application.
457 * @prot contains the protection that will be applied by the kernel.
458 * @flags contains the operational flags.
459 * Return 0 if permission is granted.
461 * Check permissions before changing memory access permissions.
462 * @vma contains the memory region to modify.
463 * @reqprot contains the protection requested by the application.
464 * @prot contains the protection that will be applied by the kernel.
465 * Return 0 if permission is granted.
467 * Check permission before performing file locking operations.
468 * Note: this hook mediates both flock and fcntl style locks.
469 * @file contains the file structure.
470 * @cmd contains the posix-translated lock operation to perform
471 * (e.g. F_RDLCK, F_WRLCK).
472 * Return 0 if permission is granted.
474 * Check permission before allowing the file operation specified by @cmd
475 * from being performed on the file @file. Note that @arg can sometimes
476 * represents a user space pointer; in other cases, it may be a simple
477 * integer value. When @arg represents a user space pointer, it should
478 * never be used by the security module.
479 * @file contains the file structure.
480 * @cmd contains the operation to be performed.
481 * @arg contains the operational arguments.
482 * Return 0 if permission is granted.
484 * Save owner security information (typically from current->security) in
485 * file->f_security for later use by the send_sigiotask hook.
486 * @file contains the file structure to update.
487 * Return 0 on success.
488 * @file_send_sigiotask:
489 * Check permission for the file owner @fown to send SIGIO or SIGURG to the
490 * process @tsk. Note that this hook is sometimes called from interrupt.
491 * Note that the fown_struct, @fown, is never outside the context of a
492 * struct file, so the file structure (and associated security information)
493 * can always be obtained:
494 * (struct file *)((long)fown - offsetof(struct file,f_owner));
495 * @tsk contains the structure of task receiving signal.
496 * @fown contains the file owner information.
497 * @sig is the signal that will be sent. When 0, kernel sends SIGIO.
498 * Return 0 if permission is granted.
500 * This hook allows security modules to control the ability of a process
501 * to receive an open file descriptor via socket IPC.
502 * @file contains the file structure being received.
503 * Return 0 if permission is granted.
505 * Security hooks for task operations.
508 * Check permission before creating a child process. See the clone(2)
509 * manual page for definitions of the @clone_flags.
510 * @clone_flags contains the flags indicating what should be shared.
511 * Return 0 if permission is granted.
512 * @task_alloc_security:
513 * @p contains the task_struct for child process.
514 * Allocate and attach a security structure to the p->security field. The
515 * security field is initialized to NULL when the task structure is
517 * Return 0 if operation was successful.
518 * @task_free_security:
519 * @p contains the task_struct for process.
520 * Deallocate and clear the p->security field.
522 * Check permission before setting one or more of the user identity
523 * attributes of the current process. The @flags parameter indicates
524 * which of the set*uid system calls invoked this hook and how to
525 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
526 * definitions at the beginning of this file for the @flags values and
528 * @id0 contains a uid.
529 * @id1 contains a uid.
530 * @id2 contains a uid.
531 * @flags contains one of the LSM_SETID_* values.
532 * Return 0 if permission is granted.
534 * Update the module's state after setting one or more of the user
535 * identity attributes of the current process. The @flags parameter
536 * indicates which of the set*uid system calls invoked this hook. If
537 * @flags is LSM_SETID_FS, then @old_ruid is the old fs uid and the other
538 * parameters are not used.
539 * @old_ruid contains the old real uid (or fs uid if LSM_SETID_FS).
540 * @old_euid contains the old effective uid (or -1 if LSM_SETID_FS).
541 * @old_suid contains the old saved uid (or -1 if LSM_SETID_FS).
542 * @flags contains one of the LSM_SETID_* values.
543 * Return 0 on success.
545 * Check permission before setting one or more of the group identity
546 * attributes of the current process. The @flags parameter indicates
547 * which of the set*gid system calls invoked this hook and how to
548 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
549 * definitions at the beginning of this file for the @flags values and
551 * @id0 contains a gid.
552 * @id1 contains a gid.
553 * @id2 contains a gid.
554 * @flags contains one of the LSM_SETID_* values.
555 * Return 0 if permission is granted.
557 * Check permission before setting the process group identifier of the
558 * process @p to @pgid.
559 * @p contains the task_struct for process being modified.
560 * @pgid contains the new pgid.
561 * Return 0 if permission is granted.
563 * Check permission before getting the process group identifier of the
565 * @p contains the task_struct for the process.
566 * Return 0 if permission is granted.
568 * Check permission before getting the session identifier of the process
570 * @p contains the task_struct for the process.
571 * Return 0 if permission is granted.
573 * Retrieve the security identifier of the process @p.
574 * @p contains the task_struct for the process and place is into @secid.
576 * Check permission before setting the supplementary group set of the
578 * @group_info contains the new group information.
579 * Return 0 if permission is granted.
581 * Check permission before setting the nice value of @p to @nice.
582 * @p contains the task_struct of process.
583 * @nice contains the new nice value.
584 * Return 0 if permission is granted.
586 * Check permission before setting the ioprio value of @p to @ioprio.
587 * @p contains the task_struct of process.
588 * @ioprio contains the new ioprio value
589 * Return 0 if permission is granted.
591 * Check permission before getting the ioprio value of @p.
592 * @p contains the task_struct of process.
593 * Return 0 if permission is granted.
595 * Check permission before setting the resource limits of the current
596 * process for @resource to @new_rlim. The old resource limit values can
597 * be examined by dereferencing (current->signal->rlim + resource).
598 * @resource contains the resource whose limit is being set.
599 * @new_rlim contains the new limits for @resource.
600 * Return 0 if permission is granted.
601 * @task_setscheduler:
602 * Check permission before setting scheduling policy and/or parameters of
603 * process @p based on @policy and @lp.
604 * @p contains the task_struct for process.
605 * @policy contains the scheduling policy.
606 * @lp contains the scheduling parameters.
607 * Return 0 if permission is granted.
608 * @task_getscheduler:
609 * Check permission before obtaining scheduling information for process
611 * @p contains the task_struct for process.
612 * Return 0 if permission is granted.
614 * Check permission before moving memory owned by process @p.
615 * @p contains the task_struct for process.
616 * Return 0 if permission is granted.
618 * Check permission before sending signal @sig to @p. @info can be NULL,
619 * the constant 1, or a pointer to a siginfo structure. If @info is 1 or
620 * SI_FROMKERNEL(info) is true, then the signal should be viewed as coming
621 * from the kernel and should typically be permitted.
622 * SIGIO signals are handled separately by the send_sigiotask hook in
624 * @p contains the task_struct for process.
625 * @info contains the signal information.
626 * @sig contains the signal value.
627 * @secid contains the sid of the process where the signal originated
628 * Return 0 if permission is granted.
630 * Check permission before allowing a process to reap a child process @p
631 * and collect its status information.
632 * @p contains the task_struct for process.
633 * Return 0 if permission is granted.
635 * Check permission before performing a process control operation on the
637 * @option contains the operation.
638 * @arg2 contains a argument.
639 * @arg3 contains a argument.
640 * @arg4 contains a argument.
641 * @arg5 contains a argument.
642 * Return 0 if permission is granted.
643 * @task_reparent_to_init:
644 * Set the security attributes in @p->security for a kernel thread that
645 * is being reparented to the init task.
646 * @p contains the task_struct for the kernel thread.
648 * Set the security attributes for an inode based on an associated task's
649 * security attributes, e.g. for /proc/pid inodes.
650 * @p contains the task_struct for the task.
651 * @inode contains the inode structure for the inode.
653 * Security hooks for Netlink messaging.
656 * Save security information for a netlink message so that permission
657 * checking can be performed when the message is processed. The security
658 * information can be saved using the eff_cap field of the
659 * netlink_skb_parms structure. Also may be used to provide fine
660 * grained control over message transmission.
661 * @sk associated sock of task sending the message.,
662 * @skb contains the sk_buff structure for the netlink message.
663 * Return 0 if the information was successfully saved and message
664 * is allowed to be transmitted.
666 * Check permission before processing the received netlink message in
668 * @skb contains the sk_buff structure for the netlink message.
669 * @cap indicates the capability required
670 * Return 0 if permission is granted.
672 * Security hooks for Unix domain networking.
674 * @unix_stream_connect:
675 * Check permissions before establishing a Unix domain stream connection
676 * between @sock and @other.
677 * @sock contains the socket structure.
678 * @other contains the peer socket structure.
679 * Return 0 if permission is granted.
681 * Check permissions before connecting or sending datagrams from @sock to
683 * @sock contains the socket structure.
684 * @sock contains the peer socket structure.
685 * Return 0 if permission is granted.
687 * The @unix_stream_connect and @unix_may_send hooks were necessary because
688 * Linux provides an alternative to the conventional file name space for Unix
689 * domain sockets. Whereas binding and connecting to sockets in the file name
690 * space is mediated by the typical file permissions (and caught by the mknod
691 * and permission hooks in inode_security_ops), binding and connecting to
692 * sockets in the abstract name space is completely unmediated. Sufficient
693 * control of Unix domain sockets in the abstract name space isn't possible
694 * using only the socket layer hooks, since we need to know the actual target
695 * socket, which is not looked up until we are inside the af_unix code.
697 * Security hooks for socket operations.
700 * Check permissions prior to creating a new socket.
701 * @family contains the requested protocol family.
702 * @type contains the requested communications type.
703 * @protocol contains the requested protocol.
704 * @kern set to 1 if a kernel socket.
705 * Return 0 if permission is granted.
706 * @socket_post_create:
707 * This hook allows a module to update or allocate a per-socket security
708 * structure. Note that the security field was not added directly to the
709 * socket structure, but rather, the socket security information is stored
710 * in the associated inode. Typically, the inode alloc_security hook will
711 * allocate and and attach security information to
712 * sock->inode->i_security. This hook may be used to update the
713 * sock->inode->i_security field with additional information that wasn't
714 * available when the inode was allocated.
715 * @sock contains the newly created socket structure.
716 * @family contains the requested protocol family.
717 * @type contains the requested communications type.
718 * @protocol contains the requested protocol.
719 * @kern set to 1 if a kernel socket.
721 * Check permission before socket protocol layer bind operation is
722 * performed and the socket @sock is bound to the address specified in the
723 * @address parameter.
724 * @sock contains the socket structure.
725 * @address contains the address to bind to.
726 * @addrlen contains the length of address.
727 * Return 0 if permission is granted.
729 * Check permission before socket protocol layer connect operation
730 * attempts to connect socket @sock to a remote address, @address.
731 * @sock contains the socket structure.
732 * @address contains the address of remote endpoint.
733 * @addrlen contains the length of address.
734 * Return 0 if permission is granted.
736 * Check permission before socket protocol layer listen operation.
737 * @sock contains the socket structure.
738 * @backlog contains the maximum length for the pending connection queue.
739 * Return 0 if permission is granted.
741 * Check permission before accepting a new connection. Note that the new
742 * socket, @newsock, has been created and some information copied to it,
743 * but the accept operation has not actually been performed.
744 * @sock contains the listening socket structure.
745 * @newsock contains the newly created server socket for connection.
746 * Return 0 if permission is granted.
747 * @socket_post_accept:
748 * This hook allows a security module to copy security
749 * information into the newly created socket's inode.
750 * @sock contains the listening socket structure.
751 * @newsock contains the newly created server socket for connection.
753 * Check permission before transmitting a message to another socket.
754 * @sock contains the socket structure.
755 * @msg contains the message to be transmitted.
756 * @size contains the size of message.
757 * Return 0 if permission is granted.
759 * Check permission before receiving a message from a socket.
760 * @sock contains the socket structure.
761 * @msg contains the message structure.
762 * @size contains the size of message structure.
763 * @flags contains the operational flags.
764 * Return 0 if permission is granted.
765 * @socket_getsockname:
766 * Check permission before the local address (name) of the socket object
767 * @sock is retrieved.
768 * @sock contains the socket structure.
769 * Return 0 if permission is granted.
770 * @socket_getpeername:
771 * Check permission before the remote address (name) of a socket object
772 * @sock is retrieved.
773 * @sock contains the socket structure.
774 * Return 0 if permission is granted.
775 * @socket_getsockopt:
776 * Check permissions before retrieving the options associated with socket
778 * @sock contains the socket structure.
779 * @level contains the protocol level to retrieve option from.
780 * @optname contains the name of option to retrieve.
781 * Return 0 if permission is granted.
782 * @socket_setsockopt:
783 * Check permissions before setting the options associated with socket
785 * @sock contains the socket structure.
786 * @level contains the protocol level to set options for.
787 * @optname contains the name of the option to set.
788 * Return 0 if permission is granted.
790 * Checks permission before all or part of a connection on the socket
791 * @sock is shut down.
792 * @sock contains the socket structure.
793 * @how contains the flag indicating how future sends and receives are handled.
794 * Return 0 if permission is granted.
795 * @socket_sock_rcv_skb:
796 * Check permissions on incoming network packets. This hook is distinct
797 * from Netfilter's IP input hooks since it is the first time that the
798 * incoming sk_buff @skb has been associated with a particular socket, @sk.
799 * @sk contains the sock (not socket) associated with the incoming sk_buff.
800 * @skb contains the incoming network data.
801 * @socket_getpeersec:
802 * This hook allows the security module to provide peer socket security
803 * state to userspace via getsockopt SO_GETPEERSEC.
804 * @sock is the local socket.
805 * @optval userspace memory where the security state is to be copied.
806 * @optlen userspace int where the module should copy the actual length
807 * of the security state.
808 * @len as input is the maximum length to copy to userspace provided
810 * Return 0 if all is well, otherwise, typical getsockopt return
812 * @sk_alloc_security:
813 * Allocate and attach a security structure to the sk->sk_security field,
814 * which is used to copy security attributes between local stream sockets.
816 * Deallocate security structure.
817 * @sk_clone_security:
818 * Clone/copy security structure.
820 * Retrieve the LSM-specific secid for the sock to enable caching of network
823 * Security hooks for XFRM operations.
825 * @xfrm_policy_alloc_security:
826 * @xp contains the xfrm_policy being added to Security Policy Database
827 * used by the XFRM system.
828 * @sec_ctx contains the security context information being provided by
829 * the user-level policy update program (e.g., setkey).
830 * Allocate a security structure to the xp->security field; the security
831 * field is initialized to NULL when the xfrm_policy is allocated.
832 * Return 0 if operation was successful (memory to allocate, legal context)
833 * @xfrm_policy_clone_security:
834 * @old contains an existing xfrm_policy in the SPD.
835 * @new contains a new xfrm_policy being cloned from old.
836 * Allocate a security structure to the new->security field
837 * that contains the information from the old->security field.
838 * Return 0 if operation was successful (memory to allocate).
839 * @xfrm_policy_free_security:
840 * @xp contains the xfrm_policy
841 * Deallocate xp->security.
842 * @xfrm_policy_delete_security:
843 * @xp contains the xfrm_policy.
844 * Authorize deletion of xp->security.
845 * @xfrm_state_alloc_security:
846 * @x contains the xfrm_state being added to the Security Association
847 * Database by the XFRM system.
848 * @sec_ctx contains the security context information being provided by
849 * the user-level SA generation program (e.g., setkey or racoon).
850 * @polsec contains the security context information associated with a xfrm
851 * policy rule from which to take the base context. polsec must be NULL
852 * when sec_ctx is specified.
853 * @secid contains the secid from which to take the mls portion of the context.
854 * Allocate a security structure to the x->security field; the security
855 * field is initialized to NULL when the xfrm_state is allocated. Set the
856 * context to correspond to either sec_ctx or polsec, with the mls portion
857 * taken from secid in the latter case.
858 * Return 0 if operation was successful (memory to allocate, legal context).
859 * @xfrm_state_free_security:
860 * @x contains the xfrm_state.
861 * Deallocate x->security.
862 * @xfrm_state_delete_security:
863 * @x contains the xfrm_state.
864 * Authorize deletion of x->security.
865 * @xfrm_policy_lookup:
866 * @xp contains the xfrm_policy for which the access control is being
868 * @fl_secid contains the flow security label that is used to authorize
869 * access to the policy xp.
870 * @dir contains the direction of the flow (input or output).
871 * Check permission when a flow selects a xfrm_policy for processing
872 * XFRMs on a packet. The hook is called when selecting either a
873 * per-socket policy or a generic xfrm policy.
874 * Return 0 if permission is granted.
875 * @xfrm_state_pol_flow_match:
876 * @x contains the state to match.
877 * @xp contains the policy to check for a match.
878 * @fl contains the flow to check for a match.
879 * Return 1 if there is a match.
880 * @xfrm_flow_state_match:
881 * @fl contains the flow key to match.
882 * @xfrm points to the xfrm_state to match.
883 * Return 1 if there is a match.
884 * @xfrm_decode_session:
885 * @skb points to skb to decode.
886 * @secid points to the flow key secid to set.
887 * @ckall says if all xfrms used should be checked for same secid.
888 * Return 0 if ckall is zero or all xfrms used have the same secid.
890 * Security hooks affecting all Key Management operations
893 * Permit allocation of a key and assign security data. Note that key does
894 * not have a serial number assigned at this point.
895 * @key points to the key.
896 * @flags is the allocation flags
897 * Return 0 if permission is granted, -ve error otherwise.
899 * Notification of destruction; free security data.
900 * @key points to the key.
903 * See whether a specific operational right is granted to a process on a
905 * @key_ref refers to the key (key pointer + possession attribute bit).
906 * @context points to the process to provide the context against which to
907 * evaluate the security data on the key.
908 * @perm describes the combination of permissions required of this key.
909 * Return 1 if permission granted, 0 if permission denied and -ve it the
910 * normal permissions model should be effected.
912 * Security hooks affecting all System V IPC operations.
915 * Check permissions for access to IPC
916 * @ipcp contains the kernel IPC permission structure
917 * @flag contains the desired (requested) permission set
918 * Return 0 if permission is granted.
920 * Security hooks for individual messages held in System V IPC message queues
921 * @msg_msg_alloc_security:
922 * Allocate and attach a security structure to the msg->security field.
923 * The security field is initialized to NULL when the structure is first
925 * @msg contains the message structure to be modified.
926 * Return 0 if operation was successful and permission is granted.
927 * @msg_msg_free_security:
928 * Deallocate the security structure for this message.
929 * @msg contains the message structure to be modified.
931 * Security hooks for System V IPC Message Queues
933 * @msg_queue_alloc_security:
934 * Allocate and attach a security structure to the
935 * msq->q_perm.security field. The security field is initialized to
936 * NULL when the structure is first created.
937 * @msq contains the message queue structure to be modified.
938 * Return 0 if operation was successful and permission is granted.
939 * @msg_queue_free_security:
940 * Deallocate security structure for this message queue.
941 * @msq contains the message queue structure to be modified.
942 * @msg_queue_associate:
943 * Check permission when a message queue is requested through the
944 * msgget system call. This hook is only called when returning the
945 * message queue identifier for an existing message queue, not when a
946 * new message queue is created.
947 * @msq contains the message queue to act upon.
948 * @msqflg contains the operation control flags.
949 * Return 0 if permission is granted.
951 * Check permission when a message control operation specified by @cmd
952 * is to be performed on the message queue @msq.
953 * The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO.
954 * @msq contains the message queue to act upon. May be NULL.
955 * @cmd contains the operation to be performed.
956 * Return 0 if permission is granted.
958 * Check permission before a message, @msg, is enqueued on the message
960 * @msq contains the message queue to send message to.
961 * @msg contains the message to be enqueued.
962 * @msqflg contains operational flags.
963 * Return 0 if permission is granted.
965 * Check permission before a message, @msg, is removed from the message
966 * queue, @msq. The @target task structure contains a pointer to the
967 * process that will be receiving the message (not equal to the current
968 * process when inline receives are being performed).
969 * @msq contains the message queue to retrieve message from.
970 * @msg contains the message destination.
971 * @target contains the task structure for recipient process.
972 * @type contains the type of message requested.
973 * @mode contains the operational flags.
974 * Return 0 if permission is granted.
976 * Security hooks for System V Shared Memory Segments
978 * @shm_alloc_security:
979 * Allocate and attach a security structure to the shp->shm_perm.security
980 * field. The security field is initialized to NULL when the structure is
982 * @shp contains the shared memory structure to be modified.
983 * Return 0 if operation was successful and permission is granted.
984 * @shm_free_security:
985 * Deallocate the security struct for this memory segment.
986 * @shp contains the shared memory structure to be modified.
988 * Check permission when a shared memory region is requested through the
989 * shmget system call. This hook is only called when returning the shared
990 * memory region identifier for an existing region, not when a new shared
991 * memory region is created.
992 * @shp contains the shared memory structure to be modified.
993 * @shmflg contains the operation control flags.
994 * Return 0 if permission is granted.
996 * Check permission when a shared memory control operation specified by
997 * @cmd is to be performed on the shared memory region @shp.
998 * The @shp may be NULL, e.g. for IPC_INFO or SHM_INFO.
999 * @shp contains shared memory structure to be modified.
1000 * @cmd contains the operation to be performed.
1001 * Return 0 if permission is granted.
1003 * Check permissions prior to allowing the shmat system call to attach the
1004 * shared memory segment @shp to the data segment of the calling process.
1005 * The attaching address is specified by @shmaddr.
1006 * @shp contains the shared memory structure to be modified.
1007 * @shmaddr contains the address to attach memory region to.
1008 * @shmflg contains the operational flags.
1009 * Return 0 if permission is granted.
1011 * Security hooks for System V Semaphores
1013 * @sem_alloc_security:
1014 * Allocate and attach a security structure to the sma->sem_perm.security
1015 * field. The security field is initialized to NULL when the structure is
1017 * @sma contains the semaphore structure
1018 * Return 0 if operation was successful and permission is granted.
1019 * @sem_free_security:
1020 * deallocate security struct for this semaphore
1021 * @sma contains the semaphore structure.
1023 * Check permission when a semaphore is requested through the semget
1024 * system call. This hook is only called when returning the semaphore
1025 * identifier for an existing semaphore, not when a new one must be
1027 * @sma contains the semaphore structure.
1028 * @semflg contains the operation control flags.
1029 * Return 0 if permission is granted.
1031 * Check permission when a semaphore operation specified by @cmd is to be
1032 * performed on the semaphore @sma. The @sma may be NULL, e.g. for
1033 * IPC_INFO or SEM_INFO.
1034 * @sma contains the semaphore structure. May be NULL.
1035 * @cmd contains the operation to be performed.
1036 * Return 0 if permission is granted.
1038 * Check permissions before performing operations on members of the
1039 * semaphore set @sma. If the @alter flag is nonzero, the semaphore set
1041 * @sma contains the semaphore structure.
1042 * @sops contains the operations to perform.
1043 * @nsops contains the number of operations to perform.
1044 * @alter contains the flag indicating whether changes are to be made.
1045 * Return 0 if permission is granted.
1048 * Check permission before allowing the @parent process to trace the
1050 * Security modules may also want to perform a process tracing check
1051 * during an execve in the set_security or apply_creds hooks of
1052 * binprm_security_ops if the process is being traced and its security
1053 * attributes would be changed by the execve.
1054 * @parent contains the task_struct structure for parent process.
1055 * @child contains the task_struct structure for child process.
1056 * Return 0 if permission is granted.
1058 * Get the @effective, @inheritable, and @permitted capability sets for
1059 * the @target process. The hook may also perform permission checking to
1060 * determine if the current process is allowed to see the capability sets
1061 * of the @target process.
1062 * @target contains the task_struct structure for target process.
1063 * @effective contains the effective capability set.
1064 * @inheritable contains the inheritable capability set.
1065 * @permitted contains the permitted capability set.
1066 * Return 0 if the capability sets were successfully obtained.
1068 * Check permission before setting the @effective, @inheritable, and
1069 * @permitted capability sets for the @target process.
1070 * Caveat: @target is also set to current if a set of processes is
1071 * specified (i.e. all processes other than current and init or a
1072 * particular process group). Hence, the capset_set hook may need to
1073 * revalidate permission to the actual target process.
1074 * @target contains the task_struct structure for target process.
1075 * @effective contains the effective capability set.
1076 * @inheritable contains the inheritable capability set.
1077 * @permitted contains the permitted capability set.
1078 * Return 0 if permission is granted.
1080 * Set the @effective, @inheritable, and @permitted capability sets for
1081 * the @target process. Since capset_check cannot always check permission
1082 * to the real @target process, this hook may also perform permission
1083 * checking to determine if the current process is allowed to set the
1084 * capability sets of the @target process. However, this hook has no way
1085 * of returning an error due to the structure of the sys_capset code.
1086 * @target contains the task_struct structure for target process.
1087 * @effective contains the effective capability set.
1088 * @inheritable contains the inheritable capability set.
1089 * @permitted contains the permitted capability set.
1091 * Check whether the @tsk process has the @cap capability.
1092 * @tsk contains the task_struct for the process.
1093 * @cap contains the capability <include/linux/capability.h>.
1094 * Return 0 if the capability is granted for @tsk.
1096 * Check permission before enabling or disabling process accounting. If
1097 * accounting is being enabled, then @file refers to the open file used to
1098 * store accounting records. If accounting is being disabled, then @file
1100 * @file contains the file structure for the accounting file (may be NULL).
1101 * Return 0 if permission is granted.
1103 * Check permission before accessing the @table sysctl variable in the
1104 * manner specified by @op.
1105 * @table contains the ctl_table structure for the sysctl variable.
1106 * @op contains the operation (001 = search, 002 = write, 004 = read).
1107 * Return 0 if permission is granted.
1109 * Check permission before accessing the kernel message ring or changing
1110 * logging to the console.
1111 * See the syslog(2) manual page for an explanation of the @type values.
1112 * @type contains the type of action.
1113 * Return 0 if permission is granted.
1115 * Check permission to change the system time.
1116 * struct timespec and timezone are defined in include/linux/time.h
1117 * @ts contains new time
1118 * @tz contains new timezone
1119 * Return 0 if permission is granted.
1120 * @vm_enough_memory:
1121 * Check permissions for allocating a new virtual mapping.
1122 * @pages contains the number of pages.
1123 * Return 0 if permission is granted.
1125 * @register_security:
1126 * allow module stacking.
1127 * @name contains the name of the security module being stacked.
1128 * @ops contains a pointer to the struct security_operations of the module to stack.
1129 * @unregister_security:
1130 * remove a stacked module.
1131 * @name contains the name of the security module being unstacked.
1132 * @ops contains a pointer to the struct security_operations of the module to unstack.
1135 * Convert secid to security context.
1136 * @secid contains the security ID.
1137 * @secdata contains the pointer that stores the converted security context.
1140 * Release the security context.
1141 * @secdata contains the security context.
1142 * @seclen contains the length of the security context.
1144 * This is the main security structure.
1146 struct security_operations
{
1147 int (*ptrace
) (struct task_struct
* parent
, struct task_struct
* child
);
1148 int (*capget
) (struct task_struct
* target
,
1149 kernel_cap_t
* effective
,
1150 kernel_cap_t
* inheritable
, kernel_cap_t
* permitted
);
1151 int (*capset_check
) (struct task_struct
* target
,
1152 kernel_cap_t
* effective
,
1153 kernel_cap_t
* inheritable
,
1154 kernel_cap_t
* permitted
);
1155 void (*capset_set
) (struct task_struct
* target
,
1156 kernel_cap_t
* effective
,
1157 kernel_cap_t
* inheritable
,
1158 kernel_cap_t
* permitted
);
1159 int (*capable
) (struct task_struct
* tsk
, int cap
);
1160 int (*acct
) (struct file
* file
);
1161 int (*sysctl
) (struct ctl_table
* table
, int op
);
1162 int (*quotactl
) (int cmds
, int type
, int id
, struct super_block
* sb
);
1163 int (*quota_on
) (struct dentry
* dentry
);
1164 int (*syslog
) (int type
);
1165 int (*settime
) (struct timespec
*ts
, struct timezone
*tz
);
1166 int (*vm_enough_memory
) (long pages
);
1168 int (*bprm_alloc_security
) (struct linux_binprm
* bprm
);
1169 void (*bprm_free_security
) (struct linux_binprm
* bprm
);
1170 void (*bprm_apply_creds
) (struct linux_binprm
* bprm
, int unsafe
);
1171 void (*bprm_post_apply_creds
) (struct linux_binprm
* bprm
);
1172 int (*bprm_set_security
) (struct linux_binprm
* bprm
);
1173 int (*bprm_check_security
) (struct linux_binprm
* bprm
);
1174 int (*bprm_secureexec
) (struct linux_binprm
* bprm
);
1176 int (*sb_alloc_security
) (struct super_block
* sb
);
1177 void (*sb_free_security
) (struct super_block
* sb
);
1178 int (*sb_copy_data
)(struct file_system_type
*type
,
1179 void *orig
, void *copy
);
1180 int (*sb_kern_mount
) (struct super_block
*sb
, void *data
);
1181 int (*sb_statfs
) (struct dentry
*dentry
);
1182 int (*sb_mount
) (char *dev_name
, struct nameidata
* nd
,
1183 char *type
, unsigned long flags
, void *data
);
1184 int (*sb_check_sb
) (struct vfsmount
* mnt
, struct nameidata
* nd
);
1185 int (*sb_umount
) (struct vfsmount
* mnt
, int flags
);
1186 void (*sb_umount_close
) (struct vfsmount
* mnt
);
1187 void (*sb_umount_busy
) (struct vfsmount
* mnt
);
1188 void (*sb_post_remount
) (struct vfsmount
* mnt
,
1189 unsigned long flags
, void *data
);
1190 void (*sb_post_mountroot
) (void);
1191 void (*sb_post_addmount
) (struct vfsmount
* mnt
,
1192 struct nameidata
* mountpoint_nd
);
1193 int (*sb_pivotroot
) (struct nameidata
* old_nd
,
1194 struct nameidata
* new_nd
);
1195 void (*sb_post_pivotroot
) (struct nameidata
* old_nd
,
1196 struct nameidata
* new_nd
);
1198 int (*inode_alloc_security
) (struct inode
*inode
);
1199 void (*inode_free_security
) (struct inode
*inode
);
1200 int (*inode_init_security
) (struct inode
*inode
, struct inode
*dir
,
1201 char **name
, void **value
, size_t *len
);
1202 int (*inode_create
) (struct inode
*dir
,
1203 struct dentry
*dentry
, int mode
);
1204 int (*inode_link
) (struct dentry
*old_dentry
,
1205 struct inode
*dir
, struct dentry
*new_dentry
);
1206 int (*inode_unlink
) (struct inode
*dir
, struct dentry
*dentry
);
1207 int (*inode_symlink
) (struct inode
*dir
,
1208 struct dentry
*dentry
, const char *old_name
);
1209 int (*inode_mkdir
) (struct inode
*dir
, struct dentry
*dentry
, int mode
);
1210 int (*inode_rmdir
) (struct inode
*dir
, struct dentry
*dentry
);
1211 int (*inode_mknod
) (struct inode
*dir
, struct dentry
*dentry
,
1212 int mode
, dev_t dev
);
1213 int (*inode_rename
) (struct inode
*old_dir
, struct dentry
*old_dentry
,
1214 struct inode
*new_dir
, struct dentry
*new_dentry
);
1215 int (*inode_readlink
) (struct dentry
*dentry
);
1216 int (*inode_follow_link
) (struct dentry
*dentry
, struct nameidata
*nd
);
1217 int (*inode_permission
) (struct inode
*inode
, int mask
, struct nameidata
*nd
);
1218 int (*inode_setattr
) (struct dentry
*dentry
, struct iattr
*attr
);
1219 int (*inode_getattr
) (struct vfsmount
*mnt
, struct dentry
*dentry
);
1220 void (*inode_delete
) (struct inode
*inode
);
1221 int (*inode_setxattr
) (struct dentry
*dentry
, char *name
, void *value
,
1222 size_t size
, int flags
);
1223 void (*inode_post_setxattr
) (struct dentry
*dentry
, char *name
, void *value
,
1224 size_t size
, int flags
);
1225 int (*inode_getxattr
) (struct dentry
*dentry
, char *name
);
1226 int (*inode_listxattr
) (struct dentry
*dentry
);
1227 int (*inode_removexattr
) (struct dentry
*dentry
, char *name
);
1228 const char *(*inode_xattr_getsuffix
) (void);
1229 int (*inode_getsecurity
)(const struct inode
*inode
, const char *name
, void *buffer
, size_t size
, int err
);
1230 int (*inode_setsecurity
)(struct inode
*inode
, const char *name
, const void *value
, size_t size
, int flags
);
1231 int (*inode_listsecurity
)(struct inode
*inode
, char *buffer
, size_t buffer_size
);
1233 int (*file_permission
) (struct file
* file
, int mask
);
1234 int (*file_alloc_security
) (struct file
* file
);
1235 void (*file_free_security
) (struct file
* file
);
1236 int (*file_ioctl
) (struct file
* file
, unsigned int cmd
,
1238 int (*file_mmap
) (struct file
* file
,
1239 unsigned long reqprot
,
1240 unsigned long prot
, unsigned long flags
);
1241 int (*file_mprotect
) (struct vm_area_struct
* vma
,
1242 unsigned long reqprot
,
1243 unsigned long prot
);
1244 int (*file_lock
) (struct file
* file
, unsigned int cmd
);
1245 int (*file_fcntl
) (struct file
* file
, unsigned int cmd
,
1247 int (*file_set_fowner
) (struct file
* file
);
1248 int (*file_send_sigiotask
) (struct task_struct
* tsk
,
1249 struct fown_struct
* fown
, int sig
);
1250 int (*file_receive
) (struct file
* file
);
1252 int (*task_create
) (unsigned long clone_flags
);
1253 int (*task_alloc_security
) (struct task_struct
* p
);
1254 void (*task_free_security
) (struct task_struct
* p
);
1255 int (*task_setuid
) (uid_t id0
, uid_t id1
, uid_t id2
, int flags
);
1256 int (*task_post_setuid
) (uid_t old_ruid
/* or fsuid */ ,
1257 uid_t old_euid
, uid_t old_suid
, int flags
);
1258 int (*task_setgid
) (gid_t id0
, gid_t id1
, gid_t id2
, int flags
);
1259 int (*task_setpgid
) (struct task_struct
* p
, pid_t pgid
);
1260 int (*task_getpgid
) (struct task_struct
* p
);
1261 int (*task_getsid
) (struct task_struct
* p
);
1262 void (*task_getsecid
) (struct task_struct
* p
, u32
* secid
);
1263 int (*task_setgroups
) (struct group_info
*group_info
);
1264 int (*task_setnice
) (struct task_struct
* p
, int nice
);
1265 int (*task_setioprio
) (struct task_struct
* p
, int ioprio
);
1266 int (*task_getioprio
) (struct task_struct
* p
);
1267 int (*task_setrlimit
) (unsigned int resource
, struct rlimit
* new_rlim
);
1268 int (*task_setscheduler
) (struct task_struct
* p
, int policy
,
1269 struct sched_param
* lp
);
1270 int (*task_getscheduler
) (struct task_struct
* p
);
1271 int (*task_movememory
) (struct task_struct
* p
);
1272 int (*task_kill
) (struct task_struct
* p
,
1273 struct siginfo
* info
, int sig
, u32 secid
);
1274 int (*task_wait
) (struct task_struct
* p
);
1275 int (*task_prctl
) (int option
, unsigned long arg2
,
1276 unsigned long arg3
, unsigned long arg4
,
1277 unsigned long arg5
);
1278 void (*task_reparent_to_init
) (struct task_struct
* p
);
1279 void (*task_to_inode
)(struct task_struct
*p
, struct inode
*inode
);
1281 int (*ipc_permission
) (struct kern_ipc_perm
* ipcp
, short flag
);
1283 int (*msg_msg_alloc_security
) (struct msg_msg
* msg
);
1284 void (*msg_msg_free_security
) (struct msg_msg
* msg
);
1286 int (*msg_queue_alloc_security
) (struct msg_queue
* msq
);
1287 void (*msg_queue_free_security
) (struct msg_queue
* msq
);
1288 int (*msg_queue_associate
) (struct msg_queue
* msq
, int msqflg
);
1289 int (*msg_queue_msgctl
) (struct msg_queue
* msq
, int cmd
);
1290 int (*msg_queue_msgsnd
) (struct msg_queue
* msq
,
1291 struct msg_msg
* msg
, int msqflg
);
1292 int (*msg_queue_msgrcv
) (struct msg_queue
* msq
,
1293 struct msg_msg
* msg
,
1294 struct task_struct
* target
,
1295 long type
, int mode
);
1297 int (*shm_alloc_security
) (struct shmid_kernel
* shp
);
1298 void (*shm_free_security
) (struct shmid_kernel
* shp
);
1299 int (*shm_associate
) (struct shmid_kernel
* shp
, int shmflg
);
1300 int (*shm_shmctl
) (struct shmid_kernel
* shp
, int cmd
);
1301 int (*shm_shmat
) (struct shmid_kernel
* shp
,
1302 char __user
*shmaddr
, int shmflg
);
1304 int (*sem_alloc_security
) (struct sem_array
* sma
);
1305 void (*sem_free_security
) (struct sem_array
* sma
);
1306 int (*sem_associate
) (struct sem_array
* sma
, int semflg
);
1307 int (*sem_semctl
) (struct sem_array
* sma
, int cmd
);
1308 int (*sem_semop
) (struct sem_array
* sma
,
1309 struct sembuf
* sops
, unsigned nsops
, int alter
);
1311 int (*netlink_send
) (struct sock
* sk
, struct sk_buff
* skb
);
1312 int (*netlink_recv
) (struct sk_buff
* skb
, int cap
);
1314 /* allow module stacking */
1315 int (*register_security
) (const char *name
,
1316 struct security_operations
*ops
);
1317 int (*unregister_security
) (const char *name
,
1318 struct security_operations
*ops
);
1320 void (*d_instantiate
) (struct dentry
*dentry
, struct inode
*inode
);
1322 int (*getprocattr
)(struct task_struct
*p
, char *name
, void *value
, size_t size
);
1323 int (*setprocattr
)(struct task_struct
*p
, char *name
, void *value
, size_t size
);
1324 int (*secid_to_secctx
)(u32 secid
, char **secdata
, u32
*seclen
);
1325 void (*release_secctx
)(char *secdata
, u32 seclen
);
1327 #ifdef CONFIG_SECURITY_NETWORK
1328 int (*unix_stream_connect
) (struct socket
* sock
,
1329 struct socket
* other
, struct sock
* newsk
);
1330 int (*unix_may_send
) (struct socket
* sock
, struct socket
* other
);
1332 int (*socket_create
) (int family
, int type
, int protocol
, int kern
);
1333 void (*socket_post_create
) (struct socket
* sock
, int family
,
1334 int type
, int protocol
, int kern
);
1335 int (*socket_bind
) (struct socket
* sock
,
1336 struct sockaddr
* address
, int addrlen
);
1337 int (*socket_connect
) (struct socket
* sock
,
1338 struct sockaddr
* address
, int addrlen
);
1339 int (*socket_listen
) (struct socket
* sock
, int backlog
);
1340 int (*socket_accept
) (struct socket
* sock
, struct socket
* newsock
);
1341 void (*socket_post_accept
) (struct socket
* sock
,
1342 struct socket
* newsock
);
1343 int (*socket_sendmsg
) (struct socket
* sock
,
1344 struct msghdr
* msg
, int size
);
1345 int (*socket_recvmsg
) (struct socket
* sock
,
1346 struct msghdr
* msg
, int size
, int flags
);
1347 int (*socket_getsockname
) (struct socket
* sock
);
1348 int (*socket_getpeername
) (struct socket
* sock
);
1349 int (*socket_getsockopt
) (struct socket
* sock
, int level
, int optname
);
1350 int (*socket_setsockopt
) (struct socket
* sock
, int level
, int optname
);
1351 int (*socket_shutdown
) (struct socket
* sock
, int how
);
1352 int (*socket_sock_rcv_skb
) (struct sock
* sk
, struct sk_buff
* skb
);
1353 int (*socket_getpeersec_stream
) (struct socket
*sock
, char __user
*optval
, int __user
*optlen
, unsigned len
);
1354 int (*socket_getpeersec_dgram
) (struct socket
*sock
, struct sk_buff
*skb
, u32
*secid
);
1355 int (*sk_alloc_security
) (struct sock
*sk
, int family
, gfp_t priority
);
1356 void (*sk_free_security
) (struct sock
*sk
);
1357 void (*sk_clone_security
) (const struct sock
*sk
, struct sock
*newsk
);
1358 void (*sk_getsecid
) (struct sock
*sk
, u32
*secid
);
1359 #endif /* CONFIG_SECURITY_NETWORK */
1361 #ifdef CONFIG_SECURITY_NETWORK_XFRM
1362 int (*xfrm_policy_alloc_security
) (struct xfrm_policy
*xp
, struct xfrm_user_sec_ctx
*sec_ctx
);
1363 int (*xfrm_policy_clone_security
) (struct xfrm_policy
*old
, struct xfrm_policy
*new);
1364 void (*xfrm_policy_free_security
) (struct xfrm_policy
*xp
);
1365 int (*xfrm_policy_delete_security
) (struct xfrm_policy
*xp
);
1366 int (*xfrm_state_alloc_security
) (struct xfrm_state
*x
,
1367 struct xfrm_user_sec_ctx
*sec_ctx
, struct xfrm_sec_ctx
*polsec
,
1369 void (*xfrm_state_free_security
) (struct xfrm_state
*x
);
1370 int (*xfrm_state_delete_security
) (struct xfrm_state
*x
);
1371 int (*xfrm_policy_lookup
)(struct xfrm_policy
*xp
, u32 fl_secid
, u8 dir
);
1372 int (*xfrm_state_pol_flow_match
)(struct xfrm_state
*x
,
1373 struct xfrm_policy
*xp
, struct flowi
*fl
);
1374 int (*xfrm_flow_state_match
)(struct flowi
*fl
, struct xfrm_state
*xfrm
);
1375 int (*xfrm_decode_session
)(struct sk_buff
*skb
, u32
*secid
, int ckall
);
1376 #endif /* CONFIG_SECURITY_NETWORK_XFRM */
1378 /* key management security hooks */
1380 int (*key_alloc
)(struct key
*key
, struct task_struct
*tsk
, unsigned long flags
);
1381 void (*key_free
)(struct key
*key
);
1382 int (*key_permission
)(key_ref_t key_ref
,
1383 struct task_struct
*context
,
1386 #endif /* CONFIG_KEYS */
1390 /* global variables */
1391 extern struct security_operations
*security_ops
;
1394 static inline int security_ptrace (struct task_struct
* parent
, struct task_struct
* child
)
1396 return security_ops
->ptrace (parent
, child
);
1399 static inline int security_capget (struct task_struct
*target
,
1400 kernel_cap_t
*effective
,
1401 kernel_cap_t
*inheritable
,
1402 kernel_cap_t
*permitted
)
1404 return security_ops
->capget (target
, effective
, inheritable
, permitted
);
1407 static inline int security_capset_check (struct task_struct
*target
,
1408 kernel_cap_t
*effective
,
1409 kernel_cap_t
*inheritable
,
1410 kernel_cap_t
*permitted
)
1412 return security_ops
->capset_check (target
, effective
, inheritable
, permitted
);
1415 static inline void security_capset_set (struct task_struct
*target
,
1416 kernel_cap_t
*effective
,
1417 kernel_cap_t
*inheritable
,
1418 kernel_cap_t
*permitted
)
1420 security_ops
->capset_set (target
, effective
, inheritable
, permitted
);
1423 static inline int security_capable(struct task_struct
*tsk
, int cap
)
1425 return security_ops
->capable(tsk
, cap
);
1428 static inline int security_acct (struct file
*file
)
1430 return security_ops
->acct (file
);
1433 static inline int security_sysctl(struct ctl_table
*table
, int op
)
1435 return security_ops
->sysctl(table
, op
);
1438 static inline int security_quotactl (int cmds
, int type
, int id
,
1439 struct super_block
*sb
)
1441 return security_ops
->quotactl (cmds
, type
, id
, sb
);
1444 static inline int security_quota_on (struct dentry
* dentry
)
1446 return security_ops
->quota_on (dentry
);
1449 static inline int security_syslog(int type
)
1451 return security_ops
->syslog(type
);
1454 static inline int security_settime(struct timespec
*ts
, struct timezone
*tz
)
1456 return security_ops
->settime(ts
, tz
);
1460 static inline int security_vm_enough_memory(long pages
)
1462 return security_ops
->vm_enough_memory(pages
);
1465 static inline int security_bprm_alloc (struct linux_binprm
*bprm
)
1467 return security_ops
->bprm_alloc_security (bprm
);
1469 static inline void security_bprm_free (struct linux_binprm
*bprm
)
1471 security_ops
->bprm_free_security (bprm
);
1473 static inline void security_bprm_apply_creds (struct linux_binprm
*bprm
, int unsafe
)
1475 security_ops
->bprm_apply_creds (bprm
, unsafe
);
1477 static inline void security_bprm_post_apply_creds (struct linux_binprm
*bprm
)
1479 security_ops
->bprm_post_apply_creds (bprm
);
1481 static inline int security_bprm_set (struct linux_binprm
*bprm
)
1483 return security_ops
->bprm_set_security (bprm
);
1486 static inline int security_bprm_check (struct linux_binprm
*bprm
)
1488 return security_ops
->bprm_check_security (bprm
);
1491 static inline int security_bprm_secureexec (struct linux_binprm
*bprm
)
1493 return security_ops
->bprm_secureexec (bprm
);
1496 static inline int security_sb_alloc (struct super_block
*sb
)
1498 return security_ops
->sb_alloc_security (sb
);
1501 static inline void security_sb_free (struct super_block
*sb
)
1503 security_ops
->sb_free_security (sb
);
1506 static inline int security_sb_copy_data (struct file_system_type
*type
,
1507 void *orig
, void *copy
)
1509 return security_ops
->sb_copy_data (type
, orig
, copy
);
1512 static inline int security_sb_kern_mount (struct super_block
*sb
, void *data
)
1514 return security_ops
->sb_kern_mount (sb
, data
);
1517 static inline int security_sb_statfs (struct dentry
*dentry
)
1519 return security_ops
->sb_statfs (dentry
);
1522 static inline int security_sb_mount (char *dev_name
, struct nameidata
*nd
,
1523 char *type
, unsigned long flags
,
1526 return security_ops
->sb_mount (dev_name
, nd
, type
, flags
, data
);
1529 static inline int security_sb_check_sb (struct vfsmount
*mnt
,
1530 struct nameidata
*nd
)
1532 return security_ops
->sb_check_sb (mnt
, nd
);
1535 static inline int security_sb_umount (struct vfsmount
*mnt
, int flags
)
1537 return security_ops
->sb_umount (mnt
, flags
);
1540 static inline void security_sb_umount_close (struct vfsmount
*mnt
)
1542 security_ops
->sb_umount_close (mnt
);
1545 static inline void security_sb_umount_busy (struct vfsmount
*mnt
)
1547 security_ops
->sb_umount_busy (mnt
);
1550 static inline void security_sb_post_remount (struct vfsmount
*mnt
,
1551 unsigned long flags
, void *data
)
1553 security_ops
->sb_post_remount (mnt
, flags
, data
);
1556 static inline void security_sb_post_mountroot (void)
1558 security_ops
->sb_post_mountroot ();
1561 static inline void security_sb_post_addmount (struct vfsmount
*mnt
,
1562 struct nameidata
*mountpoint_nd
)
1564 security_ops
->sb_post_addmount (mnt
, mountpoint_nd
);
1567 static inline int security_sb_pivotroot (struct nameidata
*old_nd
,
1568 struct nameidata
*new_nd
)
1570 return security_ops
->sb_pivotroot (old_nd
, new_nd
);
1573 static inline void security_sb_post_pivotroot (struct nameidata
*old_nd
,
1574 struct nameidata
*new_nd
)
1576 security_ops
->sb_post_pivotroot (old_nd
, new_nd
);
1579 static inline int security_inode_alloc (struct inode
*inode
)
1581 return security_ops
->inode_alloc_security (inode
);
1584 static inline void security_inode_free (struct inode
*inode
)
1586 security_ops
->inode_free_security (inode
);
1589 static inline int security_inode_init_security (struct inode
*inode
,
1595 if (unlikely (IS_PRIVATE (inode
)))
1597 return security_ops
->inode_init_security (inode
, dir
, name
, value
, len
);
1600 static inline int security_inode_create (struct inode
*dir
,
1601 struct dentry
*dentry
,
1604 if (unlikely (IS_PRIVATE (dir
)))
1606 return security_ops
->inode_create (dir
, dentry
, mode
);
1609 static inline int security_inode_link (struct dentry
*old_dentry
,
1611 struct dentry
*new_dentry
)
1613 if (unlikely (IS_PRIVATE (old_dentry
->d_inode
)))
1615 return security_ops
->inode_link (old_dentry
, dir
, new_dentry
);
1618 static inline int security_inode_unlink (struct inode
*dir
,
1619 struct dentry
*dentry
)
1621 if (unlikely (IS_PRIVATE (dentry
->d_inode
)))
1623 return security_ops
->inode_unlink (dir
, dentry
);
1626 static inline int security_inode_symlink (struct inode
*dir
,
1627 struct dentry
*dentry
,
1628 const char *old_name
)
1630 if (unlikely (IS_PRIVATE (dir
)))
1632 return security_ops
->inode_symlink (dir
, dentry
, old_name
);
1635 static inline int security_inode_mkdir (struct inode
*dir
,
1636 struct dentry
*dentry
,
1639 if (unlikely (IS_PRIVATE (dir
)))
1641 return security_ops
->inode_mkdir (dir
, dentry
, mode
);
1644 static inline int security_inode_rmdir (struct inode
*dir
,
1645 struct dentry
*dentry
)
1647 if (unlikely (IS_PRIVATE (dentry
->d_inode
)))
1649 return security_ops
->inode_rmdir (dir
, dentry
);
1652 static inline int security_inode_mknod (struct inode
*dir
,
1653 struct dentry
*dentry
,
1654 int mode
, dev_t dev
)
1656 if (unlikely (IS_PRIVATE (dir
)))
1658 return security_ops
->inode_mknod (dir
, dentry
, mode
, dev
);
1661 static inline int security_inode_rename (struct inode
*old_dir
,
1662 struct dentry
*old_dentry
,
1663 struct inode
*new_dir
,
1664 struct dentry
*new_dentry
)
1666 if (unlikely (IS_PRIVATE (old_dentry
->d_inode
) ||
1667 (new_dentry
->d_inode
&& IS_PRIVATE (new_dentry
->d_inode
))))
1669 return security_ops
->inode_rename (old_dir
, old_dentry
,
1670 new_dir
, new_dentry
);
1673 static inline int security_inode_readlink (struct dentry
*dentry
)
1675 if (unlikely (IS_PRIVATE (dentry
->d_inode
)))
1677 return security_ops
->inode_readlink (dentry
);
1680 static inline int security_inode_follow_link (struct dentry
*dentry
,
1681 struct nameidata
*nd
)
1683 if (unlikely (IS_PRIVATE (dentry
->d_inode
)))
1685 return security_ops
->inode_follow_link (dentry
, nd
);
1688 static inline int security_inode_permission (struct inode
*inode
, int mask
,
1689 struct nameidata
*nd
)
1691 if (unlikely (IS_PRIVATE (inode
)))
1693 return security_ops
->inode_permission (inode
, mask
, nd
);
1696 static inline int security_inode_setattr (struct dentry
*dentry
,
1699 if (unlikely (IS_PRIVATE (dentry
->d_inode
)))
1701 return security_ops
->inode_setattr (dentry
, attr
);
1704 static inline int security_inode_getattr (struct vfsmount
*mnt
,
1705 struct dentry
*dentry
)
1707 if (unlikely (IS_PRIVATE (dentry
->d_inode
)))
1709 return security_ops
->inode_getattr (mnt
, dentry
);
1712 static inline void security_inode_delete (struct inode
*inode
)
1714 if (unlikely (IS_PRIVATE (inode
)))
1716 security_ops
->inode_delete (inode
);
1719 static inline int security_inode_setxattr (struct dentry
*dentry
, char *name
,
1720 void *value
, size_t size
, int flags
)
1722 if (unlikely (IS_PRIVATE (dentry
->d_inode
)))
1724 return security_ops
->inode_setxattr (dentry
, name
, value
, size
, flags
);
1727 static inline void security_inode_post_setxattr (struct dentry
*dentry
, char *name
,
1728 void *value
, size_t size
, int flags
)
1730 if (unlikely (IS_PRIVATE (dentry
->d_inode
)))
1732 security_ops
->inode_post_setxattr (dentry
, name
, value
, size
, flags
);
1735 static inline int security_inode_getxattr (struct dentry
*dentry
, char *name
)
1737 if (unlikely (IS_PRIVATE (dentry
->d_inode
)))
1739 return security_ops
->inode_getxattr (dentry
, name
);
1742 static inline int security_inode_listxattr (struct dentry
*dentry
)
1744 if (unlikely (IS_PRIVATE (dentry
->d_inode
)))
1746 return security_ops
->inode_listxattr (dentry
);
1749 static inline int security_inode_removexattr (struct dentry
*dentry
, char *name
)
1751 if (unlikely (IS_PRIVATE (dentry
->d_inode
)))
1753 return security_ops
->inode_removexattr (dentry
, name
);
1756 static inline const char *security_inode_xattr_getsuffix(void)
1758 return security_ops
->inode_xattr_getsuffix();
1761 static inline int security_inode_getsecurity(const struct inode
*inode
, const char *name
, void *buffer
, size_t size
, int err
)
1763 if (unlikely (IS_PRIVATE (inode
)))
1765 return security_ops
->inode_getsecurity(inode
, name
, buffer
, size
, err
);
1768 static inline int security_inode_setsecurity(struct inode
*inode
, const char *name
, const void *value
, size_t size
, int flags
)
1770 if (unlikely (IS_PRIVATE (inode
)))
1772 return security_ops
->inode_setsecurity(inode
, name
, value
, size
, flags
);
1775 static inline int security_inode_listsecurity(struct inode
*inode
, char *buffer
, size_t buffer_size
)
1777 if (unlikely (IS_PRIVATE (inode
)))
1779 return security_ops
->inode_listsecurity(inode
, buffer
, buffer_size
);
1782 static inline int security_file_permission (struct file
*file
, int mask
)
1784 return security_ops
->file_permission (file
, mask
);
1787 static inline int security_file_alloc (struct file
*file
)
1789 return security_ops
->file_alloc_security (file
);
1792 static inline void security_file_free (struct file
*file
)
1794 security_ops
->file_free_security (file
);
1797 static inline int security_file_ioctl (struct file
*file
, unsigned int cmd
,
1800 return security_ops
->file_ioctl (file
, cmd
, arg
);
1803 static inline int security_file_mmap (struct file
*file
, unsigned long reqprot
,
1805 unsigned long flags
)
1807 return security_ops
->file_mmap (file
, reqprot
, prot
, flags
);
1810 static inline int security_file_mprotect (struct vm_area_struct
*vma
,
1811 unsigned long reqprot
,
1814 return security_ops
->file_mprotect (vma
, reqprot
, prot
);
1817 static inline int security_file_lock (struct file
*file
, unsigned int cmd
)
1819 return security_ops
->file_lock (file
, cmd
);
1822 static inline int security_file_fcntl (struct file
*file
, unsigned int cmd
,
1825 return security_ops
->file_fcntl (file
, cmd
, arg
);
1828 static inline int security_file_set_fowner (struct file
*file
)
1830 return security_ops
->file_set_fowner (file
);
1833 static inline int security_file_send_sigiotask (struct task_struct
*tsk
,
1834 struct fown_struct
*fown
,
1837 return security_ops
->file_send_sigiotask (tsk
, fown
, sig
);
1840 static inline int security_file_receive (struct file
*file
)
1842 return security_ops
->file_receive (file
);
1845 static inline int security_task_create (unsigned long clone_flags
)
1847 return security_ops
->task_create (clone_flags
);
1850 static inline int security_task_alloc (struct task_struct
*p
)
1852 return security_ops
->task_alloc_security (p
);
1855 static inline void security_task_free (struct task_struct
*p
)
1857 security_ops
->task_free_security (p
);
1860 static inline int security_task_setuid (uid_t id0
, uid_t id1
, uid_t id2
,
1863 return security_ops
->task_setuid (id0
, id1
, id2
, flags
);
1866 static inline int security_task_post_setuid (uid_t old_ruid
, uid_t old_euid
,
1867 uid_t old_suid
, int flags
)
1869 return security_ops
->task_post_setuid (old_ruid
, old_euid
, old_suid
, flags
);
1872 static inline int security_task_setgid (gid_t id0
, gid_t id1
, gid_t id2
,
1875 return security_ops
->task_setgid (id0
, id1
, id2
, flags
);
1878 static inline int security_task_setpgid (struct task_struct
*p
, pid_t pgid
)
1880 return security_ops
->task_setpgid (p
, pgid
);
1883 static inline int security_task_getpgid (struct task_struct
*p
)
1885 return security_ops
->task_getpgid (p
);
1888 static inline int security_task_getsid (struct task_struct
*p
)
1890 return security_ops
->task_getsid (p
);
1893 static inline void security_task_getsecid (struct task_struct
*p
, u32
*secid
)
1895 security_ops
->task_getsecid (p
, secid
);
1898 static inline int security_task_setgroups (struct group_info
*group_info
)
1900 return security_ops
->task_setgroups (group_info
);
1903 static inline int security_task_setnice (struct task_struct
*p
, int nice
)
1905 return security_ops
->task_setnice (p
, nice
);
1908 static inline int security_task_setioprio (struct task_struct
*p
, int ioprio
)
1910 return security_ops
->task_setioprio (p
, ioprio
);
1913 static inline int security_task_getioprio (struct task_struct
*p
)
1915 return security_ops
->task_getioprio (p
);
1918 static inline int security_task_setrlimit (unsigned int resource
,
1919 struct rlimit
*new_rlim
)
1921 return security_ops
->task_setrlimit (resource
, new_rlim
);
1924 static inline int security_task_setscheduler (struct task_struct
*p
,
1926 struct sched_param
*lp
)
1928 return security_ops
->task_setscheduler (p
, policy
, lp
);
1931 static inline int security_task_getscheduler (struct task_struct
*p
)
1933 return security_ops
->task_getscheduler (p
);
1936 static inline int security_task_movememory (struct task_struct
*p
)
1938 return security_ops
->task_movememory (p
);
1941 static inline int security_task_kill (struct task_struct
*p
,
1942 struct siginfo
*info
, int sig
,
1945 return security_ops
->task_kill (p
, info
, sig
, secid
);
1948 static inline int security_task_wait (struct task_struct
*p
)
1950 return security_ops
->task_wait (p
);
1953 static inline int security_task_prctl (int option
, unsigned long arg2
,
1958 return security_ops
->task_prctl (option
, arg2
, arg3
, arg4
, arg5
);
1961 static inline void security_task_reparent_to_init (struct task_struct
*p
)
1963 security_ops
->task_reparent_to_init (p
);
1966 static inline void security_task_to_inode(struct task_struct
*p
, struct inode
*inode
)
1968 security_ops
->task_to_inode(p
, inode
);
1971 static inline int security_ipc_permission (struct kern_ipc_perm
*ipcp
,
1974 return security_ops
->ipc_permission (ipcp
, flag
);
1977 static inline int security_msg_msg_alloc (struct msg_msg
* msg
)
1979 return security_ops
->msg_msg_alloc_security (msg
);
1982 static inline void security_msg_msg_free (struct msg_msg
* msg
)
1984 security_ops
->msg_msg_free_security(msg
);
1987 static inline int security_msg_queue_alloc (struct msg_queue
*msq
)
1989 return security_ops
->msg_queue_alloc_security (msq
);
1992 static inline void security_msg_queue_free (struct msg_queue
*msq
)
1994 security_ops
->msg_queue_free_security (msq
);
1997 static inline int security_msg_queue_associate (struct msg_queue
* msq
,
2000 return security_ops
->msg_queue_associate (msq
, msqflg
);
2003 static inline int security_msg_queue_msgctl (struct msg_queue
* msq
, int cmd
)
2005 return security_ops
->msg_queue_msgctl (msq
, cmd
);
2008 static inline int security_msg_queue_msgsnd (struct msg_queue
* msq
,
2009 struct msg_msg
* msg
, int msqflg
)
2011 return security_ops
->msg_queue_msgsnd (msq
, msg
, msqflg
);
2014 static inline int security_msg_queue_msgrcv (struct msg_queue
* msq
,
2015 struct msg_msg
* msg
,
2016 struct task_struct
* target
,
2017 long type
, int mode
)
2019 return security_ops
->msg_queue_msgrcv (msq
, msg
, target
, type
, mode
);
2022 static inline int security_shm_alloc (struct shmid_kernel
*shp
)
2024 return security_ops
->shm_alloc_security (shp
);
2027 static inline void security_shm_free (struct shmid_kernel
*shp
)
2029 security_ops
->shm_free_security (shp
);
2032 static inline int security_shm_associate (struct shmid_kernel
* shp
,
2035 return security_ops
->shm_associate(shp
, shmflg
);
2038 static inline int security_shm_shmctl (struct shmid_kernel
* shp
, int cmd
)
2040 return security_ops
->shm_shmctl (shp
, cmd
);
2043 static inline int security_shm_shmat (struct shmid_kernel
* shp
,
2044 char __user
*shmaddr
, int shmflg
)
2046 return security_ops
->shm_shmat(shp
, shmaddr
, shmflg
);
2049 static inline int security_sem_alloc (struct sem_array
*sma
)
2051 return security_ops
->sem_alloc_security (sma
);
2054 static inline void security_sem_free (struct sem_array
*sma
)
2056 security_ops
->sem_free_security (sma
);
2059 static inline int security_sem_associate (struct sem_array
* sma
, int semflg
)
2061 return security_ops
->sem_associate (sma
, semflg
);
2064 static inline int security_sem_semctl (struct sem_array
* sma
, int cmd
)
2066 return security_ops
->sem_semctl(sma
, cmd
);
2069 static inline int security_sem_semop (struct sem_array
* sma
,
2070 struct sembuf
* sops
, unsigned nsops
,
2073 return security_ops
->sem_semop(sma
, sops
, nsops
, alter
);
2076 static inline void security_d_instantiate (struct dentry
*dentry
, struct inode
*inode
)
2078 if (unlikely (inode
&& IS_PRIVATE (inode
)))
2080 security_ops
->d_instantiate (dentry
, inode
);
2083 static inline int security_getprocattr(struct task_struct
*p
, char *name
, void *value
, size_t size
)
2085 return security_ops
->getprocattr(p
, name
, value
, size
);
2088 static inline int security_setprocattr(struct task_struct
*p
, char *name
, void *value
, size_t size
)
2090 return security_ops
->setprocattr(p
, name
, value
, size
);
2093 static inline int security_netlink_send(struct sock
*sk
, struct sk_buff
* skb
)
2095 return security_ops
->netlink_send(sk
, skb
);
2098 static inline int security_netlink_recv(struct sk_buff
* skb
, int cap
)
2100 return security_ops
->netlink_recv(skb
, cap
);
2103 static inline int security_secid_to_secctx(u32 secid
, char **secdata
, u32
*seclen
)
2105 return security_ops
->secid_to_secctx(secid
, secdata
, seclen
);
2108 static inline void security_release_secctx(char *secdata
, u32 seclen
)
2110 return security_ops
->release_secctx(secdata
, seclen
);
2114 extern int security_init (void);
2115 extern int register_security (struct security_operations
*ops
);
2116 extern int unregister_security (struct security_operations
*ops
);
2117 extern int mod_reg_security (const char *name
, struct security_operations
*ops
);
2118 extern int mod_unreg_security (const char *name
, struct security_operations
*ops
);
2119 extern struct dentry
*securityfs_create_file(const char *name
, mode_t mode
,
2120 struct dentry
*parent
, void *data
,
2121 struct file_operations
*fops
);
2122 extern struct dentry
*securityfs_create_dir(const char *name
, struct dentry
*parent
);
2123 extern void securityfs_remove(struct dentry
*dentry
);
2126 #else /* CONFIG_SECURITY */
2129 * This is the default capabilities functionality. Most of these functions
2130 * are just stubbed out, but a few must call the proper capable code.
2133 static inline int security_init(void)
2138 static inline int security_ptrace (struct task_struct
*parent
, struct task_struct
* child
)
2140 return cap_ptrace (parent
, child
);
2143 static inline int security_capget (struct task_struct
*target
,
2144 kernel_cap_t
*effective
,
2145 kernel_cap_t
*inheritable
,
2146 kernel_cap_t
*permitted
)
2148 return cap_capget (target
, effective
, inheritable
, permitted
);
2151 static inline int security_capset_check (struct task_struct
*target
,
2152 kernel_cap_t
*effective
,
2153 kernel_cap_t
*inheritable
,
2154 kernel_cap_t
*permitted
)
2156 return cap_capset_check (target
, effective
, inheritable
, permitted
);
2159 static inline void security_capset_set (struct task_struct
*target
,
2160 kernel_cap_t
*effective
,
2161 kernel_cap_t
*inheritable
,
2162 kernel_cap_t
*permitted
)
2164 cap_capset_set (target
, effective
, inheritable
, permitted
);
2167 static inline int security_capable(struct task_struct
*tsk
, int cap
)
2169 return cap_capable(tsk
, cap
);
2172 static inline int security_acct (struct file
*file
)
2177 static inline int security_sysctl(struct ctl_table
*table
, int op
)
2182 static inline int security_quotactl (int cmds
, int type
, int id
,
2183 struct super_block
* sb
)
2188 static inline int security_quota_on (struct dentry
* dentry
)
2193 static inline int security_syslog(int type
)
2195 return cap_syslog(type
);
2198 static inline int security_settime(struct timespec
*ts
, struct timezone
*tz
)
2200 return cap_settime(ts
, tz
);
2203 static inline int security_vm_enough_memory(long pages
)
2205 return cap_vm_enough_memory(pages
);
2208 static inline int security_bprm_alloc (struct linux_binprm
*bprm
)
2213 static inline void security_bprm_free (struct linux_binprm
*bprm
)
2216 static inline void security_bprm_apply_creds (struct linux_binprm
*bprm
, int unsafe
)
2218 cap_bprm_apply_creds (bprm
, unsafe
);
2221 static inline void security_bprm_post_apply_creds (struct linux_binprm
*bprm
)
2226 static inline int security_bprm_set (struct linux_binprm
*bprm
)
2228 return cap_bprm_set_security (bprm
);
2231 static inline int security_bprm_check (struct linux_binprm
*bprm
)
2236 static inline int security_bprm_secureexec (struct linux_binprm
*bprm
)
2238 return cap_bprm_secureexec(bprm
);
2241 static inline int security_sb_alloc (struct super_block
*sb
)
2246 static inline void security_sb_free (struct super_block
*sb
)
2249 static inline int security_sb_copy_data (struct file_system_type
*type
,
2250 void *orig
, void *copy
)
2255 static inline int security_sb_kern_mount (struct super_block
*sb
, void *data
)
2260 static inline int security_sb_statfs (struct dentry
*dentry
)
2265 static inline int security_sb_mount (char *dev_name
, struct nameidata
*nd
,
2266 char *type
, unsigned long flags
,
2272 static inline int security_sb_check_sb (struct vfsmount
*mnt
,
2273 struct nameidata
*nd
)
2278 static inline int security_sb_umount (struct vfsmount
*mnt
, int flags
)
2283 static inline void security_sb_umount_close (struct vfsmount
*mnt
)
2286 static inline void security_sb_umount_busy (struct vfsmount
*mnt
)
2289 static inline void security_sb_post_remount (struct vfsmount
*mnt
,
2290 unsigned long flags
, void *data
)
2293 static inline void security_sb_post_mountroot (void)
2296 static inline void security_sb_post_addmount (struct vfsmount
*mnt
,
2297 struct nameidata
*mountpoint_nd
)
2300 static inline int security_sb_pivotroot (struct nameidata
*old_nd
,
2301 struct nameidata
*new_nd
)
2306 static inline void security_sb_post_pivotroot (struct nameidata
*old_nd
,
2307 struct nameidata
*new_nd
)
2310 static inline int security_inode_alloc (struct inode
*inode
)
2315 static inline void security_inode_free (struct inode
*inode
)
2318 static inline int security_inode_init_security (struct inode
*inode
,
2327 static inline int security_inode_create (struct inode
*dir
,
2328 struct dentry
*dentry
,
2334 static inline int security_inode_link (struct dentry
*old_dentry
,
2336 struct dentry
*new_dentry
)
2341 static inline int security_inode_unlink (struct inode
*dir
,
2342 struct dentry
*dentry
)
2347 static inline int security_inode_symlink (struct inode
*dir
,
2348 struct dentry
*dentry
,
2349 const char *old_name
)
2354 static inline int security_inode_mkdir (struct inode
*dir
,
2355 struct dentry
*dentry
,
2361 static inline int security_inode_rmdir (struct inode
*dir
,
2362 struct dentry
*dentry
)
2367 static inline int security_inode_mknod (struct inode
*dir
,
2368 struct dentry
*dentry
,
2369 int mode
, dev_t dev
)
2374 static inline int security_inode_rename (struct inode
*old_dir
,
2375 struct dentry
*old_dentry
,
2376 struct inode
*new_dir
,
2377 struct dentry
*new_dentry
)
2382 static inline int security_inode_readlink (struct dentry
*dentry
)
2387 static inline int security_inode_follow_link (struct dentry
*dentry
,
2388 struct nameidata
*nd
)
2393 static inline int security_inode_permission (struct inode
*inode
, int mask
,
2394 struct nameidata
*nd
)
2399 static inline int security_inode_setattr (struct dentry
*dentry
,
2405 static inline int security_inode_getattr (struct vfsmount
*mnt
,
2406 struct dentry
*dentry
)
2411 static inline void security_inode_delete (struct inode
*inode
)
2414 static inline int security_inode_setxattr (struct dentry
*dentry
, char *name
,
2415 void *value
, size_t size
, int flags
)
2417 return cap_inode_setxattr(dentry
, name
, value
, size
, flags
);
2420 static inline void security_inode_post_setxattr (struct dentry
*dentry
, char *name
,
2421 void *value
, size_t size
, int flags
)
2424 static inline int security_inode_getxattr (struct dentry
*dentry
, char *name
)
2429 static inline int security_inode_listxattr (struct dentry
*dentry
)
2434 static inline int security_inode_removexattr (struct dentry
*dentry
, char *name
)
2436 return cap_inode_removexattr(dentry
, name
);
2439 static inline const char *security_inode_xattr_getsuffix (void)
2444 static inline int security_inode_getsecurity(const struct inode
*inode
, const char *name
, void *buffer
, size_t size
, int err
)
2449 static inline int security_inode_setsecurity(struct inode
*inode
, const char *name
, const void *value
, size_t size
, int flags
)
2454 static inline int security_inode_listsecurity(struct inode
*inode
, char *buffer
, size_t buffer_size
)
2459 static inline int security_file_permission (struct file
*file
, int mask
)
2464 static inline int security_file_alloc (struct file
*file
)
2469 static inline void security_file_free (struct file
*file
)
2472 static inline int security_file_ioctl (struct file
*file
, unsigned int cmd
,
2478 static inline int security_file_mmap (struct file
*file
, unsigned long reqprot
,
2480 unsigned long flags
)
2485 static inline int security_file_mprotect (struct vm_area_struct
*vma
,
2486 unsigned long reqprot
,
2492 static inline int security_file_lock (struct file
*file
, unsigned int cmd
)
2497 static inline int security_file_fcntl (struct file
*file
, unsigned int cmd
,
2503 static inline int security_file_set_fowner (struct file
*file
)
2508 static inline int security_file_send_sigiotask (struct task_struct
*tsk
,
2509 struct fown_struct
*fown
,
2515 static inline int security_file_receive (struct file
*file
)
2520 static inline int security_task_create (unsigned long clone_flags
)
2525 static inline int security_task_alloc (struct task_struct
*p
)
2530 static inline void security_task_free (struct task_struct
*p
)
2533 static inline int security_task_setuid (uid_t id0
, uid_t id1
, uid_t id2
,
2539 static inline int security_task_post_setuid (uid_t old_ruid
, uid_t old_euid
,
2540 uid_t old_suid
, int flags
)
2542 return cap_task_post_setuid (old_ruid
, old_euid
, old_suid
, flags
);
2545 static inline int security_task_setgid (gid_t id0
, gid_t id1
, gid_t id2
,
2551 static inline int security_task_setpgid (struct task_struct
*p
, pid_t pgid
)
2556 static inline int security_task_getpgid (struct task_struct
*p
)
2561 static inline int security_task_getsid (struct task_struct
*p
)
2566 static inline void security_task_getsecid (struct task_struct
*p
, u32
*secid
)
2569 static inline int security_task_setgroups (struct group_info
*group_info
)
2574 static inline int security_task_setnice (struct task_struct
*p
, int nice
)
2579 static inline int security_task_setioprio (struct task_struct
*p
, int ioprio
)
2584 static inline int security_task_getioprio (struct task_struct
*p
)
2589 static inline int security_task_setrlimit (unsigned int resource
,
2590 struct rlimit
*new_rlim
)
2595 static inline int security_task_setscheduler (struct task_struct
*p
,
2597 struct sched_param
*lp
)
2602 static inline int security_task_getscheduler (struct task_struct
*p
)
2607 static inline int security_task_movememory (struct task_struct
*p
)
2612 static inline int security_task_kill (struct task_struct
*p
,
2613 struct siginfo
*info
, int sig
,
2619 static inline int security_task_wait (struct task_struct
*p
)
2624 static inline int security_task_prctl (int option
, unsigned long arg2
,
2632 static inline void security_task_reparent_to_init (struct task_struct
*p
)
2634 cap_task_reparent_to_init (p
);
2637 static inline void security_task_to_inode(struct task_struct
*p
, struct inode
*inode
)
2640 static inline int security_ipc_permission (struct kern_ipc_perm
*ipcp
,
2646 static inline int security_msg_msg_alloc (struct msg_msg
* msg
)
2651 static inline void security_msg_msg_free (struct msg_msg
* msg
)
2654 static inline int security_msg_queue_alloc (struct msg_queue
*msq
)
2659 static inline void security_msg_queue_free (struct msg_queue
*msq
)
2662 static inline int security_msg_queue_associate (struct msg_queue
* msq
,
2668 static inline int security_msg_queue_msgctl (struct msg_queue
* msq
, int cmd
)
2673 static inline int security_msg_queue_msgsnd (struct msg_queue
* msq
,
2674 struct msg_msg
* msg
, int msqflg
)
2679 static inline int security_msg_queue_msgrcv (struct msg_queue
* msq
,
2680 struct msg_msg
* msg
,
2681 struct task_struct
* target
,
2682 long type
, int mode
)
2687 static inline int security_shm_alloc (struct shmid_kernel
*shp
)
2692 static inline void security_shm_free (struct shmid_kernel
*shp
)
2695 static inline int security_shm_associate (struct shmid_kernel
* shp
,
2701 static inline int security_shm_shmctl (struct shmid_kernel
* shp
, int cmd
)
2706 static inline int security_shm_shmat (struct shmid_kernel
* shp
,
2707 char __user
*shmaddr
, int shmflg
)
2712 static inline int security_sem_alloc (struct sem_array
*sma
)
2717 static inline void security_sem_free (struct sem_array
*sma
)
2720 static inline int security_sem_associate (struct sem_array
* sma
, int semflg
)
2725 static inline int security_sem_semctl (struct sem_array
* sma
, int cmd
)
2730 static inline int security_sem_semop (struct sem_array
* sma
,
2731 struct sembuf
* sops
, unsigned nsops
,
2737 static inline void security_d_instantiate (struct dentry
*dentry
, struct inode
*inode
)
2740 static inline int security_getprocattr(struct task_struct
*p
, char *name
, void *value
, size_t size
)
2745 static inline int security_setprocattr(struct task_struct
*p
, char *name
, void *value
, size_t size
)
2750 static inline int security_netlink_send (struct sock
*sk
, struct sk_buff
*skb
)
2752 return cap_netlink_send (sk
, skb
);
2755 static inline int security_netlink_recv (struct sk_buff
*skb
, int cap
)
2757 return cap_netlink_recv (skb
, cap
);
2760 static inline struct dentry
*securityfs_create_dir(const char *name
,
2761 struct dentry
*parent
)
2763 return ERR_PTR(-ENODEV
);
2766 static inline struct dentry
*securityfs_create_file(const char *name
,
2768 struct dentry
*parent
,
2770 struct file_operations
*fops
)
2772 return ERR_PTR(-ENODEV
);
2775 static inline void securityfs_remove(struct dentry
*dentry
)
2779 static inline int security_secid_to_secctx(u32 secid
, char **secdata
, u32
*seclen
)
2784 static inline void security_release_secctx(char *secdata
, u32 seclen
)
2787 #endif /* CONFIG_SECURITY */
2789 #ifdef CONFIG_SECURITY_NETWORK
2790 static inline int security_unix_stream_connect(struct socket
* sock
,
2791 struct socket
* other
,
2792 struct sock
* newsk
)
2794 return security_ops
->unix_stream_connect(sock
, other
, newsk
);
2798 static inline int security_unix_may_send(struct socket
* sock
,
2799 struct socket
* other
)
2801 return security_ops
->unix_may_send(sock
, other
);
2804 static inline int security_socket_create (int family
, int type
,
2805 int protocol
, int kern
)
2807 return security_ops
->socket_create(family
, type
, protocol
, kern
);
2810 static inline void security_socket_post_create(struct socket
* sock
,
2813 int protocol
, int kern
)
2815 security_ops
->socket_post_create(sock
, family
, type
,
2819 static inline int security_socket_bind(struct socket
* sock
,
2820 struct sockaddr
* address
,
2823 return security_ops
->socket_bind(sock
, address
, addrlen
);
2826 static inline int security_socket_connect(struct socket
* sock
,
2827 struct sockaddr
* address
,
2830 return security_ops
->socket_connect(sock
, address
, addrlen
);
2833 static inline int security_socket_listen(struct socket
* sock
, int backlog
)
2835 return security_ops
->socket_listen(sock
, backlog
);
2838 static inline int security_socket_accept(struct socket
* sock
,
2839 struct socket
* newsock
)
2841 return security_ops
->socket_accept(sock
, newsock
);
2844 static inline void security_socket_post_accept(struct socket
* sock
,
2845 struct socket
* newsock
)
2847 security_ops
->socket_post_accept(sock
, newsock
);
2850 static inline int security_socket_sendmsg(struct socket
* sock
,
2851 struct msghdr
* msg
, int size
)
2853 return security_ops
->socket_sendmsg(sock
, msg
, size
);
2856 static inline int security_socket_recvmsg(struct socket
* sock
,
2857 struct msghdr
* msg
, int size
,
2860 return security_ops
->socket_recvmsg(sock
, msg
, size
, flags
);
2863 static inline int security_socket_getsockname(struct socket
* sock
)
2865 return security_ops
->socket_getsockname(sock
);
2868 static inline int security_socket_getpeername(struct socket
* sock
)
2870 return security_ops
->socket_getpeername(sock
);
2873 static inline int security_socket_getsockopt(struct socket
* sock
,
2874 int level
, int optname
)
2876 return security_ops
->socket_getsockopt(sock
, level
, optname
);
2879 static inline int security_socket_setsockopt(struct socket
* sock
,
2880 int level
, int optname
)
2882 return security_ops
->socket_setsockopt(sock
, level
, optname
);
2885 static inline int security_socket_shutdown(struct socket
* sock
, int how
)
2887 return security_ops
->socket_shutdown(sock
, how
);
2890 static inline int security_sock_rcv_skb (struct sock
* sk
,
2891 struct sk_buff
* skb
)
2893 return security_ops
->socket_sock_rcv_skb (sk
, skb
);
2896 static inline int security_socket_getpeersec_stream(struct socket
*sock
, char __user
*optval
,
2897 int __user
*optlen
, unsigned len
)
2899 return security_ops
->socket_getpeersec_stream(sock
, optval
, optlen
, len
);
2902 static inline int security_socket_getpeersec_dgram(struct socket
*sock
, struct sk_buff
*skb
, u32
*secid
)
2904 return security_ops
->socket_getpeersec_dgram(sock
, skb
, secid
);
2907 static inline int security_sk_alloc(struct sock
*sk
, int family
, gfp_t priority
)
2909 return security_ops
->sk_alloc_security(sk
, family
, priority
);
2912 static inline void security_sk_free(struct sock
*sk
)
2914 return security_ops
->sk_free_security(sk
);
2917 static inline void security_sk_clone(const struct sock
*sk
, struct sock
*newsk
)
2919 return security_ops
->sk_clone_security(sk
, newsk
);
2922 static inline void security_sk_classify_flow(struct sock
*sk
, struct flowi
*fl
)
2924 security_ops
->sk_getsecid(sk
, &fl
->secid
);
2926 #else /* CONFIG_SECURITY_NETWORK */
2927 static inline int security_unix_stream_connect(struct socket
* sock
,
2928 struct socket
* other
,
2929 struct sock
* newsk
)
2934 static inline int security_unix_may_send(struct socket
* sock
,
2935 struct socket
* other
)
2940 static inline int security_socket_create (int family
, int type
,
2941 int protocol
, int kern
)
2946 static inline void security_socket_post_create(struct socket
* sock
,
2949 int protocol
, int kern
)
2953 static inline int security_socket_bind(struct socket
* sock
,
2954 struct sockaddr
* address
,
2960 static inline int security_socket_connect(struct socket
* sock
,
2961 struct sockaddr
* address
,
2967 static inline int security_socket_listen(struct socket
* sock
, int backlog
)
2972 static inline int security_socket_accept(struct socket
* sock
,
2973 struct socket
* newsock
)
2978 static inline void security_socket_post_accept(struct socket
* sock
,
2979 struct socket
* newsock
)
2983 static inline int security_socket_sendmsg(struct socket
* sock
,
2984 struct msghdr
* msg
, int size
)
2989 static inline int security_socket_recvmsg(struct socket
* sock
,
2990 struct msghdr
* msg
, int size
,
2996 static inline int security_socket_getsockname(struct socket
* sock
)
3001 static inline int security_socket_getpeername(struct socket
* sock
)
3006 static inline int security_socket_getsockopt(struct socket
* sock
,
3007 int level
, int optname
)
3012 static inline int security_socket_setsockopt(struct socket
* sock
,
3013 int level
, int optname
)
3018 static inline int security_socket_shutdown(struct socket
* sock
, int how
)
3022 static inline int security_sock_rcv_skb (struct sock
* sk
,
3023 struct sk_buff
* skb
)
3028 static inline int security_socket_getpeersec_stream(struct socket
*sock
, char __user
*optval
,
3029 int __user
*optlen
, unsigned len
)
3031 return -ENOPROTOOPT
;
3034 static inline int security_socket_getpeersec_dgram(struct socket
*sock
, struct sk_buff
*skb
, u32
*secid
)
3036 return -ENOPROTOOPT
;
3039 static inline int security_sk_alloc(struct sock
*sk
, int family
, gfp_t priority
)
3044 static inline void security_sk_free(struct sock
*sk
)
3048 static inline void security_sk_clone(const struct sock
*sk
, struct sock
*newsk
)
3052 static inline void security_sk_classify_flow(struct sock
*sk
, struct flowi
*fl
)
3055 #endif /* CONFIG_SECURITY_NETWORK */
3057 #ifdef CONFIG_SECURITY_NETWORK_XFRM
3058 static inline int security_xfrm_policy_alloc(struct xfrm_policy
*xp
, struct xfrm_user_sec_ctx
*sec_ctx
)
3060 return security_ops
->xfrm_policy_alloc_security(xp
, sec_ctx
);
3063 static inline int security_xfrm_policy_clone(struct xfrm_policy
*old
, struct xfrm_policy
*new)
3065 return security_ops
->xfrm_policy_clone_security(old
, new);
3068 static inline void security_xfrm_policy_free(struct xfrm_policy
*xp
)
3070 security_ops
->xfrm_policy_free_security(xp
);
3073 static inline int security_xfrm_policy_delete(struct xfrm_policy
*xp
)
3075 return security_ops
->xfrm_policy_delete_security(xp
);
3078 static inline int security_xfrm_state_alloc(struct xfrm_state
*x
,
3079 struct xfrm_user_sec_ctx
*sec_ctx
)
3081 return security_ops
->xfrm_state_alloc_security(x
, sec_ctx
, NULL
, 0);
3084 static inline int security_xfrm_state_alloc_acquire(struct xfrm_state
*x
,
3085 struct xfrm_sec_ctx
*polsec
, u32 secid
)
3089 return security_ops
->xfrm_state_alloc_security(x
, NULL
, polsec
, secid
);
3092 static inline int security_xfrm_state_delete(struct xfrm_state
*x
)
3094 return security_ops
->xfrm_state_delete_security(x
);
3097 static inline void security_xfrm_state_free(struct xfrm_state
*x
)
3099 security_ops
->xfrm_state_free_security(x
);
3102 static inline int security_xfrm_policy_lookup(struct xfrm_policy
*xp
, u32 fl_secid
, u8 dir
)
3104 return security_ops
->xfrm_policy_lookup(xp
, fl_secid
, dir
);
3107 static inline int security_xfrm_state_pol_flow_match(struct xfrm_state
*x
,
3108 struct xfrm_policy
*xp
, struct flowi
*fl
)
3110 return security_ops
->xfrm_state_pol_flow_match(x
, xp
, fl
);
3113 static inline int security_xfrm_flow_state_match(struct flowi
*fl
, struct xfrm_state
*xfrm
)
3115 return security_ops
->xfrm_flow_state_match(fl
, xfrm
);
3118 static inline int security_xfrm_decode_session(struct sk_buff
*skb
, u32
*secid
)
3120 return security_ops
->xfrm_decode_session(skb
, secid
, 1);
3123 static inline void security_skb_classify_flow(struct sk_buff
*skb
, struct flowi
*fl
)
3125 int rc
= security_ops
->xfrm_decode_session(skb
, &fl
->secid
, 0);
3129 #else /* CONFIG_SECURITY_NETWORK_XFRM */
3130 static inline int security_xfrm_policy_alloc(struct xfrm_policy
*xp
, struct xfrm_user_sec_ctx
*sec_ctx
)
3135 static inline int security_xfrm_policy_clone(struct xfrm_policy
*old
, struct xfrm_policy
*new)
3140 static inline void security_xfrm_policy_free(struct xfrm_policy
*xp
)
3144 static inline int security_xfrm_policy_delete(struct xfrm_policy
*xp
)
3149 static inline int security_xfrm_state_alloc(struct xfrm_state
*x
,
3150 struct xfrm_user_sec_ctx
*sec_ctx
)
3155 static inline int security_xfrm_state_alloc_acquire(struct xfrm_state
*x
,
3156 struct xfrm_sec_ctx
*polsec
, u32 secid
)
3161 static inline void security_xfrm_state_free(struct xfrm_state
*x
)
3165 static inline int security_xfrm_state_delete(struct xfrm_state
*x
)
3170 static inline int security_xfrm_policy_lookup(struct xfrm_policy
*xp
, u32 fl_secid
, u8 dir
)
3175 static inline int security_xfrm_state_pol_flow_match(struct xfrm_state
*x
,
3176 struct xfrm_policy
*xp
, struct flowi
*fl
)
3181 static inline int security_xfrm_flow_state_match(struct flowi
*fl
,
3182 struct xfrm_state
*xfrm
)
3187 static inline int security_xfrm_decode_session(struct sk_buff
*skb
, u32
*secid
)
3192 static inline void security_skb_classify_flow(struct sk_buff
*skb
, struct flowi
*fl
)
3196 #endif /* CONFIG_SECURITY_NETWORK_XFRM */
3199 #ifdef CONFIG_SECURITY
3200 static inline int security_key_alloc(struct key
*key
,
3201 struct task_struct
*tsk
,
3202 unsigned long flags
)
3204 return security_ops
->key_alloc(key
, tsk
, flags
);
3207 static inline void security_key_free(struct key
*key
)
3209 security_ops
->key_free(key
);
3212 static inline int security_key_permission(key_ref_t key_ref
,
3213 struct task_struct
*context
,
3216 return security_ops
->key_permission(key_ref
, context
, perm
);
3221 static inline int security_key_alloc(struct key
*key
,
3222 struct task_struct
*tsk
,
3223 unsigned long flags
)
3228 static inline void security_key_free(struct key
*key
)
3232 static inline int security_key_permission(key_ref_t key_ref
,
3233 struct task_struct
*context
,
3240 #endif /* CONFIG_KEYS */
3242 #endif /* ! __LINUX_SECURITY_H */