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 sock
*sk
, 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. Also may be used to provide fine
643 * grained control over message transmission.
644 * @sk associated sock of task sending the message.,
645 * @skb contains the sk_buff structure for the netlink message.
646 * Return 0 if the information was successfully saved and message
647 * is allowed to be transmitted.
649 * Check permission before processing the received netlink message in
651 * @skb contains the sk_buff structure for the netlink message.
652 * Return 0 if permission is granted.
654 * Security hooks for Unix domain networking.
656 * @unix_stream_connect:
657 * Check permissions before establishing a Unix domain stream connection
658 * between @sock and @other.
659 * @sock contains the socket structure.
660 * @other contains the peer socket structure.
661 * Return 0 if permission is granted.
663 * Check permissions before connecting or sending datagrams from @sock to
665 * @sock contains the socket structure.
666 * @sock contains the peer socket structure.
667 * Return 0 if permission is granted.
669 * The @unix_stream_connect and @unix_may_send hooks were necessary because
670 * Linux provides an alternative to the conventional file name space for Unix
671 * domain sockets. Whereas binding and connecting to sockets in the file name
672 * space is mediated by the typical file permissions (and caught by the mknod
673 * and permission hooks in inode_security_ops), binding and connecting to
674 * sockets in the abstract name space is completely unmediated. Sufficient
675 * control of Unix domain sockets in the abstract name space isn't possible
676 * using only the socket layer hooks, since we need to know the actual target
677 * socket, which is not looked up until we are inside the af_unix code.
679 * Security hooks for socket operations.
682 * Check permissions prior to creating a new socket.
683 * @family contains the requested protocol family.
684 * @type contains the requested communications type.
685 * @protocol contains the requested protocol.
686 * @kern set to 1 if a kernel socket.
687 * Return 0 if permission is granted.
688 * @socket_post_create:
689 * This hook allows a module to update or allocate a per-socket security
690 * structure. Note that the security field was not added directly to the
691 * socket structure, but rather, the socket security information is stored
692 * in the associated inode. Typically, the inode alloc_security hook will
693 * allocate and and attach security information to
694 * sock->inode->i_security. This hook may be used to update the
695 * sock->inode->i_security field with additional information that wasn't
696 * available when the inode was allocated.
697 * @sock contains the newly created socket structure.
698 * @family contains the requested protocol family.
699 * @type contains the requested communications type.
700 * @protocol contains the requested protocol.
701 * @kern set to 1 if a kernel socket.
703 * Check permission before socket protocol layer bind operation is
704 * performed and the socket @sock is bound to the address specified in the
705 * @address parameter.
706 * @sock contains the socket structure.
707 * @address contains the address to bind to.
708 * @addrlen contains the length of address.
709 * Return 0 if permission is granted.
711 * Check permission before socket protocol layer connect operation
712 * attempts to connect socket @sock to a remote address, @address.
713 * @sock contains the socket structure.
714 * @address contains the address of remote endpoint.
715 * @addrlen contains the length of address.
716 * Return 0 if permission is granted.
718 * Check permission before socket protocol layer listen operation.
719 * @sock contains the socket structure.
720 * @backlog contains the maximum length for the pending connection queue.
721 * Return 0 if permission is granted.
723 * Check permission before accepting a new connection. Note that the new
724 * socket, @newsock, has been created and some information copied to it,
725 * but the accept operation has not actually been performed.
726 * @sock contains the listening socket structure.
727 * @newsock contains the newly created server socket for connection.
728 * Return 0 if permission is granted.
729 * @socket_post_accept:
730 * This hook allows a security module to copy security
731 * information into the newly created socket's inode.
732 * @sock contains the listening socket structure.
733 * @newsock contains the newly created server socket for connection.
735 * Check permission before transmitting a message to another socket.
736 * @sock contains the socket structure.
737 * @msg contains the message to be transmitted.
738 * @size contains the size of message.
739 * Return 0 if permission is granted.
741 * Check permission before receiving a message from a socket.
742 * @sock contains the socket structure.
743 * @msg contains the message structure.
744 * @size contains the size of message structure.
745 * @flags contains the operational flags.
746 * Return 0 if permission is granted.
747 * @socket_getsockname:
748 * Check permission before the local address (name) of the socket object
749 * @sock is retrieved.
750 * @sock contains the socket structure.
751 * Return 0 if permission is granted.
752 * @socket_getpeername:
753 * Check permission before the remote address (name) of a socket object
754 * @sock is retrieved.
755 * @sock contains the socket structure.
756 * Return 0 if permission is granted.
757 * @socket_getsockopt:
758 * Check permissions before retrieving the options associated with socket
760 * @sock contains the socket structure.
761 * @level contains the protocol level to retrieve option from.
762 * @optname contains the name of option to retrieve.
763 * Return 0 if permission is granted.
764 * @socket_setsockopt:
765 * Check permissions before setting the options associated with socket
767 * @sock contains the socket structure.
768 * @level contains the protocol level to set options for.
769 * @optname contains the name of the option to set.
770 * Return 0 if permission is granted.
772 * Checks permission before all or part of a connection on the socket
773 * @sock is shut down.
774 * @sock contains the socket structure.
775 * @how contains the flag indicating how future sends and receives are handled.
776 * Return 0 if permission is granted.
777 * @socket_sock_rcv_skb:
778 * Check permissions on incoming network packets. This hook is distinct
779 * from Netfilter's IP input hooks since it is the first time that the
780 * incoming sk_buff @skb has been associated with a particular socket, @sk.
781 * @sk contains the sock (not socket) associated with the incoming sk_buff.
782 * @skb contains the incoming network data.
783 * @socket_getpeersec:
784 * This hook allows the security module to provide peer socket security
785 * state to userspace via getsockopt SO_GETPEERSEC.
786 * @sock is the local socket.
787 * @optval userspace memory where the security state is to be copied.
788 * @optlen userspace int where the module should copy the actual length
789 * of the security state.
790 * @len as input is the maximum length to copy to userspace provided
792 * Return 0 if all is well, otherwise, typical getsockopt return
794 * @sk_alloc_security:
795 * Allocate and attach a security structure to the sk->sk_security field,
796 * which is used to copy security attributes between local stream sockets.
798 * Deallocate security structure.
800 * Security hooks affecting all System V IPC operations.
803 * Check permissions for access to IPC
804 * @ipcp contains the kernel IPC permission structure
805 * @flag contains the desired (requested) permission set
806 * Return 0 if permission is granted.
808 * Security hooks for individual messages held in System V IPC message queues
809 * @msg_msg_alloc_security:
810 * Allocate and attach a security structure to the msg->security field.
811 * The security field is initialized to NULL when the structure is first
813 * @msg contains the message structure to be modified.
814 * Return 0 if operation was successful and permission is granted.
815 * @msg_msg_free_security:
816 * Deallocate the security structure for this message.
817 * @msg contains the message structure to be modified.
819 * Security hooks for System V IPC Message Queues
821 * @msg_queue_alloc_security:
822 * Allocate and attach a security structure to the
823 * msq->q_perm.security field. The security field is initialized to
824 * NULL when the structure is first created.
825 * @msq contains the message queue structure to be modified.
826 * Return 0 if operation was successful and permission is granted.
827 * @msg_queue_free_security:
828 * Deallocate security structure for this message queue.
829 * @msq contains the message queue structure to be modified.
830 * @msg_queue_associate:
831 * Check permission when a message queue is requested through the
832 * msgget system call. This hook is only called when returning the
833 * message queue identifier for an existing message queue, not when a
834 * new message queue is created.
835 * @msq contains the message queue to act upon.
836 * @msqflg contains the operation control flags.
837 * Return 0 if permission is granted.
839 * Check permission when a message control operation specified by @cmd
840 * is to be performed on the message queue @msq.
841 * The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO.
842 * @msq contains the message queue to act upon. May be NULL.
843 * @cmd contains the operation to be performed.
844 * Return 0 if permission is granted.
846 * Check permission before a message, @msg, is enqueued on the message
848 * @msq contains the message queue to send message to.
849 * @msg contains the message to be enqueued.
850 * @msqflg contains operational flags.
851 * Return 0 if permission is granted.
853 * Check permission before a message, @msg, is removed from the message
854 * queue, @msq. The @target task structure contains a pointer to the
855 * process that will be receiving the message (not equal to the current
856 * process when inline receives are being performed).
857 * @msq contains the message queue to retrieve message from.
858 * @msg contains the message destination.
859 * @target contains the task structure for recipient process.
860 * @type contains the type of message requested.
861 * @mode contains the operational flags.
862 * Return 0 if permission is granted.
864 * Security hooks for System V Shared Memory Segments
866 * @shm_alloc_security:
867 * Allocate and attach a security structure to the shp->shm_perm.security
868 * field. The security field is initialized to NULL when the structure is
870 * @shp contains the shared memory structure to be modified.
871 * Return 0 if operation was successful and permission is granted.
872 * @shm_free_security:
873 * Deallocate the security struct for this memory segment.
874 * @shp contains the shared memory structure to be modified.
876 * Check permission when a shared memory region is requested through the
877 * shmget system call. This hook is only called when returning the shared
878 * memory region identifier for an existing region, not when a new shared
879 * memory region is created.
880 * @shp contains the shared memory structure to be modified.
881 * @shmflg contains the operation control flags.
882 * Return 0 if permission is granted.
884 * Check permission when a shared memory control operation specified by
885 * @cmd is to be performed on the shared memory region @shp.
886 * The @shp may be NULL, e.g. for IPC_INFO or SHM_INFO.
887 * @shp contains shared memory structure to be modified.
888 * @cmd contains the operation to be performed.
889 * Return 0 if permission is granted.
891 * Check permissions prior to allowing the shmat system call to attach the
892 * shared memory segment @shp to the data segment of the calling process.
893 * The attaching address is specified by @shmaddr.
894 * @shp contains the shared memory structure to be modified.
895 * @shmaddr contains the address to attach memory region to.
896 * @shmflg contains the operational flags.
897 * Return 0 if permission is granted.
899 * Security hooks for System V Semaphores
901 * @sem_alloc_security:
902 * Allocate and attach a security structure to the sma->sem_perm.security
903 * field. The security field is initialized to NULL when the structure is
905 * @sma contains the semaphore structure
906 * Return 0 if operation was successful and permission is granted.
907 * @sem_free_security:
908 * deallocate security struct for this semaphore
909 * @sma contains the semaphore structure.
911 * Check permission when a semaphore is requested through the semget
912 * system call. This hook is only called when returning the semaphore
913 * identifier for an existing semaphore, not when a new one must be
915 * @sma contains the semaphore structure.
916 * @semflg contains the operation control flags.
917 * Return 0 if permission is granted.
919 * Check permission when a semaphore operation specified by @cmd is to be
920 * performed on the semaphore @sma. The @sma may be NULL, e.g. for
921 * IPC_INFO or SEM_INFO.
922 * @sma contains the semaphore structure. May be NULL.
923 * @cmd contains the operation to be performed.
924 * Return 0 if permission is granted.
926 * Check permissions before performing operations on members of the
927 * semaphore set @sma. If the @alter flag is nonzero, the semaphore set
929 * @sma contains the semaphore structure.
930 * @sops contains the operations to perform.
931 * @nsops contains the number of operations to perform.
932 * @alter contains the flag indicating whether changes are to be made.
933 * Return 0 if permission is granted.
936 * Check permission before allowing the @parent process to trace the
938 * Security modules may also want to perform a process tracing check
939 * during an execve in the set_security or apply_creds hooks of
940 * binprm_security_ops if the process is being traced and its security
941 * attributes would be changed by the execve.
942 * @parent contains the task_struct structure for parent process.
943 * @child contains the task_struct structure for child process.
944 * Return 0 if permission is granted.
946 * Get the @effective, @inheritable, and @permitted capability sets for
947 * the @target process. The hook may also perform permission checking to
948 * determine if the current process is allowed to see the capability sets
949 * of the @target process.
950 * @target contains the task_struct structure for target process.
951 * @effective contains the effective capability set.
952 * @inheritable contains the inheritable capability set.
953 * @permitted contains the permitted capability set.
954 * Return 0 if the capability sets were successfully obtained.
956 * Check permission before setting the @effective, @inheritable, and
957 * @permitted capability sets for the @target process.
958 * Caveat: @target is also set to current if a set of processes is
959 * specified (i.e. all processes other than current and init or a
960 * particular process group). Hence, the capset_set hook may need to
961 * revalidate permission to the actual target process.
962 * @target contains the task_struct structure for target process.
963 * @effective contains the effective capability set.
964 * @inheritable contains the inheritable capability set.
965 * @permitted contains the permitted capability set.
966 * Return 0 if permission is granted.
968 * Set the @effective, @inheritable, and @permitted capability sets for
969 * the @target process. Since capset_check cannot always check permission
970 * to the real @target process, this hook may also perform permission
971 * checking to determine if the current process is allowed to set the
972 * capability sets of the @target process. However, this hook has no way
973 * of returning an error due to the structure of the sys_capset code.
974 * @target contains the task_struct structure for target process.
975 * @effective contains the effective capability set.
976 * @inheritable contains the inheritable capability set.
977 * @permitted contains the permitted capability set.
979 * Check permission before enabling or disabling process accounting. If
980 * accounting is being enabled, then @file refers to the open file used to
981 * store accounting records. If accounting is being disabled, then @file
983 * @file contains the file structure for the accounting file (may be NULL).
984 * Return 0 if permission is granted.
986 * Check permission before accessing the @table sysctl variable in the
987 * manner specified by @op.
988 * @table contains the ctl_table structure for the sysctl variable.
989 * @op contains the operation (001 = search, 002 = write, 004 = read).
990 * Return 0 if permission is granted.
992 * Check whether the @tsk process has the @cap capability.
993 * @tsk contains the task_struct for the process.
994 * @cap contains the capability <include/linux/capability.h>.
995 * Return 0 if the capability is granted for @tsk.
997 * Check permission before accessing the kernel message ring or changing
998 * logging to the console.
999 * See the syslog(2) manual page for an explanation of the @type values.
1000 * @type contains the type of action.
1001 * Return 0 if permission is granted.
1002 * @vm_enough_memory:
1003 * Check permissions for allocating a new virtual mapping.
1004 * @pages contains the number of pages.
1005 * Return 0 if permission is granted.
1007 * @register_security:
1008 * allow module stacking.
1009 * @name contains the name of the security module being stacked.
1010 * @ops contains a pointer to the struct security_operations of the module to stack.
1011 * @unregister_security:
1012 * remove a stacked module.
1013 * @name contains the name of the security module being unstacked.
1014 * @ops contains a pointer to the struct security_operations of the module to unstack.
1016 * This is the main security structure.
1018 struct security_operations
{
1019 int (*ptrace
) (struct task_struct
* parent
, struct task_struct
* child
);
1020 int (*capget
) (struct task_struct
* target
,
1021 kernel_cap_t
* effective
,
1022 kernel_cap_t
* inheritable
, kernel_cap_t
* permitted
);
1023 int (*capset_check
) (struct task_struct
* target
,
1024 kernel_cap_t
* effective
,
1025 kernel_cap_t
* inheritable
,
1026 kernel_cap_t
* permitted
);
1027 void (*capset_set
) (struct task_struct
* target
,
1028 kernel_cap_t
* effective
,
1029 kernel_cap_t
* inheritable
,
1030 kernel_cap_t
* permitted
);
1031 int (*acct
) (struct file
* file
);
1032 int (*sysctl
) (ctl_table
* table
, int op
);
1033 int (*capable
) (struct task_struct
* tsk
, int cap
);
1034 int (*quotactl
) (int cmds
, int type
, int id
, struct super_block
* sb
);
1035 int (*quota_on
) (struct file
* f
);
1036 int (*syslog
) (int type
);
1037 int (*vm_enough_memory
) (long pages
);
1039 int (*bprm_alloc_security
) (struct linux_binprm
* bprm
);
1040 void (*bprm_free_security
) (struct linux_binprm
* bprm
);
1041 void (*bprm_apply_creds
) (struct linux_binprm
* bprm
, int unsafe
);
1042 int (*bprm_set_security
) (struct linux_binprm
* bprm
);
1043 int (*bprm_check_security
) (struct linux_binprm
* bprm
);
1044 int (*bprm_secureexec
) (struct linux_binprm
* bprm
);
1046 int (*sb_alloc_security
) (struct super_block
* sb
);
1047 void (*sb_free_security
) (struct super_block
* sb
);
1048 int (*sb_copy_data
)(struct file_system_type
*type
,
1049 void *orig
, void *copy
);
1050 int (*sb_kern_mount
) (struct super_block
*sb
, void *data
);
1051 int (*sb_statfs
) (struct super_block
* sb
);
1052 int (*sb_mount
) (char *dev_name
, struct nameidata
* nd
,
1053 char *type
, unsigned long flags
, void *data
);
1054 int (*sb_check_sb
) (struct vfsmount
* mnt
, struct nameidata
* nd
);
1055 int (*sb_umount
) (struct vfsmount
* mnt
, int flags
);
1056 void (*sb_umount_close
) (struct vfsmount
* mnt
);
1057 void (*sb_umount_busy
) (struct vfsmount
* mnt
);
1058 void (*sb_post_remount
) (struct vfsmount
* mnt
,
1059 unsigned long flags
, void *data
);
1060 void (*sb_post_mountroot
) (void);
1061 void (*sb_post_addmount
) (struct vfsmount
* mnt
,
1062 struct nameidata
* mountpoint_nd
);
1063 int (*sb_pivotroot
) (struct nameidata
* old_nd
,
1064 struct nameidata
* new_nd
);
1065 void (*sb_post_pivotroot
) (struct nameidata
* old_nd
,
1066 struct nameidata
* new_nd
);
1068 int (*inode_alloc_security
) (struct inode
*inode
);
1069 void (*inode_free_security
) (struct inode
*inode
);
1070 int (*inode_create
) (struct inode
*dir
,
1071 struct dentry
*dentry
, int mode
);
1072 void (*inode_post_create
) (struct inode
*dir
,
1073 struct dentry
*dentry
, int mode
);
1074 int (*inode_link
) (struct dentry
*old_dentry
,
1075 struct inode
*dir
, struct dentry
*new_dentry
);
1076 void (*inode_post_link
) (struct dentry
*old_dentry
,
1077 struct inode
*dir
, struct dentry
*new_dentry
);
1078 int (*inode_unlink
) (struct inode
*dir
, struct dentry
*dentry
);
1079 int (*inode_symlink
) (struct inode
*dir
,
1080 struct dentry
*dentry
, const char *old_name
);
1081 void (*inode_post_symlink
) (struct inode
*dir
,
1082 struct dentry
*dentry
,
1083 const char *old_name
);
1084 int (*inode_mkdir
) (struct inode
*dir
, struct dentry
*dentry
, int mode
);
1085 void (*inode_post_mkdir
) (struct inode
*dir
, struct dentry
*dentry
,
1087 int (*inode_rmdir
) (struct inode
*dir
, struct dentry
*dentry
);
1088 int (*inode_mknod
) (struct inode
*dir
, struct dentry
*dentry
,
1089 int mode
, dev_t dev
);
1090 void (*inode_post_mknod
) (struct inode
*dir
, struct dentry
*dentry
,
1091 int mode
, dev_t dev
);
1092 int (*inode_rename
) (struct inode
*old_dir
, struct dentry
*old_dentry
,
1093 struct inode
*new_dir
, struct dentry
*new_dentry
);
1094 void (*inode_post_rename
) (struct inode
*old_dir
,
1095 struct dentry
*old_dentry
,
1096 struct inode
*new_dir
,
1097 struct dentry
*new_dentry
);
1098 int (*inode_readlink
) (struct dentry
*dentry
);
1099 int (*inode_follow_link
) (struct dentry
*dentry
, struct nameidata
*nd
);
1100 int (*inode_permission
) (struct inode
*inode
, int mask
, struct nameidata
*nd
);
1101 int (*inode_setattr
) (struct dentry
*dentry
, struct iattr
*attr
);
1102 int (*inode_getattr
) (struct vfsmount
*mnt
, struct dentry
*dentry
);
1103 void (*inode_delete
) (struct inode
*inode
);
1104 int (*inode_setxattr
) (struct dentry
*dentry
, char *name
, void *value
,
1105 size_t size
, int flags
);
1106 void (*inode_post_setxattr
) (struct dentry
*dentry
, char *name
, void *value
,
1107 size_t size
, int flags
);
1108 int (*inode_getxattr
) (struct dentry
*dentry
, char *name
);
1109 int (*inode_listxattr
) (struct dentry
*dentry
);
1110 int (*inode_removexattr
) (struct dentry
*dentry
, char *name
);
1111 int (*inode_getsecurity
)(struct dentry
*dentry
, const char *name
, void *buffer
, size_t size
);
1112 int (*inode_setsecurity
)(struct dentry
*dentry
, const char *name
, const void *value
, size_t size
, int flags
);
1113 int (*inode_listsecurity
)(struct dentry
*dentry
, char *buffer
);
1115 int (*file_permission
) (struct file
* file
, int mask
);
1116 int (*file_alloc_security
) (struct file
* file
);
1117 void (*file_free_security
) (struct file
* file
);
1118 int (*file_ioctl
) (struct file
* file
, unsigned int cmd
,
1120 int (*file_mmap
) (struct file
* file
,
1121 unsigned long prot
, unsigned long flags
);
1122 int (*file_mprotect
) (struct vm_area_struct
* vma
, unsigned long prot
);
1123 int (*file_lock
) (struct file
* file
, unsigned int cmd
);
1124 int (*file_fcntl
) (struct file
* file
, unsigned int cmd
,
1126 int (*file_set_fowner
) (struct file
* file
);
1127 int (*file_send_sigiotask
) (struct task_struct
* tsk
,
1128 struct fown_struct
* fown
,
1129 int fd
, int reason
);
1130 int (*file_receive
) (struct file
* file
);
1132 int (*task_create
) (unsigned long clone_flags
);
1133 int (*task_alloc_security
) (struct task_struct
* p
);
1134 void (*task_free_security
) (struct task_struct
* p
);
1135 int (*task_setuid
) (uid_t id0
, uid_t id1
, uid_t id2
, int flags
);
1136 int (*task_post_setuid
) (uid_t old_ruid
/* or fsuid */ ,
1137 uid_t old_euid
, uid_t old_suid
, int flags
);
1138 int (*task_setgid
) (gid_t id0
, gid_t id1
, gid_t id2
, int flags
);
1139 int (*task_setpgid
) (struct task_struct
* p
, pid_t pgid
);
1140 int (*task_getpgid
) (struct task_struct
* p
);
1141 int (*task_getsid
) (struct task_struct
* p
);
1142 int (*task_setgroups
) (struct group_info
*group_info
);
1143 int (*task_setnice
) (struct task_struct
* p
, int nice
);
1144 int (*task_setrlimit
) (unsigned int resource
, struct rlimit
* new_rlim
);
1145 int (*task_setscheduler
) (struct task_struct
* p
, int policy
,
1146 struct sched_param
* lp
);
1147 int (*task_getscheduler
) (struct task_struct
* p
);
1148 int (*task_kill
) (struct task_struct
* p
,
1149 struct siginfo
* info
, int sig
);
1150 int (*task_wait
) (struct task_struct
* p
);
1151 int (*task_prctl
) (int option
, unsigned long arg2
,
1152 unsigned long arg3
, unsigned long arg4
,
1153 unsigned long arg5
);
1154 void (*task_reparent_to_init
) (struct task_struct
* p
);
1155 void (*task_to_inode
)(struct task_struct
*p
, struct inode
*inode
);
1157 int (*ipc_permission
) (struct kern_ipc_perm
* ipcp
, short flag
);
1159 int (*msg_msg_alloc_security
) (struct msg_msg
* msg
);
1160 void (*msg_msg_free_security
) (struct msg_msg
* msg
);
1162 int (*msg_queue_alloc_security
) (struct msg_queue
* msq
);
1163 void (*msg_queue_free_security
) (struct msg_queue
* msq
);
1164 int (*msg_queue_associate
) (struct msg_queue
* msq
, int msqflg
);
1165 int (*msg_queue_msgctl
) (struct msg_queue
* msq
, int cmd
);
1166 int (*msg_queue_msgsnd
) (struct msg_queue
* msq
,
1167 struct msg_msg
* msg
, int msqflg
);
1168 int (*msg_queue_msgrcv
) (struct msg_queue
* msq
,
1169 struct msg_msg
* msg
,
1170 struct task_struct
* target
,
1171 long type
, int mode
);
1173 int (*shm_alloc_security
) (struct shmid_kernel
* shp
);
1174 void (*shm_free_security
) (struct shmid_kernel
* shp
);
1175 int (*shm_associate
) (struct shmid_kernel
* shp
, int shmflg
);
1176 int (*shm_shmctl
) (struct shmid_kernel
* shp
, int cmd
);
1177 int (*shm_shmat
) (struct shmid_kernel
* shp
,
1178 char __user
*shmaddr
, int shmflg
);
1180 int (*sem_alloc_security
) (struct sem_array
* sma
);
1181 void (*sem_free_security
) (struct sem_array
* sma
);
1182 int (*sem_associate
) (struct sem_array
* sma
, int semflg
);
1183 int (*sem_semctl
) (struct sem_array
* sma
, int cmd
);
1184 int (*sem_semop
) (struct sem_array
* sma
,
1185 struct sembuf
* sops
, unsigned nsops
, int alter
);
1187 int (*netlink_send
) (struct sock
* sk
, struct sk_buff
* skb
);
1188 int (*netlink_recv
) (struct sk_buff
* skb
);
1190 /* allow module stacking */
1191 int (*register_security
) (const char *name
,
1192 struct security_operations
*ops
);
1193 int (*unregister_security
) (const char *name
,
1194 struct security_operations
*ops
);
1196 void (*d_instantiate
) (struct dentry
*dentry
, struct inode
*inode
);
1198 int (*getprocattr
)(struct task_struct
*p
, char *name
, void *value
, size_t size
);
1199 int (*setprocattr
)(struct task_struct
*p
, char *name
, void *value
, size_t size
);
1201 #ifdef CONFIG_SECURITY_NETWORK
1202 int (*unix_stream_connect
) (struct socket
* sock
,
1203 struct socket
* other
, struct sock
* newsk
);
1204 int (*unix_may_send
) (struct socket
* sock
, struct socket
* other
);
1206 int (*socket_create
) (int family
, int type
, int protocol
, int kern
);
1207 void (*socket_post_create
) (struct socket
* sock
, int family
,
1208 int type
, int protocol
, int kern
);
1209 int (*socket_bind
) (struct socket
* sock
,
1210 struct sockaddr
* address
, int addrlen
);
1211 int (*socket_connect
) (struct socket
* sock
,
1212 struct sockaddr
* address
, int addrlen
);
1213 int (*socket_listen
) (struct socket
* sock
, int backlog
);
1214 int (*socket_accept
) (struct socket
* sock
, struct socket
* newsock
);
1215 void (*socket_post_accept
) (struct socket
* sock
,
1216 struct socket
* newsock
);
1217 int (*socket_sendmsg
) (struct socket
* sock
,
1218 struct msghdr
* msg
, int size
);
1219 int (*socket_recvmsg
) (struct socket
* sock
,
1220 struct msghdr
* msg
, int size
, int flags
);
1221 int (*socket_getsockname
) (struct socket
* sock
);
1222 int (*socket_getpeername
) (struct socket
* sock
);
1223 int (*socket_getsockopt
) (struct socket
* sock
, int level
, int optname
);
1224 int (*socket_setsockopt
) (struct socket
* sock
, int level
, int optname
);
1225 int (*socket_shutdown
) (struct socket
* sock
, int how
);
1226 int (*socket_sock_rcv_skb
) (struct sock
* sk
, struct sk_buff
* skb
);
1227 int (*socket_getpeersec
) (struct socket
*sock
, char __user
*optval
, int __user
*optlen
, unsigned len
);
1228 int (*sk_alloc_security
) (struct sock
*sk
, int family
, int priority
);
1229 void (*sk_free_security
) (struct sock
*sk
);
1230 #endif /* CONFIG_SECURITY_NETWORK */
1233 /* global variables */
1234 extern struct security_operations
*security_ops
;
1237 static inline int security_ptrace (struct task_struct
* parent
, struct task_struct
* child
)
1239 return security_ops
->ptrace (parent
, child
);
1242 static inline int security_capget (struct task_struct
*target
,
1243 kernel_cap_t
*effective
,
1244 kernel_cap_t
*inheritable
,
1245 kernel_cap_t
*permitted
)
1247 return security_ops
->capget (target
, effective
, inheritable
, permitted
);
1250 static inline int security_capset_check (struct task_struct
*target
,
1251 kernel_cap_t
*effective
,
1252 kernel_cap_t
*inheritable
,
1253 kernel_cap_t
*permitted
)
1255 return security_ops
->capset_check (target
, effective
, inheritable
, permitted
);
1258 static inline void security_capset_set (struct task_struct
*target
,
1259 kernel_cap_t
*effective
,
1260 kernel_cap_t
*inheritable
,
1261 kernel_cap_t
*permitted
)
1263 security_ops
->capset_set (target
, effective
, inheritable
, permitted
);
1266 static inline int security_acct (struct file
*file
)
1268 return security_ops
->acct (file
);
1271 static inline int security_sysctl(ctl_table
* table
, int op
)
1273 return security_ops
->sysctl(table
, op
);
1276 static inline int security_quotactl (int cmds
, int type
, int id
,
1277 struct super_block
*sb
)
1279 return security_ops
->quotactl (cmds
, type
, id
, sb
);
1282 static inline int security_quota_on (struct file
* file
)
1284 return security_ops
->quota_on (file
);
1287 static inline int security_syslog(int type
)
1289 return security_ops
->syslog(type
);
1292 static inline int security_vm_enough_memory(long pages
)
1294 return security_ops
->vm_enough_memory(pages
);
1297 static inline int security_bprm_alloc (struct linux_binprm
*bprm
)
1299 return security_ops
->bprm_alloc_security (bprm
);
1301 static inline void security_bprm_free (struct linux_binprm
*bprm
)
1303 security_ops
->bprm_free_security (bprm
);
1305 static inline void security_bprm_apply_creds (struct linux_binprm
*bprm
, int unsafe
)
1307 security_ops
->bprm_apply_creds (bprm
, unsafe
);
1309 static inline int security_bprm_set (struct linux_binprm
*bprm
)
1311 return security_ops
->bprm_set_security (bprm
);
1314 static inline int security_bprm_check (struct linux_binprm
*bprm
)
1316 return security_ops
->bprm_check_security (bprm
);
1319 static inline int security_bprm_secureexec (struct linux_binprm
*bprm
)
1321 return security_ops
->bprm_secureexec (bprm
);
1324 static inline int security_sb_alloc (struct super_block
*sb
)
1326 return security_ops
->sb_alloc_security (sb
);
1329 static inline void security_sb_free (struct super_block
*sb
)
1331 security_ops
->sb_free_security (sb
);
1334 static inline int security_sb_copy_data (struct file_system_type
*type
,
1335 void *orig
, void *copy
)
1337 return security_ops
->sb_copy_data (type
, orig
, copy
);
1340 static inline int security_sb_kern_mount (struct super_block
*sb
, void *data
)
1342 return security_ops
->sb_kern_mount (sb
, data
);
1345 static inline int security_sb_statfs (struct super_block
*sb
)
1347 return security_ops
->sb_statfs (sb
);
1350 static inline int security_sb_mount (char *dev_name
, struct nameidata
*nd
,
1351 char *type
, unsigned long flags
,
1354 return security_ops
->sb_mount (dev_name
, nd
, type
, flags
, data
);
1357 static inline int security_sb_check_sb (struct vfsmount
*mnt
,
1358 struct nameidata
*nd
)
1360 return security_ops
->sb_check_sb (mnt
, nd
);
1363 static inline int security_sb_umount (struct vfsmount
*mnt
, int flags
)
1365 return security_ops
->sb_umount (mnt
, flags
);
1368 static inline void security_sb_umount_close (struct vfsmount
*mnt
)
1370 security_ops
->sb_umount_close (mnt
);
1373 static inline void security_sb_umount_busy (struct vfsmount
*mnt
)
1375 security_ops
->sb_umount_busy (mnt
);
1378 static inline void security_sb_post_remount (struct vfsmount
*mnt
,
1379 unsigned long flags
, void *data
)
1381 security_ops
->sb_post_remount (mnt
, flags
, data
);
1384 static inline void security_sb_post_mountroot (void)
1386 security_ops
->sb_post_mountroot ();
1389 static inline void security_sb_post_addmount (struct vfsmount
*mnt
,
1390 struct nameidata
*mountpoint_nd
)
1392 security_ops
->sb_post_addmount (mnt
, mountpoint_nd
);
1395 static inline int security_sb_pivotroot (struct nameidata
*old_nd
,
1396 struct nameidata
*new_nd
)
1398 return security_ops
->sb_pivotroot (old_nd
, new_nd
);
1401 static inline void security_sb_post_pivotroot (struct nameidata
*old_nd
,
1402 struct nameidata
*new_nd
)
1404 security_ops
->sb_post_pivotroot (old_nd
, new_nd
);
1407 static inline int security_inode_alloc (struct inode
*inode
)
1409 return security_ops
->inode_alloc_security (inode
);
1412 static inline void security_inode_free (struct inode
*inode
)
1414 security_ops
->inode_free_security (inode
);
1417 static inline int security_inode_create (struct inode
*dir
,
1418 struct dentry
*dentry
,
1421 return security_ops
->inode_create (dir
, dentry
, mode
);
1424 static inline void security_inode_post_create (struct inode
*dir
,
1425 struct dentry
*dentry
,
1428 security_ops
->inode_post_create (dir
, dentry
, mode
);
1431 static inline int security_inode_link (struct dentry
*old_dentry
,
1433 struct dentry
*new_dentry
)
1435 return security_ops
->inode_link (old_dentry
, dir
, new_dentry
);
1438 static inline void security_inode_post_link (struct dentry
*old_dentry
,
1440 struct dentry
*new_dentry
)
1442 security_ops
->inode_post_link (old_dentry
, dir
, new_dentry
);
1445 static inline int security_inode_unlink (struct inode
*dir
,
1446 struct dentry
*dentry
)
1448 return security_ops
->inode_unlink (dir
, dentry
);
1451 static inline int security_inode_symlink (struct inode
*dir
,
1452 struct dentry
*dentry
,
1453 const char *old_name
)
1455 return security_ops
->inode_symlink (dir
, dentry
, old_name
);
1458 static inline void security_inode_post_symlink (struct inode
*dir
,
1459 struct dentry
*dentry
,
1460 const char *old_name
)
1462 security_ops
->inode_post_symlink (dir
, dentry
, old_name
);
1465 static inline int security_inode_mkdir (struct inode
*dir
,
1466 struct dentry
*dentry
,
1469 return security_ops
->inode_mkdir (dir
, dentry
, mode
);
1472 static inline void security_inode_post_mkdir (struct inode
*dir
,
1473 struct dentry
*dentry
,
1476 security_ops
->inode_post_mkdir (dir
, dentry
, mode
);
1479 static inline int security_inode_rmdir (struct inode
*dir
,
1480 struct dentry
*dentry
)
1482 return security_ops
->inode_rmdir (dir
, dentry
);
1485 static inline int security_inode_mknod (struct inode
*dir
,
1486 struct dentry
*dentry
,
1487 int mode
, dev_t dev
)
1489 return security_ops
->inode_mknod (dir
, dentry
, mode
, dev
);
1492 static inline void security_inode_post_mknod (struct inode
*dir
,
1493 struct dentry
*dentry
,
1494 int mode
, dev_t dev
)
1496 security_ops
->inode_post_mknod (dir
, dentry
, mode
, dev
);
1499 static inline int security_inode_rename (struct inode
*old_dir
,
1500 struct dentry
*old_dentry
,
1501 struct inode
*new_dir
,
1502 struct dentry
*new_dentry
)
1504 return security_ops
->inode_rename (old_dir
, old_dentry
,
1505 new_dir
, new_dentry
);
1508 static inline void security_inode_post_rename (struct inode
*old_dir
,
1509 struct dentry
*old_dentry
,
1510 struct inode
*new_dir
,
1511 struct dentry
*new_dentry
)
1513 security_ops
->inode_post_rename (old_dir
, old_dentry
,
1514 new_dir
, new_dentry
);
1517 static inline int security_inode_readlink (struct dentry
*dentry
)
1519 return security_ops
->inode_readlink (dentry
);
1522 static inline int security_inode_follow_link (struct dentry
*dentry
,
1523 struct nameidata
*nd
)
1525 return security_ops
->inode_follow_link (dentry
, nd
);
1528 static inline int security_inode_permission (struct inode
*inode
, int mask
,
1529 struct nameidata
*nd
)
1531 return security_ops
->inode_permission (inode
, mask
, nd
);
1534 static inline int security_inode_setattr (struct dentry
*dentry
,
1537 return security_ops
->inode_setattr (dentry
, attr
);
1540 static inline int security_inode_getattr (struct vfsmount
*mnt
,
1541 struct dentry
*dentry
)
1543 return security_ops
->inode_getattr (mnt
, dentry
);
1546 static inline void security_inode_delete (struct inode
*inode
)
1548 security_ops
->inode_delete (inode
);
1551 static inline int security_inode_setxattr (struct dentry
*dentry
, char *name
,
1552 void *value
, size_t size
, int flags
)
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 security_ops
->inode_post_setxattr (dentry
, name
, value
, size
, flags
);
1563 static inline int security_inode_getxattr (struct dentry
*dentry
, char *name
)
1565 return security_ops
->inode_getxattr (dentry
, name
);
1568 static inline int security_inode_listxattr (struct dentry
*dentry
)
1570 return security_ops
->inode_listxattr (dentry
);
1573 static inline int security_inode_removexattr (struct dentry
*dentry
, char *name
)
1575 return security_ops
->inode_removexattr (dentry
, name
);
1578 static inline int security_inode_getsecurity(struct dentry
*dentry
, const char *name
, void *buffer
, size_t size
)
1580 return security_ops
->inode_getsecurity(dentry
, name
, buffer
, size
);
1583 static inline int security_inode_setsecurity(struct dentry
*dentry
, const char *name
, const void *value
, size_t size
, int flags
)
1585 return security_ops
->inode_setsecurity(dentry
, name
, value
, size
, flags
);
1588 static inline int security_inode_listsecurity(struct dentry
*dentry
, char *buffer
)
1590 return security_ops
->inode_listsecurity(dentry
, buffer
);
1593 static inline int security_file_permission (struct file
*file
, int mask
)
1595 return security_ops
->file_permission (file
, mask
);
1598 static inline int security_file_alloc (struct file
*file
)
1600 return security_ops
->file_alloc_security (file
);
1603 static inline void security_file_free (struct file
*file
)
1605 security_ops
->file_free_security (file
);
1608 static inline int security_file_ioctl (struct file
*file
, unsigned int cmd
,
1611 return security_ops
->file_ioctl (file
, cmd
, arg
);
1614 static inline int security_file_mmap (struct file
*file
, unsigned long prot
,
1615 unsigned long flags
)
1617 return security_ops
->file_mmap (file
, prot
, flags
);
1620 static inline int security_file_mprotect (struct vm_area_struct
*vma
,
1623 return security_ops
->file_mprotect (vma
, prot
);
1626 static inline int security_file_lock (struct file
*file
, unsigned int cmd
)
1628 return security_ops
->file_lock (file
, cmd
);
1631 static inline int security_file_fcntl (struct file
*file
, unsigned int cmd
,
1634 return security_ops
->file_fcntl (file
, cmd
, arg
);
1637 static inline int security_file_set_fowner (struct file
*file
)
1639 return security_ops
->file_set_fowner (file
);
1642 static inline int security_file_send_sigiotask (struct task_struct
*tsk
,
1643 struct fown_struct
*fown
,
1646 return security_ops
->file_send_sigiotask (tsk
, fown
, fd
, reason
);
1649 static inline int security_file_receive (struct file
*file
)
1651 return security_ops
->file_receive (file
);
1654 static inline int security_task_create (unsigned long clone_flags
)
1656 return security_ops
->task_create (clone_flags
);
1659 static inline int security_task_alloc (struct task_struct
*p
)
1661 return security_ops
->task_alloc_security (p
);
1664 static inline void security_task_free (struct task_struct
*p
)
1666 security_ops
->task_free_security (p
);
1669 static inline int security_task_setuid (uid_t id0
, uid_t id1
, uid_t id2
,
1672 return security_ops
->task_setuid (id0
, id1
, id2
, flags
);
1675 static inline int security_task_post_setuid (uid_t old_ruid
, uid_t old_euid
,
1676 uid_t old_suid
, int flags
)
1678 return security_ops
->task_post_setuid (old_ruid
, old_euid
, old_suid
, flags
);
1681 static inline int security_task_setgid (gid_t id0
, gid_t id1
, gid_t id2
,
1684 return security_ops
->task_setgid (id0
, id1
, id2
, flags
);
1687 static inline int security_task_setpgid (struct task_struct
*p
, pid_t pgid
)
1689 return security_ops
->task_setpgid (p
, pgid
);
1692 static inline int security_task_getpgid (struct task_struct
*p
)
1694 return security_ops
->task_getpgid (p
);
1697 static inline int security_task_getsid (struct task_struct
*p
)
1699 return security_ops
->task_getsid (p
);
1702 static inline int security_task_setgroups (struct group_info
*group_info
)
1704 return security_ops
->task_setgroups (group_info
);
1707 static inline int security_task_setnice (struct task_struct
*p
, int nice
)
1709 return security_ops
->task_setnice (p
, nice
);
1712 static inline int security_task_setrlimit (unsigned int resource
,
1713 struct rlimit
*new_rlim
)
1715 return security_ops
->task_setrlimit (resource
, new_rlim
);
1718 static inline int security_task_setscheduler (struct task_struct
*p
,
1720 struct sched_param
*lp
)
1722 return security_ops
->task_setscheduler (p
, policy
, lp
);
1725 static inline int security_task_getscheduler (struct task_struct
*p
)
1727 return security_ops
->task_getscheduler (p
);
1730 static inline int security_task_kill (struct task_struct
*p
,
1731 struct siginfo
*info
, int sig
)
1733 return security_ops
->task_kill (p
, info
, sig
);
1736 static inline int security_task_wait (struct task_struct
*p
)
1738 return security_ops
->task_wait (p
);
1741 static inline int security_task_prctl (int option
, unsigned long arg2
,
1746 return security_ops
->task_prctl (option
, arg2
, arg3
, arg4
, arg5
);
1749 static inline void security_task_reparent_to_init (struct task_struct
*p
)
1751 security_ops
->task_reparent_to_init (p
);
1754 static inline void security_task_to_inode(struct task_struct
*p
, struct inode
*inode
)
1756 security_ops
->task_to_inode(p
, inode
);
1759 static inline int security_ipc_permission (struct kern_ipc_perm
*ipcp
,
1762 return security_ops
->ipc_permission (ipcp
, flag
);
1765 static inline int security_msg_msg_alloc (struct msg_msg
* msg
)
1767 return security_ops
->msg_msg_alloc_security (msg
);
1770 static inline void security_msg_msg_free (struct msg_msg
* msg
)
1772 security_ops
->msg_msg_free_security(msg
);
1775 static inline int security_msg_queue_alloc (struct msg_queue
*msq
)
1777 return security_ops
->msg_queue_alloc_security (msq
);
1780 static inline void security_msg_queue_free (struct msg_queue
*msq
)
1782 security_ops
->msg_queue_free_security (msq
);
1785 static inline int security_msg_queue_associate (struct msg_queue
* msq
,
1788 return security_ops
->msg_queue_associate (msq
, msqflg
);
1791 static inline int security_msg_queue_msgctl (struct msg_queue
* msq
, int cmd
)
1793 return security_ops
->msg_queue_msgctl (msq
, cmd
);
1796 static inline int security_msg_queue_msgsnd (struct msg_queue
* msq
,
1797 struct msg_msg
* msg
, int msqflg
)
1799 return security_ops
->msg_queue_msgsnd (msq
, msg
, msqflg
);
1802 static inline int security_msg_queue_msgrcv (struct msg_queue
* msq
,
1803 struct msg_msg
* msg
,
1804 struct task_struct
* target
,
1805 long type
, int mode
)
1807 return security_ops
->msg_queue_msgrcv (msq
, msg
, target
, type
, mode
);
1810 static inline int security_shm_alloc (struct shmid_kernel
*shp
)
1812 return security_ops
->shm_alloc_security (shp
);
1815 static inline void security_shm_free (struct shmid_kernel
*shp
)
1817 security_ops
->shm_free_security (shp
);
1820 static inline int security_shm_associate (struct shmid_kernel
* shp
,
1823 return security_ops
->shm_associate(shp
, shmflg
);
1826 static inline int security_shm_shmctl (struct shmid_kernel
* shp
, int cmd
)
1828 return security_ops
->shm_shmctl (shp
, cmd
);
1831 static inline int security_shm_shmat (struct shmid_kernel
* shp
,
1832 char __user
*shmaddr
, int shmflg
)
1834 return security_ops
->shm_shmat(shp
, shmaddr
, shmflg
);
1837 static inline int security_sem_alloc (struct sem_array
*sma
)
1839 return security_ops
->sem_alloc_security (sma
);
1842 static inline void security_sem_free (struct sem_array
*sma
)
1844 security_ops
->sem_free_security (sma
);
1847 static inline int security_sem_associate (struct sem_array
* sma
, int semflg
)
1849 return security_ops
->sem_associate (sma
, semflg
);
1852 static inline int security_sem_semctl (struct sem_array
* sma
, int cmd
)
1854 return security_ops
->sem_semctl(sma
, cmd
);
1857 static inline int security_sem_semop (struct sem_array
* sma
,
1858 struct sembuf
* sops
, unsigned nsops
,
1861 return security_ops
->sem_semop(sma
, sops
, nsops
, alter
);
1864 static inline void security_d_instantiate (struct dentry
*dentry
, struct inode
*inode
)
1866 security_ops
->d_instantiate (dentry
, inode
);
1869 static inline int security_getprocattr(struct task_struct
*p
, char *name
, void *value
, size_t size
)
1871 return security_ops
->getprocattr(p
, name
, value
, size
);
1874 static inline int security_setprocattr(struct task_struct
*p
, char *name
, void *value
, size_t size
)
1876 return security_ops
->setprocattr(p
, name
, value
, size
);
1879 static inline int security_netlink_send(struct sock
*sk
, struct sk_buff
* skb
)
1881 return security_ops
->netlink_send(sk
, skb
);
1884 static inline int security_netlink_recv(struct sk_buff
* skb
)
1886 return security_ops
->netlink_recv(skb
);
1890 extern int security_scaffolding_startup (void);
1891 extern int register_security (struct security_operations
*ops
);
1892 extern int unregister_security (struct security_operations
*ops
);
1893 extern int mod_reg_security (const char *name
, struct security_operations
*ops
);
1894 extern int mod_unreg_security (const char *name
, struct security_operations
*ops
);
1897 #else /* CONFIG_SECURITY */
1900 * This is the default capabilities functionality. Most of these functions
1901 * are just stubbed out, but a few must call the proper capable code.
1904 static inline int security_scaffolding_startup (void)
1909 static inline int security_ptrace (struct task_struct
*parent
, struct task_struct
* child
)
1911 return cap_ptrace (parent
, child
);
1914 static inline int security_capget (struct task_struct
*target
,
1915 kernel_cap_t
*effective
,
1916 kernel_cap_t
*inheritable
,
1917 kernel_cap_t
*permitted
)
1919 return cap_capget (target
, effective
, inheritable
, permitted
);
1922 static inline int security_capset_check (struct task_struct
*target
,
1923 kernel_cap_t
*effective
,
1924 kernel_cap_t
*inheritable
,
1925 kernel_cap_t
*permitted
)
1927 return cap_capset_check (target
, effective
, inheritable
, permitted
);
1930 static inline void security_capset_set (struct task_struct
*target
,
1931 kernel_cap_t
*effective
,
1932 kernel_cap_t
*inheritable
,
1933 kernel_cap_t
*permitted
)
1935 cap_capset_set (target
, effective
, inheritable
, permitted
);
1938 static inline int security_acct (struct file
*file
)
1943 static inline int security_sysctl(ctl_table
* table
, int op
)
1948 static inline int security_quotactl (int cmds
, int type
, int id
,
1949 struct super_block
* sb
)
1954 static inline int security_quota_on (struct file
* file
)
1959 static inline int security_syslog(int type
)
1961 return cap_syslog(type
);
1964 static inline int security_vm_enough_memory(long pages
)
1966 return cap_vm_enough_memory(pages
);
1969 static inline int security_bprm_alloc (struct linux_binprm
*bprm
)
1974 static inline void security_bprm_free (struct linux_binprm
*bprm
)
1977 static inline void security_bprm_apply_creds (struct linux_binprm
*bprm
, int unsafe
)
1979 cap_bprm_apply_creds (bprm
, unsafe
);
1982 static inline int security_bprm_set (struct linux_binprm
*bprm
)
1984 return cap_bprm_set_security (bprm
);
1987 static inline int security_bprm_check (struct linux_binprm
*bprm
)
1992 static inline int security_bprm_secureexec (struct linux_binprm
*bprm
)
1994 return cap_bprm_secureexec(bprm
);
1997 static inline int security_sb_alloc (struct super_block
*sb
)
2002 static inline void security_sb_free (struct super_block
*sb
)
2005 static inline int security_sb_copy_data (struct file_system_type
*type
,
2006 void *orig
, void *copy
)
2011 static inline int security_sb_kern_mount (struct super_block
*sb
, void *data
)
2016 static inline int security_sb_statfs (struct super_block
*sb
)
2021 static inline int security_sb_mount (char *dev_name
, struct nameidata
*nd
,
2022 char *type
, unsigned long flags
,
2028 static inline int security_sb_check_sb (struct vfsmount
*mnt
,
2029 struct nameidata
*nd
)
2034 static inline int security_sb_umount (struct vfsmount
*mnt
, int flags
)
2039 static inline void security_sb_umount_close (struct vfsmount
*mnt
)
2042 static inline void security_sb_umount_busy (struct vfsmount
*mnt
)
2045 static inline void security_sb_post_remount (struct vfsmount
*mnt
,
2046 unsigned long flags
, void *data
)
2049 static inline void security_sb_post_mountroot (void)
2052 static inline void security_sb_post_addmount (struct vfsmount
*mnt
,
2053 struct nameidata
*mountpoint_nd
)
2056 static inline int security_sb_pivotroot (struct nameidata
*old_nd
,
2057 struct nameidata
*new_nd
)
2062 static inline void security_sb_post_pivotroot (struct nameidata
*old_nd
,
2063 struct nameidata
*new_nd
)
2066 static inline int security_inode_alloc (struct inode
*inode
)
2071 static inline void security_inode_free (struct inode
*inode
)
2074 static inline int security_inode_create (struct inode
*dir
,
2075 struct dentry
*dentry
,
2081 static inline void security_inode_post_create (struct inode
*dir
,
2082 struct dentry
*dentry
,
2086 static inline int security_inode_link (struct dentry
*old_dentry
,
2088 struct dentry
*new_dentry
)
2093 static inline void security_inode_post_link (struct dentry
*old_dentry
,
2095 struct dentry
*new_dentry
)
2098 static inline int security_inode_unlink (struct inode
*dir
,
2099 struct dentry
*dentry
)
2104 static inline int security_inode_symlink (struct inode
*dir
,
2105 struct dentry
*dentry
,
2106 const char *old_name
)
2111 static inline void security_inode_post_symlink (struct inode
*dir
,
2112 struct dentry
*dentry
,
2113 const char *old_name
)
2116 static inline int security_inode_mkdir (struct inode
*dir
,
2117 struct dentry
*dentry
,
2123 static inline void security_inode_post_mkdir (struct inode
*dir
,
2124 struct dentry
*dentry
,
2128 static inline int security_inode_rmdir (struct inode
*dir
,
2129 struct dentry
*dentry
)
2134 static inline int security_inode_mknod (struct inode
*dir
,
2135 struct dentry
*dentry
,
2136 int mode
, dev_t dev
)
2141 static inline void security_inode_post_mknod (struct inode
*dir
,
2142 struct dentry
*dentry
,
2143 int mode
, dev_t dev
)
2146 static inline int security_inode_rename (struct inode
*old_dir
,
2147 struct dentry
*old_dentry
,
2148 struct inode
*new_dir
,
2149 struct dentry
*new_dentry
)
2154 static inline void security_inode_post_rename (struct inode
*old_dir
,
2155 struct dentry
*old_dentry
,
2156 struct inode
*new_dir
,
2157 struct dentry
*new_dentry
)
2160 static inline int security_inode_readlink (struct dentry
*dentry
)
2165 static inline int security_inode_follow_link (struct dentry
*dentry
,
2166 struct nameidata
*nd
)
2171 static inline int security_inode_permission (struct inode
*inode
, int mask
,
2172 struct nameidata
*nd
)
2177 static inline int security_inode_setattr (struct dentry
*dentry
,
2183 static inline int security_inode_getattr (struct vfsmount
*mnt
,
2184 struct dentry
*dentry
)
2189 static inline void security_inode_delete (struct inode
*inode
)
2192 static inline int security_inode_setxattr (struct dentry
*dentry
, char *name
,
2193 void *value
, size_t size
, int flags
)
2195 return cap_inode_setxattr(dentry
, name
, value
, size
, flags
);
2198 static inline void security_inode_post_setxattr (struct dentry
*dentry
, char *name
,
2199 void *value
, size_t size
, int flags
)
2202 static inline int security_inode_getxattr (struct dentry
*dentry
, char *name
)
2207 static inline int security_inode_listxattr (struct dentry
*dentry
)
2212 static inline int security_inode_removexattr (struct dentry
*dentry
, char *name
)
2214 return cap_inode_removexattr(dentry
, name
);
2217 static inline int security_inode_getsecurity(struct dentry
*dentry
, const char *name
, void *buffer
, size_t size
)
2222 static inline int security_inode_setsecurity(struct dentry
*dentry
, const char *name
, const void *value
, size_t size
, int flags
)
2227 static inline int security_inode_listsecurity(struct dentry
*dentry
, char *buffer
)
2232 static inline int security_file_permission (struct file
*file
, int mask
)
2237 static inline int security_file_alloc (struct file
*file
)
2242 static inline void security_file_free (struct file
*file
)
2245 static inline int security_file_ioctl (struct file
*file
, unsigned int cmd
,
2251 static inline int security_file_mmap (struct file
*file
, unsigned long prot
,
2252 unsigned long flags
)
2257 static inline int security_file_mprotect (struct vm_area_struct
*vma
,
2263 static inline int security_file_lock (struct file
*file
, unsigned int cmd
)
2268 static inline int security_file_fcntl (struct file
*file
, unsigned int cmd
,
2274 static inline int security_file_set_fowner (struct file
*file
)
2279 static inline int security_file_send_sigiotask (struct task_struct
*tsk
,
2280 struct fown_struct
*fown
,
2286 static inline int security_file_receive (struct file
*file
)
2291 static inline int security_task_create (unsigned long clone_flags
)
2296 static inline int security_task_alloc (struct task_struct
*p
)
2301 static inline void security_task_free (struct task_struct
*p
)
2304 static inline int security_task_setuid (uid_t id0
, uid_t id1
, uid_t id2
,
2310 static inline int security_task_post_setuid (uid_t old_ruid
, uid_t old_euid
,
2311 uid_t old_suid
, int flags
)
2313 return cap_task_post_setuid (old_ruid
, old_euid
, old_suid
, flags
);
2316 static inline int security_task_setgid (gid_t id0
, gid_t id1
, gid_t id2
,
2322 static inline int security_task_setpgid (struct task_struct
*p
, pid_t pgid
)
2327 static inline int security_task_getpgid (struct task_struct
*p
)
2332 static inline int security_task_getsid (struct task_struct
*p
)
2337 static inline int security_task_setgroups (struct group_info
*group_info
)
2342 static inline int security_task_setnice (struct task_struct
*p
, int nice
)
2347 static inline int security_task_setrlimit (unsigned int resource
,
2348 struct rlimit
*new_rlim
)
2353 static inline int security_task_setscheduler (struct task_struct
*p
,
2355 struct sched_param
*lp
)
2360 static inline int security_task_getscheduler (struct task_struct
*p
)
2365 static inline int security_task_kill (struct task_struct
*p
,
2366 struct siginfo
*info
, int sig
)
2371 static inline int security_task_wait (struct task_struct
*p
)
2376 static inline int security_task_prctl (int option
, unsigned long arg2
,
2384 static inline void security_task_reparent_to_init (struct task_struct
*p
)
2386 cap_task_reparent_to_init (p
);
2389 static inline void security_task_to_inode(struct task_struct
*p
, struct inode
*inode
)
2392 static inline int security_ipc_permission (struct kern_ipc_perm
*ipcp
,
2398 static inline int security_msg_msg_alloc (struct msg_msg
* msg
)
2403 static inline void security_msg_msg_free (struct msg_msg
* msg
)
2406 static inline int security_msg_queue_alloc (struct msg_queue
*msq
)
2411 static inline void security_msg_queue_free (struct msg_queue
*msq
)
2414 static inline int security_msg_queue_associate (struct msg_queue
* msq
,
2420 static inline int security_msg_queue_msgctl (struct msg_queue
* msq
, int cmd
)
2425 static inline int security_msg_queue_msgsnd (struct msg_queue
* msq
,
2426 struct msg_msg
* msg
, int msqflg
)
2431 static inline int security_msg_queue_msgrcv (struct msg_queue
* msq
,
2432 struct msg_msg
* msg
,
2433 struct task_struct
* target
,
2434 long type
, int mode
)
2439 static inline int security_shm_alloc (struct shmid_kernel
*shp
)
2444 static inline void security_shm_free (struct shmid_kernel
*shp
)
2447 static inline int security_shm_associate (struct shmid_kernel
* shp
,
2453 static inline int security_shm_shmctl (struct shmid_kernel
* shp
, int cmd
)
2458 static inline int security_shm_shmat (struct shmid_kernel
* shp
,
2459 char __user
*shmaddr
, int shmflg
)
2464 static inline int security_sem_alloc (struct sem_array
*sma
)
2469 static inline void security_sem_free (struct sem_array
*sma
)
2472 static inline int security_sem_associate (struct sem_array
* sma
, int semflg
)
2477 static inline int security_sem_semctl (struct sem_array
* sma
, int cmd
)
2482 static inline int security_sem_semop (struct sem_array
* sma
,
2483 struct sembuf
* sops
, unsigned nsops
,
2489 static inline void security_d_instantiate (struct dentry
*dentry
, struct inode
*inode
)
2492 static inline int security_getprocattr(struct task_struct
*p
, char *name
, void *value
, size_t size
)
2497 static inline int security_setprocattr(struct task_struct
*p
, char *name
, void *value
, size_t size
)
2503 * The netlink capability defaults need to be used inline by default
2504 * (rather than hooking into the capability module) to reduce overhead
2505 * in the networking code.
2507 static inline int security_netlink_send (struct sock
*sk
, struct sk_buff
*skb
)
2509 return cap_netlink_send (sk
, skb
);
2512 static inline int security_netlink_recv (struct sk_buff
*skb
)
2514 return cap_netlink_recv (skb
);
2517 #endif /* CONFIG_SECURITY */
2519 #ifdef CONFIG_SECURITY_NETWORK
2520 static inline int security_unix_stream_connect(struct socket
* sock
,
2521 struct socket
* other
,
2522 struct sock
* newsk
)
2524 return security_ops
->unix_stream_connect(sock
, other
, newsk
);
2528 static inline int security_unix_may_send(struct socket
* sock
,
2529 struct socket
* other
)
2531 return security_ops
->unix_may_send(sock
, other
);
2534 static inline int security_socket_create (int family
, int type
,
2535 int protocol
, int kern
)
2537 return security_ops
->socket_create(family
, type
, protocol
, kern
);
2540 static inline void security_socket_post_create(struct socket
* sock
,
2543 int protocol
, int kern
)
2545 security_ops
->socket_post_create(sock
, family
, type
,
2549 static inline int security_socket_bind(struct socket
* sock
,
2550 struct sockaddr
* address
,
2553 return security_ops
->socket_bind(sock
, address
, addrlen
);
2556 static inline int security_socket_connect(struct socket
* sock
,
2557 struct sockaddr
* address
,
2560 return security_ops
->socket_connect(sock
, address
, addrlen
);
2563 static inline int security_socket_listen(struct socket
* sock
, int backlog
)
2565 return security_ops
->socket_listen(sock
, backlog
);
2568 static inline int security_socket_accept(struct socket
* sock
,
2569 struct socket
* newsock
)
2571 return security_ops
->socket_accept(sock
, newsock
);
2574 static inline void security_socket_post_accept(struct socket
* sock
,
2575 struct socket
* newsock
)
2577 security_ops
->socket_post_accept(sock
, newsock
);
2580 static inline int security_socket_sendmsg(struct socket
* sock
,
2581 struct msghdr
* msg
, int size
)
2583 return security_ops
->socket_sendmsg(sock
, msg
, size
);
2586 static inline int security_socket_recvmsg(struct socket
* sock
,
2587 struct msghdr
* msg
, int size
,
2590 return security_ops
->socket_recvmsg(sock
, msg
, size
, flags
);
2593 static inline int security_socket_getsockname(struct socket
* sock
)
2595 return security_ops
->socket_getsockname(sock
);
2598 static inline int security_socket_getpeername(struct socket
* sock
)
2600 return security_ops
->socket_getpeername(sock
);
2603 static inline int security_socket_getsockopt(struct socket
* sock
,
2604 int level
, int optname
)
2606 return security_ops
->socket_getsockopt(sock
, level
, optname
);
2609 static inline int security_socket_setsockopt(struct socket
* sock
,
2610 int level
, int optname
)
2612 return security_ops
->socket_setsockopt(sock
, level
, optname
);
2615 static inline int security_socket_shutdown(struct socket
* sock
, int how
)
2617 return security_ops
->socket_shutdown(sock
, how
);
2620 static inline int security_sock_rcv_skb (struct sock
* sk
,
2621 struct sk_buff
* skb
)
2623 return security_ops
->socket_sock_rcv_skb (sk
, skb
);
2626 static inline int security_socket_getpeersec(struct socket
*sock
, char __user
*optval
,
2627 int __user
*optlen
, unsigned len
)
2629 return security_ops
->socket_getpeersec(sock
, optval
, optlen
, len
);
2632 static inline int security_sk_alloc(struct sock
*sk
, int family
, int priority
)
2634 return security_ops
->sk_alloc_security(sk
, family
, priority
);
2637 static inline void security_sk_free(struct sock
*sk
)
2639 return security_ops
->sk_free_security(sk
);
2641 #else /* CONFIG_SECURITY_NETWORK */
2642 static inline int security_unix_stream_connect(struct socket
* sock
,
2643 struct socket
* other
,
2644 struct sock
* newsk
)
2649 static inline int security_unix_may_send(struct socket
* sock
,
2650 struct socket
* other
)
2655 static inline int security_socket_create (int family
, int type
,
2656 int protocol
, int kern
)
2661 static inline void security_socket_post_create(struct socket
* sock
,
2664 int protocol
, int kern
)
2668 static inline int security_socket_bind(struct socket
* sock
,
2669 struct sockaddr
* address
,
2675 static inline int security_socket_connect(struct socket
* sock
,
2676 struct sockaddr
* address
,
2682 static inline int security_socket_listen(struct socket
* sock
, int backlog
)
2687 static inline int security_socket_accept(struct socket
* sock
,
2688 struct socket
* newsock
)
2693 static inline void security_socket_post_accept(struct socket
* sock
,
2694 struct socket
* newsock
)
2698 static inline int security_socket_sendmsg(struct socket
* sock
,
2699 struct msghdr
* msg
, int size
)
2704 static inline int security_socket_recvmsg(struct socket
* sock
,
2705 struct msghdr
* msg
, int size
,
2711 static inline int security_socket_getsockname(struct socket
* sock
)
2716 static inline int security_socket_getpeername(struct socket
* sock
)
2721 static inline int security_socket_getsockopt(struct socket
* sock
,
2722 int level
, int optname
)
2727 static inline int security_socket_setsockopt(struct socket
* sock
,
2728 int level
, int optname
)
2733 static inline int security_socket_shutdown(struct socket
* sock
, int how
)
2737 static inline int security_sock_rcv_skb (struct sock
* sk
,
2738 struct sk_buff
* skb
)
2743 static inline int security_socket_getpeersec(struct socket
*sock
, char __user
*optval
,
2744 int __user
*optlen
, unsigned len
)
2746 return -ENOPROTOOPT
;
2749 static inline int security_sk_alloc(struct sock
*sk
, int family
, int priority
)
2754 static inline void security_sk_free(struct sock
*sk
)
2757 #endif /* CONFIG_SECURITY_NETWORK */
2759 #endif /* ! __LINUX_SECURITY_H */