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>
37 * These functions are in security/capability.c and are used
38 * as the default capabilities functions
40 extern int cap_capable (struct task_struct *tsk, int cap);
41 extern int cap_settime (struct timespec *ts, struct timezone *tz);
42 extern int cap_ptrace (struct task_struct *parent, struct task_struct *child);
43 extern int cap_capget (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
44 extern int cap_capset_check (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
45 extern void cap_capset_set (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
46 extern int cap_bprm_set_security (struct linux_binprm *bprm);
47 extern void cap_bprm_apply_creds (struct linux_binprm *bprm, int unsafe);
48 extern int cap_bprm_secureexec(struct linux_binprm *bprm);
49 extern int cap_inode_setxattr(struct dentry *dentry, char *name, void *value, size_t size, int flags);
50 extern int cap_inode_removexattr(struct dentry *dentry, char *name);
51 extern int cap_task_post_setuid (uid_t old_ruid, uid_t old_euid, uid_t old_suid, int flags);
52 extern void cap_task_reparent_to_init (struct task_struct *p);
53 extern int cap_syslog (int type);
54 extern int cap_vm_enough_memory (long pages);
62 extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
63 extern int cap_netlink_recv(struct sk_buff *skb);
66 * Values used in the task_security_ops calls
68 /* setuid or setgid, id0 == uid or gid */
69 #define LSM_SETID_ID 1
71 /* setreuid or setregid, id0 == real, id1 == eff */
72 #define LSM_SETID_RE 2
74 /* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
75 #define LSM_SETID_RES 4
77 /* setfsuid or setfsgid, id0 == fsuid or fsgid */
78 #define LSM_SETID_FS 8
80 /* forward declares to avoid warnings */
83 struct swap_info_struct;
85 /* bprm_apply_creds unsafe reasons */
86 #define LSM_UNSAFE_SHARE 1
87 #define LSM_UNSAFE_PTRACE 2
88 #define LSM_UNSAFE_PTRACE_CAP 4
90 #ifdef CONFIG_SECURITY
93 * struct security_operations - main security structure
95 * Security hooks for program execution operations.
97 * @bprm_alloc_security:
98 * Allocate and attach a security structure to the @bprm->security field.
99 * The security field is initialized to NULL when the bprm structure is
101 * @bprm contains the linux_binprm structure to be modified.
102 * Return 0 if operation was successful.
103 * @bprm_free_security:
104 * @bprm contains the linux_binprm structure to be modified.
105 * Deallocate and clear the @bprm->security field.
107 * Compute and set the security attributes of a process being transformed
108 * by an execve operation based on the old attributes (current->security)
109 * and the information saved in @bprm->security by the set_security hook.
110 * Since this hook function (and its caller) are void, this hook can not
111 * return an error. However, it can leave the security attributes of the
112 * process unchanged if an access failure occurs at this point.
113 * bprm_apply_creds is called under task_lock. @unsafe indicates various
114 * reasons why it may be unsafe to change security state.
115 * @bprm contains the linux_binprm structure.
116 * @bprm_post_apply_creds:
117 * Runs after bprm_apply_creds with the task_lock dropped, so that
118 * functions which cannot be called safely under the task_lock can
119 * be used. This hook is a good place to perform state changes on
120 * the process such as closing open file descriptors to which access
121 * is no longer granted if the attributes were changed.
122 * Note that a security module might need to save state between
123 * bprm_apply_creds and bprm_post_apply_creds to store the decision
124 * on whether the process may proceed.
125 * @bprm contains the linux_binprm structure.
126 * @bprm_set_security:
127 * Save security information in the bprm->security field, typically based
128 * on information about the bprm->file, for later use by the apply_creds
129 * hook. This hook may also optionally check permissions (e.g. for
130 * transitions between security domains).
131 * This hook may be called multiple times during a single execve, e.g. for
132 * interpreters. The hook can tell whether it has already been called by
133 * checking to see if @bprm->security is non-NULL. If so, then the hook
134 * may decide either to retain the security information saved earlier or
136 * @bprm contains the linux_binprm structure.
137 * Return 0 if the hook is successful and permission is granted.
138 * @bprm_check_security:
139 * This hook mediates the point when a search for a binary handler will
140 * begin. It allows a check the @bprm->security value which is set in
141 * the preceding set_security call. The primary difference from
142 * set_security is that the argv list and envp list are reliably
143 * available in @bprm. This hook may be called multiple times
144 * during a single execve; and in each pass set_security is called
146 * @bprm contains the linux_binprm structure.
147 * Return 0 if the hook is successful and permission is granted.
149 * Return a boolean value (0 or 1) indicating whether a "secure exec"
150 * is required. The flag is passed in the auxiliary table
151 * on the initial stack to the ELF interpreter to indicate whether libc
152 * should enable secure mode.
153 * @bprm contains the linux_binprm structure.
155 * Security hooks for filesystem operations.
157 * @sb_alloc_security:
158 * Allocate and attach a security structure to the sb->s_security field.
159 * The s_security field is initialized to NULL when the structure is
161 * @sb contains the super_block structure to be modified.
162 * Return 0 if operation was successful.
164 * Deallocate and clear the sb->s_security field.
165 * @sb contains the super_block structure to be modified.
167 * Check permission before obtaining filesystem statistics for the @sb
169 * @sb contains the super_block structure for the filesystem.
170 * Return 0 if permission is granted.
172 * Check permission before an object specified by @dev_name is mounted on
173 * the mount point named by @nd. For an ordinary mount, @dev_name
174 * identifies a device if the file system type requires a device. For a
175 * remount (@flags & MS_REMOUNT), @dev_name is irrelevant. For a
176 * loopback/bind mount (@flags & MS_BIND), @dev_name identifies the
177 * pathname of the object being mounted.
178 * @dev_name contains the name for object being mounted.
179 * @nd contains the nameidata structure for mount point object.
180 * @type contains the filesystem type.
181 * @flags contains the mount flags.
182 * @data contains the filesystem-specific data.
183 * Return 0 if permission is granted.
185 * Allow mount option data to be copied prior to parsing by the filesystem,
186 * so that the security module can extract security-specific mount
187 * options cleanly (a filesystem may modify the data e.g. with strsep()).
188 * This also allows the original mount data to be stripped of security-
189 * specific options to avoid having to make filesystems aware of them.
190 * @type the type of filesystem being mounted.
191 * @orig the original mount data copied from userspace.
192 * @copy copied data which will be passed to the security module.
193 * Returns 0 if the copy was successful.
195 * Check permission before the device with superblock @mnt->sb is mounted
196 * on the mount point named by @nd.
197 * @mnt contains the vfsmount for device being mounted.
198 * @nd contains the nameidata object for the mount point.
199 * Return 0 if permission is granted.
201 * Check permission before the @mnt file system is unmounted.
202 * @mnt contains the mounted file system.
203 * @flags contains the unmount flags, e.g. MNT_FORCE.
204 * Return 0 if permission is granted.
206 * Close any files in the @mnt mounted filesystem that are held open by
207 * the security module. This hook is called during an umount operation
208 * prior to checking whether the filesystem is still busy.
209 * @mnt contains the mounted filesystem.
211 * Handle a failed umount of the @mnt mounted filesystem, e.g. re-opening
212 * any files that were closed by umount_close. This hook is called during
213 * an umount operation if the umount fails after a call to the
215 * @mnt contains the mounted filesystem.
217 * Update the security module's state when a filesystem is remounted.
218 * This hook is only called if the remount was successful.
219 * @mnt contains the mounted file system.
220 * @flags contains the new filesystem flags.
221 * @data contains the filesystem-specific data.
222 * @sb_post_mountroot:
223 * Update the security module's state when the root filesystem is mounted.
224 * This hook is only called if the mount was successful.
226 * Update the security module's state when a filesystem is mounted.
227 * This hook is called any time a mount is successfully grafetd to
229 * @mnt contains the mounted filesystem.
230 * @mountpoint_nd contains the nameidata structure for the mount point.
232 * Check permission before pivoting the root filesystem.
233 * @old_nd contains the nameidata structure for the new location of the current root (put_old).
234 * @new_nd contains the nameidata structure for the new root (new_root).
235 * Return 0 if permission is granted.
236 * @sb_post_pivotroot:
237 * Update module state after a successful pivot.
238 * @old_nd contains the nameidata structure for the old root.
239 * @new_nd contains the nameidata structure for the new root.
241 * Security hooks for inode operations.
243 * @inode_alloc_security:
244 * Allocate and attach a security structure to @inode->i_security. The
245 * i_security field is initialized to NULL when the inode structure is
247 * @inode contains the inode structure.
248 * Return 0 if operation was successful.
249 * @inode_free_security:
250 * @inode contains the inode structure.
251 * Deallocate the inode security structure and set @inode->i_security to
253 * @inode_init_security:
254 * Obtain the security attribute name suffix and value to set on a newly
255 * created inode and set up the incore security field for the new inode.
256 * This hook is called by the fs code as part of the inode creation
257 * transaction and provides for atomic labeling of the inode, unlike
258 * the post_create/mkdir/... hooks called by the VFS. The hook function
259 * is expected to allocate the name and value via kmalloc, with the caller
260 * being responsible for calling kfree after using them.
261 * If the security module does not use security attributes or does
262 * not wish to put a security attribute on this particular inode,
263 * then it should return -EOPNOTSUPP to skip this processing.
264 * @inode contains the inode structure of the newly created inode.
265 * @dir contains the inode structure of the parent directory.
266 * @name will be set to the allocated name suffix (e.g. selinux).
267 * @value will be set to the allocated attribute value.
268 * @len will be set to the length of the value.
269 * Returns 0 if @name and @value have been successfully set,
270 * -EOPNOTSUPP if no security attribute is needed, or
271 * -ENOMEM on memory allocation failure.
273 * Check permission to create a regular file.
274 * @dir contains inode structure of the parent of the new file.
275 * @dentry contains the dentry structure for the file to be created.
276 * @mode contains the file mode of the file to be created.
277 * Return 0 if permission is granted.
279 * Check permission before creating a new hard link to a file.
280 * @old_dentry contains the dentry structure for an existing link to the file.
281 * @dir contains the inode structure of the parent directory of the new link.
282 * @new_dentry contains the dentry structure for the new link.
283 * Return 0 if permission is granted.
285 * Check the permission to remove a hard link to a file.
286 * @dir contains the inode structure of parent directory of the file.
287 * @dentry contains the dentry structure for file to be unlinked.
288 * Return 0 if permission is granted.
290 * Check the permission to create a symbolic link to a file.
291 * @dir contains the inode structure of parent directory of the symbolic link.
292 * @dentry contains the dentry structure of the symbolic link.
293 * @old_name contains the pathname of file.
294 * Return 0 if permission is granted.
296 * Check permissions to create a new directory in the existing directory
297 * associated with inode strcture @dir.
298 * @dir containst the inode structure of parent of the directory to be created.
299 * @dentry contains the dentry structure of new directory.
300 * @mode contains the mode of new directory.
301 * Return 0 if permission is granted.
303 * Check the permission to remove a directory.
304 * @dir contains the inode structure of parent of the directory to be removed.
305 * @dentry contains the dentry structure of directory to be removed.
306 * Return 0 if permission is granted.
308 * Check permissions when creating a special file (or a socket or a fifo
309 * file created via the mknod system call). Note that if mknod operation
310 * is being done for a regular file, then the create hook will be called
312 * @dir contains the inode structure of parent of the new file.
313 * @dentry contains the dentry structure of the new file.
314 * @mode contains the mode of the new file.
315 * @dev contains the the device number.
316 * Return 0 if permission is granted.
318 * Check for permission to rename a file or directory.
319 * @old_dir contains the inode structure for parent of the old link.
320 * @old_dentry contains the dentry structure of the old link.
321 * @new_dir contains the inode structure for parent of the new link.
322 * @new_dentry contains the dentry structure of the new link.
323 * Return 0 if permission is granted.
325 * Check the permission to read the symbolic link.
326 * @dentry contains the dentry structure for the file link.
327 * Return 0 if permission is granted.
328 * @inode_follow_link:
329 * Check permission to follow a symbolic link when looking up a pathname.
330 * @dentry contains the dentry structure for the link.
331 * @nd contains the nameidata structure for the parent directory.
332 * Return 0 if permission is granted.
334 * Check permission before accessing an inode. This hook is called by the
335 * existing Linux permission function, so a security module can use it to
336 * provide additional checking for existing Linux permission checks.
337 * Notice that this hook is called when a file is opened (as well as many
338 * other operations), whereas the file_security_ops permission hook is
339 * called when the actual read/write operations are performed.
340 * @inode contains the inode structure to check.
341 * @mask contains the permission mask.
342 * @nd contains the nameidata (may be NULL).
343 * Return 0 if permission is granted.
345 * Check permission before setting file attributes. Note that the kernel
346 * call to notify_change is performed from several locations, whenever
347 * file attributes change (such as when a file is truncated, chown/chmod
348 * operations, transferring disk quotas, etc).
349 * @dentry contains the dentry structure for the file.
350 * @attr is the iattr structure containing the new file attributes.
351 * Return 0 if permission is granted.
353 * Check permission before obtaining file attributes.
354 * @mnt is the vfsmount where the dentry was looked up
355 * @dentry contains the dentry structure for the file.
356 * Return 0 if permission is granted.
358 * @inode contains the inode structure for deleted inode.
359 * This hook is called when a deleted inode is released (i.e. an inode
360 * with no hard links has its use count drop to zero). A security module
361 * can use this hook to release any persistent label associated with the
364 * Check permission before setting the extended attributes
365 * @value identified by @name for @dentry.
366 * Return 0 if permission is granted.
367 * @inode_post_setxattr:
368 * Update inode security field after successful setxattr operation.
369 * @value identified by @name for @dentry.
371 * Check permission before obtaining the extended attributes
372 * identified by @name for @dentry.
373 * Return 0 if permission is granted.
375 * Check permission before obtaining the list of extended attribute
377 * Return 0 if permission is granted.
378 * @inode_removexattr:
379 * Check permission before removing the extended attribute
380 * identified by @name for @dentry.
381 * Return 0 if permission is granted.
382 * @inode_getsecurity:
383 * Copy the extended attribute representation of the security label
384 * associated with @name for @inode into @buffer. @buffer may be
385 * NULL to request the size of the buffer required. @size indicates
386 * the size of @buffer in bytes. Note that @name is the remainder
387 * of the attribute name after the security. prefix has been removed.
388 * @err is the return value from the preceding fs getxattr call,
389 * and can be used by the security module to determine whether it
390 * should try and canonicalize the attribute value.
391 * Return number of bytes used/required on success.
392 * @inode_setsecurity:
393 * Set the security label associated with @name for @inode from the
394 * extended attribute value @value. @size indicates the size of the
395 * @value in bytes. @flags may be XATTR_CREATE, XATTR_REPLACE, or 0.
396 * Note that @name is the remainder of the attribute name after the
397 * security. prefix has been removed.
398 * Return 0 on success.
399 * @inode_listsecurity:
400 * Copy the extended attribute names for the security labels
401 * associated with @inode into @buffer. The maximum size of @buffer
402 * is specified by @buffer_size. @buffer may be NULL to request
403 * the size of the buffer required.
404 * Returns number of bytes used/required on success.
406 * Security hooks for file operations
409 * Check file permissions before accessing an open file. This hook is
410 * called by various operations that read or write files. A security
411 * module can use this hook to perform additional checking on these
412 * operations, e.g. to revalidate permissions on use to support privilege
413 * bracketing or policy changes. Notice that this hook is used when the
414 * actual read/write operations are performed, whereas the
415 * inode_security_ops hook is called when a file is opened (as well as
416 * many other operations).
417 * Caveat: Although this hook can be used to revalidate permissions for
418 * various system call operations that read or write files, it does not
419 * address the revalidation of permissions for memory-mapped files.
420 * Security modules must handle this separately if they need such
422 * @file contains the file structure being accessed.
423 * @mask contains the requested permissions.
424 * Return 0 if permission is granted.
425 * @file_alloc_security:
426 * Allocate and attach a security structure to the file->f_security field.
427 * The security field is initialized to NULL when the structure is first
429 * @file contains the file structure to secure.
430 * Return 0 if the hook is successful and permission is granted.
431 * @file_free_security:
432 * Deallocate and free any security structures stored in file->f_security.
433 * @file contains the file structure being modified.
435 * @file contains the file structure.
436 * @cmd contains the operation to perform.
437 * @arg contains the operational arguments.
438 * Check permission for an ioctl operation on @file. Note that @arg can
439 * sometimes represents a user space pointer; in other cases, it may be a
440 * simple integer value. When @arg represents a user space pointer, it
441 * should never be used by the security module.
442 * Return 0 if permission is granted.
444 * Check permissions for a mmap operation. The @file may be NULL, e.g.
445 * if mapping anonymous memory.
446 * @file contains the file structure for file to map (may be NULL).
447 * @reqprot contains the protection requested by the application.
448 * @prot contains the protection that will be applied by the kernel.
449 * @flags contains the operational flags.
450 * Return 0 if permission is granted.
452 * Check permissions before changing memory access permissions.
453 * @vma contains the memory region to modify.
454 * @reqprot contains the protection requested by the application.
455 * @prot contains the protection that will be applied by the kernel.
456 * Return 0 if permission is granted.
458 * Check permission before performing file locking operations.
459 * Note: this hook mediates both flock and fcntl style locks.
460 * @file contains the file structure.
461 * @cmd contains the posix-translated lock operation to perform
462 * (e.g. F_RDLCK, F_WRLCK).
463 * Return 0 if permission is granted.
465 * Check permission before allowing the file operation specified by @cmd
466 * from being performed on the file @file. Note that @arg can sometimes
467 * represents a user space pointer; in other cases, it may be a simple
468 * integer value. When @arg represents a user space pointer, it should
469 * never be used by the security module.
470 * @file contains the file structure.
471 * @cmd contains the operation to be performed.
472 * @arg contains the operational arguments.
473 * Return 0 if permission is granted.
475 * Save owner security information (typically from current->security) in
476 * file->f_security for later use by the send_sigiotask hook.
477 * @file contains the file structure to update.
478 * Return 0 on success.
479 * @file_send_sigiotask:
480 * Check permission for the file owner @fown to send SIGIO or SIGURG to the
481 * process @tsk. Note that this hook is sometimes called from interrupt.
482 * Note that the fown_struct, @fown, is never outside the context of a
483 * struct file, so the file structure (and associated security information)
484 * can always be obtained:
485 * (struct file *)((long)fown - offsetof(struct file,f_owner));
486 * @tsk contains the structure of task receiving signal.
487 * @fown contains the file owner information.
488 * @sig is the signal that will be sent. When 0, kernel sends SIGIO.
489 * Return 0 if permission is granted.
491 * This hook allows security modules to control the ability of a process
492 * to receive an open file descriptor via socket IPC.
493 * @file contains the file structure being received.
494 * Return 0 if permission is granted.
496 * Security hooks for task operations.
499 * Check permission before creating a child process. See the clone(2)
500 * manual page for definitions of the @clone_flags.
501 * @clone_flags contains the flags indicating what should be shared.
502 * Return 0 if permission is granted.
503 * @task_alloc_security:
504 * @p contains the task_struct for child process.
505 * Allocate and attach a security structure to the p->security field. The
506 * security field is initialized to NULL when the task structure is
508 * Return 0 if operation was successful.
509 * @task_free_security:
510 * @p contains the task_struct for process.
511 * Deallocate and clear the p->security field.
513 * Check permission before setting one or more of the user identity
514 * attributes of the current process. The @flags parameter indicates
515 * which of the set*uid system calls invoked this hook and how to
516 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
517 * definitions at the beginning of this file for the @flags values and
519 * @id0 contains a uid.
520 * @id1 contains a uid.
521 * @id2 contains a uid.
522 * @flags contains one of the LSM_SETID_* values.
523 * Return 0 if permission is granted.
525 * Update the module's state after setting one or more of the user
526 * identity attributes of the current process. The @flags parameter
527 * indicates which of the set*uid system calls invoked this hook. If
528 * @flags is LSM_SETID_FS, then @old_ruid is the old fs uid and the other
529 * parameters are not used.
530 * @old_ruid contains the old real uid (or fs uid if LSM_SETID_FS).
531 * @old_euid contains the old effective uid (or -1 if LSM_SETID_FS).
532 * @old_suid contains the old saved uid (or -1 if LSM_SETID_FS).
533 * @flags contains one of the LSM_SETID_* values.
534 * Return 0 on success.
536 * Check permission before setting one or more of the group identity
537 * attributes of the current process. The @flags parameter indicates
538 * which of the set*gid system calls invoked this hook and how to
539 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
540 * definitions at the beginning of this file for the @flags values and
542 * @id0 contains a gid.
543 * @id1 contains a gid.
544 * @id2 contains a gid.
545 * @flags contains one of the LSM_SETID_* values.
546 * Return 0 if permission is granted.
548 * Check permission before setting the process group identifier of the
549 * process @p to @pgid.
550 * @p contains the task_struct for process being modified.
551 * @pgid contains the new pgid.
552 * Return 0 if permission is granted.
554 * Check permission before getting the process group identifier of the
556 * @p contains the task_struct for the process.
557 * Return 0 if permission is granted.
559 * Check permission before getting the session identifier of the process
561 * @p contains the task_struct for the process.
562 * Return 0 if permission is granted.
564 * Check permission before setting the supplementary group set of the
566 * @group_info contains the new group information.
567 * Return 0 if permission is granted.
569 * Check permission before setting the nice value of @p to @nice.
570 * @p contains the task_struct of process.
571 * @nice contains the new nice value.
572 * Return 0 if permission is granted.
574 * Check permission before setting the resource limits of the current
575 * process for @resource to @new_rlim. The old resource limit values can
576 * be examined by dereferencing (current->signal->rlim + resource).
577 * @resource contains the resource whose limit is being set.
578 * @new_rlim contains the new limits for @resource.
579 * Return 0 if permission is granted.
580 * @task_setscheduler:
581 * Check permission before setting scheduling policy and/or parameters of
582 * process @p based on @policy and @lp.
583 * @p contains the task_struct for process.
584 * @policy contains the scheduling policy.
585 * @lp contains the scheduling parameters.
586 * Return 0 if permission is granted.
587 * @task_getscheduler:
588 * Check permission before obtaining scheduling information for process
590 * @p contains the task_struct for process.
591 * Return 0 if permission is granted.
593 * Check permission before sending signal @sig to @p. @info can be NULL,
594 * the constant 1, or a pointer to a siginfo structure. If @info is 1 or
595 * SI_FROMKERNEL(info) is true, then the signal should be viewed as coming
596 * from the kernel and should typically be permitted.
597 * SIGIO signals are handled separately by the send_sigiotask hook in
599 * @p contains the task_struct for process.
600 * @info contains the signal information.
601 * @sig contains the signal value.
602 * Return 0 if permission is granted.
604 * Check permission before allowing a process to reap a child process @p
605 * and collect its status information.
606 * @p contains the task_struct for process.
607 * Return 0 if permission is granted.
609 * Check permission before performing a process control operation on the
611 * @option contains the operation.
612 * @arg2 contains a argument.
613 * @arg3 contains a argument.
614 * @arg4 contains a argument.
615 * @arg5 contains a argument.
616 * Return 0 if permission is granted.
617 * @task_reparent_to_init:
618 * Set the security attributes in @p->security for a kernel thread that
619 * is being reparented to the init task.
620 * @p contains the task_struct for the kernel thread.
622 * Set the security attributes for an inode based on an associated task's
623 * security attributes, e.g. for /proc/pid inodes.
624 * @p contains the task_struct for the task.
625 * @inode contains the inode structure for the inode.
627 * Security hooks for Netlink messaging.
630 * Save security information for a netlink message so that permission
631 * checking can be performed when the message is processed. The security
632 * information can be saved using the eff_cap field of the
633 * netlink_skb_parms structure. Also may be used to provide fine
634 * grained control over message transmission.
635 * @sk associated sock of task sending the message.,
636 * @skb contains the sk_buff structure for the netlink message.
637 * Return 0 if the information was successfully saved and message
638 * is allowed to be transmitted.
640 * Check permission before processing the received netlink message in
642 * @skb contains the sk_buff structure for the netlink message.
643 * Return 0 if permission is granted.
645 * Security hooks for Unix domain networking.
647 * @unix_stream_connect:
648 * Check permissions before establishing a Unix domain stream connection
649 * between @sock and @other.
650 * @sock contains the socket structure.
651 * @other contains the peer socket structure.
652 * Return 0 if permission is granted.
654 * Check permissions before connecting or sending datagrams from @sock to
656 * @sock contains the socket structure.
657 * @sock contains the peer socket structure.
658 * Return 0 if permission is granted.
660 * The @unix_stream_connect and @unix_may_send hooks were necessary because
661 * Linux provides an alternative to the conventional file name space for Unix
662 * domain sockets. Whereas binding and connecting to sockets in the file name
663 * space is mediated by the typical file permissions (and caught by the mknod
664 * and permission hooks in inode_security_ops), binding and connecting to
665 * sockets in the abstract name space is completely unmediated. Sufficient
666 * control of Unix domain sockets in the abstract name space isn't possible
667 * using only the socket layer hooks, since we need to know the actual target
668 * socket, which is not looked up until we are inside the af_unix code.
670 * Security hooks for socket operations.
673 * Check permissions prior to creating a new socket.
674 * @family contains the requested protocol family.
675 * @type contains the requested communications type.
676 * @protocol contains the requested protocol.
677 * @kern set to 1 if a kernel socket.
678 * Return 0 if permission is granted.
679 * @socket_post_create:
680 * This hook allows a module to update or allocate a per-socket security
681 * structure. Note that the security field was not added directly to the
682 * socket structure, but rather, the socket security information is stored
683 * in the associated inode. Typically, the inode alloc_security hook will
684 * allocate and and attach security information to
685 * sock->inode->i_security. This hook may be used to update the
686 * sock->inode->i_security field with additional information that wasn't
687 * available when the inode was allocated.
688 * @sock contains the newly created socket structure.
689 * @family contains the requested protocol family.
690 * @type contains the requested communications type.
691 * @protocol contains the requested protocol.
692 * @kern set to 1 if a kernel socket.
694 * Check permission before socket protocol layer bind operation is
695 * performed and the socket @sock is bound to the address specified in the
696 * @address parameter.
697 * @sock contains the socket structure.
698 * @address contains the address to bind to.
699 * @addrlen contains the length of address.
700 * Return 0 if permission is granted.
702 * Check permission before socket protocol layer connect operation
703 * attempts to connect socket @sock to a remote address, @address.
704 * @sock contains the socket structure.
705 * @address contains the address of remote endpoint.
706 * @addrlen contains the length of address.
707 * Return 0 if permission is granted.
709 * Check permission before socket protocol layer listen operation.
710 * @sock contains the socket structure.
711 * @backlog contains the maximum length for the pending connection queue.
712 * Return 0 if permission is granted.
714 * Check permission before accepting a new connection. Note that the new
715 * socket, @newsock, has been created and some information copied to it,
716 * but the accept operation has not actually been performed.
717 * @sock contains the listening socket structure.
718 * @newsock contains the newly created server socket for connection.
719 * Return 0 if permission is granted.
720 * @socket_post_accept:
721 * This hook allows a security module to copy security
722 * information into the newly created socket's inode.
723 * @sock contains the listening socket structure.
724 * @newsock contains the newly created server socket for connection.
726 * Check permission before transmitting a message to another socket.
727 * @sock contains the socket structure.
728 * @msg contains the message to be transmitted.
729 * @size contains the size of message.
730 * Return 0 if permission is granted.
732 * Check permission before receiving a message from a socket.
733 * @sock contains the socket structure.
734 * @msg contains the message structure.
735 * @size contains the size of message structure.
736 * @flags contains the operational flags.
737 * Return 0 if permission is granted.
738 * @socket_getsockname:
739 * Check permission before the local address (name) of the socket object
740 * @sock is retrieved.
741 * @sock contains the socket structure.
742 * Return 0 if permission is granted.
743 * @socket_getpeername:
744 * Check permission before the remote address (name) of a socket object
745 * @sock is retrieved.
746 * @sock contains the socket structure.
747 * Return 0 if permission is granted.
748 * @socket_getsockopt:
749 * Check permissions before retrieving the options associated with socket
751 * @sock contains the socket structure.
752 * @level contains the protocol level to retrieve option from.
753 * @optname contains the name of option to retrieve.
754 * Return 0 if permission is granted.
755 * @socket_setsockopt:
756 * Check permissions before setting the options associated with socket
758 * @sock contains the socket structure.
759 * @level contains the protocol level to set options for.
760 * @optname contains the name of the option to set.
761 * Return 0 if permission is granted.
763 * Checks permission before all or part of a connection on the socket
764 * @sock is shut down.
765 * @sock contains the socket structure.
766 * @how contains the flag indicating how future sends and receives are handled.
767 * Return 0 if permission is granted.
768 * @socket_sock_rcv_skb:
769 * Check permissions on incoming network packets. This hook is distinct
770 * from Netfilter's IP input hooks since it is the first time that the
771 * incoming sk_buff @skb has been associated with a particular socket, @sk.
772 * @sk contains the sock (not socket) associated with the incoming sk_buff.
773 * @skb contains the incoming network data.
774 * @socket_getpeersec:
775 * This hook allows the security module to provide peer socket security
776 * state to userspace via getsockopt SO_GETPEERSEC.
777 * @sock is the local socket.
778 * @optval userspace memory where the security state is to be copied.
779 * @optlen userspace int where the module should copy the actual length
780 * of the security state.
781 * @len as input is the maximum length to copy to userspace provided
783 * Return 0 if all is well, otherwise, typical getsockopt return
785 * @sk_alloc_security:
786 * Allocate and attach a security structure to the sk->sk_security field,
787 * which is used to copy security attributes between local stream sockets.
789 * Deallocate security structure.
791 * Security hooks affecting all System V IPC operations.
794 * Check permissions for access to IPC
795 * @ipcp contains the kernel IPC permission structure
796 * @flag contains the desired (requested) permission set
797 * Return 0 if permission is granted.
799 * Security hooks for individual messages held in System V IPC message queues
800 * @msg_msg_alloc_security:
801 * Allocate and attach a security structure to the msg->security field.
802 * The security field is initialized to NULL when the structure is first
804 * @msg contains the message structure to be modified.
805 * Return 0 if operation was successful and permission is granted.
806 * @msg_msg_free_security:
807 * Deallocate the security structure for this message.
808 * @msg contains the message structure to be modified.
810 * Security hooks for System V IPC Message Queues
812 * @msg_queue_alloc_security:
813 * Allocate and attach a security structure to the
814 * msq->q_perm.security field. The security field is initialized to
815 * NULL when the structure is first created.
816 * @msq contains the message queue structure to be modified.
817 * Return 0 if operation was successful and permission is granted.
818 * @msg_queue_free_security:
819 * Deallocate security structure for this message queue.
820 * @msq contains the message queue structure to be modified.
821 * @msg_queue_associate:
822 * Check permission when a message queue is requested through the
823 * msgget system call. This hook is only called when returning the
824 * message queue identifier for an existing message queue, not when a
825 * new message queue is created.
826 * @msq contains the message queue to act upon.
827 * @msqflg contains the operation control flags.
828 * Return 0 if permission is granted.
830 * Check permission when a message control operation specified by @cmd
831 * is to be performed on the message queue @msq.
832 * The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO.
833 * @msq contains the message queue to act upon. May be NULL.
834 * @cmd contains the operation to be performed.
835 * Return 0 if permission is granted.
837 * Check permission before a message, @msg, is enqueued on the message
839 * @msq contains the message queue to send message to.
840 * @msg contains the message to be enqueued.
841 * @msqflg contains operational flags.
842 * Return 0 if permission is granted.
844 * Check permission before a message, @msg, is removed from the message
845 * queue, @msq. The @target task structure contains a pointer to the
846 * process that will be receiving the message (not equal to the current
847 * process when inline receives are being performed).
848 * @msq contains the message queue to retrieve message from.
849 * @msg contains the message destination.
850 * @target contains the task structure for recipient process.
851 * @type contains the type of message requested.
852 * @mode contains the operational flags.
853 * Return 0 if permission is granted.
855 * Security hooks for System V Shared Memory Segments
857 * @shm_alloc_security:
858 * Allocate and attach a security structure to the shp->shm_perm.security
859 * field. The security field is initialized to NULL when the structure is
861 * @shp contains the shared memory structure to be modified.
862 * Return 0 if operation was successful and permission is granted.
863 * @shm_free_security:
864 * Deallocate the security struct for this memory segment.
865 * @shp contains the shared memory structure to be modified.
867 * Check permission when a shared memory region is requested through the
868 * shmget system call. This hook is only called when returning the shared
869 * memory region identifier for an existing region, not when a new shared
870 * memory region is created.
871 * @shp contains the shared memory structure to be modified.
872 * @shmflg contains the operation control flags.
873 * Return 0 if permission is granted.
875 * Check permission when a shared memory control operation specified by
876 * @cmd is to be performed on the shared memory region @shp.
877 * The @shp may be NULL, e.g. for IPC_INFO or SHM_INFO.
878 * @shp contains shared memory structure to be modified.
879 * @cmd contains the operation to be performed.
880 * Return 0 if permission is granted.
882 * Check permissions prior to allowing the shmat system call to attach the
883 * shared memory segment @shp to the data segment of the calling process.
884 * The attaching address is specified by @shmaddr.
885 * @shp contains the shared memory structure to be modified.
886 * @shmaddr contains the address to attach memory region to.
887 * @shmflg contains the operational flags.
888 * Return 0 if permission is granted.
890 * Security hooks for System V Semaphores
892 * @sem_alloc_security:
893 * Allocate and attach a security structure to the sma->sem_perm.security
894 * field. The security field is initialized to NULL when the structure is
896 * @sma contains the semaphore structure
897 * Return 0 if operation was successful and permission is granted.
898 * @sem_free_security:
899 * deallocate security struct for this semaphore
900 * @sma contains the semaphore structure.
902 * Check permission when a semaphore is requested through the semget
903 * system call. This hook is only called when returning the semaphore
904 * identifier for an existing semaphore, not when a new one must be
906 * @sma contains the semaphore structure.
907 * @semflg contains the operation control flags.
908 * Return 0 if permission is granted.
910 * Check permission when a semaphore operation specified by @cmd is to be
911 * performed on the semaphore @sma. The @sma may be NULL, e.g. for
912 * IPC_INFO or SEM_INFO.
913 * @sma contains the semaphore structure. May be NULL.
914 * @cmd contains the operation to be performed.
915 * Return 0 if permission is granted.
917 * Check permissions before performing operations on members of the
918 * semaphore set @sma. If the @alter flag is nonzero, the semaphore set
920 * @sma contains the semaphore structure.
921 * @sops contains the operations to perform.
922 * @nsops contains the number of operations to perform.
923 * @alter contains the flag indicating whether changes are to be made.
924 * Return 0 if permission is granted.
927 * Check permission before allowing the @parent process to trace the
929 * Security modules may also want to perform a process tracing check
930 * during an execve in the set_security or apply_creds hooks of
931 * binprm_security_ops if the process is being traced and its security
932 * attributes would be changed by the execve.
933 * @parent contains the task_struct structure for parent process.
934 * @child contains the task_struct structure for child process.
935 * Return 0 if permission is granted.
937 * Get the @effective, @inheritable, and @permitted capability sets for
938 * the @target process. The hook may also perform permission checking to
939 * determine if the current process is allowed to see the capability sets
940 * of the @target process.
941 * @target contains the task_struct structure for target process.
942 * @effective contains the effective capability set.
943 * @inheritable contains the inheritable capability set.
944 * @permitted contains the permitted capability set.
945 * Return 0 if the capability sets were successfully obtained.
947 * Check permission before setting the @effective, @inheritable, and
948 * @permitted capability sets for the @target process.
949 * Caveat: @target is also set to current if a set of processes is
950 * specified (i.e. all processes other than current and init or a
951 * particular process group). Hence, the capset_set hook may need to
952 * revalidate permission to the actual target process.
953 * @target contains the task_struct structure for target process.
954 * @effective contains the effective capability set.
955 * @inheritable contains the inheritable capability set.
956 * @permitted contains the permitted capability set.
957 * Return 0 if permission is granted.
959 * Set the @effective, @inheritable, and @permitted capability sets for
960 * the @target process. Since capset_check cannot always check permission
961 * to the real @target process, this hook may also perform permission
962 * checking to determine if the current process is allowed to set the
963 * capability sets of the @target process. However, this hook has no way
964 * of returning an error due to the structure of the sys_capset code.
965 * @target contains the task_struct structure for target process.
966 * @effective contains the effective capability set.
967 * @inheritable contains the inheritable capability set.
968 * @permitted contains the permitted capability set.
970 * Check permission before enabling or disabling process accounting. If
971 * accounting is being enabled, then @file refers to the open file used to
972 * store accounting records. If accounting is being disabled, then @file
974 * @file contains the file structure for the accounting file (may be NULL).
975 * Return 0 if permission is granted.
977 * Check permission before accessing the @table sysctl variable in the
978 * manner specified by @op.
979 * @table contains the ctl_table structure for the sysctl variable.
980 * @op contains the operation (001 = search, 002 = write, 004 = read).
981 * Return 0 if permission is granted.
983 * Check whether the @tsk process has the @cap capability.
984 * @tsk contains the task_struct for the process.
985 * @cap contains the capability <include/linux/capability.h>.
986 * Return 0 if the capability is granted for @tsk.
988 * Check permission before accessing the kernel message ring or changing
989 * logging to the console.
990 * See the syslog(2) manual page for an explanation of the @type values.
991 * @type contains the type of action.
992 * Return 0 if permission is granted.
994 * Check permission to change the system time.
995 * struct timespec and timezone are defined in include/linux/time.h
996 * @ts contains new time
997 * @tz contains new timezone
998 * Return 0 if permission is granted.
1000 * Check permissions for allocating a new virtual mapping.
1001 * @pages contains the number of pages.
1002 * Return 0 if permission is granted.
1004 * @register_security:
1005 * allow module stacking.
1006 * @name contains the name of the security module being stacked.
1007 * @ops contains a pointer to the struct security_operations of the module to stack.
1008 * @unregister_security:
1009 * remove a stacked module.
1010 * @name contains the name of the security module being unstacked.
1011 * @ops contains a pointer to the struct security_operations of the module to unstack.
1013 * This is the main security structure.
1015 struct security_operations {
1016 int (*ptrace) (struct task_struct * parent, struct task_struct * child);
1017 int (*capget) (struct task_struct * target,
1018 kernel_cap_t * effective,
1019 kernel_cap_t * inheritable, kernel_cap_t * permitted);
1020 int (*capset_check) (struct task_struct * target,
1021 kernel_cap_t * effective,
1022 kernel_cap_t * inheritable,
1023 kernel_cap_t * permitted);
1024 void (*capset_set) (struct task_struct * target,
1025 kernel_cap_t * effective,
1026 kernel_cap_t * inheritable,
1027 kernel_cap_t * permitted);
1028 int (*acct) (struct file * file);
1029 int (*sysctl) (struct ctl_table * table, int op);
1030 int (*capable) (struct task_struct * tsk, int cap);
1031 int (*quotactl) (int cmds, int type, int id, struct super_block * sb);
1032 int (*quota_on) (struct dentry * dentry);
1033 int (*syslog) (int type);
1034 int (*settime) (struct timespec *ts, struct timezone *tz);
1035 int (*vm_enough_memory) (long pages);
1037 int (*bprm_alloc_security) (struct linux_binprm * bprm);
1038 void (*bprm_free_security) (struct linux_binprm * bprm);
1039 void (*bprm_apply_creds) (struct linux_binprm * bprm, int unsafe);
1040 void (*bprm_post_apply_creds) (struct linux_binprm * bprm);
1041 int (*bprm_set_security) (struct linux_binprm * bprm);
1042 int (*bprm_check_security) (struct linux_binprm * bprm);
1043 int (*bprm_secureexec) (struct linux_binprm * bprm);
1045 int (*sb_alloc_security) (struct super_block * sb);
1046 void (*sb_free_security) (struct super_block * sb);
1047 int (*sb_copy_data)(struct file_system_type *type,
1048 void *orig, void *copy);
1049 int (*sb_kern_mount) (struct super_block *sb, void *data);
1050 int (*sb_statfs) (struct super_block * sb);
1051 int (*sb_mount) (char *dev_name, struct nameidata * nd,
1052 char *type, unsigned long flags, void *data);
1053 int (*sb_check_sb) (struct vfsmount * mnt, struct nameidata * nd);
1054 int (*sb_umount) (struct vfsmount * mnt, int flags);
1055 void (*sb_umount_close) (struct vfsmount * mnt);
1056 void (*sb_umount_busy) (struct vfsmount * mnt);
1057 void (*sb_post_remount) (struct vfsmount * mnt,
1058 unsigned long flags, void *data);
1059 void (*sb_post_mountroot) (void);
1060 void (*sb_post_addmount) (struct vfsmount * mnt,
1061 struct nameidata * mountpoint_nd);
1062 int (*sb_pivotroot) (struct nameidata * old_nd,
1063 struct nameidata * new_nd);
1064 void (*sb_post_pivotroot) (struct nameidata * old_nd,
1065 struct nameidata * new_nd);
1067 int (*inode_alloc_security) (struct inode *inode);
1068 void (*inode_free_security) (struct inode *inode);
1069 int (*inode_init_security) (struct inode *inode, struct inode *dir,
1070 char **name, void **value, size_t *len);
1071 int (*inode_create) (struct inode *dir,
1072 struct dentry *dentry, int mode);
1073 int (*inode_link) (struct dentry *old_dentry,
1074 struct inode *dir, struct dentry *new_dentry);
1075 int (*inode_unlink) (struct inode *dir, struct dentry *dentry);
1076 int (*inode_symlink) (struct inode *dir,
1077 struct dentry *dentry, const char *old_name);
1078 int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode);
1079 int (*inode_rmdir) (struct inode *dir, struct dentry *dentry);
1080 int (*inode_mknod) (struct inode *dir, struct dentry *dentry,
1081 int mode, dev_t dev);
1082 int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
1083 struct inode *new_dir, struct dentry *new_dentry);
1084 int (*inode_readlink) (struct dentry *dentry);
1085 int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
1086 int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd);
1087 int (*inode_setattr) (struct dentry *dentry, struct iattr *attr);
1088 int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
1089 void (*inode_delete) (struct inode *inode);
1090 int (*inode_setxattr) (struct dentry *dentry, char *name, void *value,
1091 size_t size, int flags);
1092 void (*inode_post_setxattr) (struct dentry *dentry, char *name, void *value,
1093 size_t size, int flags);
1094 int (*inode_getxattr) (struct dentry *dentry, char *name);
1095 int (*inode_listxattr) (struct dentry *dentry);
1096 int (*inode_removexattr) (struct dentry *dentry, char *name);
1097 int (*inode_getsecurity)(struct inode *inode, const char *name, void *buffer, size_t size, int err);
1098 int (*inode_setsecurity)(struct inode *inode, const char *name, const void *value, size_t size, int flags);
1099 int (*inode_listsecurity)(struct inode *inode, char *buffer, size_t buffer_size);
1101 int (*file_permission) (struct file * file, int mask);
1102 int (*file_alloc_security) (struct file * file);
1103 void (*file_free_security) (struct file * file);
1104 int (*file_ioctl) (struct file * file, unsigned int cmd,
1106 int (*file_mmap) (struct file * file,
1107 unsigned long reqprot,
1108 unsigned long prot, unsigned long flags);
1109 int (*file_mprotect) (struct vm_area_struct * vma,
1110 unsigned long reqprot,
1111 unsigned long prot);
1112 int (*file_lock) (struct file * file, unsigned int cmd);
1113 int (*file_fcntl) (struct file * file, unsigned int cmd,
1115 int (*file_set_fowner) (struct file * file);
1116 int (*file_send_sigiotask) (struct task_struct * tsk,
1117 struct fown_struct * fown, int sig);
1118 int (*file_receive) (struct file * file);
1120 int (*task_create) (unsigned long clone_flags);
1121 int (*task_alloc_security) (struct task_struct * p);
1122 void (*task_free_security) (struct task_struct * p);
1123 int (*task_setuid) (uid_t id0, uid_t id1, uid_t id2, int flags);
1124 int (*task_post_setuid) (uid_t old_ruid /* or fsuid */ ,
1125 uid_t old_euid, uid_t old_suid, int flags);
1126 int (*task_setgid) (gid_t id0, gid_t id1, gid_t id2, int flags);
1127 int (*task_setpgid) (struct task_struct * p, pid_t pgid);
1128 int (*task_getpgid) (struct task_struct * p);
1129 int (*task_getsid) (struct task_struct * p);
1130 int (*task_setgroups) (struct group_info *group_info);
1131 int (*task_setnice) (struct task_struct * p, int nice);
1132 int (*task_setrlimit) (unsigned int resource, struct rlimit * new_rlim);
1133 int (*task_setscheduler) (struct task_struct * p, int policy,
1134 struct sched_param * lp);
1135 int (*task_getscheduler) (struct task_struct * p);
1136 int (*task_kill) (struct task_struct * p,
1137 struct siginfo * info, int sig);
1138 int (*task_wait) (struct task_struct * p);
1139 int (*task_prctl) (int option, unsigned long arg2,
1140 unsigned long arg3, unsigned long arg4,
1141 unsigned long arg5);
1142 void (*task_reparent_to_init) (struct task_struct * p);
1143 void (*task_to_inode)(struct task_struct *p, struct inode *inode);
1145 int (*ipc_permission) (struct kern_ipc_perm * ipcp, short flag);
1147 int (*msg_msg_alloc_security) (struct msg_msg * msg);
1148 void (*msg_msg_free_security) (struct msg_msg * msg);
1150 int (*msg_queue_alloc_security) (struct msg_queue * msq);
1151 void (*msg_queue_free_security) (struct msg_queue * msq);
1152 int (*msg_queue_associate) (struct msg_queue * msq, int msqflg);
1153 int (*msg_queue_msgctl) (struct msg_queue * msq, int cmd);
1154 int (*msg_queue_msgsnd) (struct msg_queue * msq,
1155 struct msg_msg * msg, int msqflg);
1156 int (*msg_queue_msgrcv) (struct msg_queue * msq,
1157 struct msg_msg * msg,
1158 struct task_struct * target,
1159 long type, int mode);
1161 int (*shm_alloc_security) (struct shmid_kernel * shp);
1162 void (*shm_free_security) (struct shmid_kernel * shp);
1163 int (*shm_associate) (struct shmid_kernel * shp, int shmflg);
1164 int (*shm_shmctl) (struct shmid_kernel * shp, int cmd);
1165 int (*shm_shmat) (struct shmid_kernel * shp,
1166 char __user *shmaddr, int shmflg);
1168 int (*sem_alloc_security) (struct sem_array * sma);
1169 void (*sem_free_security) (struct sem_array * sma);
1170 int (*sem_associate) (struct sem_array * sma, int semflg);
1171 int (*sem_semctl) (struct sem_array * sma, int cmd);
1172 int (*sem_semop) (struct sem_array * sma,
1173 struct sembuf * sops, unsigned nsops, int alter);
1175 int (*netlink_send) (struct sock * sk, struct sk_buff * skb);
1176 int (*netlink_recv) (struct sk_buff * skb);
1178 /* allow module stacking */
1179 int (*register_security) (const char *name,
1180 struct security_operations *ops);
1181 int (*unregister_security) (const char *name,
1182 struct security_operations *ops);
1184 void (*d_instantiate) (struct dentry *dentry, struct inode *inode);
1186 int (*getprocattr)(struct task_struct *p, char *name, void *value, size_t size);
1187 int (*setprocattr)(struct task_struct *p, char *name, void *value, size_t size);
1189 #ifdef CONFIG_SECURITY_NETWORK
1190 int (*unix_stream_connect) (struct socket * sock,
1191 struct socket * other, struct sock * newsk);
1192 int (*unix_may_send) (struct socket * sock, struct socket * other);
1194 int (*socket_create) (int family, int type, int protocol, int kern);
1195 void (*socket_post_create) (struct socket * sock, int family,
1196 int type, int protocol, int kern);
1197 int (*socket_bind) (struct socket * sock,
1198 struct sockaddr * address, int addrlen);
1199 int (*socket_connect) (struct socket * sock,
1200 struct sockaddr * address, int addrlen);
1201 int (*socket_listen) (struct socket * sock, int backlog);
1202 int (*socket_accept) (struct socket * sock, struct socket * newsock);
1203 void (*socket_post_accept) (struct socket * sock,
1204 struct socket * newsock);
1205 int (*socket_sendmsg) (struct socket * sock,
1206 struct msghdr * msg, int size);
1207 int (*socket_recvmsg) (struct socket * sock,
1208 struct msghdr * msg, int size, int flags);
1209 int (*socket_getsockname) (struct socket * sock);
1210 int (*socket_getpeername) (struct socket * sock);
1211 int (*socket_getsockopt) (struct socket * sock, int level, int optname);
1212 int (*socket_setsockopt) (struct socket * sock, int level, int optname);
1213 int (*socket_shutdown) (struct socket * sock, int how);
1214 int (*socket_sock_rcv_skb) (struct sock * sk, struct sk_buff * skb);
1215 int (*socket_getpeersec) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len);
1216 int (*sk_alloc_security) (struct sock *sk, int family, gfp_t priority);
1217 void (*sk_free_security) (struct sock *sk);
1218 #endif /* CONFIG_SECURITY_NETWORK */
1221 /* global variables */
1222 extern struct security_operations *security_ops;
1225 static inline int security_ptrace (struct task_struct * parent, struct task_struct * child)
1227 return security_ops->ptrace (parent, child);
1230 static inline int security_capget (struct task_struct *target,
1231 kernel_cap_t *effective,
1232 kernel_cap_t *inheritable,
1233 kernel_cap_t *permitted)
1235 return security_ops->capget (target, effective, inheritable, permitted);
1238 static inline int security_capset_check (struct task_struct *target,
1239 kernel_cap_t *effective,
1240 kernel_cap_t *inheritable,
1241 kernel_cap_t *permitted)
1243 return security_ops->capset_check (target, effective, inheritable, permitted);
1246 static inline void security_capset_set (struct task_struct *target,
1247 kernel_cap_t *effective,
1248 kernel_cap_t *inheritable,
1249 kernel_cap_t *permitted)
1251 security_ops->capset_set (target, effective, inheritable, permitted);
1254 static inline int security_acct (struct file *file)
1256 return security_ops->acct (file);
1259 static inline int security_sysctl(struct ctl_table *table, int op)
1261 return security_ops->sysctl(table, op);
1264 static inline int security_quotactl (int cmds, int type, int id,
1265 struct super_block *sb)
1267 return security_ops->quotactl (cmds, type, id, sb);
1270 static inline int security_quota_on (struct dentry * dentry)
1272 return security_ops->quota_on (dentry);
1275 static inline int security_syslog(int type)
1277 return security_ops->syslog(type);
1280 static inline int security_settime(struct timespec *ts, struct timezone *tz)
1282 return security_ops->settime(ts, tz);
1286 static inline int security_vm_enough_memory(long pages)
1288 return security_ops->vm_enough_memory(pages);
1291 static inline int security_bprm_alloc (struct linux_binprm *bprm)
1293 return security_ops->bprm_alloc_security (bprm);
1295 static inline void security_bprm_free (struct linux_binprm *bprm)
1297 security_ops->bprm_free_security (bprm);
1299 static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
1301 security_ops->bprm_apply_creds (bprm, unsafe);
1303 static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
1305 security_ops->bprm_post_apply_creds (bprm);
1307 static inline int security_bprm_set (struct linux_binprm *bprm)
1309 return security_ops->bprm_set_security (bprm);
1312 static inline int security_bprm_check (struct linux_binprm *bprm)
1314 return security_ops->bprm_check_security (bprm);
1317 static inline int security_bprm_secureexec (struct linux_binprm *bprm)
1319 return security_ops->bprm_secureexec (bprm);
1322 static inline int security_sb_alloc (struct super_block *sb)
1324 return security_ops->sb_alloc_security (sb);
1327 static inline void security_sb_free (struct super_block *sb)
1329 security_ops->sb_free_security (sb);
1332 static inline int security_sb_copy_data (struct file_system_type *type,
1333 void *orig, void *copy)
1335 return security_ops->sb_copy_data (type, orig, copy);
1338 static inline int security_sb_kern_mount (struct super_block *sb, void *data)
1340 return security_ops->sb_kern_mount (sb, data);
1343 static inline int security_sb_statfs (struct super_block *sb)
1345 return security_ops->sb_statfs (sb);
1348 static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
1349 char *type, unsigned long flags,
1352 return security_ops->sb_mount (dev_name, nd, type, flags, data);
1355 static inline int security_sb_check_sb (struct vfsmount *mnt,
1356 struct nameidata *nd)
1358 return security_ops->sb_check_sb (mnt, nd);
1361 static inline int security_sb_umount (struct vfsmount *mnt, int flags)
1363 return security_ops->sb_umount (mnt, flags);
1366 static inline void security_sb_umount_close (struct vfsmount *mnt)
1368 security_ops->sb_umount_close (mnt);
1371 static inline void security_sb_umount_busy (struct vfsmount *mnt)
1373 security_ops->sb_umount_busy (mnt);
1376 static inline void security_sb_post_remount (struct vfsmount *mnt,
1377 unsigned long flags, void *data)
1379 security_ops->sb_post_remount (mnt, flags, data);
1382 static inline void security_sb_post_mountroot (void)
1384 security_ops->sb_post_mountroot ();
1387 static inline void security_sb_post_addmount (struct vfsmount *mnt,
1388 struct nameidata *mountpoint_nd)
1390 security_ops->sb_post_addmount (mnt, mountpoint_nd);
1393 static inline int security_sb_pivotroot (struct nameidata *old_nd,
1394 struct nameidata *new_nd)
1396 return security_ops->sb_pivotroot (old_nd, new_nd);
1399 static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
1400 struct nameidata *new_nd)
1402 security_ops->sb_post_pivotroot (old_nd, new_nd);
1405 static inline int security_inode_alloc (struct inode *inode)
1407 if (unlikely (IS_PRIVATE (inode)))
1409 return security_ops->inode_alloc_security (inode);
1412 static inline void security_inode_free (struct inode *inode)
1414 if (unlikely (IS_PRIVATE (inode)))
1416 security_ops->inode_free_security (inode);
1419 static inline int security_inode_init_security (struct inode *inode,
1425 if (unlikely (IS_PRIVATE (inode)))
1427 return security_ops->inode_init_security (inode, dir, name, value, len);
1430 static inline int security_inode_create (struct inode *dir,
1431 struct dentry *dentry,
1434 if (unlikely (IS_PRIVATE (dir)))
1436 return security_ops->inode_create (dir, dentry, mode);
1439 static inline int security_inode_link (struct dentry *old_dentry,
1441 struct dentry *new_dentry)
1443 if (unlikely (IS_PRIVATE (old_dentry->d_inode)))
1445 return security_ops->inode_link (old_dentry, dir, new_dentry);
1448 static inline int security_inode_unlink (struct inode *dir,
1449 struct dentry *dentry)
1451 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1453 return security_ops->inode_unlink (dir, dentry);
1456 static inline int security_inode_symlink (struct inode *dir,
1457 struct dentry *dentry,
1458 const char *old_name)
1460 if (unlikely (IS_PRIVATE (dir)))
1462 return security_ops->inode_symlink (dir, dentry, old_name);
1465 static inline int security_inode_mkdir (struct inode *dir,
1466 struct dentry *dentry,
1469 if (unlikely (IS_PRIVATE (dir)))
1471 return security_ops->inode_mkdir (dir, dentry, mode);
1474 static inline int security_inode_rmdir (struct inode *dir,
1475 struct dentry *dentry)
1477 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1479 return security_ops->inode_rmdir (dir, dentry);
1482 static inline int security_inode_mknod (struct inode *dir,
1483 struct dentry *dentry,
1484 int mode, dev_t dev)
1486 if (unlikely (IS_PRIVATE (dir)))
1488 return security_ops->inode_mknod (dir, dentry, mode, dev);
1491 static inline int security_inode_rename (struct inode *old_dir,
1492 struct dentry *old_dentry,
1493 struct inode *new_dir,
1494 struct dentry *new_dentry)
1496 if (unlikely (IS_PRIVATE (old_dentry->d_inode) ||
1497 (new_dentry->d_inode && IS_PRIVATE (new_dentry->d_inode))))
1499 return security_ops->inode_rename (old_dir, old_dentry,
1500 new_dir, new_dentry);
1503 static inline int security_inode_readlink (struct dentry *dentry)
1505 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1507 return security_ops->inode_readlink (dentry);
1510 static inline int security_inode_follow_link (struct dentry *dentry,
1511 struct nameidata *nd)
1513 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1515 return security_ops->inode_follow_link (dentry, nd);
1518 static inline int security_inode_permission (struct inode *inode, int mask,
1519 struct nameidata *nd)
1521 if (unlikely (IS_PRIVATE (inode)))
1523 return security_ops->inode_permission (inode, mask, nd);
1526 static inline int security_inode_setattr (struct dentry *dentry,
1529 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1531 return security_ops->inode_setattr (dentry, attr);
1534 static inline int security_inode_getattr (struct vfsmount *mnt,
1535 struct dentry *dentry)
1537 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1539 return security_ops->inode_getattr (mnt, dentry);
1542 static inline void security_inode_delete (struct inode *inode)
1544 if (unlikely (IS_PRIVATE (inode)))
1546 security_ops->inode_delete (inode);
1549 static inline int security_inode_setxattr (struct dentry *dentry, char *name,
1550 void *value, size_t size, int flags)
1552 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1554 return security_ops->inode_setxattr (dentry, name, value, size, flags);
1557 static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
1558 void *value, size_t size, int flags)
1560 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1562 security_ops->inode_post_setxattr (dentry, name, value, size, flags);
1565 static inline int security_inode_getxattr (struct dentry *dentry, char *name)
1567 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1569 return security_ops->inode_getxattr (dentry, name);
1572 static inline int security_inode_listxattr (struct dentry *dentry)
1574 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1576 return security_ops->inode_listxattr (dentry);
1579 static inline int security_inode_removexattr (struct dentry *dentry, char *name)
1581 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1583 return security_ops->inode_removexattr (dentry, name);
1586 static inline int security_inode_getsecurity(struct inode *inode, const char *name, void *buffer, size_t size, int err)
1588 if (unlikely (IS_PRIVATE (inode)))
1590 return security_ops->inode_getsecurity(inode, name, buffer, size, err);
1593 static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
1595 if (unlikely (IS_PRIVATE (inode)))
1597 return security_ops->inode_setsecurity(inode, name, value, size, flags);
1600 static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
1602 if (unlikely (IS_PRIVATE (inode)))
1604 return security_ops->inode_listsecurity(inode, buffer, buffer_size);
1607 static inline int security_file_permission (struct file *file, int mask)
1609 return security_ops->file_permission (file, mask);
1612 static inline int security_file_alloc (struct file *file)
1614 return security_ops->file_alloc_security (file);
1617 static inline void security_file_free (struct file *file)
1619 security_ops->file_free_security (file);
1622 static inline int security_file_ioctl (struct file *file, unsigned int cmd,
1625 return security_ops->file_ioctl (file, cmd, arg);
1628 static inline int security_file_mmap (struct file *file, unsigned long reqprot,
1630 unsigned long flags)
1632 return security_ops->file_mmap (file, reqprot, prot, flags);
1635 static inline int security_file_mprotect (struct vm_area_struct *vma,
1636 unsigned long reqprot,
1639 return security_ops->file_mprotect (vma, reqprot, prot);
1642 static inline int security_file_lock (struct file *file, unsigned int cmd)
1644 return security_ops->file_lock (file, cmd);
1647 static inline int security_file_fcntl (struct file *file, unsigned int cmd,
1650 return security_ops->file_fcntl (file, cmd, arg);
1653 static inline int security_file_set_fowner (struct file *file)
1655 return security_ops->file_set_fowner (file);
1658 static inline int security_file_send_sigiotask (struct task_struct *tsk,
1659 struct fown_struct *fown,
1662 return security_ops->file_send_sigiotask (tsk, fown, sig);
1665 static inline int security_file_receive (struct file *file)
1667 return security_ops->file_receive (file);
1670 static inline int security_task_create (unsigned long clone_flags)
1672 return security_ops->task_create (clone_flags);
1675 static inline int security_task_alloc (struct task_struct *p)
1677 return security_ops->task_alloc_security (p);
1680 static inline void security_task_free (struct task_struct *p)
1682 security_ops->task_free_security (p);
1685 static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
1688 return security_ops->task_setuid (id0, id1, id2, flags);
1691 static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
1692 uid_t old_suid, int flags)
1694 return security_ops->task_post_setuid (old_ruid, old_euid, old_suid, flags);
1697 static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
1700 return security_ops->task_setgid (id0, id1, id2, flags);
1703 static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
1705 return security_ops->task_setpgid (p, pgid);
1708 static inline int security_task_getpgid (struct task_struct *p)
1710 return security_ops->task_getpgid (p);
1713 static inline int security_task_getsid (struct task_struct *p)
1715 return security_ops->task_getsid (p);
1718 static inline int security_task_setgroups (struct group_info *group_info)
1720 return security_ops->task_setgroups (group_info);
1723 static inline int security_task_setnice (struct task_struct *p, int nice)
1725 return security_ops->task_setnice (p, nice);
1728 static inline int security_task_setrlimit (unsigned int resource,
1729 struct rlimit *new_rlim)
1731 return security_ops->task_setrlimit (resource, new_rlim);
1734 static inline int security_task_setscheduler (struct task_struct *p,
1736 struct sched_param *lp)
1738 return security_ops->task_setscheduler (p, policy, lp);
1741 static inline int security_task_getscheduler (struct task_struct *p)
1743 return security_ops->task_getscheduler (p);
1746 static inline int security_task_kill (struct task_struct *p,
1747 struct siginfo *info, int sig)
1749 return security_ops->task_kill (p, info, sig);
1752 static inline int security_task_wait (struct task_struct *p)
1754 return security_ops->task_wait (p);
1757 static inline int security_task_prctl (int option, unsigned long arg2,
1762 return security_ops->task_prctl (option, arg2, arg3, arg4, arg5);
1765 static inline void security_task_reparent_to_init (struct task_struct *p)
1767 security_ops->task_reparent_to_init (p);
1770 static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
1772 security_ops->task_to_inode(p, inode);
1775 static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
1778 return security_ops->ipc_permission (ipcp, flag);
1781 static inline int security_msg_msg_alloc (struct msg_msg * msg)
1783 return security_ops->msg_msg_alloc_security (msg);
1786 static inline void security_msg_msg_free (struct msg_msg * msg)
1788 security_ops->msg_msg_free_security(msg);
1791 static inline int security_msg_queue_alloc (struct msg_queue *msq)
1793 return security_ops->msg_queue_alloc_security (msq);
1796 static inline void security_msg_queue_free (struct msg_queue *msq)
1798 security_ops->msg_queue_free_security (msq);
1801 static inline int security_msg_queue_associate (struct msg_queue * msq,
1804 return security_ops->msg_queue_associate (msq, msqflg);
1807 static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
1809 return security_ops->msg_queue_msgctl (msq, cmd);
1812 static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
1813 struct msg_msg * msg, int msqflg)
1815 return security_ops->msg_queue_msgsnd (msq, msg, msqflg);
1818 static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
1819 struct msg_msg * msg,
1820 struct task_struct * target,
1821 long type, int mode)
1823 return security_ops->msg_queue_msgrcv (msq, msg, target, type, mode);
1826 static inline int security_shm_alloc (struct shmid_kernel *shp)
1828 return security_ops->shm_alloc_security (shp);
1831 static inline void security_shm_free (struct shmid_kernel *shp)
1833 security_ops->shm_free_security (shp);
1836 static inline int security_shm_associate (struct shmid_kernel * shp,
1839 return security_ops->shm_associate(shp, shmflg);
1842 static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
1844 return security_ops->shm_shmctl (shp, cmd);
1847 static inline int security_shm_shmat (struct shmid_kernel * shp,
1848 char __user *shmaddr, int shmflg)
1850 return security_ops->shm_shmat(shp, shmaddr, shmflg);
1853 static inline int security_sem_alloc (struct sem_array *sma)
1855 return security_ops->sem_alloc_security (sma);
1858 static inline void security_sem_free (struct sem_array *sma)
1860 security_ops->sem_free_security (sma);
1863 static inline int security_sem_associate (struct sem_array * sma, int semflg)
1865 return security_ops->sem_associate (sma, semflg);
1868 static inline int security_sem_semctl (struct sem_array * sma, int cmd)
1870 return security_ops->sem_semctl(sma, cmd);
1873 static inline int security_sem_semop (struct sem_array * sma,
1874 struct sembuf * sops, unsigned nsops,
1877 return security_ops->sem_semop(sma, sops, nsops, alter);
1880 static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
1882 if (unlikely (inode && IS_PRIVATE (inode)))
1884 security_ops->d_instantiate (dentry, inode);
1887 static inline int security_getprocattr(struct task_struct *p, char *name, void *value, size_t size)
1889 return security_ops->getprocattr(p, name, value, size);
1892 static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
1894 return security_ops->setprocattr(p, name, value, size);
1897 static inline int security_netlink_send(struct sock *sk, struct sk_buff * skb)
1899 return security_ops->netlink_send(sk, skb);
1902 static inline int security_netlink_recv(struct sk_buff * skb)
1904 return security_ops->netlink_recv(skb);
1908 extern int security_init (void);
1909 extern int register_security (struct security_operations *ops);
1910 extern int unregister_security (struct security_operations *ops);
1911 extern int mod_reg_security (const char *name, struct security_operations *ops);
1912 extern int mod_unreg_security (const char *name, struct security_operations *ops);
1913 extern struct dentry *securityfs_create_file(const char *name, mode_t mode,
1914 struct dentry *parent, void *data,
1915 struct file_operations *fops);
1916 extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
1917 extern void securityfs_remove(struct dentry *dentry);
1920 #else /* CONFIG_SECURITY */
1923 * This is the default capabilities functionality. Most of these functions
1924 * are just stubbed out, but a few must call the proper capable code.
1927 static inline int security_init(void)
1932 static inline int security_ptrace (struct task_struct *parent, struct task_struct * child)
1934 return cap_ptrace (parent, child);
1937 static inline int security_capget (struct task_struct *target,
1938 kernel_cap_t *effective,
1939 kernel_cap_t *inheritable,
1940 kernel_cap_t *permitted)
1942 return cap_capget (target, effective, inheritable, permitted);
1945 static inline int security_capset_check (struct task_struct *target,
1946 kernel_cap_t *effective,
1947 kernel_cap_t *inheritable,
1948 kernel_cap_t *permitted)
1950 return cap_capset_check (target, effective, inheritable, permitted);
1953 static inline void security_capset_set (struct task_struct *target,
1954 kernel_cap_t *effective,
1955 kernel_cap_t *inheritable,
1956 kernel_cap_t *permitted)
1958 cap_capset_set (target, effective, inheritable, permitted);
1961 static inline int security_acct (struct file *file)
1966 static inline int security_sysctl(struct ctl_table *table, int op)
1971 static inline int security_quotactl (int cmds, int type, int id,
1972 struct super_block * sb)
1977 static inline int security_quota_on (struct dentry * dentry)
1982 static inline int security_syslog(int type)
1984 return cap_syslog(type);
1987 static inline int security_settime(struct timespec *ts, struct timezone *tz)
1989 return cap_settime(ts, tz);
1992 static inline int security_vm_enough_memory(long pages)
1994 return cap_vm_enough_memory(pages);
1997 static inline int security_bprm_alloc (struct linux_binprm *bprm)
2002 static inline void security_bprm_free (struct linux_binprm *bprm)
2005 static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
2007 cap_bprm_apply_creds (bprm, unsafe);
2010 static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
2015 static inline int security_bprm_set (struct linux_binprm *bprm)
2017 return cap_bprm_set_security (bprm);
2020 static inline int security_bprm_check (struct linux_binprm *bprm)
2025 static inline int security_bprm_secureexec (struct linux_binprm *bprm)
2027 return cap_bprm_secureexec(bprm);
2030 static inline int security_sb_alloc (struct super_block *sb)
2035 static inline void security_sb_free (struct super_block *sb)
2038 static inline int security_sb_copy_data (struct file_system_type *type,
2039 void *orig, void *copy)
2044 static inline int security_sb_kern_mount (struct super_block *sb, void *data)
2049 static inline int security_sb_statfs (struct super_block *sb)
2054 static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
2055 char *type, unsigned long flags,
2061 static inline int security_sb_check_sb (struct vfsmount *mnt,
2062 struct nameidata *nd)
2067 static inline int security_sb_umount (struct vfsmount *mnt, int flags)
2072 static inline void security_sb_umount_close (struct vfsmount *mnt)
2075 static inline void security_sb_umount_busy (struct vfsmount *mnt)
2078 static inline void security_sb_post_remount (struct vfsmount *mnt,
2079 unsigned long flags, void *data)
2082 static inline void security_sb_post_mountroot (void)
2085 static inline void security_sb_post_addmount (struct vfsmount *mnt,
2086 struct nameidata *mountpoint_nd)
2089 static inline int security_sb_pivotroot (struct nameidata *old_nd,
2090 struct nameidata *new_nd)
2095 static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
2096 struct nameidata *new_nd)
2099 static inline int security_inode_alloc (struct inode *inode)
2104 static inline void security_inode_free (struct inode *inode)
2107 static inline int security_inode_init_security (struct inode *inode,
2116 static inline int security_inode_create (struct inode *dir,
2117 struct dentry *dentry,
2123 static inline int security_inode_link (struct dentry *old_dentry,
2125 struct dentry *new_dentry)
2130 static inline int security_inode_unlink (struct inode *dir,
2131 struct dentry *dentry)
2136 static inline int security_inode_symlink (struct inode *dir,
2137 struct dentry *dentry,
2138 const char *old_name)
2143 static inline int security_inode_mkdir (struct inode *dir,
2144 struct dentry *dentry,
2150 static inline int security_inode_rmdir (struct inode *dir,
2151 struct dentry *dentry)
2156 static inline int security_inode_mknod (struct inode *dir,
2157 struct dentry *dentry,
2158 int mode, dev_t dev)
2163 static inline int security_inode_rename (struct inode *old_dir,
2164 struct dentry *old_dentry,
2165 struct inode *new_dir,
2166 struct dentry *new_dentry)
2171 static inline int security_inode_readlink (struct dentry *dentry)
2176 static inline int security_inode_follow_link (struct dentry *dentry,
2177 struct nameidata *nd)
2182 static inline int security_inode_permission (struct inode *inode, int mask,
2183 struct nameidata *nd)
2188 static inline int security_inode_setattr (struct dentry *dentry,
2194 static inline int security_inode_getattr (struct vfsmount *mnt,
2195 struct dentry *dentry)
2200 static inline void security_inode_delete (struct inode *inode)
2203 static inline int security_inode_setxattr (struct dentry *dentry, char *name,
2204 void *value, size_t size, int flags)
2206 return cap_inode_setxattr(dentry, name, value, size, flags);
2209 static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
2210 void *value, size_t size, int flags)
2213 static inline int security_inode_getxattr (struct dentry *dentry, char *name)
2218 static inline int security_inode_listxattr (struct dentry *dentry)
2223 static inline int security_inode_removexattr (struct dentry *dentry, char *name)
2225 return cap_inode_removexattr(dentry, name);
2228 static inline int security_inode_getsecurity(struct inode *inode, const char *name, void *buffer, size_t size, int err)
2233 static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
2238 static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
2243 static inline int security_file_permission (struct file *file, int mask)
2248 static inline int security_file_alloc (struct file *file)
2253 static inline void security_file_free (struct file *file)
2256 static inline int security_file_ioctl (struct file *file, unsigned int cmd,
2262 static inline int security_file_mmap (struct file *file, unsigned long reqprot,
2264 unsigned long flags)
2269 static inline int security_file_mprotect (struct vm_area_struct *vma,
2270 unsigned long reqprot,
2276 static inline int security_file_lock (struct file *file, unsigned int cmd)
2281 static inline int security_file_fcntl (struct file *file, unsigned int cmd,
2287 static inline int security_file_set_fowner (struct file *file)
2292 static inline int security_file_send_sigiotask (struct task_struct *tsk,
2293 struct fown_struct *fown,
2299 static inline int security_file_receive (struct file *file)
2304 static inline int security_task_create (unsigned long clone_flags)
2309 static inline int security_task_alloc (struct task_struct *p)
2314 static inline void security_task_free (struct task_struct *p)
2317 static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
2323 static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
2324 uid_t old_suid, int flags)
2326 return cap_task_post_setuid (old_ruid, old_euid, old_suid, flags);
2329 static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
2335 static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
2340 static inline int security_task_getpgid (struct task_struct *p)
2345 static inline int security_task_getsid (struct task_struct *p)
2350 static inline int security_task_setgroups (struct group_info *group_info)
2355 static inline int security_task_setnice (struct task_struct *p, int nice)
2360 static inline int security_task_setrlimit (unsigned int resource,
2361 struct rlimit *new_rlim)
2366 static inline int security_task_setscheduler (struct task_struct *p,
2368 struct sched_param *lp)
2373 static inline int security_task_getscheduler (struct task_struct *p)
2378 static inline int security_task_kill (struct task_struct *p,
2379 struct siginfo *info, int sig)
2384 static inline int security_task_wait (struct task_struct *p)
2389 static inline int security_task_prctl (int option, unsigned long arg2,
2397 static inline void security_task_reparent_to_init (struct task_struct *p)
2399 cap_task_reparent_to_init (p);
2402 static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
2405 static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
2411 static inline int security_msg_msg_alloc (struct msg_msg * msg)
2416 static inline void security_msg_msg_free (struct msg_msg * msg)
2419 static inline int security_msg_queue_alloc (struct msg_queue *msq)
2424 static inline void security_msg_queue_free (struct msg_queue *msq)
2427 static inline int security_msg_queue_associate (struct msg_queue * msq,
2433 static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
2438 static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
2439 struct msg_msg * msg, int msqflg)
2444 static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
2445 struct msg_msg * msg,
2446 struct task_struct * target,
2447 long type, int mode)
2452 static inline int security_shm_alloc (struct shmid_kernel *shp)
2457 static inline void security_shm_free (struct shmid_kernel *shp)
2460 static inline int security_shm_associate (struct shmid_kernel * shp,
2466 static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
2471 static inline int security_shm_shmat (struct shmid_kernel * shp,
2472 char __user *shmaddr, int shmflg)
2477 static inline int security_sem_alloc (struct sem_array *sma)
2482 static inline void security_sem_free (struct sem_array *sma)
2485 static inline int security_sem_associate (struct sem_array * sma, int semflg)
2490 static inline int security_sem_semctl (struct sem_array * sma, int cmd)
2495 static inline int security_sem_semop (struct sem_array * sma,
2496 struct sembuf * sops, unsigned nsops,
2502 static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
2505 static inline int security_getprocattr(struct task_struct *p, char *name, void *value, size_t size)
2510 static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2515 static inline int security_netlink_send (struct sock *sk, struct sk_buff *skb)
2517 return cap_netlink_send (sk, skb);
2520 static inline int security_netlink_recv (struct sk_buff *skb)
2522 return cap_netlink_recv (skb);
2525 #endif /* CONFIG_SECURITY */
2527 #ifdef CONFIG_SECURITY_NETWORK
2528 static inline int security_unix_stream_connect(struct socket * sock,
2529 struct socket * other,
2530 struct sock * newsk)
2532 return security_ops->unix_stream_connect(sock, other, newsk);
2536 static inline int security_unix_may_send(struct socket * sock,
2537 struct socket * other)
2539 return security_ops->unix_may_send(sock, other);
2542 static inline int security_socket_create (int family, int type,
2543 int protocol, int kern)
2545 return security_ops->socket_create(family, type, protocol, kern);
2548 static inline void security_socket_post_create(struct socket * sock,
2551 int protocol, int kern)
2553 security_ops->socket_post_create(sock, family, type,
2557 static inline int security_socket_bind(struct socket * sock,
2558 struct sockaddr * address,
2561 return security_ops->socket_bind(sock, address, addrlen);
2564 static inline int security_socket_connect(struct socket * sock,
2565 struct sockaddr * address,
2568 return security_ops->socket_connect(sock, address, addrlen);
2571 static inline int security_socket_listen(struct socket * sock, int backlog)
2573 return security_ops->socket_listen(sock, backlog);
2576 static inline int security_socket_accept(struct socket * sock,
2577 struct socket * newsock)
2579 return security_ops->socket_accept(sock, newsock);
2582 static inline void security_socket_post_accept(struct socket * sock,
2583 struct socket * newsock)
2585 security_ops->socket_post_accept(sock, newsock);
2588 static inline int security_socket_sendmsg(struct socket * sock,
2589 struct msghdr * msg, int size)
2591 return security_ops->socket_sendmsg(sock, msg, size);
2594 static inline int security_socket_recvmsg(struct socket * sock,
2595 struct msghdr * msg, int size,
2598 return security_ops->socket_recvmsg(sock, msg, size, flags);
2601 static inline int security_socket_getsockname(struct socket * sock)
2603 return security_ops->socket_getsockname(sock);
2606 static inline int security_socket_getpeername(struct socket * sock)
2608 return security_ops->socket_getpeername(sock);
2611 static inline int security_socket_getsockopt(struct socket * sock,
2612 int level, int optname)
2614 return security_ops->socket_getsockopt(sock, level, optname);
2617 static inline int security_socket_setsockopt(struct socket * sock,
2618 int level, int optname)
2620 return security_ops->socket_setsockopt(sock, level, optname);
2623 static inline int security_socket_shutdown(struct socket * sock, int how)
2625 return security_ops->socket_shutdown(sock, how);
2628 static inline int security_sock_rcv_skb (struct sock * sk,
2629 struct sk_buff * skb)
2631 return security_ops->socket_sock_rcv_skb (sk, skb);
2634 static inline int security_socket_getpeersec(struct socket *sock, char __user *optval,
2635 int __user *optlen, unsigned len)
2637 return security_ops->socket_getpeersec(sock, optval, optlen, len);
2640 static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
2642 return security_ops->sk_alloc_security(sk, family, priority);
2645 static inline void security_sk_free(struct sock *sk)
2647 return security_ops->sk_free_security(sk);
2649 #else /* CONFIG_SECURITY_NETWORK */
2650 static inline int security_unix_stream_connect(struct socket * sock,
2651 struct socket * other,
2652 struct sock * newsk)
2657 static inline int security_unix_may_send(struct socket * sock,
2658 struct socket * other)
2663 static inline int security_socket_create (int family, int type,
2664 int protocol, int kern)
2669 static inline void security_socket_post_create(struct socket * sock,
2672 int protocol, int kern)
2676 static inline int security_socket_bind(struct socket * sock,
2677 struct sockaddr * address,
2683 static inline int security_socket_connect(struct socket * sock,
2684 struct sockaddr * address,
2690 static inline int security_socket_listen(struct socket * sock, int backlog)
2695 static inline int security_socket_accept(struct socket * sock,
2696 struct socket * newsock)
2701 static inline void security_socket_post_accept(struct socket * sock,
2702 struct socket * newsock)
2706 static inline int security_socket_sendmsg(struct socket * sock,
2707 struct msghdr * msg, int size)
2712 static inline int security_socket_recvmsg(struct socket * sock,
2713 struct msghdr * msg, int size,
2719 static inline int security_socket_getsockname(struct socket * sock)
2724 static inline int security_socket_getpeername(struct socket * sock)
2729 static inline int security_socket_getsockopt(struct socket * sock,
2730 int level, int optname)
2735 static inline int security_socket_setsockopt(struct socket * sock,
2736 int level, int optname)
2741 static inline int security_socket_shutdown(struct socket * sock, int how)
2745 static inline int security_sock_rcv_skb (struct sock * sk,
2746 struct sk_buff * skb)
2751 static inline int security_socket_getpeersec(struct socket *sock, char __user *optval,
2752 int __user *optlen, unsigned len)
2754 return -ENOPROTOOPT;
2757 static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
2762 static inline void security_sk_free(struct sock *sk)
2765 #endif /* CONFIG_SECURITY_NETWORK */
2767 #endif /* ! __LINUX_SECURITY_H */