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/sysctl.h>
31 #include <linux/shm.h>
32 #include <linux/msg.h>
33 #include <linux/sched.h>
34 #include <linux/skbuff.h>
35 #include <linux/netlink.h>
38 * These functions are in security/capability.c and are used
39 * as the default capabilities functions
41 extern int cap_capable (struct task_struct *tsk, int cap);
42 extern int cap_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);
56 static inline int cap_netlink_send (struct sk_buff *skb)
58 NETLINK_CB (skb).eff_cap = current->cap_effective;
62 static inline int cap_netlink_recv (struct sk_buff *skb)
64 if (!cap_raised (NETLINK_CB (skb).eff_cap, CAP_NET_ADMIN))
70 * Values used in the task_security_ops calls
72 /* setuid or setgid, id0 == uid or gid */
73 #define LSM_SETID_ID 1
75 /* setreuid or setregid, id0 == real, id1 == eff */
76 #define LSM_SETID_RE 2
78 /* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
79 #define LSM_SETID_RES 4
81 /* setfsuid or setfsgid, id0 == fsuid or fsgid */
82 #define LSM_SETID_FS 8
84 /* forward declares to avoid warnings */
87 struct swap_info_struct;
89 /* bprm_apply_creds unsafe reasons */
90 #define LSM_UNSAFE_SHARE 1
91 #define LSM_UNSAFE_PTRACE 2
92 #define LSM_UNSAFE_PTRACE_CAP 4
94 #ifdef CONFIG_SECURITY
97 * struct security_operations - main security structure
99 * Security hooks for program execution operations.
101 * @bprm_alloc_security:
102 * Allocate and attach a security structure to the @bprm->security field.
103 * The security field is initialized to NULL when the bprm structure is
105 * @bprm contains the linux_binprm structure to be modified.
106 * Return 0 if operation was successful.
107 * @bprm_free_security:
108 * @bprm contains the linux_binprm structure to be modified.
109 * Deallocate and clear the @bprm->security field.
111 * Compute and set the security attributes of a process being transformed
112 * by an execve operation based on the old attributes (current->security)
113 * and the information saved in @bprm->security by the set_security hook.
114 * Since this hook function (and its caller) are void, this hook can not
115 * return an error. However, it can leave the security attributes of the
116 * process unchanged if an access failure occurs at this point. It can
117 * also perform other state changes on the process (e.g. closing open
118 * file descriptors to which access is no longer granted if the attributes
120 * bprm_apply_creds is called under task_lock. @unsafe indicates various
121 * reasons why it may be unsafe to change security state.
122 * @bprm contains the linux_binprm structure.
123 * @bprm_set_security:
124 * Save security information in the bprm->security field, typically based
125 * on information about the bprm->file, for later use by the apply_creds
126 * hook. This hook may also optionally check permissions (e.g. for
127 * transitions between security domains).
128 * This hook may be called multiple times during a single execve, e.g. for
129 * interpreters. The hook can tell whether it has already been called by
130 * checking to see if @bprm->security is non-NULL. If so, then the hook
131 * may decide either to retain the security information saved earlier or
133 * @bprm contains the linux_binprm structure.
134 * Return 0 if the hook is successful and permission is granted.
135 * @bprm_check_security:
136 * This hook mediates the point when a search for a binary handler will
137 * begin. It allows a check the @bprm->security value which is set in
138 * the preceding set_security call. The primary difference from
139 * set_security is that the argv list and envp list are reliably
140 * available in @bprm. This hook may be called multiple times
141 * during a single execve; and in each pass set_security is called
143 * @bprm contains the linux_binprm structure.
144 * Return 0 if the hook is successful and permission is granted.
146 * Return a boolean value (0 or 1) indicating whether a "secure exec"
147 * is required. The flag is passed in the auxiliary table
148 * on the initial stack to the ELF interpreter to indicate whether libc
149 * should enable secure mode.
150 * @bprm contains the linux_binprm structure.
152 * Security hooks for filesystem operations.
154 * @sb_alloc_security:
155 * Allocate and attach a security structure to the sb->s_security field.
156 * The s_security field is initialized to NULL when the structure is
158 * @sb contains the super_block structure to be modified.
159 * Return 0 if operation was successful.
161 * Deallocate and clear the sb->s_security field.
162 * @sb contains the super_block structure to be modified.
164 * Check permission before obtaining filesystem statistics for the @sb
166 * @sb contains the super_block structure for the filesystem.
167 * Return 0 if permission is granted.
169 * Check permission before an object specified by @dev_name is mounted on
170 * the mount point named by @nd. For an ordinary mount, @dev_name
171 * identifies a device if the file system type requires a device. For a
172 * remount (@flags & MS_REMOUNT), @dev_name is irrelevant. For a
173 * loopback/bind mount (@flags & MS_BIND), @dev_name identifies the
174 * pathname of the object being mounted.
175 * @dev_name contains the name for object being mounted.
176 * @nd contains the nameidata structure for mount point object.
177 * @type contains the filesystem type.
178 * @flags contains the mount flags.
179 * @data contains the filesystem-specific data.
180 * Return 0 if permission is granted.
182 * Allow mount option data to be copied prior to parsing by the filesystem,
183 * so that the security module can extract security-specific mount
184 * options cleanly (a filesystem may modify the data e.g. with strsep()).
185 * This also allows the original mount data to be stripped of security-
186 * specific options to avoid having to make filesystems aware of them.
187 * @type the type of filesystem being mounted.
188 * @orig the original mount data copied from userspace.
189 * @copy copied data which will be passed to the security module.
190 * Returns 0 if the copy was successful.
192 * Check permission before the device with superblock @mnt->sb is mounted
193 * on the mount point named by @nd.
194 * @mnt contains the vfsmount for device being mounted.
195 * @nd contains the nameidata object for the mount point.
196 * Return 0 if permission is granted.
198 * Check permission before the @mnt file system is unmounted.
199 * @mnt contains the mounted file system.
200 * @flags contains the unmount flags, e.g. MNT_FORCE.
201 * Return 0 if permission is granted.
203 * Close any files in the @mnt mounted filesystem that are held open by
204 * the security module. This hook is called during an umount operation
205 * prior to checking whether the filesystem is still busy.
206 * @mnt contains the mounted filesystem.
208 * Handle a failed umount of the @mnt mounted filesystem, e.g. re-opening
209 * any files that were closed by umount_close. This hook is called during
210 * an umount operation if the umount fails after a call to the
212 * @mnt contains the mounted filesystem.
214 * Update the security module's state when a filesystem is remounted.
215 * This hook is only called if the remount was successful.
216 * @mnt contains the mounted file system.
217 * @flags contains the new filesystem flags.
218 * @data contains the filesystem-specific data.
219 * @sb_post_mountroot:
220 * Update the security module's state when the root filesystem is mounted.
221 * This hook is only called if the mount was successful.
223 * Update the security module's state when a filesystem is mounted.
224 * This hook is called any time a mount is successfully grafetd to
226 * @mnt contains the mounted filesystem.
227 * @mountpoint_nd contains the nameidata structure for the mount point.
229 * Check permission before pivoting the root filesystem.
230 * @old_nd contains the nameidata structure for the new location of the current root (put_old).
231 * @new_nd contains the nameidata structure for the new root (new_root).
232 * Return 0 if permission is granted.
233 * @sb_post_pivotroot:
234 * Update module state after a successful pivot.
235 * @old_nd contains the nameidata structure for the old root.
236 * @new_nd contains the nameidata structure for the new root.
238 * Security hooks for inode operations.
240 * @inode_alloc_security:
241 * Allocate and attach a security structure to @inode->i_security. The
242 * i_security field is initialized to NULL when the inode structure is
244 * @inode contains the inode structure.
245 * Return 0 if operation was successful.
246 * @inode_free_security:
247 * @inode contains the inode structure.
248 * Deallocate the inode security structure and set @inode->i_security to
251 * Check permission to create a regular file.
252 * @dir contains inode structure of the parent of the new file.
253 * @dentry contains the dentry structure for the file to be created.
254 * @mode contains the file mode of the file to be created.
255 * Return 0 if permission is granted.
256 * @inode_post_create:
257 * Set the security attributes on a newly created regular file. This hook
258 * is called after a file has been successfully created.
259 * @dir contains the inode structure of the parent directory of the new file.
260 * @dentry contains the the dentry structure for the newly created file.
261 * @mode contains the file mode.
263 * Check permission before creating a new hard link to a file.
264 * @old_dentry contains the dentry structure for an existing link to the file.
265 * @dir contains the inode structure of the parent directory of the new link.
266 * @new_dentry contains the dentry structure for the new link.
267 * Return 0 if permission is granted.
269 * Set security attributes for a new hard link to a file.
270 * @old_dentry contains the dentry structure for the existing link.
271 * @dir contains the inode structure of the parent directory of the new file.
272 * @new_dentry contains the dentry structure for the new file link.
274 * Check the permission to remove a hard link to a file.
275 * @dir contains the inode structure of parent directory of the file.
276 * @dentry contains the dentry structure for file to be unlinked.
277 * Return 0 if permission is granted.
279 * Check the permission to create a symbolic link to a file.
280 * @dir contains the inode structure of parent directory of the symbolic link.
281 * @dentry contains the dentry structure of the symbolic link.
282 * @old_name contains the pathname of file.
283 * Return 0 if permission is granted.
284 * @inode_post_symlink:
285 * @dir contains the inode structure of the parent directory of the new link.
286 * @dentry contains the dentry structure of new symbolic link.
287 * @old_name contains the pathname of file.
288 * Set security attributes for a newly created symbolic link. Note that
289 * @dentry->d_inode may be NULL, since the filesystem might not
290 * instantiate the dentry (e.g. NFS).
292 * Check permissions to create a new directory in the existing directory
293 * associated with inode strcture @dir.
294 * @dir containst the inode structure of parent of the directory to be created.
295 * @dentry contains the dentry structure of new directory.
296 * @mode contains the mode of new directory.
297 * Return 0 if permission is granted.
299 * Set security attributes on a newly created directory.
300 * @dir contains the inode structure of parent of the directory to be created.
301 * @dentry contains the dentry structure of new directory.
302 * @mode contains the mode of new directory.
304 * Check the permission to remove a directory.
305 * @dir contains the inode structure of parent of the directory to be removed.
306 * @dentry contains the dentry structure of directory to be removed.
307 * Return 0 if permission is granted.
309 * Check permissions when creating a special file (or a socket or a fifo
310 * file created via the mknod system call). Note that if mknod operation
311 * is being done for a regular file, then the create hook will be called
313 * @dir contains the inode structure of parent of the new file.
314 * @dentry contains the dentry structure of the new file.
315 * @mode contains the mode of the new file.
316 * @dev contains the the device number.
317 * Return 0 if permission is granted.
319 * Set security attributes on a newly created special file (or socket or
320 * fifo file created via the mknod system call).
321 * @dir contains the inode structure of parent of the new node.
322 * @dentry contains the dentry structure of the new node.
323 * @mode contains the mode of the new node.
324 * @dev contains the the device number.
326 * Check for permission to rename a file or directory.
327 * @old_dir contains the inode structure for parent of the old link.
328 * @old_dentry contains the dentry structure of the old link.
329 * @new_dir contains the inode structure for parent of the new link.
330 * @new_dentry contains the dentry structure of the new link.
331 * Return 0 if permission is granted.
332 * @inode_post_rename:
333 * Set security attributes on a renamed file or directory.
334 * @old_dir contains the inode structure for parent of the old link.
335 * @old_dentry contains the dentry structure of the old link.
336 * @new_dir contains the inode structure for parent of the new link.
337 * @new_dentry contains the dentry structure of the new link.
339 * Check the permission to read the symbolic link.
340 * @dentry contains the dentry structure for the file link.
341 * Return 0 if permission is granted.
342 * @inode_follow_link:
343 * Check permission to follow a symbolic link when looking up a pathname.
344 * @dentry contains the dentry structure for the link.
345 * @nd contains the nameidata structure for the parent directory.
346 * Return 0 if permission is granted.
348 * Check permission before accessing an inode. This hook is called by the
349 * existing Linux permission function, so a security module can use it to
350 * provide additional checking for existing Linux permission checks.
351 * Notice that this hook is called when a file is opened (as well as many
352 * other operations), whereas the file_security_ops permission hook is
353 * called when the actual read/write operations are performed.
354 * @inode contains the inode structure to check.
355 * @mask contains the permission mask.
356 * @nd contains the nameidata (may be NULL).
357 * Return 0 if permission is granted.
359 * Check permission before setting file attributes. Note that the kernel
360 * call to notify_change is performed from several locations, whenever
361 * file attributes change (such as when a file is truncated, chown/chmod
362 * operations, transferring disk quotas, etc).
363 * @dentry contains the dentry structure for the file.
364 * @attr is the iattr structure containing the new file attributes.
365 * Return 0 if permission is granted.
367 * Check permission before obtaining file attributes.
368 * @mnt is the vfsmount where the dentry was looked up
369 * @dentry contains the dentry structure for the file.
370 * Return 0 if permission is granted.
372 * @inode contains the inode structure for deleted inode.
373 * This hook is called when a deleted inode is released (i.e. an inode
374 * with no hard links has its use count drop to zero). A security module
375 * can use this hook to release any persistent label associated with the
378 * Check permission before setting the extended attributes
379 * @value identified by @name for @dentry.
380 * Return 0 if permission is granted.
381 * @inode_post_setxattr:
382 * Update inode security field after successful setxattr operation.
383 * @value identified by @name for @dentry.
385 * Check permission before obtaining the extended attributes
386 * identified by @name for @dentry.
387 * Return 0 if permission is granted.
389 * Check permission before obtaining the list of extended attribute
391 * Return 0 if permission is granted.
392 * @inode_removexattr:
393 * Check permission before removing the extended attribute
394 * identified by @name for @dentry.
395 * Return 0 if permission is granted.
396 * @inode_getsecurity:
397 * Copy the extended attribute representation of the security label
398 * associated with @name for @dentry into @buffer. @buffer may be
399 * NULL to request the size of the buffer required. @size indicates
400 * the size of @buffer in bytes. Note that @name is the remainder
401 * of the attribute name after the security. prefix has been removed.
402 * Return number of bytes used/required on success.
403 * @inode_setsecurity:
404 * Set the security label associated with @name for @dentry from the
405 * extended attribute value @value. @size indicates the size of the
406 * @value in bytes. @flags may be XATTR_CREATE, XATTR_REPLACE, or 0.
407 * Note that @name is the remainder of the attribute name after the
408 * security. prefix has been removed.
409 * Return 0 on success.
410 * @inode_listsecurity:
411 * Copy the extended attribute names for the security labels
412 * associated with @dentry into @buffer. @buffer may be NULL to
413 * request the size of the buffer required.
414 * Returns number of bytes used/required on success.
416 * Security hooks for file operations
419 * Check file permissions before accessing an open file. This hook is
420 * called by various operations that read or write files. A security
421 * module can use this hook to perform additional checking on these
422 * operations, e.g. to revalidate permissions on use to support privilege
423 * bracketing or policy changes. Notice that this hook is used when the
424 * actual read/write operations are performed, whereas the
425 * inode_security_ops hook is called when a file is opened (as well as
426 * many other operations).
427 * Caveat: Although this hook can be used to revalidate permissions for
428 * various system call operations that read or write files, it does not
429 * address the revalidation of permissions for memory-mapped files.
430 * Security modules must handle this separately if they need such
432 * @file contains the file structure being accessed.
433 * @mask contains the requested permissions.
434 * Return 0 if permission is granted.
435 * @file_alloc_security:
436 * Allocate and attach a security structure to the file->f_security field.
437 * The security field is initialized to NULL when the structure is first
439 * @file contains the file structure to secure.
440 * Return 0 if the hook is successful and permission is granted.
441 * @file_free_security:
442 * Deallocate and free any security structures stored in file->f_security.
443 * @file contains the file structure being modified.
445 * @file contains the file structure.
446 * @cmd contains the operation to perform.
447 * @arg contains the operational arguments.
448 * Check permission for an ioctl operation on @file. Note that @arg can
449 * sometimes represents a user space pointer; in other cases, it may be a
450 * simple integer value. When @arg represents a user space pointer, it
451 * should never be used by the security module.
452 * Return 0 if permission is granted.
454 * Check permissions for a mmap operation. The @file may be NULL, e.g.
455 * if mapping anonymous memory.
456 * @file contains the file structure for file to map (may be NULL).
457 * @prot contains the requested permissions.
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 * @prot contains the requested permissions.
464 * Return 0 if permission is granted.
466 * Check permission before performing file locking operations.
467 * Note: this hook mediates both flock and fcntl style locks.
468 * @file contains the file structure.
469 * @cmd contains the posix-translated lock operation to perform
470 * (e.g. F_RDLCK, F_WRLCK).
471 * Return 0 if permission is granted.
473 * Check permission before allowing the file operation specified by @cmd
474 * from being performed on the file @file. Note that @arg can sometimes
475 * represents a user space pointer; in other cases, it may be a simple
476 * integer value. When @arg represents a user space pointer, it should
477 * never be used by the security module.
478 * @file contains the file structure.
479 * @cmd contains the operation to be performed.
480 * @arg contains the operational arguments.
481 * Return 0 if permission is granted.
483 * Save owner security information (typically from current->security) in
484 * file->f_security for later use by the send_sigiotask hook.
485 * @file contains the file structure to update.
486 * Return 0 on success.
487 * @file_send_sigiotask:
488 * Check permission for the file owner @fown to send SIGIO to the process
489 * @tsk. Note that this hook is always called from interrupt. Note that
490 * the fown_struct, @fown, is never outside the context of a struct file,
491 * so the file structure (and associated security information) can always
493 * (struct file *)((long)fown - offsetof(struct file,f_owner));
494 * @tsk contains the structure of task receiving signal.
495 * @fown contains the file owner information.
496 * @fd contains the file descriptor.
497 * @reason contains the operational flags.
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 * Check permission before setting the supplementary group set of the
575 * @group_info contains the new group information.
576 * Return 0 if permission is granted.
578 * Check permission before setting the nice value of @p to @nice.
579 * @p contains the task_struct of process.
580 * @nice contains the new nice value.
581 * Return 0 if permission is granted.
583 * Check permission before setting the resource limits of the current
584 * process for @resource to @new_rlim. The old resource limit values can
585 * be examined by dereferencing (current->rlim + resource).
586 * @resource contains the resource whose limit is being set.
587 * @new_rlim contains the new limits for @resource.
588 * Return 0 if permission is granted.
589 * @task_setscheduler:
590 * Check permission before setting scheduling policy and/or parameters of
591 * process @p based on @policy and @lp.
592 * @p contains the task_struct for process.
593 * @policy contains the scheduling policy.
594 * @lp contains the scheduling parameters.
595 * Return 0 if permission is granted.
596 * @task_getscheduler:
597 * Check permission before obtaining scheduling information for process
599 * @p contains the task_struct for process.
600 * Return 0 if permission is granted.
602 * Check permission before sending signal @sig to @p. @info can be NULL,
603 * the constant 1, or a pointer to a siginfo structure. If @info is 1 or
604 * SI_FROMKERNEL(info) is true, then the signal should be viewed as coming
605 * from the kernel and should typically be permitted.
606 * SIGIO signals are handled separately by the send_sigiotask hook in
608 * @p contains the task_struct for process.
609 * @info contains the signal information.
610 * @sig contains the signal value.
611 * Return 0 if permission is granted.
613 * Check permission before allowing a process to reap a child process @p
614 * and collect its status information.
615 * @p contains the task_struct for process.
616 * Return 0 if permission is granted.
618 * Check permission before performing a process control operation on the
620 * @option contains the operation.
621 * @arg2 contains a argument.
622 * @arg3 contains a argument.
623 * @arg4 contains a argument.
624 * @arg5 contains a argument.
625 * Return 0 if permission is granted.
626 * @task_reparent_to_init:
627 * Set the security attributes in @p->security for a kernel thread that
628 * is being reparented to the init task.
629 * @p contains the task_struct for the kernel thread.
631 * Set the security attributes for an inode based on an associated task's
632 * security attributes, e.g. for /proc/pid inodes.
633 * @p contains the task_struct for the task.
634 * @inode contains the inode structure for the inode.
636 * Security hooks for Netlink messaging.
639 * Save security information for a netlink message so that permission
640 * checking can be performed when the message is processed. The security
641 * information can be saved using the eff_cap field of the
642 * netlink_skb_parms structure.
643 * @skb contains the sk_buff structure for the netlink message.
644 * Return 0 if the information was successfully saved.
646 * Check permission before processing the received netlink message in
648 * @skb contains the sk_buff structure for the netlink message.
649 * Return 0 if permission is granted.
651 * Security hooks for Unix domain networking.
653 * @unix_stream_connect:
654 * Check permissions before establishing a Unix domain stream connection
655 * between @sock and @other.
656 * @sock contains the socket structure.
657 * @other contains the peer socket structure.
658 * Return 0 if permission is granted.
660 * Check permissions before connecting or sending datagrams from @sock to
662 * @sock contains the socket structure.
663 * @sock contains the peer socket structure.
664 * Return 0 if permission is granted.
666 * The @unix_stream_connect and @unix_may_send hooks were necessary because
667 * Linux provides an alternative to the conventional file name space for Unix
668 * domain sockets. Whereas binding and connecting to sockets in the file name
669 * space is mediated by the typical file permissions (and caught by the mknod
670 * and permission hooks in inode_security_ops), binding and connecting to
671 * sockets in the abstract name space is completely unmediated. Sufficient
672 * control of Unix domain sockets in the abstract name space isn't possible
673 * using only the socket layer hooks, since we need to know the actual target
674 * socket, which is not looked up until we are inside the af_unix code.
676 * Security hooks for socket operations.
679 * Check permissions prior to creating a new socket.
680 * @family contains the requested protocol family.
681 * @type contains the requested communications type.
682 * @protocol contains the requested protocol.
683 * @kern set to 1 if a kernel socket.
684 * Return 0 if permission is granted.
685 * @socket_post_create:
686 * This hook allows a module to update or allocate a per-socket security
687 * structure. Note that the security field was not added directly to the
688 * socket structure, but rather, the socket security information is stored
689 * in the associated inode. Typically, the inode alloc_security hook will
690 * allocate and and attach security information to
691 * sock->inode->i_security. This hook may be used to update the
692 * sock->inode->i_security field with additional information that wasn't
693 * available when the inode was allocated.
694 * @sock contains the newly created socket structure.
695 * @family contains the requested protocol family.
696 * @type contains the requested communications type.
697 * @protocol contains the requested protocol.
698 * @kern set to 1 if a kernel socket.
700 * Check permission before socket protocol layer bind operation is
701 * performed and the socket @sock is bound to the address specified in the
702 * @address parameter.
703 * @sock contains the socket structure.
704 * @address contains the address to bind to.
705 * @addrlen contains the length of address.
706 * Return 0 if permission is granted.
708 * Check permission before socket protocol layer connect operation
709 * attempts to connect socket @sock to a remote address, @address.
710 * @sock contains the socket structure.
711 * @address contains the address of remote endpoint.
712 * @addrlen contains the length of address.
713 * Return 0 if permission is granted.
715 * Check permission before socket protocol layer listen operation.
716 * @sock contains the socket structure.
717 * @backlog contains the maximum length for the pending connection queue.
718 * Return 0 if permission is granted.
720 * Check permission before accepting a new connection. Note that the new
721 * socket, @newsock, has been created and some information copied to it,
722 * but the accept operation has not actually been performed.
723 * @sock contains the listening socket structure.
724 * @newsock contains the newly created server socket for connection.
725 * Return 0 if permission is granted.
726 * @socket_post_accept:
727 * This hook allows a security module to copy security
728 * information into the newly created socket's inode.
729 * @sock contains the listening socket structure.
730 * @newsock contains the newly created server socket for connection.
732 * Check permission before transmitting a message to another socket.
733 * @sock contains the socket structure.
734 * @msg contains the message to be transmitted.
735 * @size contains the size of message.
736 * Return 0 if permission is granted.
738 * Check permission before receiving a message from a socket.
739 * @sock contains the socket structure.
740 * @msg contains the message structure.
741 * @size contains the size of message structure.
742 * @flags contains the operational flags.
743 * Return 0 if permission is granted.
744 * @socket_getsockname:
745 * Check permission before the local address (name) of the socket object
746 * @sock is retrieved.
747 * @sock contains the socket structure.
748 * Return 0 if permission is granted.
749 * @socket_getpeername:
750 * Check permission before the remote address (name) of a socket object
751 * @sock is retrieved.
752 * @sock contains the socket structure.
753 * Return 0 if permission is granted.
754 * @socket_getsockopt:
755 * Check permissions before retrieving the options associated with socket
757 * @sock contains the socket structure.
758 * @level contains the protocol level to retrieve option from.
759 * @optname contains the name of option to retrieve.
760 * Return 0 if permission is granted.
761 * @socket_setsockopt:
762 * Check permissions before setting the options associated with socket
764 * @sock contains the socket structure.
765 * @level contains the protocol level to set options for.
766 * @optname contains the name of the option to set.
767 * Return 0 if permission is granted.
769 * Checks permission before all or part of a connection on the socket
770 * @sock is shut down.
771 * @sock contains the socket structure.
772 * @how contains the flag indicating how future sends and receives are handled.
773 * Return 0 if permission is granted.
774 * @socket_sock_rcv_skb:
775 * Check permissions on incoming network packets. This hook is distinct
776 * from Netfilter's IP input hooks since it is the first time that the
777 * incoming sk_buff @skb has been associated with a particular socket, @sk.
778 * @sk contains the sock (not socket) associated with the incoming sk_buff.
779 * @skb contains the incoming network data.
780 * @socket_getpeersec:
781 * This hook allows the security module to provide peer socket security
782 * state to userspace via getsockopt SO_GETPEERSEC.
783 * @sock is the local socket.
784 * @optval userspace memory where the security state is to be copied.
785 * @optlen userspace int where the module should copy the actual length
786 * of the security state.
787 * @len as input is the maximum length to copy to userspace provided
789 * Return 0 if all is well, otherwise, typical getsockopt return
791 * @sk_alloc_security:
792 * Allocate and attach a security structure to the sk->sk_security field,
793 * which is used to copy security attributes between local stream sockets.
795 * Deallocate security structure.
797 * Security hooks affecting all System V IPC operations.
800 * Check permissions for access to IPC
801 * @ipcp contains the kernel IPC permission structure
802 * @flag contains the desired (requested) permission set
803 * Return 0 if permission is granted.
805 * Security hooks for individual messages held in System V IPC message queues
806 * @msg_msg_alloc_security:
807 * Allocate and attach a security structure to the msg->security field.
808 * The security field is initialized to NULL when the structure is first
810 * @msg contains the message structure to be modified.
811 * Return 0 if operation was successful and permission is granted.
812 * @msg_msg_free_security:
813 * Deallocate the security structure for this message.
814 * @msg contains the message structure to be modified.
816 * Security hooks for System V IPC Message Queues
818 * @msg_queue_alloc_security:
819 * Allocate and attach a security structure to the
820 * msq->q_perm.security field. The security field is initialized to
821 * NULL when the structure is first created.
822 * @msq contains the message queue structure to be modified.
823 * Return 0 if operation was successful and permission is granted.
824 * @msg_queue_free_security:
825 * Deallocate security structure for this message queue.
826 * @msq contains the message queue structure to be modified.
827 * @msg_queue_associate:
828 * Check permission when a message queue is requested through the
829 * msgget system call. This hook is only called when returning the
830 * message queue identifier for an existing message queue, not when a
831 * new message queue is created.
832 * @msq contains the message queue to act upon.
833 * @msqflg contains the operation control flags.
834 * Return 0 if permission is granted.
836 * Check permission when a message control operation specified by @cmd
837 * is to be performed on the message queue @msq.
838 * The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO.
839 * @msq contains the message queue to act upon. May be NULL.
840 * @cmd contains the operation to be performed.
841 * Return 0 if permission is granted.
843 * Check permission before a message, @msg, is enqueued on the message
845 * @msq contains the message queue to send message to.
846 * @msg contains the message to be enqueued.
847 * @msqflg contains operational flags.
848 * Return 0 if permission is granted.
850 * Check permission before a message, @msg, is removed from the message
851 * queue, @msq. The @target task structure contains a pointer to the
852 * process that will be receiving the message (not equal to the current
853 * process when inline receives are being performed).
854 * @msq contains the message queue to retrieve message from.
855 * @msg contains the message destination.
856 * @target contains the task structure for recipient process.
857 * @type contains the type of message requested.
858 * @mode contains the operational flags.
859 * Return 0 if permission is granted.
861 * Security hooks for System V Shared Memory Segments
863 * @shm_alloc_security:
864 * Allocate and attach a security structure to the shp->shm_perm.security
865 * field. The security field is initialized to NULL when the structure is
867 * @shp contains the shared memory structure to be modified.
868 * Return 0 if operation was successful and permission is granted.
869 * @shm_free_security:
870 * Deallocate the security struct for this memory segment.
871 * @shp contains the shared memory structure to be modified.
873 * Check permission when a shared memory region is requested through the
874 * shmget system call. This hook is only called when returning the shared
875 * memory region identifier for an existing region, not when a new shared
876 * memory region is created.
877 * @shp contains the shared memory structure to be modified.
878 * @shmflg contains the operation control flags.
879 * Return 0 if permission is granted.
881 * Check permission when a shared memory control operation specified by
882 * @cmd is to be performed on the shared memory region @shp.
883 * The @shp may be NULL, e.g. for IPC_INFO or SHM_INFO.
884 * @shp contains shared memory structure to be modified.
885 * @cmd contains the operation to be performed.
886 * Return 0 if permission is granted.
888 * Check permissions prior to allowing the shmat system call to attach the
889 * shared memory segment @shp to the data segment of the calling process.
890 * The attaching address is specified by @shmaddr.
891 * @shp contains the shared memory structure to be modified.
892 * @shmaddr contains the address to attach memory region to.
893 * @shmflg contains the operational flags.
894 * Return 0 if permission is granted.
896 * Security hooks for System V Semaphores
898 * @sem_alloc_security:
899 * Allocate and attach a security structure to the sma->sem_perm.security
900 * field. The security field is initialized to NULL when the structure is
902 * @sma contains the semaphore structure
903 * Return 0 if operation was successful and permission is granted.
904 * @sem_free_security:
905 * deallocate security struct for this semaphore
906 * @sma contains the semaphore structure.
908 * Check permission when a semaphore is requested through the semget
909 * system call. This hook is only called when returning the semaphore
910 * identifier for an existing semaphore, not when a new one must be
912 * @sma contains the semaphore structure.
913 * @semflg contains the operation control flags.
914 * Return 0 if permission is granted.
916 * Check permission when a semaphore operation specified by @cmd is to be
917 * performed on the semaphore @sma. The @sma may be NULL, e.g. for
918 * IPC_INFO or SEM_INFO.
919 * @sma contains the semaphore structure. May be NULL.
920 * @cmd contains the operation to be performed.
921 * Return 0 if permission is granted.
923 * Check permissions before performing operations on members of the
924 * semaphore set @sma. If the @alter flag is nonzero, the semaphore set
926 * @sma contains the semaphore structure.
927 * @sops contains the operations to perform.
928 * @nsops contains the number of operations to perform.
929 * @alter contains the flag indicating whether changes are to be made.
930 * Return 0 if permission is granted.
933 * Check permission before allowing the @parent process to trace the
935 * Security modules may also want to perform a process tracing check
936 * during an execve in the set_security or apply_creds hooks of
937 * binprm_security_ops if the process is being traced and its security
938 * attributes would be changed by the execve.
939 * @parent contains the task_struct structure for parent process.
940 * @child contains the task_struct structure for child process.
941 * Return 0 if permission is granted.
943 * Get the @effective, @inheritable, and @permitted capability sets for
944 * the @target process. The hook may also perform permission checking to
945 * determine if the current process is allowed to see the capability sets
946 * of the @target process.
947 * @target contains the task_struct structure for target process.
948 * @effective contains the effective capability set.
949 * @inheritable contains the inheritable capability set.
950 * @permitted contains the permitted capability set.
951 * Return 0 if the capability sets were successfully obtained.
953 * Check permission before setting the @effective, @inheritable, and
954 * @permitted capability sets for the @target process.
955 * Caveat: @target is also set to current if a set of processes is
956 * specified (i.e. all processes other than current and init or a
957 * particular process group). Hence, the capset_set hook may need to
958 * revalidate permission to the actual target process.
959 * @target contains the task_struct structure for target process.
960 * @effective contains the effective capability set.
961 * @inheritable contains the inheritable capability set.
962 * @permitted contains the permitted capability set.
963 * Return 0 if permission is granted.
965 * Set the @effective, @inheritable, and @permitted capability sets for
966 * the @target process. Since capset_check cannot always check permission
967 * to the real @target process, this hook may also perform permission
968 * checking to determine if the current process is allowed to set the
969 * capability sets of the @target process. However, this hook has no way
970 * of returning an error due to the structure of the sys_capset code.
971 * @target contains the task_struct structure for target process.
972 * @effective contains the effective capability set.
973 * @inheritable contains the inheritable capability set.
974 * @permitted contains the permitted capability set.
976 * Check permission before enabling or disabling process accounting. If
977 * accounting is being enabled, then @file refers to the open file used to
978 * store accounting records. If accounting is being disabled, then @file
980 * @file contains the file structure for the accounting file (may be NULL).
981 * Return 0 if permission is granted.
983 * Check permission before accessing the @table sysctl variable in the
984 * manner specified by @op.
985 * @table contains the ctl_table structure for the sysctl variable.
986 * @op contains the operation (001 = search, 002 = write, 004 = read).
987 * Return 0 if permission is granted.
989 * Check whether the @tsk process has the @cap capability.
990 * @tsk contains the task_struct for the process.
991 * @cap contains the capability <include/linux/capability.h>.
992 * Return 0 if the capability is granted for @tsk.
994 * Check permission before accessing the kernel message ring or changing
995 * logging to the console.
996 * See the syslog(2) manual page for an explanation of the @type values.
997 * @type contains the type of action.
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) (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 file * f);
1033 int (*syslog) (int type);
1034 int (*vm_enough_memory) (long pages);
1036 int (*bprm_alloc_security) (struct linux_binprm * bprm);
1037 void (*bprm_free_security) (struct linux_binprm * bprm);
1038 void (*bprm_apply_creds) (struct linux_binprm * bprm, int unsafe);
1039 int (*bprm_set_security) (struct linux_binprm * bprm);
1040 int (*bprm_check_security) (struct linux_binprm * bprm);
1041 int (*bprm_secureexec) (struct linux_binprm * bprm);
1043 int (*sb_alloc_security) (struct super_block * sb);
1044 void (*sb_free_security) (struct super_block * sb);
1045 int (*sb_copy_data)(struct file_system_type *type,
1046 void *orig, void *copy);
1047 int (*sb_kern_mount) (struct super_block *sb, void *data);
1048 int (*sb_statfs) (struct super_block * sb);
1049 int (*sb_mount) (char *dev_name, struct nameidata * nd,
1050 char *type, unsigned long flags, void *data);
1051 int (*sb_check_sb) (struct vfsmount * mnt, struct nameidata * nd);
1052 int (*sb_umount) (struct vfsmount * mnt, int flags);
1053 void (*sb_umount_close) (struct vfsmount * mnt);
1054 void (*sb_umount_busy) (struct vfsmount * mnt);
1055 void (*sb_post_remount) (struct vfsmount * mnt,
1056 unsigned long flags, void *data);
1057 void (*sb_post_mountroot) (void);
1058 void (*sb_post_addmount) (struct vfsmount * mnt,
1059 struct nameidata * mountpoint_nd);
1060 int (*sb_pivotroot) (struct nameidata * old_nd,
1061 struct nameidata * new_nd);
1062 void (*sb_post_pivotroot) (struct nameidata * old_nd,
1063 struct nameidata * new_nd);
1065 int (*inode_alloc_security) (struct inode *inode);
1066 void (*inode_free_security) (struct inode *inode);
1067 int (*inode_create) (struct inode *dir,
1068 struct dentry *dentry, int mode);
1069 void (*inode_post_create) (struct inode *dir,
1070 struct dentry *dentry, int mode);
1071 int (*inode_link) (struct dentry *old_dentry,
1072 struct inode *dir, struct dentry *new_dentry);
1073 void (*inode_post_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 void (*inode_post_symlink) (struct inode *dir,
1079 struct dentry *dentry,
1080 const char *old_name);
1081 int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode);
1082 void (*inode_post_mkdir) (struct inode *dir, struct dentry *dentry,
1084 int (*inode_rmdir) (struct inode *dir, struct dentry *dentry);
1085 int (*inode_mknod) (struct inode *dir, struct dentry *dentry,
1086 int mode, dev_t dev);
1087 void (*inode_post_mknod) (struct inode *dir, struct dentry *dentry,
1088 int mode, dev_t dev);
1089 int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
1090 struct inode *new_dir, struct dentry *new_dentry);
1091 void (*inode_post_rename) (struct inode *old_dir,
1092 struct dentry *old_dentry,
1093 struct inode *new_dir,
1094 struct dentry *new_dentry);
1095 int (*inode_readlink) (struct dentry *dentry);
1096 int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
1097 int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd);
1098 int (*inode_setattr) (struct dentry *dentry, struct iattr *attr);
1099 int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
1100 void (*inode_delete) (struct inode *inode);
1101 int (*inode_setxattr) (struct dentry *dentry, char *name, void *value,
1102 size_t size, int flags);
1103 void (*inode_post_setxattr) (struct dentry *dentry, char *name, void *value,
1104 size_t size, int flags);
1105 int (*inode_getxattr) (struct dentry *dentry, char *name);
1106 int (*inode_listxattr) (struct dentry *dentry);
1107 int (*inode_removexattr) (struct dentry *dentry, char *name);
1108 int (*inode_getsecurity)(struct dentry *dentry, const char *name, void *buffer, size_t size);
1109 int (*inode_setsecurity)(struct dentry *dentry, const char *name, const void *value, size_t size, int flags);
1110 int (*inode_listsecurity)(struct dentry *dentry, char *buffer);
1112 int (*file_permission) (struct file * file, int mask);
1113 int (*file_alloc_security) (struct file * file);
1114 void (*file_free_security) (struct file * file);
1115 int (*file_ioctl) (struct file * file, unsigned int cmd,
1117 int (*file_mmap) (struct file * file,
1118 unsigned long prot, unsigned long flags);
1119 int (*file_mprotect) (struct vm_area_struct * vma, unsigned long prot);
1120 int (*file_lock) (struct file * file, unsigned int cmd);
1121 int (*file_fcntl) (struct file * file, unsigned int cmd,
1123 int (*file_set_fowner) (struct file * file);
1124 int (*file_send_sigiotask) (struct task_struct * tsk,
1125 struct fown_struct * fown,
1126 int fd, int reason);
1127 int (*file_receive) (struct file * file);
1129 int (*task_create) (unsigned long clone_flags);
1130 int (*task_alloc_security) (struct task_struct * p);
1131 void (*task_free_security) (struct task_struct * p);
1132 int (*task_setuid) (uid_t id0, uid_t id1, uid_t id2, int flags);
1133 int (*task_post_setuid) (uid_t old_ruid /* or fsuid */ ,
1134 uid_t old_euid, uid_t old_suid, int flags);
1135 int (*task_setgid) (gid_t id0, gid_t id1, gid_t id2, int flags);
1136 int (*task_setpgid) (struct task_struct * p, pid_t pgid);
1137 int (*task_getpgid) (struct task_struct * p);
1138 int (*task_getsid) (struct task_struct * p);
1139 int (*task_setgroups) (struct group_info *group_info);
1140 int (*task_setnice) (struct task_struct * p, int nice);
1141 int (*task_setrlimit) (unsigned int resource, struct rlimit * new_rlim);
1142 int (*task_setscheduler) (struct task_struct * p, int policy,
1143 struct sched_param * lp);
1144 int (*task_getscheduler) (struct task_struct * p);
1145 int (*task_kill) (struct task_struct * p,
1146 struct siginfo * info, int sig);
1147 int (*task_wait) (struct task_struct * p);
1148 int (*task_prctl) (int option, unsigned long arg2,
1149 unsigned long arg3, unsigned long arg4,
1150 unsigned long arg5);
1151 void (*task_reparent_to_init) (struct task_struct * p);
1152 void (*task_to_inode)(struct task_struct *p, struct inode *inode);
1154 int (*ipc_permission) (struct kern_ipc_perm * ipcp, short flag);
1156 int (*msg_msg_alloc_security) (struct msg_msg * msg);
1157 void (*msg_msg_free_security) (struct msg_msg * msg);
1159 int (*msg_queue_alloc_security) (struct msg_queue * msq);
1160 void (*msg_queue_free_security) (struct msg_queue * msq);
1161 int (*msg_queue_associate) (struct msg_queue * msq, int msqflg);
1162 int (*msg_queue_msgctl) (struct msg_queue * msq, int cmd);
1163 int (*msg_queue_msgsnd) (struct msg_queue * msq,
1164 struct msg_msg * msg, int msqflg);
1165 int (*msg_queue_msgrcv) (struct msg_queue * msq,
1166 struct msg_msg * msg,
1167 struct task_struct * target,
1168 long type, int mode);
1170 int (*shm_alloc_security) (struct shmid_kernel * shp);
1171 void (*shm_free_security) (struct shmid_kernel * shp);
1172 int (*shm_associate) (struct shmid_kernel * shp, int shmflg);
1173 int (*shm_shmctl) (struct shmid_kernel * shp, int cmd);
1174 int (*shm_shmat) (struct shmid_kernel * shp,
1175 char *shmaddr, int shmflg);
1177 int (*sem_alloc_security) (struct sem_array * sma);
1178 void (*sem_free_security) (struct sem_array * sma);
1179 int (*sem_associate) (struct sem_array * sma, int semflg);
1180 int (*sem_semctl) (struct sem_array * sma, int cmd);
1181 int (*sem_semop) (struct sem_array * sma,
1182 struct sembuf * sops, unsigned nsops, int alter);
1184 int (*netlink_send) (struct sk_buff * skb);
1185 int (*netlink_recv) (struct sk_buff * skb);
1187 /* allow module stacking */
1188 int (*register_security) (const char *name,
1189 struct security_operations *ops);
1190 int (*unregister_security) (const char *name,
1191 struct security_operations *ops);
1193 void (*d_instantiate) (struct dentry *dentry, struct inode *inode);
1195 int (*getprocattr)(struct task_struct *p, char *name, void *value, size_t size);
1196 int (*setprocattr)(struct task_struct *p, char *name, void *value, size_t size);
1198 #ifdef CONFIG_SECURITY_NETWORK
1199 int (*unix_stream_connect) (struct socket * sock,
1200 struct socket * other, struct sock * newsk);
1201 int (*unix_may_send) (struct socket * sock, struct socket * other);
1203 int (*socket_create) (int family, int type, int protocol, int kern);
1204 void (*socket_post_create) (struct socket * sock, int family,
1205 int type, int protocol, int kern);
1206 int (*socket_bind) (struct socket * sock,
1207 struct sockaddr * address, int addrlen);
1208 int (*socket_connect) (struct socket * sock,
1209 struct sockaddr * address, int addrlen);
1210 int (*socket_listen) (struct socket * sock, int backlog);
1211 int (*socket_accept) (struct socket * sock, struct socket * newsock);
1212 void (*socket_post_accept) (struct socket * sock,
1213 struct socket * newsock);
1214 int (*socket_sendmsg) (struct socket * sock,
1215 struct msghdr * msg, int size);
1216 int (*socket_recvmsg) (struct socket * sock,
1217 struct msghdr * msg, int size, int flags);
1218 int (*socket_getsockname) (struct socket * sock);
1219 int (*socket_getpeername) (struct socket * sock);
1220 int (*socket_getsockopt) (struct socket * sock, int level, int optname);
1221 int (*socket_setsockopt) (struct socket * sock, int level, int optname);
1222 int (*socket_shutdown) (struct socket * sock, int how);
1223 int (*socket_sock_rcv_skb) (struct sock * sk, struct sk_buff * skb);
1224 int (*socket_getpeersec) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len);
1225 int (*sk_alloc_security) (struct sock *sk, int family, int priority);
1226 void (*sk_free_security) (struct sock *sk);
1227 #endif /* CONFIG_SECURITY_NETWORK */
1230 /* global variables */
1231 extern struct security_operations *security_ops;
1234 static inline int security_ptrace (struct task_struct * parent, struct task_struct * child)
1236 return security_ops->ptrace (parent, child);
1239 static inline int security_capget (struct task_struct *target,
1240 kernel_cap_t *effective,
1241 kernel_cap_t *inheritable,
1242 kernel_cap_t *permitted)
1244 return security_ops->capget (target, effective, inheritable, permitted);
1247 static inline int security_capset_check (struct task_struct *target,
1248 kernel_cap_t *effective,
1249 kernel_cap_t *inheritable,
1250 kernel_cap_t *permitted)
1252 return security_ops->capset_check (target, effective, inheritable, permitted);
1255 static inline void security_capset_set (struct task_struct *target,
1256 kernel_cap_t *effective,
1257 kernel_cap_t *inheritable,
1258 kernel_cap_t *permitted)
1260 security_ops->capset_set (target, effective, inheritable, permitted);
1263 static inline int security_acct (struct file *file)
1265 return security_ops->acct (file);
1268 static inline int security_sysctl(ctl_table * table, int op)
1270 return security_ops->sysctl(table, op);
1273 static inline int security_quotactl (int cmds, int type, int id,
1274 struct super_block *sb)
1276 return security_ops->quotactl (cmds, type, id, sb);
1279 static inline int security_quota_on (struct file * file)
1281 return security_ops->quota_on (file);
1284 static inline int security_syslog(int type)
1286 return security_ops->syslog(type);
1289 static inline int security_vm_enough_memory(long pages)
1291 return security_ops->vm_enough_memory(pages);
1294 static inline int security_bprm_alloc (struct linux_binprm *bprm)
1296 return security_ops->bprm_alloc_security (bprm);
1298 static inline void security_bprm_free (struct linux_binprm *bprm)
1300 security_ops->bprm_free_security (bprm);
1302 static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
1304 security_ops->bprm_apply_creds (bprm, unsafe);
1306 static inline int security_bprm_set (struct linux_binprm *bprm)
1308 return security_ops->bprm_set_security (bprm);
1311 static inline int security_bprm_check (struct linux_binprm *bprm)
1313 return security_ops->bprm_check_security (bprm);
1316 static inline int security_bprm_secureexec (struct linux_binprm *bprm)
1318 return security_ops->bprm_secureexec (bprm);
1321 static inline int security_sb_alloc (struct super_block *sb)
1323 return security_ops->sb_alloc_security (sb);
1326 static inline void security_sb_free (struct super_block *sb)
1328 security_ops->sb_free_security (sb);
1331 static inline int security_sb_copy_data (struct file_system_type *type,
1332 void *orig, void *copy)
1334 return security_ops->sb_copy_data (type, orig, copy);
1337 static inline int security_sb_kern_mount (struct super_block *sb, void *data)
1339 return security_ops->sb_kern_mount (sb, data);
1342 static inline int security_sb_statfs (struct super_block *sb)
1344 return security_ops->sb_statfs (sb);
1347 static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
1348 char *type, unsigned long flags,
1351 return security_ops->sb_mount (dev_name, nd, type, flags, data);
1354 static inline int security_sb_check_sb (struct vfsmount *mnt,
1355 struct nameidata *nd)
1357 return security_ops->sb_check_sb (mnt, nd);
1360 static inline int security_sb_umount (struct vfsmount *mnt, int flags)
1362 return security_ops->sb_umount (mnt, flags);
1365 static inline void security_sb_umount_close (struct vfsmount *mnt)
1367 security_ops->sb_umount_close (mnt);
1370 static inline void security_sb_umount_busy (struct vfsmount *mnt)
1372 security_ops->sb_umount_busy (mnt);
1375 static inline void security_sb_post_remount (struct vfsmount *mnt,
1376 unsigned long flags, void *data)
1378 security_ops->sb_post_remount (mnt, flags, data);
1381 static inline void security_sb_post_mountroot (void)
1383 security_ops->sb_post_mountroot ();
1386 static inline void security_sb_post_addmount (struct vfsmount *mnt,
1387 struct nameidata *mountpoint_nd)
1389 security_ops->sb_post_addmount (mnt, mountpoint_nd);
1392 static inline int security_sb_pivotroot (struct nameidata *old_nd,
1393 struct nameidata *new_nd)
1395 return security_ops->sb_pivotroot (old_nd, new_nd);
1398 static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
1399 struct nameidata *new_nd)
1401 security_ops->sb_post_pivotroot (old_nd, new_nd);
1404 static inline int security_inode_alloc (struct inode *inode)
1406 return security_ops->inode_alloc_security (inode);
1409 static inline void security_inode_free (struct inode *inode)
1411 security_ops->inode_free_security (inode);
1414 static inline int security_inode_create (struct inode *dir,
1415 struct dentry *dentry,
1418 return security_ops->inode_create (dir, dentry, mode);
1421 static inline void security_inode_post_create (struct inode *dir,
1422 struct dentry *dentry,
1425 security_ops->inode_post_create (dir, dentry, mode);
1428 static inline int security_inode_link (struct dentry *old_dentry,
1430 struct dentry *new_dentry)
1432 return security_ops->inode_link (old_dentry, dir, new_dentry);
1435 static inline void security_inode_post_link (struct dentry *old_dentry,
1437 struct dentry *new_dentry)
1439 security_ops->inode_post_link (old_dentry, dir, new_dentry);
1442 static inline int security_inode_unlink (struct inode *dir,
1443 struct dentry *dentry)
1445 return security_ops->inode_unlink (dir, dentry);
1448 static inline int security_inode_symlink (struct inode *dir,
1449 struct dentry *dentry,
1450 const char *old_name)
1452 return security_ops->inode_symlink (dir, dentry, old_name);
1455 static inline void security_inode_post_symlink (struct inode *dir,
1456 struct dentry *dentry,
1457 const char *old_name)
1459 security_ops->inode_post_symlink (dir, dentry, old_name);
1462 static inline int security_inode_mkdir (struct inode *dir,
1463 struct dentry *dentry,
1466 return security_ops->inode_mkdir (dir, dentry, mode);
1469 static inline void security_inode_post_mkdir (struct inode *dir,
1470 struct dentry *dentry,
1473 security_ops->inode_post_mkdir (dir, dentry, mode);
1476 static inline int security_inode_rmdir (struct inode *dir,
1477 struct dentry *dentry)
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 return security_ops->inode_mknod (dir, dentry, mode, dev);
1489 static inline void security_inode_post_mknod (struct inode *dir,
1490 struct dentry *dentry,
1491 int mode, dev_t dev)
1493 security_ops->inode_post_mknod (dir, dentry, mode, dev);
1496 static inline int security_inode_rename (struct inode *old_dir,
1497 struct dentry *old_dentry,
1498 struct inode *new_dir,
1499 struct dentry *new_dentry)
1501 return security_ops->inode_rename (old_dir, old_dentry,
1502 new_dir, new_dentry);
1505 static inline void security_inode_post_rename (struct inode *old_dir,
1506 struct dentry *old_dentry,
1507 struct inode *new_dir,
1508 struct dentry *new_dentry)
1510 security_ops->inode_post_rename (old_dir, old_dentry,
1511 new_dir, new_dentry);
1514 static inline int security_inode_readlink (struct dentry *dentry)
1516 return security_ops->inode_readlink (dentry);
1519 static inline int security_inode_follow_link (struct dentry *dentry,
1520 struct nameidata *nd)
1522 return security_ops->inode_follow_link (dentry, nd);
1525 static inline int security_inode_permission (struct inode *inode, int mask,
1526 struct nameidata *nd)
1528 return security_ops->inode_permission (inode, mask, nd);
1531 static inline int security_inode_setattr (struct dentry *dentry,
1534 return security_ops->inode_setattr (dentry, attr);
1537 static inline int security_inode_getattr (struct vfsmount *mnt,
1538 struct dentry *dentry)
1540 return security_ops->inode_getattr (mnt, dentry);
1543 static inline void security_inode_delete (struct inode *inode)
1545 security_ops->inode_delete (inode);
1548 static inline int security_inode_setxattr (struct dentry *dentry, char *name,
1549 void *value, size_t size, int flags)
1551 return security_ops->inode_setxattr (dentry, name, value, size, flags);
1554 static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
1555 void *value, size_t size, int flags)
1557 security_ops->inode_post_setxattr (dentry, name, value, size, flags);
1560 static inline int security_inode_getxattr (struct dentry *dentry, char *name)
1562 return security_ops->inode_getxattr (dentry, name);
1565 static inline int security_inode_listxattr (struct dentry *dentry)
1567 return security_ops->inode_listxattr (dentry);
1570 static inline int security_inode_removexattr (struct dentry *dentry, char *name)
1572 return security_ops->inode_removexattr (dentry, name);
1575 static inline int security_inode_getsecurity(struct dentry *dentry, const char *name, void *buffer, size_t size)
1577 return security_ops->inode_getsecurity(dentry, name, buffer, size);
1580 static inline int security_inode_setsecurity(struct dentry *dentry, const char *name, const void *value, size_t size, int flags)
1582 return security_ops->inode_setsecurity(dentry, name, value, size, flags);
1585 static inline int security_inode_listsecurity(struct dentry *dentry, char *buffer)
1587 return security_ops->inode_listsecurity(dentry, buffer);
1590 static inline int security_file_permission (struct file *file, int mask)
1592 return security_ops->file_permission (file, mask);
1595 static inline int security_file_alloc (struct file *file)
1597 return security_ops->file_alloc_security (file);
1600 static inline void security_file_free (struct file *file)
1602 security_ops->file_free_security (file);
1605 static inline int security_file_ioctl (struct file *file, unsigned int cmd,
1608 return security_ops->file_ioctl (file, cmd, arg);
1611 static inline int security_file_mmap (struct file *file, unsigned long prot,
1612 unsigned long flags)
1614 return security_ops->file_mmap (file, prot, flags);
1617 static inline int security_file_mprotect (struct vm_area_struct *vma,
1620 return security_ops->file_mprotect (vma, prot);
1623 static inline int security_file_lock (struct file *file, unsigned int cmd)
1625 return security_ops->file_lock (file, cmd);
1628 static inline int security_file_fcntl (struct file *file, unsigned int cmd,
1631 return security_ops->file_fcntl (file, cmd, arg);
1634 static inline int security_file_set_fowner (struct file *file)
1636 return security_ops->file_set_fowner (file);
1639 static inline int security_file_send_sigiotask (struct task_struct *tsk,
1640 struct fown_struct *fown,
1643 return security_ops->file_send_sigiotask (tsk, fown, fd, reason);
1646 static inline int security_file_receive (struct file *file)
1648 return security_ops->file_receive (file);
1651 static inline int security_task_create (unsigned long clone_flags)
1653 return security_ops->task_create (clone_flags);
1656 static inline int security_task_alloc (struct task_struct *p)
1658 return security_ops->task_alloc_security (p);
1661 static inline void security_task_free (struct task_struct *p)
1663 security_ops->task_free_security (p);
1666 static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
1669 return security_ops->task_setuid (id0, id1, id2, flags);
1672 static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
1673 uid_t old_suid, int flags)
1675 return security_ops->task_post_setuid (old_ruid, old_euid, old_suid, flags);
1678 static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
1681 return security_ops->task_setgid (id0, id1, id2, flags);
1684 static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
1686 return security_ops->task_setpgid (p, pgid);
1689 static inline int security_task_getpgid (struct task_struct *p)
1691 return security_ops->task_getpgid (p);
1694 static inline int security_task_getsid (struct task_struct *p)
1696 return security_ops->task_getsid (p);
1699 static inline int security_task_setgroups (struct group_info *group_info)
1701 return security_ops->task_setgroups (group_info);
1704 static inline int security_task_setnice (struct task_struct *p, int nice)
1706 return security_ops->task_setnice (p, nice);
1709 static inline int security_task_setrlimit (unsigned int resource,
1710 struct rlimit *new_rlim)
1712 return security_ops->task_setrlimit (resource, new_rlim);
1715 static inline int security_task_setscheduler (struct task_struct *p,
1717 struct sched_param *lp)
1719 return security_ops->task_setscheduler (p, policy, lp);
1722 static inline int security_task_getscheduler (struct task_struct *p)
1724 return security_ops->task_getscheduler (p);
1727 static inline int security_task_kill (struct task_struct *p,
1728 struct siginfo *info, int sig)
1730 return security_ops->task_kill (p, info, sig);
1733 static inline int security_task_wait (struct task_struct *p)
1735 return security_ops->task_wait (p);
1738 static inline int security_task_prctl (int option, unsigned long arg2,
1743 return security_ops->task_prctl (option, arg2, arg3, arg4, arg5);
1746 static inline void security_task_reparent_to_init (struct task_struct *p)
1748 security_ops->task_reparent_to_init (p);
1751 static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
1753 security_ops->task_to_inode(p, inode);
1756 static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
1759 return security_ops->ipc_permission (ipcp, flag);
1762 static inline int security_msg_msg_alloc (struct msg_msg * msg)
1764 return security_ops->msg_msg_alloc_security (msg);
1767 static inline void security_msg_msg_free (struct msg_msg * msg)
1769 security_ops->msg_msg_free_security(msg);
1772 static inline int security_msg_queue_alloc (struct msg_queue *msq)
1774 return security_ops->msg_queue_alloc_security (msq);
1777 static inline void security_msg_queue_free (struct msg_queue *msq)
1779 security_ops->msg_queue_free_security (msq);
1782 static inline int security_msg_queue_associate (struct msg_queue * msq,
1785 return security_ops->msg_queue_associate (msq, msqflg);
1788 static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
1790 return security_ops->msg_queue_msgctl (msq, cmd);
1793 static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
1794 struct msg_msg * msg, int msqflg)
1796 return security_ops->msg_queue_msgsnd (msq, msg, msqflg);
1799 static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
1800 struct msg_msg * msg,
1801 struct task_struct * target,
1802 long type, int mode)
1804 return security_ops->msg_queue_msgrcv (msq, msg, target, type, mode);
1807 static inline int security_shm_alloc (struct shmid_kernel *shp)
1809 return security_ops->shm_alloc_security (shp);
1812 static inline void security_shm_free (struct shmid_kernel *shp)
1814 security_ops->shm_free_security (shp);
1817 static inline int security_shm_associate (struct shmid_kernel * shp,
1820 return security_ops->shm_associate(shp, shmflg);
1823 static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
1825 return security_ops->shm_shmctl (shp, cmd);
1828 static inline int security_shm_shmat (struct shmid_kernel * shp,
1829 char __user *shmaddr, int shmflg)
1831 return security_ops->shm_shmat(shp, shmaddr, shmflg);
1834 static inline int security_sem_alloc (struct sem_array *sma)
1836 return security_ops->sem_alloc_security (sma);
1839 static inline void security_sem_free (struct sem_array *sma)
1841 security_ops->sem_free_security (sma);
1844 static inline int security_sem_associate (struct sem_array * sma, int semflg)
1846 return security_ops->sem_associate (sma, semflg);
1849 static inline int security_sem_semctl (struct sem_array * sma, int cmd)
1851 return security_ops->sem_semctl(sma, cmd);
1854 static inline int security_sem_semop (struct sem_array * sma,
1855 struct sembuf * sops, unsigned nsops,
1858 return security_ops->sem_semop(sma, sops, nsops, alter);
1861 static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
1863 security_ops->d_instantiate (dentry, inode);
1866 static inline int security_getprocattr(struct task_struct *p, char *name, void *value, size_t size)
1868 return security_ops->getprocattr(p, name, value, size);
1871 static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
1873 return security_ops->setprocattr(p, name, value, size);
1876 static inline int security_netlink_send(struct sk_buff * skb)
1878 return security_ops->netlink_send(skb);
1881 static inline int security_netlink_recv(struct sk_buff * skb)
1883 return security_ops->netlink_recv(skb);
1887 extern int security_scaffolding_startup (void);
1888 extern int register_security (struct security_operations *ops);
1889 extern int unregister_security (struct security_operations *ops);
1890 extern int mod_reg_security (const char *name, struct security_operations *ops);
1891 extern int mod_unreg_security (const char *name, struct security_operations *ops);
1894 #else /* CONFIG_SECURITY */
1897 * This is the default capabilities functionality. Most of these functions
1898 * are just stubbed out, but a few must call the proper capable code.
1901 static inline int security_scaffolding_startup (void)
1906 static inline int security_ptrace (struct task_struct *parent, struct task_struct * child)
1908 return cap_ptrace (parent, child);
1911 static inline int security_capget (struct task_struct *target,
1912 kernel_cap_t *effective,
1913 kernel_cap_t *inheritable,
1914 kernel_cap_t *permitted)
1916 return cap_capget (target, effective, inheritable, permitted);
1919 static inline int security_capset_check (struct task_struct *target,
1920 kernel_cap_t *effective,
1921 kernel_cap_t *inheritable,
1922 kernel_cap_t *permitted)
1924 return cap_capset_check (target, effective, inheritable, permitted);
1927 static inline void security_capset_set (struct task_struct *target,
1928 kernel_cap_t *effective,
1929 kernel_cap_t *inheritable,
1930 kernel_cap_t *permitted)
1932 cap_capset_set (target, effective, inheritable, permitted);
1935 static inline int security_acct (struct file *file)
1940 static inline int security_sysctl(ctl_table * table, int op)
1945 static inline int security_quotactl (int cmds, int type, int id,
1946 struct super_block * sb)
1951 static inline int security_quota_on (struct file * file)
1956 static inline int security_syslog(int type)
1958 return cap_syslog(type);
1961 static inline int security_vm_enough_memory(long pages)
1963 return cap_vm_enough_memory(pages);
1966 static inline int security_bprm_alloc (struct linux_binprm *bprm)
1971 static inline void security_bprm_free (struct linux_binprm *bprm)
1974 static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
1976 cap_bprm_apply_creds (bprm, unsafe);
1979 static inline int security_bprm_set (struct linux_binprm *bprm)
1981 return cap_bprm_set_security (bprm);
1984 static inline int security_bprm_check (struct linux_binprm *bprm)
1989 static inline int security_bprm_secureexec (struct linux_binprm *bprm)
1991 return cap_bprm_secureexec(bprm);
1994 static inline int security_sb_alloc (struct super_block *sb)
1999 static inline void security_sb_free (struct super_block *sb)
2002 static inline int security_sb_copy_data (struct file_system_type *type,
2003 void *orig, void *copy)
2008 static inline int security_sb_kern_mount (struct super_block *sb, void *data)
2013 static inline int security_sb_statfs (struct super_block *sb)
2018 static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
2019 char *type, unsigned long flags,
2025 static inline int security_sb_check_sb (struct vfsmount *mnt,
2026 struct nameidata *nd)
2031 static inline int security_sb_umount (struct vfsmount *mnt, int flags)
2036 static inline void security_sb_umount_close (struct vfsmount *mnt)
2039 static inline void security_sb_umount_busy (struct vfsmount *mnt)
2042 static inline void security_sb_post_remount (struct vfsmount *mnt,
2043 unsigned long flags, void *data)
2046 static inline void security_sb_post_mountroot (void)
2049 static inline void security_sb_post_addmount (struct vfsmount *mnt,
2050 struct nameidata *mountpoint_nd)
2053 static inline int security_sb_pivotroot (struct nameidata *old_nd,
2054 struct nameidata *new_nd)
2059 static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
2060 struct nameidata *new_nd)
2063 static inline int security_inode_alloc (struct inode *inode)
2068 static inline void security_inode_free (struct inode *inode)
2071 static inline int security_inode_create (struct inode *dir,
2072 struct dentry *dentry,
2078 static inline void security_inode_post_create (struct inode *dir,
2079 struct dentry *dentry,
2083 static inline int security_inode_link (struct dentry *old_dentry,
2085 struct dentry *new_dentry)
2090 static inline void security_inode_post_link (struct dentry *old_dentry,
2092 struct dentry *new_dentry)
2095 static inline int security_inode_unlink (struct inode *dir,
2096 struct dentry *dentry)
2101 static inline int security_inode_symlink (struct inode *dir,
2102 struct dentry *dentry,
2103 const char *old_name)
2108 static inline void security_inode_post_symlink (struct inode *dir,
2109 struct dentry *dentry,
2110 const char *old_name)
2113 static inline int security_inode_mkdir (struct inode *dir,
2114 struct dentry *dentry,
2120 static inline void security_inode_post_mkdir (struct inode *dir,
2121 struct dentry *dentry,
2125 static inline int security_inode_rmdir (struct inode *dir,
2126 struct dentry *dentry)
2131 static inline int security_inode_mknod (struct inode *dir,
2132 struct dentry *dentry,
2133 int mode, dev_t dev)
2138 static inline void security_inode_post_mknod (struct inode *dir,
2139 struct dentry *dentry,
2140 int mode, dev_t dev)
2143 static inline int security_inode_rename (struct inode *old_dir,
2144 struct dentry *old_dentry,
2145 struct inode *new_dir,
2146 struct dentry *new_dentry)
2151 static inline void security_inode_post_rename (struct inode *old_dir,
2152 struct dentry *old_dentry,
2153 struct inode *new_dir,
2154 struct dentry *new_dentry)
2157 static inline int security_inode_readlink (struct dentry *dentry)
2162 static inline int security_inode_follow_link (struct dentry *dentry,
2163 struct nameidata *nd)
2168 static inline int security_inode_permission (struct inode *inode, int mask,
2169 struct nameidata *nd)
2174 static inline int security_inode_setattr (struct dentry *dentry,
2180 static inline int security_inode_getattr (struct vfsmount *mnt,
2181 struct dentry *dentry)
2186 static inline void security_inode_delete (struct inode *inode)
2189 static inline int security_inode_setxattr (struct dentry *dentry, char *name,
2190 void *value, size_t size, int flags)
2192 return cap_inode_setxattr(dentry, name, value, size, flags);
2195 static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
2196 void *value, size_t size, int flags)
2199 static inline int security_inode_getxattr (struct dentry *dentry, char *name)
2204 static inline int security_inode_listxattr (struct dentry *dentry)
2209 static inline int security_inode_removexattr (struct dentry *dentry, char *name)
2211 return cap_inode_removexattr(dentry, name);
2214 static inline int security_inode_getsecurity(struct dentry *dentry, const char *name, void *buffer, size_t size)
2219 static inline int security_inode_setsecurity(struct dentry *dentry, const char *name, const void *value, size_t size, int flags)
2224 static inline int security_inode_listsecurity(struct dentry *dentry, char *buffer)
2229 static inline int security_file_permission (struct file *file, int mask)
2234 static inline int security_file_alloc (struct file *file)
2239 static inline void security_file_free (struct file *file)
2242 static inline int security_file_ioctl (struct file *file, unsigned int cmd,
2248 static inline int security_file_mmap (struct file *file, unsigned long prot,
2249 unsigned long flags)
2254 static inline int security_file_mprotect (struct vm_area_struct *vma,
2260 static inline int security_file_lock (struct file *file, unsigned int cmd)
2265 static inline int security_file_fcntl (struct file *file, unsigned int cmd,
2271 static inline int security_file_set_fowner (struct file *file)
2276 static inline int security_file_send_sigiotask (struct task_struct *tsk,
2277 struct fown_struct *fown,
2283 static inline int security_file_receive (struct file *file)
2288 static inline int security_task_create (unsigned long clone_flags)
2293 static inline int security_task_alloc (struct task_struct *p)
2298 static inline void security_task_free (struct task_struct *p)
2301 static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
2307 static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
2308 uid_t old_suid, int flags)
2310 return cap_task_post_setuid (old_ruid, old_euid, old_suid, flags);
2313 static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
2319 static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
2324 static inline int security_task_getpgid (struct task_struct *p)
2329 static inline int security_task_getsid (struct task_struct *p)
2334 static inline int security_task_setgroups (struct group_info *group_info)
2339 static inline int security_task_setnice (struct task_struct *p, int nice)
2344 static inline int security_task_setrlimit (unsigned int resource,
2345 struct rlimit *new_rlim)
2350 static inline int security_task_setscheduler (struct task_struct *p,
2352 struct sched_param *lp)
2357 static inline int security_task_getscheduler (struct task_struct *p)
2362 static inline int security_task_kill (struct task_struct *p,
2363 struct siginfo *info, int sig)
2368 static inline int security_task_wait (struct task_struct *p)
2373 static inline int security_task_prctl (int option, unsigned long arg2,
2381 static inline void security_task_reparent_to_init (struct task_struct *p)
2383 cap_task_reparent_to_init (p);
2386 static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
2389 static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
2395 static inline int security_msg_msg_alloc (struct msg_msg * msg)
2400 static inline void security_msg_msg_free (struct msg_msg * msg)
2403 static inline int security_msg_queue_alloc (struct msg_queue *msq)
2408 static inline void security_msg_queue_free (struct msg_queue *msq)
2411 static inline int security_msg_queue_associate (struct msg_queue * msq,
2417 static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
2422 static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
2423 struct msg_msg * msg, int msqflg)
2428 static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
2429 struct msg_msg * msg,
2430 struct task_struct * target,
2431 long type, int mode)
2436 static inline int security_shm_alloc (struct shmid_kernel *shp)
2441 static inline void security_shm_free (struct shmid_kernel *shp)
2444 static inline int security_shm_associate (struct shmid_kernel * shp,
2450 static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
2455 static inline int security_shm_shmat (struct shmid_kernel * shp,
2456 char __user *shmaddr, int shmflg)
2461 static inline int security_sem_alloc (struct sem_array *sma)
2466 static inline void security_sem_free (struct sem_array *sma)
2469 static inline int security_sem_associate (struct sem_array * sma, int semflg)
2474 static inline int security_sem_semctl (struct sem_array * sma, int cmd)
2479 static inline int security_sem_semop (struct sem_array * sma,
2480 struct sembuf * sops, unsigned nsops,
2486 static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
2489 static inline int security_getprocattr(struct task_struct *p, char *name, void *value, size_t size)
2494 static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2500 * The netlink capability defaults need to be used inline by default
2501 * (rather than hooking into the capability module) to reduce overhead
2502 * in the networking code.
2504 static inline int security_netlink_send (struct sk_buff *skb)
2506 return cap_netlink_send (skb);
2509 static inline int security_netlink_recv (struct sk_buff *skb)
2511 return cap_netlink_recv (skb);
2514 #endif /* CONFIG_SECURITY */
2516 #ifdef CONFIG_SECURITY_NETWORK
2517 static inline int security_unix_stream_connect(struct socket * sock,
2518 struct socket * other,
2519 struct sock * newsk)
2521 return security_ops->unix_stream_connect(sock, other, newsk);
2525 static inline int security_unix_may_send(struct socket * sock,
2526 struct socket * other)
2528 return security_ops->unix_may_send(sock, other);
2531 static inline int security_socket_create (int family, int type,
2532 int protocol, int kern)
2534 return security_ops->socket_create(family, type, protocol, kern);
2537 static inline void security_socket_post_create(struct socket * sock,
2540 int protocol, int kern)
2542 security_ops->socket_post_create(sock, family, type,
2546 static inline int security_socket_bind(struct socket * sock,
2547 struct sockaddr * address,
2550 return security_ops->socket_bind(sock, address, addrlen);
2553 static inline int security_socket_connect(struct socket * sock,
2554 struct sockaddr * address,
2557 return security_ops->socket_connect(sock, address, addrlen);
2560 static inline int security_socket_listen(struct socket * sock, int backlog)
2562 return security_ops->socket_listen(sock, backlog);
2565 static inline int security_socket_accept(struct socket * sock,
2566 struct socket * newsock)
2568 return security_ops->socket_accept(sock, newsock);
2571 static inline void security_socket_post_accept(struct socket * sock,
2572 struct socket * newsock)
2574 security_ops->socket_post_accept(sock, newsock);
2577 static inline int security_socket_sendmsg(struct socket * sock,
2578 struct msghdr * msg, int size)
2580 return security_ops->socket_sendmsg(sock, msg, size);
2583 static inline int security_socket_recvmsg(struct socket * sock,
2584 struct msghdr * msg, int size,
2587 return security_ops->socket_recvmsg(sock, msg, size, flags);
2590 static inline int security_socket_getsockname(struct socket * sock)
2592 return security_ops->socket_getsockname(sock);
2595 static inline int security_socket_getpeername(struct socket * sock)
2597 return security_ops->socket_getpeername(sock);
2600 static inline int security_socket_getsockopt(struct socket * sock,
2601 int level, int optname)
2603 return security_ops->socket_getsockopt(sock, level, optname);
2606 static inline int security_socket_setsockopt(struct socket * sock,
2607 int level, int optname)
2609 return security_ops->socket_setsockopt(sock, level, optname);
2612 static inline int security_socket_shutdown(struct socket * sock, int how)
2614 return security_ops->socket_shutdown(sock, how);
2617 static inline int security_sock_rcv_skb (struct sock * sk,
2618 struct sk_buff * skb)
2620 return security_ops->socket_sock_rcv_skb (sk, skb);
2623 static inline int security_socket_getpeersec(struct socket *sock, char __user *optval,
2624 int __user *optlen, unsigned len)
2626 return security_ops->socket_getpeersec(sock, optval, optlen, len);
2629 static inline int security_sk_alloc(struct sock *sk, int family, int priority)
2631 return security_ops->sk_alloc_security(sk, family, priority);
2634 static inline void security_sk_free(struct sock *sk)
2636 return security_ops->sk_free_security(sk);
2638 #else /* CONFIG_SECURITY_NETWORK */
2639 static inline int security_unix_stream_connect(struct socket * sock,
2640 struct socket * other,
2641 struct sock * newsk)
2646 static inline int security_unix_may_send(struct socket * sock,
2647 struct socket * other)
2652 static inline int security_socket_create (int family, int type,
2653 int protocol, int kern)
2658 static inline void security_socket_post_create(struct socket * sock,
2661 int protocol, int kern)
2665 static inline int security_socket_bind(struct socket * sock,
2666 struct sockaddr * address,
2672 static inline int security_socket_connect(struct socket * sock,
2673 struct sockaddr * address,
2679 static inline int security_socket_listen(struct socket * sock, int backlog)
2684 static inline int security_socket_accept(struct socket * sock,
2685 struct socket * newsock)
2690 static inline void security_socket_post_accept(struct socket * sock,
2691 struct socket * newsock)
2695 static inline int security_socket_sendmsg(struct socket * sock,
2696 struct msghdr * msg, int size)
2701 static inline int security_socket_recvmsg(struct socket * sock,
2702 struct msghdr * msg, int size,
2708 static inline int security_socket_getsockname(struct socket * sock)
2713 static inline int security_socket_getpeername(struct socket * sock)
2718 static inline int security_socket_getsockopt(struct socket * sock,
2719 int level, int optname)
2724 static inline int security_socket_setsockopt(struct socket * sock,
2725 int level, int optname)
2730 static inline int security_socket_shutdown(struct socket * sock, int how)
2734 static inline int security_sock_rcv_skb (struct sock * sk,
2735 struct sk_buff * skb)
2740 static inline int security_socket_getpeersec(struct socket *sock, char __user *optval,
2741 int __user *optlen, unsigned len)
2743 return -ENOPROTOOPT;
2746 static inline int security_sk_alloc(struct sock *sk, int family, int priority)
2751 static inline void security_sk_free(struct sock *sk)
2754 #endif /* CONFIG_SECURITY_NETWORK */
2756 #endif /* ! __LINUX_SECURITY_H */