]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blame - include/linux/security.h
security: call security_file_permission from rw_verify_area
[mirror_ubuntu-focal-kernel.git] / include / linux / security.h
CommitLineData
1da177e4
LT
1/*
2 * Linux Security plug
3 *
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)
9 *
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.
14 *
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.
19 *
20 */
21
22#ifndef __LINUX_SECURITY_H
23#define __LINUX_SECURITY_H
24
25#include <linux/fs.h>
26#include <linux/binfmts.h>
27#include <linux/signal.h>
28#include <linux/resource.h>
29#include <linux/sem.h>
30#include <linux/shm.h>
31#include <linux/msg.h>
32#include <linux/sched.h>
29db9190 33#include <linux/key.h>
e0d1caa7 34#include <linux/xfrm.h>
beb8d13b 35#include <net/flow.h>
1da177e4 36
c9180a57
EP
37/* only a char in selinux superblock security struct flags */
38#define FSCONTEXT_MNT 0x01
39#define CONTEXT_MNT 0x02
40#define ROOTCONTEXT_MNT 0x04
41#define DEFCONTEXT_MNT 0x08
42
72c2d582
AM
43/*
44 * Bounding set
45 */
46extern kernel_cap_t cap_bset;
47
48extern unsigned securebits;
49
1da177e4
LT
50struct ctl_table;
51
52/*
53 * These functions are in security/capability.c and are used
54 * as the default capabilities functions
55 */
56extern int cap_capable (struct task_struct *tsk, int cap);
57extern int cap_settime (struct timespec *ts, struct timezone *tz);
58extern int cap_ptrace (struct task_struct *parent, struct task_struct *child);
59extern int cap_capget (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
60extern int cap_capset_check (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
61extern void cap_capset_set (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
62extern int cap_bprm_set_security (struct linux_binprm *bprm);
63extern void cap_bprm_apply_creds (struct linux_binprm *bprm, int unsafe);
64extern int cap_bprm_secureexec(struct linux_binprm *bprm);
65extern int cap_inode_setxattr(struct dentry *dentry, char *name, void *value, size_t size, int flags);
66extern int cap_inode_removexattr(struct dentry *dentry, char *name);
b5376771
SH
67extern int cap_inode_need_killpriv(struct dentry *dentry);
68extern int cap_inode_killpriv(struct dentry *dentry);
1da177e4
LT
69extern int cap_task_post_setuid (uid_t old_ruid, uid_t old_euid, uid_t old_suid, int flags);
70extern void cap_task_reparent_to_init (struct task_struct *p);
b5376771
SH
71extern int cap_task_kill(struct task_struct *p, struct siginfo *info, int sig, u32 secid);
72extern int cap_task_setscheduler (struct task_struct *p, int policy, struct sched_param *lp);
73extern int cap_task_setioprio (struct task_struct *p, int ioprio);
74extern int cap_task_setnice (struct task_struct *p, int nice);
1da177e4 75extern int cap_syslog (int type);
20510f2f 76extern int cap_vm_enough_memory(struct mm_struct *mm, long pages);
1da177e4
LT
77
78struct msghdr;
79struct sk_buff;
80struct sock;
81struct sockaddr;
82struct socket;
df71837d
TJ
83struct flowi;
84struct dst_entry;
85struct xfrm_selector;
86struct xfrm_policy;
87struct xfrm_state;
88struct xfrm_user_sec_ctx;
1da177e4
LT
89
90extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
c7bdb545 91extern int cap_netlink_recv(struct sk_buff *skb, int cap);
1da177e4 92
ed032189 93extern unsigned long mmap_min_addr;
1da177e4
LT
94/*
95 * Values used in the task_security_ops calls
96 */
97/* setuid or setgid, id0 == uid or gid */
98#define LSM_SETID_ID 1
99
100/* setreuid or setregid, id0 == real, id1 == eff */
101#define LSM_SETID_RE 2
102
103/* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
104#define LSM_SETID_RES 4
105
106/* setfsuid or setfsgid, id0 == fsuid or fsgid */
107#define LSM_SETID_FS 8
108
109/* forward declares to avoid warnings */
110struct nfsctl_arg;
111struct sched_param;
112struct swap_info_struct;
4237c75c 113struct request_sock;
1da177e4
LT
114
115/* bprm_apply_creds unsafe reasons */
116#define LSM_UNSAFE_SHARE 1
117#define LSM_UNSAFE_PTRACE 2
118#define LSM_UNSAFE_PTRACE_CAP 4
119
120#ifdef CONFIG_SECURITY
121
122/**
123 * struct security_operations - main security structure
124 *
125 * Security hooks for program execution operations.
126 *
127 * @bprm_alloc_security:
128 * Allocate and attach a security structure to the @bprm->security field.
129 * The security field is initialized to NULL when the bprm structure is
130 * allocated.
131 * @bprm contains the linux_binprm structure to be modified.
132 * Return 0 if operation was successful.
133 * @bprm_free_security:
134 * @bprm contains the linux_binprm structure to be modified.
135 * Deallocate and clear the @bprm->security field.
136 * @bprm_apply_creds:
137 * Compute and set the security attributes of a process being transformed
138 * by an execve operation based on the old attributes (current->security)
139 * and the information saved in @bprm->security by the set_security hook.
140 * Since this hook function (and its caller) are void, this hook can not
141 * return an error. However, it can leave the security attributes of the
142 * process unchanged if an access failure occurs at this point.
143 * bprm_apply_creds is called under task_lock. @unsafe indicates various
144 * reasons why it may be unsafe to change security state.
145 * @bprm contains the linux_binprm structure.
146 * @bprm_post_apply_creds:
147 * Runs after bprm_apply_creds with the task_lock dropped, so that
148 * functions which cannot be called safely under the task_lock can
149 * be used. This hook is a good place to perform state changes on
150 * the process such as closing open file descriptors to which access
151 * is no longer granted if the attributes were changed.
152 * Note that a security module might need to save state between
153 * bprm_apply_creds and bprm_post_apply_creds to store the decision
154 * on whether the process may proceed.
155 * @bprm contains the linux_binprm structure.
156 * @bprm_set_security:
157 * Save security information in the bprm->security field, typically based
158 * on information about the bprm->file, for later use by the apply_creds
159 * hook. This hook may also optionally check permissions (e.g. for
160 * transitions between security domains).
161 * This hook may be called multiple times during a single execve, e.g. for
162 * interpreters. The hook can tell whether it has already been called by
163 * checking to see if @bprm->security is non-NULL. If so, then the hook
164 * may decide either to retain the security information saved earlier or
165 * to replace it.
166 * @bprm contains the linux_binprm structure.
167 * Return 0 if the hook is successful and permission is granted.
168 * @bprm_check_security:
169 * This hook mediates the point when a search for a binary handler will
170 * begin. It allows a check the @bprm->security value which is set in
171 * the preceding set_security call. The primary difference from
172 * set_security is that the argv list and envp list are reliably
173 * available in @bprm. This hook may be called multiple times
174 * during a single execve; and in each pass set_security is called
175 * first.
176 * @bprm contains the linux_binprm structure.
177 * Return 0 if the hook is successful and permission is granted.
178 * @bprm_secureexec:
179 * Return a boolean value (0 or 1) indicating whether a "secure exec"
180 * is required. The flag is passed in the auxiliary table
181 * on the initial stack to the ELF interpreter to indicate whether libc
182 * should enable secure mode.
183 * @bprm contains the linux_binprm structure.
184 *
185 * Security hooks for filesystem operations.
186 *
187 * @sb_alloc_security:
188 * Allocate and attach a security structure to the sb->s_security field.
189 * The s_security field is initialized to NULL when the structure is
190 * allocated.
191 * @sb contains the super_block structure to be modified.
192 * Return 0 if operation was successful.
193 * @sb_free_security:
194 * Deallocate and clear the sb->s_security field.
195 * @sb contains the super_block structure to be modified.
196 * @sb_statfs:
726c3342
DH
197 * Check permission before obtaining filesystem statistics for the @mnt
198 * mountpoint.
199 * @dentry is a handle on the superblock for the filesystem.
1da177e4
LT
200 * Return 0 if permission is granted.
201 * @sb_mount:
202 * Check permission before an object specified by @dev_name is mounted on
203 * the mount point named by @nd. For an ordinary mount, @dev_name
204 * identifies a device if the file system type requires a device. For a
205 * remount (@flags & MS_REMOUNT), @dev_name is irrelevant. For a
206 * loopback/bind mount (@flags & MS_BIND), @dev_name identifies the
207 * pathname of the object being mounted.
208 * @dev_name contains the name for object being mounted.
209 * @nd contains the nameidata structure for mount point object.
210 * @type contains the filesystem type.
211 * @flags contains the mount flags.
212 * @data contains the filesystem-specific data.
213 * Return 0 if permission is granted.
214 * @sb_copy_data:
215 * Allow mount option data to be copied prior to parsing by the filesystem,
216 * so that the security module can extract security-specific mount
217 * options cleanly (a filesystem may modify the data e.g. with strsep()).
218 * This also allows the original mount data to be stripped of security-
219 * specific options to avoid having to make filesystems aware of them.
220 * @type the type of filesystem being mounted.
221 * @orig the original mount data copied from userspace.
222 * @copy copied data which will be passed to the security module.
223 * Returns 0 if the copy was successful.
224 * @sb_check_sb:
225 * Check permission before the device with superblock @mnt->sb is mounted
226 * on the mount point named by @nd.
227 * @mnt contains the vfsmount for device being mounted.
228 * @nd contains the nameidata object for the mount point.
229 * Return 0 if permission is granted.
230 * @sb_umount:
231 * Check permission before the @mnt file system is unmounted.
232 * @mnt contains the mounted file system.
233 * @flags contains the unmount flags, e.g. MNT_FORCE.
234 * Return 0 if permission is granted.
235 * @sb_umount_close:
236 * Close any files in the @mnt mounted filesystem that are held open by
237 * the security module. This hook is called during an umount operation
238 * prior to checking whether the filesystem is still busy.
239 * @mnt contains the mounted filesystem.
240 * @sb_umount_busy:
241 * Handle a failed umount of the @mnt mounted filesystem, e.g. re-opening
242 * any files that were closed by umount_close. This hook is called during
243 * an umount operation if the umount fails after a call to the
244 * umount_close hook.
245 * @mnt contains the mounted filesystem.
246 * @sb_post_remount:
247 * Update the security module's state when a filesystem is remounted.
248 * This hook is only called if the remount was successful.
249 * @mnt contains the mounted file system.
250 * @flags contains the new filesystem flags.
251 * @data contains the filesystem-specific data.
1da177e4
LT
252 * @sb_post_addmount:
253 * Update the security module's state when a filesystem is mounted.
254 * This hook is called any time a mount is successfully grafetd to
255 * the tree.
256 * @mnt contains the mounted filesystem.
257 * @mountpoint_nd contains the nameidata structure for the mount point.
258 * @sb_pivotroot:
259 * Check permission before pivoting the root filesystem.
260 * @old_nd contains the nameidata structure for the new location of the current root (put_old).
261 * @new_nd contains the nameidata structure for the new root (new_root).
262 * Return 0 if permission is granted.
263 * @sb_post_pivotroot:
264 * Update module state after a successful pivot.
265 * @old_nd contains the nameidata structure for the old root.
266 * @new_nd contains the nameidata structure for the new root.
c9180a57
EP
267 * @sb_get_mnt_opts:
268 * Get the security relevant mount options used for a superblock
269 * @sb the superblock to get security mount options from
270 * @mount_options array for pointers to mount options
271 * @mount_flags array of ints specifying what each mount options is
272 * @num_opts number of options in the arrays
273 * @sb_set_mnt_opts:
274 * Set the security relevant mount options used for a superblock
275 * @sb the superblock to set security mount options for
276 * @mount_options array for pointers to mount options
277 * @mount_flags array of ints specifying what each mount options is
278 * @num_opts number of options in the arrays
279 * @sb_clone_mnt_opts:
280 * Copy all security options from a given superblock to another
281 * @oldsb old superblock which contain information to clone
282 * @newsb new superblock which needs filled in
1da177e4
LT
283 *
284 * Security hooks for inode operations.
285 *
286 * @inode_alloc_security:
287 * Allocate and attach a security structure to @inode->i_security. The
288 * i_security field is initialized to NULL when the inode structure is
289 * allocated.
290 * @inode contains the inode structure.
291 * Return 0 if operation was successful.
292 * @inode_free_security:
293 * @inode contains the inode structure.
294 * Deallocate the inode security structure and set @inode->i_security to
295 * NULL.
5e41ff9e
SS
296 * @inode_init_security:
297 * Obtain the security attribute name suffix and value to set on a newly
298 * created inode and set up the incore security field for the new inode.
299 * This hook is called by the fs code as part of the inode creation
300 * transaction and provides for atomic labeling of the inode, unlike
301 * the post_create/mkdir/... hooks called by the VFS. The hook function
302 * is expected to allocate the name and value via kmalloc, with the caller
303 * being responsible for calling kfree after using them.
304 * If the security module does not use security attributes or does
305 * not wish to put a security attribute on this particular inode,
306 * then it should return -EOPNOTSUPP to skip this processing.
307 * @inode contains the inode structure of the newly created inode.
308 * @dir contains the inode structure of the parent directory.
309 * @name will be set to the allocated name suffix (e.g. selinux).
310 * @value will be set to the allocated attribute value.
311 * @len will be set to the length of the value.
312 * Returns 0 if @name and @value have been successfully set,
313 * -EOPNOTSUPP if no security attribute is needed, or
314 * -ENOMEM on memory allocation failure.
1da177e4
LT
315 * @inode_create:
316 * Check permission to create a regular file.
317 * @dir contains inode structure of the parent of the new file.
318 * @dentry contains the dentry structure for the file to be created.
319 * @mode contains the file mode of the file to be created.
320 * Return 0 if permission is granted.
1da177e4
LT
321 * @inode_link:
322 * Check permission before creating a new hard link to a file.
323 * @old_dentry contains the dentry structure for an existing link to the file.
324 * @dir contains the inode structure of the parent directory of the new link.
325 * @new_dentry contains the dentry structure for the new link.
326 * Return 0 if permission is granted.
1da177e4
LT
327 * @inode_unlink:
328 * Check the permission to remove a hard link to a file.
329 * @dir contains the inode structure of parent directory of the file.
330 * @dentry contains the dentry structure for file to be unlinked.
331 * Return 0 if permission is granted.
332 * @inode_symlink:
333 * Check the permission to create a symbolic link to a file.
334 * @dir contains the inode structure of parent directory of the symbolic link.
335 * @dentry contains the dentry structure of the symbolic link.
336 * @old_name contains the pathname of file.
337 * Return 0 if permission is granted.
1da177e4
LT
338 * @inode_mkdir:
339 * Check permissions to create a new directory in the existing directory
340 * associated with inode strcture @dir.
341 * @dir containst the inode structure of parent of the directory to be created.
342 * @dentry contains the dentry structure of new directory.
343 * @mode contains the mode of new directory.
344 * Return 0 if permission is granted.
1da177e4
LT
345 * @inode_rmdir:
346 * Check the permission to remove a directory.
347 * @dir contains the inode structure of parent of the directory to be removed.
348 * @dentry contains the dentry structure of directory to be removed.
349 * Return 0 if permission is granted.
350 * @inode_mknod:
351 * Check permissions when creating a special file (or a socket or a fifo
352 * file created via the mknod system call). Note that if mknod operation
353 * is being done for a regular file, then the create hook will be called
354 * and not this hook.
355 * @dir contains the inode structure of parent of the new file.
356 * @dentry contains the dentry structure of the new file.
357 * @mode contains the mode of the new file.
59c51591 358 * @dev contains the device number.
1da177e4 359 * Return 0 if permission is granted.
1da177e4
LT
360 * @inode_rename:
361 * Check for permission to rename a file or directory.
362 * @old_dir contains the inode structure for parent of the old link.
363 * @old_dentry contains the dentry structure of the old link.
364 * @new_dir contains the inode structure for parent of the new link.
365 * @new_dentry contains the dentry structure of the new link.
366 * Return 0 if permission is granted.
1da177e4
LT
367 * @inode_readlink:
368 * Check the permission to read the symbolic link.
369 * @dentry contains the dentry structure for the file link.
370 * Return 0 if permission is granted.
371 * @inode_follow_link:
372 * Check permission to follow a symbolic link when looking up a pathname.
373 * @dentry contains the dentry structure for the link.
374 * @nd contains the nameidata structure for the parent directory.
375 * Return 0 if permission is granted.
376 * @inode_permission:
377 * Check permission before accessing an inode. This hook is called by the
378 * existing Linux permission function, so a security module can use it to
379 * provide additional checking for existing Linux permission checks.
380 * Notice that this hook is called when a file is opened (as well as many
381 * other operations), whereas the file_security_ops permission hook is
382 * called when the actual read/write operations are performed.
383 * @inode contains the inode structure to check.
384 * @mask contains the permission mask.
385 * @nd contains the nameidata (may be NULL).
386 * Return 0 if permission is granted.
387 * @inode_setattr:
388 * Check permission before setting file attributes. Note that the kernel
389 * call to notify_change is performed from several locations, whenever
390 * file attributes change (such as when a file is truncated, chown/chmod
391 * operations, transferring disk quotas, etc).
392 * @dentry contains the dentry structure for the file.
393 * @attr is the iattr structure containing the new file attributes.
394 * Return 0 if permission is granted.
395 * @inode_getattr:
396 * Check permission before obtaining file attributes.
397 * @mnt is the vfsmount where the dentry was looked up
398 * @dentry contains the dentry structure for the file.
399 * Return 0 if permission is granted.
400 * @inode_delete:
401 * @inode contains the inode structure for deleted inode.
402 * This hook is called when a deleted inode is released (i.e. an inode
403 * with no hard links has its use count drop to zero). A security module
404 * can use this hook to release any persistent label associated with the
405 * inode.
406 * @inode_setxattr:
407 * Check permission before setting the extended attributes
408 * @value identified by @name for @dentry.
409 * Return 0 if permission is granted.
410 * @inode_post_setxattr:
411 * Update inode security field after successful setxattr operation.
412 * @value identified by @name for @dentry.
413 * @inode_getxattr:
414 * Check permission before obtaining the extended attributes
415 * identified by @name for @dentry.
416 * Return 0 if permission is granted.
417 * @inode_listxattr:
418 * Check permission before obtaining the list of extended attribute
419 * names for @dentry.
420 * Return 0 if permission is granted.
421 * @inode_removexattr:
422 * Check permission before removing the extended attribute
423 * identified by @name for @dentry.
424 * Return 0 if permission is granted.
425 * @inode_getsecurity:
426 * Copy the extended attribute representation of the security label
427 * associated with @name for @inode into @buffer. @buffer may be
428 * NULL to request the size of the buffer required. @size indicates
429 * the size of @buffer in bytes. Note that @name is the remainder
430 * of the attribute name after the security. prefix has been removed.
d381d8a9
JM
431 * @err is the return value from the preceding fs getxattr call,
432 * and can be used by the security module to determine whether it
433 * should try and canonicalize the attribute value.
1da177e4
LT
434 * Return number of bytes used/required on success.
435 * @inode_setsecurity:
436 * Set the security label associated with @name for @inode from the
437 * extended attribute value @value. @size indicates the size of the
438 * @value in bytes. @flags may be XATTR_CREATE, XATTR_REPLACE, or 0.
439 * Note that @name is the remainder of the attribute name after the
440 * security. prefix has been removed.
441 * Return 0 on success.
442 * @inode_listsecurity:
443 * Copy the extended attribute names for the security labels
444 * associated with @inode into @buffer. The maximum size of @buffer
445 * is specified by @buffer_size. @buffer may be NULL to request
446 * the size of the buffer required.
447 * Returns number of bytes used/required on success.
b5376771
SH
448 * @inode_need_killpriv:
449 * Called when an inode has been changed.
450 * @dentry is the dentry being changed.
451 * Return <0 on error to abort the inode change operation.
452 * Return 0 if inode_killpriv does not need to be called.
453 * Return >0 if inode_killpriv does need to be called.
454 * @inode_killpriv:
455 * The setuid bit is being removed. Remove similar security labels.
456 * Called with the dentry->d_inode->i_mutex held.
457 * @dentry is the dentry being changed.
458 * Return 0 on success. If error is returned, then the operation
459 * causing setuid bit removal is failed.
1da177e4
LT
460 *
461 * Security hooks for file operations
462 *
463 * @file_permission:
464 * Check file permissions before accessing an open file. This hook is
465 * called by various operations that read or write files. A security
466 * module can use this hook to perform additional checking on these
467 * operations, e.g. to revalidate permissions on use to support privilege
468 * bracketing or policy changes. Notice that this hook is used when the
469 * actual read/write operations are performed, whereas the
470 * inode_security_ops hook is called when a file is opened (as well as
471 * many other operations).
472 * Caveat: Although this hook can be used to revalidate permissions for
473 * various system call operations that read or write files, it does not
474 * address the revalidation of permissions for memory-mapped files.
475 * Security modules must handle this separately if they need such
476 * revalidation.
477 * @file contains the file structure being accessed.
478 * @mask contains the requested permissions.
479 * Return 0 if permission is granted.
480 * @file_alloc_security:
481 * Allocate and attach a security structure to the file->f_security field.
482 * The security field is initialized to NULL when the structure is first
483 * created.
484 * @file contains the file structure to secure.
485 * Return 0 if the hook is successful and permission is granted.
486 * @file_free_security:
487 * Deallocate and free any security structures stored in file->f_security.
488 * @file contains the file structure being modified.
489 * @file_ioctl:
490 * @file contains the file structure.
491 * @cmd contains the operation to perform.
492 * @arg contains the operational arguments.
493 * Check permission for an ioctl operation on @file. Note that @arg can
494 * sometimes represents a user space pointer; in other cases, it may be a
495 * simple integer value. When @arg represents a user space pointer, it
496 * should never be used by the security module.
497 * Return 0 if permission is granted.
498 * @file_mmap :
499 * Check permissions for a mmap operation. The @file may be NULL, e.g.
500 * if mapping anonymous memory.
501 * @file contains the file structure for file to map (may be NULL).
502 * @reqprot contains the protection requested by the application.
503 * @prot contains the protection that will be applied by the kernel.
504 * @flags contains the operational flags.
505 * Return 0 if permission is granted.
506 * @file_mprotect:
507 * Check permissions before changing memory access permissions.
508 * @vma contains the memory region to modify.
509 * @reqprot contains the protection requested by the application.
510 * @prot contains the protection that will be applied by the kernel.
511 * Return 0 if permission is granted.
512 * @file_lock:
513 * Check permission before performing file locking operations.
514 * Note: this hook mediates both flock and fcntl style locks.
515 * @file contains the file structure.
516 * @cmd contains the posix-translated lock operation to perform
517 * (e.g. F_RDLCK, F_WRLCK).
518 * Return 0 if permission is granted.
519 * @file_fcntl:
520 * Check permission before allowing the file operation specified by @cmd
521 * from being performed on the file @file. Note that @arg can sometimes
522 * represents a user space pointer; in other cases, it may be a simple
523 * integer value. When @arg represents a user space pointer, it should
524 * never be used by the security module.
525 * @file contains the file structure.
526 * @cmd contains the operation to be performed.
527 * @arg contains the operational arguments.
528 * Return 0 if permission is granted.
529 * @file_set_fowner:
530 * Save owner security information (typically from current->security) in
531 * file->f_security for later use by the send_sigiotask hook.
532 * @file contains the file structure to update.
533 * Return 0 on success.
534 * @file_send_sigiotask:
535 * Check permission for the file owner @fown to send SIGIO or SIGURG to the
536 * process @tsk. Note that this hook is sometimes called from interrupt.
537 * Note that the fown_struct, @fown, is never outside the context of a
538 * struct file, so the file structure (and associated security information)
539 * can always be obtained:
b385a144 540 * container_of(fown, struct file, f_owner)
1da177e4
LT
541 * @tsk contains the structure of task receiving signal.
542 * @fown contains the file owner information.
543 * @sig is the signal that will be sent. When 0, kernel sends SIGIO.
544 * Return 0 if permission is granted.
545 * @file_receive:
546 * This hook allows security modules to control the ability of a process
547 * to receive an open file descriptor via socket IPC.
548 * @file contains the file structure being received.
549 * Return 0 if permission is granted.
550 *
788e7dd4
YN
551 * Security hook for dentry
552 *
553 * @dentry_open
554 * Save open-time permission checking state for later use upon
555 * file_permission, and recheck access if anything has changed
556 * since inode_permission.
557 *
1da177e4
LT
558 * Security hooks for task operations.
559 *
560 * @task_create:
561 * Check permission before creating a child process. See the clone(2)
562 * manual page for definitions of the @clone_flags.
563 * @clone_flags contains the flags indicating what should be shared.
564 * Return 0 if permission is granted.
565 * @task_alloc_security:
566 * @p contains the task_struct for child process.
567 * Allocate and attach a security structure to the p->security field. The
568 * security field is initialized to NULL when the task structure is
569 * allocated.
570 * Return 0 if operation was successful.
571 * @task_free_security:
572 * @p contains the task_struct for process.
573 * Deallocate and clear the p->security field.
574 * @task_setuid:
575 * Check permission before setting one or more of the user identity
576 * attributes of the current process. The @flags parameter indicates
577 * which of the set*uid system calls invoked this hook and how to
578 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
579 * definitions at the beginning of this file for the @flags values and
580 * their meanings.
581 * @id0 contains a uid.
582 * @id1 contains a uid.
583 * @id2 contains a uid.
584 * @flags contains one of the LSM_SETID_* values.
585 * Return 0 if permission is granted.
586 * @task_post_setuid:
587 * Update the module's state after setting one or more of the user
588 * identity attributes of the current process. The @flags parameter
589 * indicates which of the set*uid system calls invoked this hook. If
590 * @flags is LSM_SETID_FS, then @old_ruid is the old fs uid and the other
591 * parameters are not used.
592 * @old_ruid contains the old real uid (or fs uid if LSM_SETID_FS).
593 * @old_euid contains the old effective uid (or -1 if LSM_SETID_FS).
594 * @old_suid contains the old saved uid (or -1 if LSM_SETID_FS).
595 * @flags contains one of the LSM_SETID_* values.
596 * Return 0 on success.
597 * @task_setgid:
598 * Check permission before setting one or more of the group identity
599 * attributes of the current process. The @flags parameter indicates
600 * which of the set*gid system calls invoked this hook and how to
601 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
602 * definitions at the beginning of this file for the @flags values and
603 * their meanings.
604 * @id0 contains a gid.
605 * @id1 contains a gid.
606 * @id2 contains a gid.
607 * @flags contains one of the LSM_SETID_* values.
608 * Return 0 if permission is granted.
609 * @task_setpgid:
610 * Check permission before setting the process group identifier of the
611 * process @p to @pgid.
612 * @p contains the task_struct for process being modified.
613 * @pgid contains the new pgid.
614 * Return 0 if permission is granted.
615 * @task_getpgid:
616 * Check permission before getting the process group identifier of the
617 * process @p.
618 * @p contains the task_struct for the process.
619 * Return 0 if permission is granted.
620 * @task_getsid:
621 * Check permission before getting the session identifier of the process
622 * @p.
623 * @p contains the task_struct for the process.
624 * Return 0 if permission is granted.
f9008e4c
DQ
625 * @task_getsecid:
626 * Retrieve the security identifier of the process @p.
627 * @p contains the task_struct for the process and place is into @secid.
1da177e4
LT
628 * @task_setgroups:
629 * Check permission before setting the supplementary group set of the
630 * current process.
631 * @group_info contains the new group information.
632 * Return 0 if permission is granted.
633 * @task_setnice:
634 * Check permission before setting the nice value of @p to @nice.
635 * @p contains the task_struct of process.
636 * @nice contains the new nice value.
637 * Return 0 if permission is granted.
03e68060
JM
638 * @task_setioprio
639 * Check permission before setting the ioprio value of @p to @ioprio.
640 * @p contains the task_struct of process.
641 * @ioprio contains the new ioprio value
642 * Return 0 if permission is granted.
a1836a42
DQ
643 * @task_getioprio
644 * Check permission before getting the ioprio value of @p.
645 * @p contains the task_struct of process.
646 * Return 0 if permission is granted.
1da177e4
LT
647 * @task_setrlimit:
648 * Check permission before setting the resource limits of the current
649 * process for @resource to @new_rlim. The old resource limit values can
650 * be examined by dereferencing (current->signal->rlim + resource).
651 * @resource contains the resource whose limit is being set.
652 * @new_rlim contains the new limits for @resource.
653 * Return 0 if permission is granted.
654 * @task_setscheduler:
655 * Check permission before setting scheduling policy and/or parameters of
656 * process @p based on @policy and @lp.
657 * @p contains the task_struct for process.
658 * @policy contains the scheduling policy.
659 * @lp contains the scheduling parameters.
660 * Return 0 if permission is granted.
661 * @task_getscheduler:
662 * Check permission before obtaining scheduling information for process
663 * @p.
664 * @p contains the task_struct for process.
665 * Return 0 if permission is granted.
35601547
DQ
666 * @task_movememory
667 * Check permission before moving memory owned by process @p.
668 * @p contains the task_struct for process.
669 * Return 0 if permission is granted.
1da177e4
LT
670 * @task_kill:
671 * Check permission before sending signal @sig to @p. @info can be NULL,
672 * the constant 1, or a pointer to a siginfo structure. If @info is 1 or
673 * SI_FROMKERNEL(info) is true, then the signal should be viewed as coming
674 * from the kernel and should typically be permitted.
675 * SIGIO signals are handled separately by the send_sigiotask hook in
676 * file_security_ops.
677 * @p contains the task_struct for process.
678 * @info contains the signal information.
679 * @sig contains the signal value.
f9008e4c 680 * @secid contains the sid of the process where the signal originated
1da177e4
LT
681 * Return 0 if permission is granted.
682 * @task_wait:
683 * Check permission before allowing a process to reap a child process @p
684 * and collect its status information.
685 * @p contains the task_struct for process.
686 * Return 0 if permission is granted.
687 * @task_prctl:
688 * Check permission before performing a process control operation on the
689 * current process.
690 * @option contains the operation.
691 * @arg2 contains a argument.
692 * @arg3 contains a argument.
693 * @arg4 contains a argument.
694 * @arg5 contains a argument.
695 * Return 0 if permission is granted.
696 * @task_reparent_to_init:
697 * Set the security attributes in @p->security for a kernel thread that
698 * is being reparented to the init task.
699 * @p contains the task_struct for the kernel thread.
700 * @task_to_inode:
701 * Set the security attributes for an inode based on an associated task's
702 * security attributes, e.g. for /proc/pid inodes.
703 * @p contains the task_struct for the task.
704 * @inode contains the inode structure for the inode.
705 *
706 * Security hooks for Netlink messaging.
707 *
708 * @netlink_send:
709 * Save security information for a netlink message so that permission
710 * checking can be performed when the message is processed. The security
711 * information can be saved using the eff_cap field of the
712 * netlink_skb_parms structure. Also may be used to provide fine
713 * grained control over message transmission.
714 * @sk associated sock of task sending the message.,
715 * @skb contains the sk_buff structure for the netlink message.
716 * Return 0 if the information was successfully saved and message
717 * is allowed to be transmitted.
718 * @netlink_recv:
719 * Check permission before processing the received netlink message in
720 * @skb.
721 * @skb contains the sk_buff structure for the netlink message.
c7bdb545 722 * @cap indicates the capability required
1da177e4
LT
723 * Return 0 if permission is granted.
724 *
725 * Security hooks for Unix domain networking.
726 *
727 * @unix_stream_connect:
728 * Check permissions before establishing a Unix domain stream connection
729 * between @sock and @other.
730 * @sock contains the socket structure.
731 * @other contains the peer socket structure.
732 * Return 0 if permission is granted.
733 * @unix_may_send:
734 * Check permissions before connecting or sending datagrams from @sock to
735 * @other.
736 * @sock contains the socket structure.
737 * @sock contains the peer socket structure.
738 * Return 0 if permission is granted.
739 *
740 * The @unix_stream_connect and @unix_may_send hooks were necessary because
741 * Linux provides an alternative to the conventional file name space for Unix
742 * domain sockets. Whereas binding and connecting to sockets in the file name
743 * space is mediated by the typical file permissions (and caught by the mknod
744 * and permission hooks in inode_security_ops), binding and connecting to
745 * sockets in the abstract name space is completely unmediated. Sufficient
746 * control of Unix domain sockets in the abstract name space isn't possible
747 * using only the socket layer hooks, since we need to know the actual target
748 * socket, which is not looked up until we are inside the af_unix code.
749 *
750 * Security hooks for socket operations.
751 *
752 * @socket_create:
753 * Check permissions prior to creating a new socket.
754 * @family contains the requested protocol family.
755 * @type contains the requested communications type.
756 * @protocol contains the requested protocol.
757 * @kern set to 1 if a kernel socket.
758 * Return 0 if permission is granted.
759 * @socket_post_create:
760 * This hook allows a module to update or allocate a per-socket security
761 * structure. Note that the security field was not added directly to the
762 * socket structure, but rather, the socket security information is stored
763 * in the associated inode. Typically, the inode alloc_security hook will
764 * allocate and and attach security information to
765 * sock->inode->i_security. This hook may be used to update the
766 * sock->inode->i_security field with additional information that wasn't
767 * available when the inode was allocated.
768 * @sock contains the newly created socket structure.
769 * @family contains the requested protocol family.
770 * @type contains the requested communications type.
771 * @protocol contains the requested protocol.
772 * @kern set to 1 if a kernel socket.
773 * @socket_bind:
774 * Check permission before socket protocol layer bind operation is
775 * performed and the socket @sock is bound to the address specified in the
776 * @address parameter.
777 * @sock contains the socket structure.
778 * @address contains the address to bind to.
779 * @addrlen contains the length of address.
780 * Return 0 if permission is granted.
781 * @socket_connect:
782 * Check permission before socket protocol layer connect operation
783 * attempts to connect socket @sock to a remote address, @address.
784 * @sock contains the socket structure.
785 * @address contains the address of remote endpoint.
786 * @addrlen contains the length of address.
787 * Return 0 if permission is granted.
788 * @socket_listen:
789 * Check permission before socket protocol layer listen operation.
790 * @sock contains the socket structure.
791 * @backlog contains the maximum length for the pending connection queue.
792 * Return 0 if permission is granted.
793 * @socket_accept:
794 * Check permission before accepting a new connection. Note that the new
795 * socket, @newsock, has been created and some information copied to it,
796 * but the accept operation has not actually been performed.
797 * @sock contains the listening socket structure.
798 * @newsock contains the newly created server socket for connection.
799 * Return 0 if permission is granted.
800 * @socket_post_accept:
801 * This hook allows a security module to copy security
802 * information into the newly created socket's inode.
803 * @sock contains the listening socket structure.
804 * @newsock contains the newly created server socket for connection.
805 * @socket_sendmsg:
806 * Check permission before transmitting a message to another socket.
807 * @sock contains the socket structure.
808 * @msg contains the message to be transmitted.
809 * @size contains the size of message.
810 * Return 0 if permission is granted.
811 * @socket_recvmsg:
812 * Check permission before receiving a message from a socket.
813 * @sock contains the socket structure.
814 * @msg contains the message structure.
815 * @size contains the size of message structure.
816 * @flags contains the operational flags.
817 * Return 0 if permission is granted.
818 * @socket_getsockname:
819 * Check permission before the local address (name) of the socket object
820 * @sock is retrieved.
821 * @sock contains the socket structure.
822 * Return 0 if permission is granted.
823 * @socket_getpeername:
824 * Check permission before the remote address (name) of a socket object
825 * @sock is retrieved.
826 * @sock contains the socket structure.
827 * Return 0 if permission is granted.
828 * @socket_getsockopt:
829 * Check permissions before retrieving the options associated with socket
830 * @sock.
831 * @sock contains the socket structure.
832 * @level contains the protocol level to retrieve option from.
833 * @optname contains the name of option to retrieve.
834 * Return 0 if permission is granted.
835 * @socket_setsockopt:
836 * Check permissions before setting the options associated with socket
837 * @sock.
838 * @sock contains the socket structure.
839 * @level contains the protocol level to set options for.
840 * @optname contains the name of the option to set.
841 * Return 0 if permission is granted.
842 * @socket_shutdown:
843 * Checks permission before all or part of a connection on the socket
844 * @sock is shut down.
845 * @sock contains the socket structure.
846 * @how contains the flag indicating how future sends and receives are handled.
847 * Return 0 if permission is granted.
848 * @socket_sock_rcv_skb:
849 * Check permissions on incoming network packets. This hook is distinct
850 * from Netfilter's IP input hooks since it is the first time that the
851 * incoming sk_buff @skb has been associated with a particular socket, @sk.
852 * @sk contains the sock (not socket) associated with the incoming sk_buff.
853 * @skb contains the incoming network data.
6da34bae 854 * @socket_getpeersec_stream:
1da177e4 855 * This hook allows the security module to provide peer socket security
6da34bae
SH
856 * state for unix or connected tcp sockets to userspace via getsockopt
857 * SO_GETPEERSEC. For tcp sockets this can be meaningful if the
858 * socket is associated with an ipsec SA.
1da177e4
LT
859 * @sock is the local socket.
860 * @optval userspace memory where the security state is to be copied.
861 * @optlen userspace int where the module should copy the actual length
862 * of the security state.
863 * @len as input is the maximum length to copy to userspace provided
864 * by the caller.
865 * Return 0 if all is well, otherwise, typical getsockopt return
866 * values.
6da34bae
SH
867 * @socket_getpeersec_dgram:
868 * This hook allows the security module to provide peer socket security
869 * state for udp sockets on a per-packet basis to userspace via
870 * getsockopt SO_GETPEERSEC. The application must first have indicated
871 * the IP_PASSSEC option via getsockopt. It can then retrieve the
872 * security state returned by this hook for a packet via the SCM_SECURITY
873 * ancillary message type.
874 * @skb is the skbuff for the packet being queried
875 * @secdata is a pointer to a buffer in which to copy the security data
876 * @seclen is the maximum length for @secdata
877 * Return 0 on success, error on failure.
1da177e4
LT
878 * @sk_alloc_security:
879 * Allocate and attach a security structure to the sk->sk_security field,
880 * which is used to copy security attributes between local stream sockets.
881 * @sk_free_security:
882 * Deallocate security structure.
892c141e
VY
883 * @sk_clone_security:
884 * Clone/copy security structure.
beb8d13b
VY
885 * @sk_getsecid:
886 * Retrieve the LSM-specific secid for the sock to enable caching of network
df71837d 887 * authorizations.
4237c75c
VY
888 * @sock_graft:
889 * Sets the socket's isec sid to the sock's sid.
890 * @inet_conn_request:
891 * Sets the openreq's sid to socket's sid with MLS portion taken from peer sid.
892 * @inet_csk_clone:
893 * Sets the new child socket's sid to the openreq sid.
6b877699
VY
894 * @inet_conn_established:
895 * Sets the connection's peersid to the secmark on skb.
4237c75c
VY
896 * @req_classify_flow:
897 * Sets the flow's sid to the openreq sid.
df71837d
TJ
898 *
899 * Security hooks for XFRM operations.
900 *
901 * @xfrm_policy_alloc_security:
902 * @xp contains the xfrm_policy being added to Security Policy Database
903 * used by the XFRM system.
904 * @sec_ctx contains the security context information being provided by
905 * the user-level policy update program (e.g., setkey).
e0d1caa7 906 * Allocate a security structure to the xp->security field; the security
c1a856c9 907 * field is initialized to NULL when the xfrm_policy is allocated.
df71837d
TJ
908 * Return 0 if operation was successful (memory to allocate, legal context)
909 * @xfrm_policy_clone_security:
910 * @old contains an existing xfrm_policy in the SPD.
911 * @new contains a new xfrm_policy being cloned from old.
c8c05a8e
CZ
912 * Allocate a security structure to the new->security field
913 * that contains the information from the old->security field.
df71837d
TJ
914 * Return 0 if operation was successful (memory to allocate).
915 * @xfrm_policy_free_security:
916 * @xp contains the xfrm_policy
c8c05a8e
CZ
917 * Deallocate xp->security.
918 * @xfrm_policy_delete_security:
919 * @xp contains the xfrm_policy.
920 * Authorize deletion of xp->security.
df71837d
TJ
921 * @xfrm_state_alloc_security:
922 * @x contains the xfrm_state being added to the Security Association
923 * Database by the XFRM system.
924 * @sec_ctx contains the security context information being provided by
925 * the user-level SA generation program (e.g., setkey or racoon).
e0d1caa7
VY
926 * @secid contains the secid from which to take the mls portion of the context.
927 * Allocate a security structure to the x->security field; the security
928 * field is initialized to NULL when the xfrm_state is allocated. Set the
929 * context to correspond to either sec_ctx or polsec, with the mls portion
930 * taken from secid in the latter case.
df71837d
TJ
931 * Return 0 if operation was successful (memory to allocate, legal context).
932 * @xfrm_state_free_security:
933 * @x contains the xfrm_state.
c8c05a8e
CZ
934 * Deallocate x->security.
935 * @xfrm_state_delete_security:
936 * @x contains the xfrm_state.
937 * Authorize deletion of x->security.
df71837d
TJ
938 * @xfrm_policy_lookup:
939 * @xp contains the xfrm_policy for which the access control is being
940 * checked.
e0d1caa7 941 * @fl_secid contains the flow security label that is used to authorize
df71837d
TJ
942 * access to the policy xp.
943 * @dir contains the direction of the flow (input or output).
e0d1caa7 944 * Check permission when a flow selects a xfrm_policy for processing
df71837d
TJ
945 * XFRMs on a packet. The hook is called when selecting either a
946 * per-socket policy or a generic xfrm policy.
5b368e61
VY
947 * Return 0 if permission is granted, -ESRCH otherwise, or -errno
948 * on other errors.
e0d1caa7
VY
949 * @xfrm_state_pol_flow_match:
950 * @x contains the state to match.
951 * @xp contains the policy to check for a match.
952 * @fl contains the flow to check for a match.
953 * Return 1 if there is a match.
e0d1caa7
VY
954 * @xfrm_decode_session:
955 * @skb points to skb to decode.
beb8d13b
VY
956 * @secid points to the flow key secid to set.
957 * @ckall says if all xfrms used should be checked for same secid.
958 * Return 0 if ckall is zero or all xfrms used have the same secid.
1da177e4 959 *
29db9190
DH
960 * Security hooks affecting all Key Management operations
961 *
962 * @key_alloc:
963 * Permit allocation of a key and assign security data. Note that key does
964 * not have a serial number assigned at this point.
965 * @key points to the key.
7e047ef5 966 * @flags is the allocation flags
29db9190
DH
967 * Return 0 if permission is granted, -ve error otherwise.
968 * @key_free:
969 * Notification of destruction; free security data.
970 * @key points to the key.
971 * No return value.
972 * @key_permission:
973 * See whether a specific operational right is granted to a process on a
974 * key.
975 * @key_ref refers to the key (key pointer + possession attribute bit).
976 * @context points to the process to provide the context against which to
977 * evaluate the security data on the key.
978 * @perm describes the combination of permissions required of this key.
979 * Return 1 if permission granted, 0 if permission denied and -ve it the
980 * normal permissions model should be effected.
981 *
1da177e4
LT
982 * Security hooks affecting all System V IPC operations.
983 *
984 * @ipc_permission:
985 * Check permissions for access to IPC
986 * @ipcp contains the kernel IPC permission structure
987 * @flag contains the desired (requested) permission set
988 * Return 0 if permission is granted.
989 *
990 * Security hooks for individual messages held in System V IPC message queues
991 * @msg_msg_alloc_security:
992 * Allocate and attach a security structure to the msg->security field.
993 * The security field is initialized to NULL when the structure is first
994 * created.
995 * @msg contains the message structure to be modified.
996 * Return 0 if operation was successful and permission is granted.
997 * @msg_msg_free_security:
998 * Deallocate the security structure for this message.
999 * @msg contains the message structure to be modified.
1000 *
1001 * Security hooks for System V IPC Message Queues
1002 *
1003 * @msg_queue_alloc_security:
1004 * Allocate and attach a security structure to the
1005 * msq->q_perm.security field. The security field is initialized to
1006 * NULL when the structure is first created.
1007 * @msq contains the message queue structure to be modified.
1008 * Return 0 if operation was successful and permission is granted.
1009 * @msg_queue_free_security:
1010 * Deallocate security structure for this message queue.
1011 * @msq contains the message queue structure to be modified.
1012 * @msg_queue_associate:
1013 * Check permission when a message queue is requested through the
1014 * msgget system call. This hook is only called when returning the
1015 * message queue identifier for an existing message queue, not when a
1016 * new message queue is created.
1017 * @msq contains the message queue to act upon.
1018 * @msqflg contains the operation control flags.
1019 * Return 0 if permission is granted.
1020 * @msg_queue_msgctl:
1021 * Check permission when a message control operation specified by @cmd
1022 * is to be performed on the message queue @msq.
1023 * The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO.
1024 * @msq contains the message queue to act upon. May be NULL.
1025 * @cmd contains the operation to be performed.
1026 * Return 0 if permission is granted.
1027 * @msg_queue_msgsnd:
1028 * Check permission before a message, @msg, is enqueued on the message
1029 * queue, @msq.
1030 * @msq contains the message queue to send message to.
1031 * @msg contains the message to be enqueued.
1032 * @msqflg contains operational flags.
1033 * Return 0 if permission is granted.
1034 * @msg_queue_msgrcv:
1035 * Check permission before a message, @msg, is removed from the message
1036 * queue, @msq. The @target task structure contains a pointer to the
1037 * process that will be receiving the message (not equal to the current
1038 * process when inline receives are being performed).
1039 * @msq contains the message queue to retrieve message from.
1040 * @msg contains the message destination.
1041 * @target contains the task structure for recipient process.
1042 * @type contains the type of message requested.
1043 * @mode contains the operational flags.
1044 * Return 0 if permission is granted.
1045 *
1046 * Security hooks for System V Shared Memory Segments
1047 *
1048 * @shm_alloc_security:
1049 * Allocate and attach a security structure to the shp->shm_perm.security
1050 * field. The security field is initialized to NULL when the structure is
1051 * first created.
1052 * @shp contains the shared memory structure to be modified.
1053 * Return 0 if operation was successful and permission is granted.
1054 * @shm_free_security:
1055 * Deallocate the security struct for this memory segment.
1056 * @shp contains the shared memory structure to be modified.
1057 * @shm_associate:
1058 * Check permission when a shared memory region is requested through the
1059 * shmget system call. This hook is only called when returning the shared
1060 * memory region identifier for an existing region, not when a new shared
1061 * memory region is created.
1062 * @shp contains the shared memory structure to be modified.
1063 * @shmflg contains the operation control flags.
1064 * Return 0 if permission is granted.
1065 * @shm_shmctl:
1066 * Check permission when a shared memory control operation specified by
1067 * @cmd is to be performed on the shared memory region @shp.
1068 * The @shp may be NULL, e.g. for IPC_INFO or SHM_INFO.
1069 * @shp contains shared memory structure to be modified.
1070 * @cmd contains the operation to be performed.
1071 * Return 0 if permission is granted.
1072 * @shm_shmat:
1073 * Check permissions prior to allowing the shmat system call to attach the
1074 * shared memory segment @shp to the data segment of the calling process.
1075 * The attaching address is specified by @shmaddr.
1076 * @shp contains the shared memory structure to be modified.
1077 * @shmaddr contains the address to attach memory region to.
1078 * @shmflg contains the operational flags.
1079 * Return 0 if permission is granted.
1080 *
1081 * Security hooks for System V Semaphores
1082 *
1083 * @sem_alloc_security:
1084 * Allocate and attach a security structure to the sma->sem_perm.security
1085 * field. The security field is initialized to NULL when the structure is
1086 * first created.
1087 * @sma contains the semaphore structure
1088 * Return 0 if operation was successful and permission is granted.
1089 * @sem_free_security:
1090 * deallocate security struct for this semaphore
1091 * @sma contains the semaphore structure.
1092 * @sem_associate:
1093 * Check permission when a semaphore is requested through the semget
1094 * system call. This hook is only called when returning the semaphore
1095 * identifier for an existing semaphore, not when a new one must be
1096 * created.
1097 * @sma contains the semaphore structure.
1098 * @semflg contains the operation control flags.
1099 * Return 0 if permission is granted.
1100 * @sem_semctl:
1101 * Check permission when a semaphore operation specified by @cmd is to be
1102 * performed on the semaphore @sma. The @sma may be NULL, e.g. for
1103 * IPC_INFO or SEM_INFO.
1104 * @sma contains the semaphore structure. May be NULL.
1105 * @cmd contains the operation to be performed.
1106 * Return 0 if permission is granted.
1107 * @sem_semop
1108 * Check permissions before performing operations on members of the
1109 * semaphore set @sma. If the @alter flag is nonzero, the semaphore set
1110 * may be modified.
1111 * @sma contains the semaphore structure.
1112 * @sops contains the operations to perform.
1113 * @nsops contains the number of operations to perform.
1114 * @alter contains the flag indicating whether changes are to be made.
1115 * Return 0 if permission is granted.
1116 *
1117 * @ptrace:
1118 * Check permission before allowing the @parent process to trace the
1119 * @child process.
1120 * Security modules may also want to perform a process tracing check
1121 * during an execve in the set_security or apply_creds hooks of
1122 * binprm_security_ops if the process is being traced and its security
1123 * attributes would be changed by the execve.
1124 * @parent contains the task_struct structure for parent process.
1125 * @child contains the task_struct structure for child process.
1126 * Return 0 if permission is granted.
1127 * @capget:
1128 * Get the @effective, @inheritable, and @permitted capability sets for
1129 * the @target process. The hook may also perform permission checking to
1130 * determine if the current process is allowed to see the capability sets
1131 * of the @target process.
1132 * @target contains the task_struct structure for target process.
1133 * @effective contains the effective capability set.
1134 * @inheritable contains the inheritable capability set.
1135 * @permitted contains the permitted capability set.
1136 * Return 0 if the capability sets were successfully obtained.
1137 * @capset_check:
1138 * Check permission before setting the @effective, @inheritable, and
1139 * @permitted capability sets for the @target process.
1140 * Caveat: @target is also set to current if a set of processes is
1141 * specified (i.e. all processes other than current and init or a
1142 * particular process group). Hence, the capset_set hook may need to
1143 * revalidate permission to the actual target process.
1144 * @target contains the task_struct structure for target process.
1145 * @effective contains the effective capability set.
1146 * @inheritable contains the inheritable capability set.
1147 * @permitted contains the permitted capability set.
1148 * Return 0 if permission is granted.
1149 * @capset_set:
1150 * Set the @effective, @inheritable, and @permitted capability sets for
1151 * the @target process. Since capset_check cannot always check permission
1152 * to the real @target process, this hook may also perform permission
1153 * checking to determine if the current process is allowed to set the
1154 * capability sets of the @target process. However, this hook has no way
1155 * of returning an error due to the structure of the sys_capset code.
1156 * @target contains the task_struct structure for target process.
1157 * @effective contains the effective capability set.
1158 * @inheritable contains the inheritable capability set.
1159 * @permitted contains the permitted capability set.
12b5989b
CW
1160 * @capable:
1161 * Check whether the @tsk process has the @cap capability.
1162 * @tsk contains the task_struct for the process.
1163 * @cap contains the capability <include/linux/capability.h>.
1164 * Return 0 if the capability is granted for @tsk.
1da177e4
LT
1165 * @acct:
1166 * Check permission before enabling or disabling process accounting. If
1167 * accounting is being enabled, then @file refers to the open file used to
1168 * store accounting records. If accounting is being disabled, then @file
1169 * is NULL.
1170 * @file contains the file structure for the accounting file (may be NULL).
1171 * Return 0 if permission is granted.
1172 * @sysctl:
1173 * Check permission before accessing the @table sysctl variable in the
1174 * manner specified by @op.
1175 * @table contains the ctl_table structure for the sysctl variable.
1176 * @op contains the operation (001 = search, 002 = write, 004 = read).
1177 * Return 0 if permission is granted.
1da177e4
LT
1178 * @syslog:
1179 * Check permission before accessing the kernel message ring or changing
1180 * logging to the console.
1181 * See the syslog(2) manual page for an explanation of the @type values.
1182 * @type contains the type of action.
1183 * Return 0 if permission is granted.
1184 * @settime:
1185 * Check permission to change the system time.
1186 * struct timespec and timezone are defined in include/linux/time.h
1187 * @ts contains new time
1188 * @tz contains new timezone
1189 * Return 0 if permission is granted.
1190 * @vm_enough_memory:
1191 * Check permissions for allocating a new virtual mapping.
34b4e4aa 1192 * @mm contains the mm struct it is being added to.
1da177e4
LT
1193 * @pages contains the number of pages.
1194 * Return 0 if permission is granted.
1195 *
1196 * @register_security:
1197 * allow module stacking.
1198 * @name contains the name of the security module being stacked.
1199 * @ops contains a pointer to the struct security_operations of the module to stack.
1da177e4 1200 *
dc49c1f9
CZ
1201 * @secid_to_secctx:
1202 * Convert secid to security context.
1203 * @secid contains the security ID.
1204 * @secdata contains the pointer that stores the converted security context.
1205 *
1206 * @release_secctx:
1207 * Release the security context.
1208 * @secdata contains the security context.
1209 * @seclen contains the length of the security context.
1210 *
1da177e4
LT
1211 * This is the main security structure.
1212 */
1213struct security_operations {
1214 int (*ptrace) (struct task_struct * parent, struct task_struct * child);
1215 int (*capget) (struct task_struct * target,
1216 kernel_cap_t * effective,
1217 kernel_cap_t * inheritable, kernel_cap_t * permitted);
1218 int (*capset_check) (struct task_struct * target,
1219 kernel_cap_t * effective,
1220 kernel_cap_t * inheritable,
1221 kernel_cap_t * permitted);
1222 void (*capset_set) (struct task_struct * target,
1223 kernel_cap_t * effective,
1224 kernel_cap_t * inheritable,
1225 kernel_cap_t * permitted);
12b5989b 1226 int (*capable) (struct task_struct * tsk, int cap);
1da177e4
LT
1227 int (*acct) (struct file * file);
1228 int (*sysctl) (struct ctl_table * table, int op);
1da177e4
LT
1229 int (*quotactl) (int cmds, int type, int id, struct super_block * sb);
1230 int (*quota_on) (struct dentry * dentry);
1231 int (*syslog) (int type);
1232 int (*settime) (struct timespec *ts, struct timezone *tz);
34b4e4aa 1233 int (*vm_enough_memory) (struct mm_struct *mm, long pages);
1da177e4
LT
1234
1235 int (*bprm_alloc_security) (struct linux_binprm * bprm);
1236 void (*bprm_free_security) (struct linux_binprm * bprm);
1237 void (*bprm_apply_creds) (struct linux_binprm * bprm, int unsafe);
1238 void (*bprm_post_apply_creds) (struct linux_binprm * bprm);
1239 int (*bprm_set_security) (struct linux_binprm * bprm);
1240 int (*bprm_check_security) (struct linux_binprm * bprm);
1241 int (*bprm_secureexec) (struct linux_binprm * bprm);
1242
1243 int (*sb_alloc_security) (struct super_block * sb);
1244 void (*sb_free_security) (struct super_block * sb);
1245 int (*sb_copy_data)(struct file_system_type *type,
1246 void *orig, void *copy);
1247 int (*sb_kern_mount) (struct super_block *sb, void *data);
726c3342 1248 int (*sb_statfs) (struct dentry *dentry);
1da177e4
LT
1249 int (*sb_mount) (char *dev_name, struct nameidata * nd,
1250 char *type, unsigned long flags, void *data);
1251 int (*sb_check_sb) (struct vfsmount * mnt, struct nameidata * nd);
1252 int (*sb_umount) (struct vfsmount * mnt, int flags);
1253 void (*sb_umount_close) (struct vfsmount * mnt);
1254 void (*sb_umount_busy) (struct vfsmount * mnt);
1255 void (*sb_post_remount) (struct vfsmount * mnt,
1256 unsigned long flags, void *data);
1da177e4
LT
1257 void (*sb_post_addmount) (struct vfsmount * mnt,
1258 struct nameidata * mountpoint_nd);
1259 int (*sb_pivotroot) (struct nameidata * old_nd,
1260 struct nameidata * new_nd);
1261 void (*sb_post_pivotroot) (struct nameidata * old_nd,
1262 struct nameidata * new_nd);
c9180a57
EP
1263 int (*sb_get_mnt_opts) (const struct super_block *sb,
1264 char ***mount_options, int **flags,
1265 int *num_opts);
1266 int (*sb_set_mnt_opts) (struct super_block *sb, char **mount_options,
1267 int *flags, int num_opts);
1268 void (*sb_clone_mnt_opts) (const struct super_block *oldsb,
1269 struct super_block *newsb);
1da177e4
LT
1270
1271 int (*inode_alloc_security) (struct inode *inode);
1272 void (*inode_free_security) (struct inode *inode);
5e41ff9e
SS
1273 int (*inode_init_security) (struct inode *inode, struct inode *dir,
1274 char **name, void **value, size_t *len);
1da177e4
LT
1275 int (*inode_create) (struct inode *dir,
1276 struct dentry *dentry, int mode);
1da177e4
LT
1277 int (*inode_link) (struct dentry *old_dentry,
1278 struct inode *dir, struct dentry *new_dentry);
1da177e4
LT
1279 int (*inode_unlink) (struct inode *dir, struct dentry *dentry);
1280 int (*inode_symlink) (struct inode *dir,
1281 struct dentry *dentry, const char *old_name);
1da177e4 1282 int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode);
1da177e4
LT
1283 int (*inode_rmdir) (struct inode *dir, struct dentry *dentry);
1284 int (*inode_mknod) (struct inode *dir, struct dentry *dentry,
1285 int mode, dev_t dev);
1da177e4
LT
1286 int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
1287 struct inode *new_dir, struct dentry *new_dentry);
1da177e4
LT
1288 int (*inode_readlink) (struct dentry *dentry);
1289 int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
1290 int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd);
1291 int (*inode_setattr) (struct dentry *dentry, struct iattr *attr);
1292 int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
1293 void (*inode_delete) (struct inode *inode);
1294 int (*inode_setxattr) (struct dentry *dentry, char *name, void *value,
1295 size_t size, int flags);
1296 void (*inode_post_setxattr) (struct dentry *dentry, char *name, void *value,
1297 size_t size, int flags);
1298 int (*inode_getxattr) (struct dentry *dentry, char *name);
1299 int (*inode_listxattr) (struct dentry *dentry);
1300 int (*inode_removexattr) (struct dentry *dentry, char *name);
b5376771
SH
1301 int (*inode_need_killpriv) (struct dentry *dentry);
1302 int (*inode_killpriv) (struct dentry *dentry);
7306a0b9 1303 int (*inode_getsecurity)(const struct inode *inode, const char *name, void *buffer, size_t size, int err);
1da177e4
LT
1304 int (*inode_setsecurity)(struct inode *inode, const char *name, const void *value, size_t size, int flags);
1305 int (*inode_listsecurity)(struct inode *inode, char *buffer, size_t buffer_size);
1306
1307 int (*file_permission) (struct file * file, int mask);
1308 int (*file_alloc_security) (struct file * file);
1309 void (*file_free_security) (struct file * file);
1310 int (*file_ioctl) (struct file * file, unsigned int cmd,
1311 unsigned long arg);
1312 int (*file_mmap) (struct file * file,
ed032189
EP
1313 unsigned long reqprot, unsigned long prot,
1314 unsigned long flags, unsigned long addr,
1315 unsigned long addr_only);
1da177e4
LT
1316 int (*file_mprotect) (struct vm_area_struct * vma,
1317 unsigned long reqprot,
1318 unsigned long prot);
1319 int (*file_lock) (struct file * file, unsigned int cmd);
1320 int (*file_fcntl) (struct file * file, unsigned int cmd,
1321 unsigned long arg);
1322 int (*file_set_fowner) (struct file * file);
1323 int (*file_send_sigiotask) (struct task_struct * tsk,
1324 struct fown_struct * fown, int sig);
1325 int (*file_receive) (struct file * file);
788e7dd4 1326 int (*dentry_open) (struct file *file);
1da177e4
LT
1327
1328 int (*task_create) (unsigned long clone_flags);
1329 int (*task_alloc_security) (struct task_struct * p);
1330 void (*task_free_security) (struct task_struct * p);
1331 int (*task_setuid) (uid_t id0, uid_t id1, uid_t id2, int flags);
1332 int (*task_post_setuid) (uid_t old_ruid /* or fsuid */ ,
1333 uid_t old_euid, uid_t old_suid, int flags);
1334 int (*task_setgid) (gid_t id0, gid_t id1, gid_t id2, int flags);
1335 int (*task_setpgid) (struct task_struct * p, pid_t pgid);
1336 int (*task_getpgid) (struct task_struct * p);
1337 int (*task_getsid) (struct task_struct * p);
f9008e4c 1338 void (*task_getsecid) (struct task_struct * p, u32 * secid);
1da177e4
LT
1339 int (*task_setgroups) (struct group_info *group_info);
1340 int (*task_setnice) (struct task_struct * p, int nice);
03e68060 1341 int (*task_setioprio) (struct task_struct * p, int ioprio);
a1836a42 1342 int (*task_getioprio) (struct task_struct * p);
1da177e4
LT
1343 int (*task_setrlimit) (unsigned int resource, struct rlimit * new_rlim);
1344 int (*task_setscheduler) (struct task_struct * p, int policy,
1345 struct sched_param * lp);
1346 int (*task_getscheduler) (struct task_struct * p);
35601547 1347 int (*task_movememory) (struct task_struct * p);
1da177e4 1348 int (*task_kill) (struct task_struct * p,
f9008e4c 1349 struct siginfo * info, int sig, u32 secid);
1da177e4
LT
1350 int (*task_wait) (struct task_struct * p);
1351 int (*task_prctl) (int option, unsigned long arg2,
1352 unsigned long arg3, unsigned long arg4,
1353 unsigned long arg5);
1354 void (*task_reparent_to_init) (struct task_struct * p);
1355 void (*task_to_inode)(struct task_struct *p, struct inode *inode);
1356
1357 int (*ipc_permission) (struct kern_ipc_perm * ipcp, short flag);
1358
1359 int (*msg_msg_alloc_security) (struct msg_msg * msg);
1360 void (*msg_msg_free_security) (struct msg_msg * msg);
1361
1362 int (*msg_queue_alloc_security) (struct msg_queue * msq);
1363 void (*msg_queue_free_security) (struct msg_queue * msq);
1364 int (*msg_queue_associate) (struct msg_queue * msq, int msqflg);
1365 int (*msg_queue_msgctl) (struct msg_queue * msq, int cmd);
1366 int (*msg_queue_msgsnd) (struct msg_queue * msq,
1367 struct msg_msg * msg, int msqflg);
1368 int (*msg_queue_msgrcv) (struct msg_queue * msq,
1369 struct msg_msg * msg,
1370 struct task_struct * target,
1371 long type, int mode);
1372
1373 int (*shm_alloc_security) (struct shmid_kernel * shp);
1374 void (*shm_free_security) (struct shmid_kernel * shp);
1375 int (*shm_associate) (struct shmid_kernel * shp, int shmflg);
1376 int (*shm_shmctl) (struct shmid_kernel * shp, int cmd);
1377 int (*shm_shmat) (struct shmid_kernel * shp,
1378 char __user *shmaddr, int shmflg);
1379
1380 int (*sem_alloc_security) (struct sem_array * sma);
1381 void (*sem_free_security) (struct sem_array * sma);
1382 int (*sem_associate) (struct sem_array * sma, int semflg);
1383 int (*sem_semctl) (struct sem_array * sma, int cmd);
1384 int (*sem_semop) (struct sem_array * sma,
1385 struct sembuf * sops, unsigned nsops, int alter);
1386
1387 int (*netlink_send) (struct sock * sk, struct sk_buff * skb);
c7bdb545 1388 int (*netlink_recv) (struct sk_buff * skb, int cap);
1da177e4
LT
1389
1390 /* allow module stacking */
1391 int (*register_security) (const char *name,
1392 struct security_operations *ops);
1da177e4
LT
1393
1394 void (*d_instantiate) (struct dentry *dentry, struct inode *inode);
1395
04ff9708 1396 int (*getprocattr)(struct task_struct *p, char *name, char **value);
1da177e4 1397 int (*setprocattr)(struct task_struct *p, char *name, void *value, size_t size);
dc49c1f9
CZ
1398 int (*secid_to_secctx)(u32 secid, char **secdata, u32 *seclen);
1399 void (*release_secctx)(char *secdata, u32 seclen);
1da177e4
LT
1400
1401#ifdef CONFIG_SECURITY_NETWORK
1402 int (*unix_stream_connect) (struct socket * sock,
1403 struct socket * other, struct sock * newsk);
1404 int (*unix_may_send) (struct socket * sock, struct socket * other);
1405
1406 int (*socket_create) (int family, int type, int protocol, int kern);
7420ed23
VY
1407 int (*socket_post_create) (struct socket * sock, int family,
1408 int type, int protocol, int kern);
1da177e4
LT
1409 int (*socket_bind) (struct socket * sock,
1410 struct sockaddr * address, int addrlen);
1411 int (*socket_connect) (struct socket * sock,
1412 struct sockaddr * address, int addrlen);
1413 int (*socket_listen) (struct socket * sock, int backlog);
1414 int (*socket_accept) (struct socket * sock, struct socket * newsock);
1415 void (*socket_post_accept) (struct socket * sock,
1416 struct socket * newsock);
1417 int (*socket_sendmsg) (struct socket * sock,
1418 struct msghdr * msg, int size);
1419 int (*socket_recvmsg) (struct socket * sock,
1420 struct msghdr * msg, int size, int flags);
1421 int (*socket_getsockname) (struct socket * sock);
1422 int (*socket_getpeername) (struct socket * sock);
1423 int (*socket_getsockopt) (struct socket * sock, int level, int optname);
1424 int (*socket_setsockopt) (struct socket * sock, int level, int optname);
1425 int (*socket_shutdown) (struct socket * sock, int how);
1426 int (*socket_sock_rcv_skb) (struct sock * sk, struct sk_buff * skb);
2c7946a7 1427 int (*socket_getpeersec_stream) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len);
dc49c1f9 1428 int (*socket_getpeersec_dgram) (struct socket *sock, struct sk_buff *skb, u32 *secid);
7d877f3b 1429 int (*sk_alloc_security) (struct sock *sk, int family, gfp_t priority);
1da177e4 1430 void (*sk_free_security) (struct sock *sk);
892c141e 1431 void (*sk_clone_security) (const struct sock *sk, struct sock *newsk);
beb8d13b 1432 void (*sk_getsecid) (struct sock *sk, u32 *secid);
4237c75c
VY
1433 void (*sock_graft)(struct sock* sk, struct socket *parent);
1434 int (*inet_conn_request)(struct sock *sk, struct sk_buff *skb,
1435 struct request_sock *req);
1436 void (*inet_csk_clone)(struct sock *newsk, const struct request_sock *req);
6b877699 1437 void (*inet_conn_established)(struct sock *sk, struct sk_buff *skb);
4237c75c 1438 void (*req_classify_flow)(const struct request_sock *req, struct flowi *fl);
1da177e4 1439#endif /* CONFIG_SECURITY_NETWORK */
29db9190 1440
df71837d 1441#ifdef CONFIG_SECURITY_NETWORK_XFRM
cb969f07 1442 int (*xfrm_policy_alloc_security) (struct xfrm_policy *xp,
c1a856c9 1443 struct xfrm_user_sec_ctx *sec_ctx);
df71837d
TJ
1444 int (*xfrm_policy_clone_security) (struct xfrm_policy *old, struct xfrm_policy *new);
1445 void (*xfrm_policy_free_security) (struct xfrm_policy *xp);
c8c05a8e 1446 int (*xfrm_policy_delete_security) (struct xfrm_policy *xp);
e0d1caa7 1447 int (*xfrm_state_alloc_security) (struct xfrm_state *x,
c1a856c9 1448 struct xfrm_user_sec_ctx *sec_ctx,
e0d1caa7 1449 u32 secid);
df71837d 1450 void (*xfrm_state_free_security) (struct xfrm_state *x);
c8c05a8e 1451 int (*xfrm_state_delete_security) (struct xfrm_state *x);
e0d1caa7
VY
1452 int (*xfrm_policy_lookup)(struct xfrm_policy *xp, u32 fl_secid, u8 dir);
1453 int (*xfrm_state_pol_flow_match)(struct xfrm_state *x,
1454 struct xfrm_policy *xp, struct flowi *fl);
beb8d13b 1455 int (*xfrm_decode_session)(struct sk_buff *skb, u32 *secid, int ckall);
df71837d
TJ
1456#endif /* CONFIG_SECURITY_NETWORK_XFRM */
1457
29db9190
DH
1458 /* key management security hooks */
1459#ifdef CONFIG_KEYS
7e047ef5 1460 int (*key_alloc)(struct key *key, struct task_struct *tsk, unsigned long flags);
29db9190
DH
1461 void (*key_free)(struct key *key);
1462 int (*key_permission)(key_ref_t key_ref,
1463 struct task_struct *context,
1464 key_perm_t perm);
1465
1466#endif /* CONFIG_KEYS */
1467
1da177e4
LT
1468};
1469
1da177e4
LT
1470/* prototypes */
1471extern int security_init (void);
1472extern int register_security (struct security_operations *ops);
1da177e4 1473extern int mod_reg_security (const char *name, struct security_operations *ops);
b67dbf9d
GKH
1474extern struct dentry *securityfs_create_file(const char *name, mode_t mode,
1475 struct dentry *parent, void *data,
54047320 1476 const struct file_operations *fops);
b67dbf9d
GKH
1477extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
1478extern void securityfs_remove(struct dentry *dentry);
1da177e4
LT
1479
1480
20510f2f
JM
1481/* Security operations */
1482int security_ptrace(struct task_struct *parent, struct task_struct *child);
1483int security_capget(struct task_struct *target,
1484 kernel_cap_t *effective,
1485 kernel_cap_t *inheritable,
1486 kernel_cap_t *permitted);
1487int security_capset_check(struct task_struct *target,
1488 kernel_cap_t *effective,
1489 kernel_cap_t *inheritable,
1490 kernel_cap_t *permitted);
1491void security_capset_set(struct task_struct *target,
1492 kernel_cap_t *effective,
1493 kernel_cap_t *inheritable,
1494 kernel_cap_t *permitted);
1495int security_capable(struct task_struct *tsk, int cap);
1496int security_acct(struct file *file);
1497int security_sysctl(struct ctl_table *table, int op);
1498int security_quotactl(int cmds, int type, int id, struct super_block *sb);
1499int security_quota_on(struct dentry *dentry);
1500int security_syslog(int type);
1501int security_settime(struct timespec *ts, struct timezone *tz);
1502int security_vm_enough_memory(long pages);
1503int security_vm_enough_memory_mm(struct mm_struct *mm, long pages);
1504int security_bprm_alloc(struct linux_binprm *bprm);
1505void security_bprm_free(struct linux_binprm *bprm);
1506void security_bprm_apply_creds(struct linux_binprm *bprm, int unsafe);
1507void security_bprm_post_apply_creds(struct linux_binprm *bprm);
1508int security_bprm_set(struct linux_binprm *bprm);
1509int security_bprm_check(struct linux_binprm *bprm);
1510int security_bprm_secureexec(struct linux_binprm *bprm);
1511int security_sb_alloc(struct super_block *sb);
1512void security_sb_free(struct super_block *sb);
1513int security_sb_copy_data(struct file_system_type *type, void *orig, void *copy);
1514int security_sb_kern_mount(struct super_block *sb, void *data);
1515int security_sb_statfs(struct dentry *dentry);
1516int security_sb_mount(char *dev_name, struct nameidata *nd,
1517 char *type, unsigned long flags, void *data);
1518int security_sb_check_sb(struct vfsmount *mnt, struct nameidata *nd);
1519int security_sb_umount(struct vfsmount *mnt, int flags);
1520void security_sb_umount_close(struct vfsmount *mnt);
1521void security_sb_umount_busy(struct vfsmount *mnt);
1522void security_sb_post_remount(struct vfsmount *mnt, unsigned long flags, void *data);
20510f2f
JM
1523void security_sb_post_addmount(struct vfsmount *mnt, struct nameidata *mountpoint_nd);
1524int security_sb_pivotroot(struct nameidata *old_nd, struct nameidata *new_nd);
1525void security_sb_post_pivotroot(struct nameidata *old_nd, struct nameidata *new_nd);
c9180a57
EP
1526int security_sb_get_mnt_opts(const struct super_block *sb, char ***mount_options,
1527 int **flags, int *num_opts);
1528int security_sb_set_mnt_opts(struct super_block *sb, char **mount_options,
1529 int *flags, int num_opts);
1530void security_sb_clone_mnt_opts(const struct super_block *oldsb,
1531 struct super_block *newsb);
1532
20510f2f
JM
1533int security_inode_alloc(struct inode *inode);
1534void security_inode_free(struct inode *inode);
1535int security_inode_init_security(struct inode *inode, struct inode *dir,
1536 char **name, void **value, size_t *len);
1537int security_inode_create(struct inode *dir, struct dentry *dentry, int mode);
1538int security_inode_link(struct dentry *old_dentry, struct inode *dir,
1539 struct dentry *new_dentry);
1540int security_inode_unlink(struct inode *dir, struct dentry *dentry);
1541int security_inode_symlink(struct inode *dir, struct dentry *dentry,
1542 const char *old_name);
1543int security_inode_mkdir(struct inode *dir, struct dentry *dentry, int mode);
1544int security_inode_rmdir(struct inode *dir, struct dentry *dentry);
1545int security_inode_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev);
1546int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
1547 struct inode *new_dir, struct dentry *new_dentry);
1548int security_inode_readlink(struct dentry *dentry);
1549int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd);
1550int security_inode_permission(struct inode *inode, int mask, struct nameidata *nd);
1551int security_inode_setattr(struct dentry *dentry, struct iattr *attr);
1552int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry);
1553void security_inode_delete(struct inode *inode);
1554int security_inode_setxattr(struct dentry *dentry, char *name,
1555 void *value, size_t size, int flags);
1556void security_inode_post_setxattr(struct dentry *dentry, char *name,
1557 void *value, size_t size, int flags);
1558int security_inode_getxattr(struct dentry *dentry, char *name);
1559int security_inode_listxattr(struct dentry *dentry);
1560int security_inode_removexattr(struct dentry *dentry, char *name);
b5376771
SH
1561int security_inode_need_killpriv(struct dentry *dentry);
1562int security_inode_killpriv(struct dentry *dentry);
20510f2f
JM
1563int security_inode_getsecurity(const struct inode *inode, const char *name, void *buffer, size_t size, int err);
1564int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags);
1565int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size);
1566int security_file_permission(struct file *file, int mask);
1567int security_file_alloc(struct file *file);
1568void security_file_free(struct file *file);
1569int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
1570int security_file_mmap(struct file *file, unsigned long reqprot,
1571 unsigned long prot, unsigned long flags,
1572 unsigned long addr, unsigned long addr_only);
1573int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
1574 unsigned long prot);
1575int security_file_lock(struct file *file, unsigned int cmd);
1576int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
1577int security_file_set_fowner(struct file *file);
1578int security_file_send_sigiotask(struct task_struct *tsk,
1579 struct fown_struct *fown, int sig);
1580int security_file_receive(struct file *file);
1581int security_dentry_open(struct file *file);
1582int security_task_create(unsigned long clone_flags);
1583int security_task_alloc(struct task_struct *p);
1584void security_task_free(struct task_struct *p);
1585int security_task_setuid(uid_t id0, uid_t id1, uid_t id2, int flags);
1586int security_task_post_setuid(uid_t old_ruid, uid_t old_euid,
1587 uid_t old_suid, int flags);
1588int security_task_setgid(gid_t id0, gid_t id1, gid_t id2, int flags);
1589int security_task_setpgid(struct task_struct *p, pid_t pgid);
1590int security_task_getpgid(struct task_struct *p);
1591int security_task_getsid(struct task_struct *p);
1592void security_task_getsecid(struct task_struct *p, u32 *secid);
1593int security_task_setgroups(struct group_info *group_info);
1594int security_task_setnice(struct task_struct *p, int nice);
1595int security_task_setioprio(struct task_struct *p, int ioprio);
1596int security_task_getioprio(struct task_struct *p);
1597int security_task_setrlimit(unsigned int resource, struct rlimit *new_rlim);
1598int security_task_setscheduler(struct task_struct *p,
1599 int policy, struct sched_param *lp);
1600int security_task_getscheduler(struct task_struct *p);
1601int security_task_movememory(struct task_struct *p);
1602int security_task_kill(struct task_struct *p, struct siginfo *info,
1603 int sig, u32 secid);
1604int security_task_wait(struct task_struct *p);
1605int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
1606 unsigned long arg4, unsigned long arg5);
1607void security_task_reparent_to_init(struct task_struct *p);
1608void security_task_to_inode(struct task_struct *p, struct inode *inode);
1609int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag);
1610int security_msg_msg_alloc(struct msg_msg *msg);
1611void security_msg_msg_free(struct msg_msg *msg);
1612int security_msg_queue_alloc(struct msg_queue *msq);
1613void security_msg_queue_free(struct msg_queue *msq);
1614int security_msg_queue_associate(struct msg_queue *msq, int msqflg);
1615int security_msg_queue_msgctl(struct msg_queue *msq, int cmd);
1616int security_msg_queue_msgsnd(struct msg_queue *msq,
1617 struct msg_msg *msg, int msqflg);
1618int security_msg_queue_msgrcv(struct msg_queue *msq, struct msg_msg *msg,
1619 struct task_struct *target, long type, int mode);
1620int security_shm_alloc(struct shmid_kernel *shp);
1621void security_shm_free(struct shmid_kernel *shp);
1622int security_shm_associate(struct shmid_kernel *shp, int shmflg);
1623int security_shm_shmctl(struct shmid_kernel *shp, int cmd);
1624int security_shm_shmat(struct shmid_kernel *shp, char __user *shmaddr, int shmflg);
1625int security_sem_alloc(struct sem_array *sma);
1626void security_sem_free(struct sem_array *sma);
1627int security_sem_associate(struct sem_array *sma, int semflg);
1628int security_sem_semctl(struct sem_array *sma, int cmd);
1629int security_sem_semop(struct sem_array *sma, struct sembuf *sops,
1630 unsigned nsops, int alter);
1631void security_d_instantiate (struct dentry *dentry, struct inode *inode);
1632int security_getprocattr(struct task_struct *p, char *name, char **value);
1633int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size);
1634int security_netlink_send(struct sock *sk, struct sk_buff *skb);
1635int security_netlink_recv(struct sk_buff *skb, int cap);
1636int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen);
1637void security_release_secctx(char *secdata, u32 seclen);
1638
1da177e4
LT
1639#else /* CONFIG_SECURITY */
1640
1641/*
1642 * This is the default capabilities functionality. Most of these functions
1643 * are just stubbed out, but a few must call the proper capable code.
1644 */
1645
1646static inline int security_init(void)
1647{
1648 return 0;
1649}
1650
1651static inline int security_ptrace (struct task_struct *parent, struct task_struct * child)
1652{
1653 return cap_ptrace (parent, child);
1654}
1655
1656static inline int security_capget (struct task_struct *target,
1657 kernel_cap_t *effective,
1658 kernel_cap_t *inheritable,
1659 kernel_cap_t *permitted)
1660{
1661 return cap_capget (target, effective, inheritable, permitted);
1662}
1663
1664static inline int security_capset_check (struct task_struct *target,
1665 kernel_cap_t *effective,
1666 kernel_cap_t *inheritable,
1667 kernel_cap_t *permitted)
1668{
1669 return cap_capset_check (target, effective, inheritable, permitted);
1670}
1671
1672static inline void security_capset_set (struct task_struct *target,
1673 kernel_cap_t *effective,
1674 kernel_cap_t *inheritable,
1675 kernel_cap_t *permitted)
1676{
1677 cap_capset_set (target, effective, inheritable, permitted);
1678}
1679
12b5989b
CW
1680static inline int security_capable(struct task_struct *tsk, int cap)
1681{
1682 return cap_capable(tsk, cap);
1683}
1684
1da177e4
LT
1685static inline int security_acct (struct file *file)
1686{
1687 return 0;
1688}
1689
1690static inline int security_sysctl(struct ctl_table *table, int op)
1691{
1692 return 0;
1693}
1694
1695static inline int security_quotactl (int cmds, int type, int id,
1696 struct super_block * sb)
1697{
1698 return 0;
1699}
1700
1701static inline int security_quota_on (struct dentry * dentry)
1702{
1703 return 0;
1704}
1705
1706static inline int security_syslog(int type)
1707{
1708 return cap_syslog(type);
1709}
1710
1711static inline int security_settime(struct timespec *ts, struct timezone *tz)
1712{
1713 return cap_settime(ts, tz);
1714}
1715
1716static inline int security_vm_enough_memory(long pages)
1717{
34b4e4aa
AC
1718 return cap_vm_enough_memory(current->mm, pages);
1719}
1720
1721static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
1722{
1723 return cap_vm_enough_memory(mm, pages);
1da177e4
LT
1724}
1725
1726static inline int security_bprm_alloc (struct linux_binprm *bprm)
1727{
1728 return 0;
1729}
1730
1731static inline void security_bprm_free (struct linux_binprm *bprm)
1732{ }
1733
1734static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
1735{
1736 cap_bprm_apply_creds (bprm, unsafe);
1737}
1738
1739static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
1740{
1741 return;
1742}
1743
1744static inline int security_bprm_set (struct linux_binprm *bprm)
1745{
1746 return cap_bprm_set_security (bprm);
1747}
1748
1749static inline int security_bprm_check (struct linux_binprm *bprm)
1750{
1751 return 0;
1752}
1753
1754static inline int security_bprm_secureexec (struct linux_binprm *bprm)
1755{
1756 return cap_bprm_secureexec(bprm);
1757}
1758
1759static inline int security_sb_alloc (struct super_block *sb)
1760{
1761 return 0;
1762}
1763
1764static inline void security_sb_free (struct super_block *sb)
1765{ }
1766
1767static inline int security_sb_copy_data (struct file_system_type *type,
1768 void *orig, void *copy)
1769{
1770 return 0;
1771}
1772
1773static inline int security_sb_kern_mount (struct super_block *sb, void *data)
1774{
1775 return 0;
1776}
1777
726c3342 1778static inline int security_sb_statfs (struct dentry *dentry)
1da177e4
LT
1779{
1780 return 0;
1781}
1782
1783static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
1784 char *type, unsigned long flags,
1785 void *data)
1786{
1787 return 0;
1788}
1789
1790static inline int security_sb_check_sb (struct vfsmount *mnt,
1791 struct nameidata *nd)
1792{
1793 return 0;
1794}
1795
1796static inline int security_sb_umount (struct vfsmount *mnt, int flags)
1797{
1798 return 0;
1799}
1800
1801static inline void security_sb_umount_close (struct vfsmount *mnt)
1802{ }
1803
1804static inline void security_sb_umount_busy (struct vfsmount *mnt)
1805{ }
1806
1807static inline void security_sb_post_remount (struct vfsmount *mnt,
1808 unsigned long flags, void *data)
1809{ }
1810
1da177e4
LT
1811static inline void security_sb_post_addmount (struct vfsmount *mnt,
1812 struct nameidata *mountpoint_nd)
1813{ }
1814
1815static inline int security_sb_pivotroot (struct nameidata *old_nd,
1816 struct nameidata *new_nd)
1817{
1818 return 0;
1819}
1820
1821static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
1822 struct nameidata *new_nd)
1823{ }
1824
1825static inline int security_inode_alloc (struct inode *inode)
1826{
1827 return 0;
1828}
1829
1830static inline void security_inode_free (struct inode *inode)
1831{ }
5e41ff9e
SS
1832
1833static inline int security_inode_init_security (struct inode *inode,
1834 struct inode *dir,
1835 char **name,
1836 void **value,
1837 size_t *len)
1838{
1839 return -EOPNOTSUPP;
1840}
1da177e4
LT
1841
1842static inline int security_inode_create (struct inode *dir,
1843 struct dentry *dentry,
1844 int mode)
1845{
1846 return 0;
1847}
1848
1da177e4
LT
1849static inline int security_inode_link (struct dentry *old_dentry,
1850 struct inode *dir,
1851 struct dentry *new_dentry)
1852{
1853 return 0;
1854}
1855
1da177e4
LT
1856static inline int security_inode_unlink (struct inode *dir,
1857 struct dentry *dentry)
1858{
1859 return 0;
1860}
1861
1862static inline int security_inode_symlink (struct inode *dir,
1863 struct dentry *dentry,
1864 const char *old_name)
1865{
1866 return 0;
1867}
1868
1da177e4
LT
1869static inline int security_inode_mkdir (struct inode *dir,
1870 struct dentry *dentry,
1871 int mode)
1872{
1873 return 0;
1874}
1875
1da177e4
LT
1876static inline int security_inode_rmdir (struct inode *dir,
1877 struct dentry *dentry)
1878{
1879 return 0;
1880}
1881
1882static inline int security_inode_mknod (struct inode *dir,
1883 struct dentry *dentry,
1884 int mode, dev_t dev)
1885{
1886 return 0;
1887}
1888
1da177e4
LT
1889static inline int security_inode_rename (struct inode *old_dir,
1890 struct dentry *old_dentry,
1891 struct inode *new_dir,
1892 struct dentry *new_dentry)
1893{
1894 return 0;
1895}
1896
1da177e4
LT
1897static inline int security_inode_readlink (struct dentry *dentry)
1898{
1899 return 0;
1900}
1901
1902static inline int security_inode_follow_link (struct dentry *dentry,
1903 struct nameidata *nd)
1904{
1905 return 0;
1906}
1907
1908static inline int security_inode_permission (struct inode *inode, int mask,
1909 struct nameidata *nd)
1910{
1911 return 0;
1912}
1913
1914static inline int security_inode_setattr (struct dentry *dentry,
1915 struct iattr *attr)
1916{
1917 return 0;
1918}
1919
1920static inline int security_inode_getattr (struct vfsmount *mnt,
1921 struct dentry *dentry)
1922{
1923 return 0;
1924}
1925
1926static inline void security_inode_delete (struct inode *inode)
1927{ }
1928
1929static inline int security_inode_setxattr (struct dentry *dentry, char *name,
1930 void *value, size_t size, int flags)
1931{
1932 return cap_inode_setxattr(dentry, name, value, size, flags);
1933}
1934
1935static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
1936 void *value, size_t size, int flags)
1937{ }
1938
1939static inline int security_inode_getxattr (struct dentry *dentry, char *name)
1940{
1941 return 0;
1942}
1943
1944static inline int security_inode_listxattr (struct dentry *dentry)
1945{
1946 return 0;
1947}
1948
1949static inline int security_inode_removexattr (struct dentry *dentry, char *name)
1950{
1951 return cap_inode_removexattr(dentry, name);
1952}
1953
b5376771
SH
1954static inline int security_inode_need_killpriv(struct dentry *dentry)
1955{
1956 return cap_inode_need_killpriv(dentry);
1957}
1958
1959static inline int security_inode_killpriv(struct dentry *dentry)
1960{
1961 return cap_inode_killpriv(dentry);
1962}
1963
7306a0b9 1964static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void *buffer, size_t size, int err)
1da177e4
LT
1965{
1966 return -EOPNOTSUPP;
1967}
1968
1969static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
1970{
1971 return -EOPNOTSUPP;
1972}
1973
1974static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
1975{
1976 return 0;
1977}
1978
1979static inline int security_file_permission (struct file *file, int mask)
1980{
1981 return 0;
1982}
1983
1984static inline int security_file_alloc (struct file *file)
1985{
1986 return 0;
1987}
1988
1989static inline void security_file_free (struct file *file)
1990{ }
1991
1992static inline int security_file_ioctl (struct file *file, unsigned int cmd,
1993 unsigned long arg)
1994{
1995 return 0;
1996}
1997
1998static inline int security_file_mmap (struct file *file, unsigned long reqprot,
1999 unsigned long prot,
ed032189
EP
2000 unsigned long flags,
2001 unsigned long addr,
2002 unsigned long addr_only)
1da177e4
LT
2003{
2004 return 0;
2005}
2006
2007static inline int security_file_mprotect (struct vm_area_struct *vma,
2008 unsigned long reqprot,
2009 unsigned long prot)
2010{
2011 return 0;
2012}
2013
2014static inline int security_file_lock (struct file *file, unsigned int cmd)
2015{
2016 return 0;
2017}
2018
2019static inline int security_file_fcntl (struct file *file, unsigned int cmd,
2020 unsigned long arg)
2021{
2022 return 0;
2023}
2024
2025static inline int security_file_set_fowner (struct file *file)
2026{
2027 return 0;
2028}
2029
2030static inline int security_file_send_sigiotask (struct task_struct *tsk,
2031 struct fown_struct *fown,
2032 int sig)
2033{
2034 return 0;
2035}
2036
2037static inline int security_file_receive (struct file *file)
2038{
2039 return 0;
2040}
2041
788e7dd4
YN
2042static inline int security_dentry_open (struct file *file)
2043{
2044 return 0;
2045}
2046
1da177e4
LT
2047static inline int security_task_create (unsigned long clone_flags)
2048{
2049 return 0;
2050}
2051
2052static inline int security_task_alloc (struct task_struct *p)
2053{
2054 return 0;
2055}
2056
2057static inline void security_task_free (struct task_struct *p)
2058{ }
2059
2060static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
2061 int flags)
2062{
2063 return 0;
2064}
2065
2066static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
2067 uid_t old_suid, int flags)
2068{
2069 return cap_task_post_setuid (old_ruid, old_euid, old_suid, flags);
2070}
2071
2072static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
2073 int flags)
2074{
2075 return 0;
2076}
2077
2078static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
2079{
2080 return 0;
2081}
2082
2083static inline int security_task_getpgid (struct task_struct *p)
2084{
2085 return 0;
2086}
2087
2088static inline int security_task_getsid (struct task_struct *p)
2089{
2090 return 0;
2091}
2092
f9008e4c
DQ
2093static inline void security_task_getsecid (struct task_struct *p, u32 *secid)
2094{ }
2095
1da177e4
LT
2096static inline int security_task_setgroups (struct group_info *group_info)
2097{
2098 return 0;
2099}
2100
2101static inline int security_task_setnice (struct task_struct *p, int nice)
2102{
b5376771 2103 return cap_task_setnice(p, nice);
1da177e4
LT
2104}
2105
03e68060
JM
2106static inline int security_task_setioprio (struct task_struct *p, int ioprio)
2107{
b5376771 2108 return cap_task_setioprio(p, ioprio);
03e68060
JM
2109}
2110
a1836a42
DQ
2111static inline int security_task_getioprio (struct task_struct *p)
2112{
2113 return 0;
2114}
2115
1da177e4
LT
2116static inline int security_task_setrlimit (unsigned int resource,
2117 struct rlimit *new_rlim)
2118{
2119 return 0;
2120}
2121
2122static inline int security_task_setscheduler (struct task_struct *p,
2123 int policy,
2124 struct sched_param *lp)
2125{
b5376771 2126 return cap_task_setscheduler(p, policy, lp);
1da177e4
LT
2127}
2128
2129static inline int security_task_getscheduler (struct task_struct *p)
2130{
2131 return 0;
2132}
2133
35601547
DQ
2134static inline int security_task_movememory (struct task_struct *p)
2135{
2136 return 0;
2137}
2138
1da177e4 2139static inline int security_task_kill (struct task_struct *p,
f9008e4c
DQ
2140 struct siginfo *info, int sig,
2141 u32 secid)
1da177e4 2142{
b5376771 2143 return cap_task_kill(p, info, sig, secid);
1da177e4
LT
2144}
2145
2146static inline int security_task_wait (struct task_struct *p)
2147{
2148 return 0;
2149}
2150
2151static inline int security_task_prctl (int option, unsigned long arg2,
2152 unsigned long arg3,
2153 unsigned long arg4,
2154 unsigned long arg5)
2155{
2156 return 0;
2157}
2158
2159static inline void security_task_reparent_to_init (struct task_struct *p)
2160{
2161 cap_task_reparent_to_init (p);
2162}
2163
2164static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
2165{ }
2166
2167static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
2168 short flag)
2169{
2170 return 0;
2171}
2172
2173static inline int security_msg_msg_alloc (struct msg_msg * msg)
2174{
2175 return 0;
2176}
2177
2178static inline void security_msg_msg_free (struct msg_msg * msg)
2179{ }
2180
2181static inline int security_msg_queue_alloc (struct msg_queue *msq)
2182{
2183 return 0;
2184}
2185
2186static inline void security_msg_queue_free (struct msg_queue *msq)
2187{ }
2188
2189static inline int security_msg_queue_associate (struct msg_queue * msq,
2190 int msqflg)
2191{
2192 return 0;
2193}
2194
2195static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
2196{
2197 return 0;
2198}
2199
2200static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
2201 struct msg_msg * msg, int msqflg)
2202{
2203 return 0;
2204}
2205
2206static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
2207 struct msg_msg * msg,
2208 struct task_struct * target,
2209 long type, int mode)
2210{
2211 return 0;
2212}
2213
2214static inline int security_shm_alloc (struct shmid_kernel *shp)
2215{
2216 return 0;
2217}
2218
2219static inline void security_shm_free (struct shmid_kernel *shp)
2220{ }
2221
2222static inline int security_shm_associate (struct shmid_kernel * shp,
2223 int shmflg)
2224{
2225 return 0;
2226}
2227
2228static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
2229{
2230 return 0;
2231}
2232
2233static inline int security_shm_shmat (struct shmid_kernel * shp,
2234 char __user *shmaddr, int shmflg)
2235{
2236 return 0;
2237}
2238
2239static inline int security_sem_alloc (struct sem_array *sma)
2240{
2241 return 0;
2242}
2243
2244static inline void security_sem_free (struct sem_array *sma)
2245{ }
2246
2247static inline int security_sem_associate (struct sem_array * sma, int semflg)
2248{
2249 return 0;
2250}
2251
2252static inline int security_sem_semctl (struct sem_array * sma, int cmd)
2253{
2254 return 0;
2255}
2256
2257static inline int security_sem_semop (struct sem_array * sma,
2258 struct sembuf * sops, unsigned nsops,
2259 int alter)
2260{
2261 return 0;
2262}
2263
2264static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
2265{ }
2266
04ff9708 2267static inline int security_getprocattr(struct task_struct *p, char *name, char **value)
1da177e4
LT
2268{
2269 return -EINVAL;
2270}
2271
2272static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2273{
2274 return -EINVAL;
2275}
2276
2277static inline int security_netlink_send (struct sock *sk, struct sk_buff *skb)
2278{
2279 return cap_netlink_send (sk, skb);
2280}
2281
c7bdb545 2282static inline int security_netlink_recv (struct sk_buff *skb, int cap)
1da177e4 2283{
c7bdb545 2284 return cap_netlink_recv (skb, cap);
1da177e4
LT
2285}
2286
ed5a9270
RD
2287static inline struct dentry *securityfs_create_dir(const char *name,
2288 struct dentry *parent)
2289{
2290 return ERR_PTR(-ENODEV);
2291}
2292
2293static inline struct dentry *securityfs_create_file(const char *name,
2294 mode_t mode,
2295 struct dentry *parent,
2296 void *data,
2297 struct file_operations *fops)
2298{
2299 return ERR_PTR(-ENODEV);
2300}
2301
2302static inline void securityfs_remove(struct dentry *dentry)
2303{
2304}
2305
dc49c1f9
CZ
2306static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
2307{
2308 return -EOPNOTSUPP;
2309}
2310
2311static inline void security_release_secctx(char *secdata, u32 seclen)
2312{
dc49c1f9 2313}
1da177e4
LT
2314#endif /* CONFIG_SECURITY */
2315
2316#ifdef CONFIG_SECURITY_NETWORK
4237c75c 2317
20510f2f
JM
2318int security_unix_stream_connect(struct socket *sock, struct socket *other,
2319 struct sock *newsk);
2320int security_unix_may_send(struct socket *sock, struct socket *other);
2321int security_socket_create(int family, int type, int protocol, int kern);
2322int security_socket_post_create(struct socket *sock, int family,
2323 int type, int protocol, int kern);
2324int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen);
2325int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen);
2326int security_socket_listen(struct socket *sock, int backlog);
2327int security_socket_accept(struct socket *sock, struct socket *newsock);
2328void security_socket_post_accept(struct socket *sock, struct socket *newsock);
2329int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size);
2330int security_socket_recvmsg(struct socket *sock, struct msghdr *msg,
2331 int size, int flags);
2332int security_socket_getsockname(struct socket *sock);
2333int security_socket_getpeername(struct socket *sock);
2334int security_socket_getsockopt(struct socket *sock, int level, int optname);
2335int security_socket_setsockopt(struct socket *sock, int level, int optname);
2336int security_socket_shutdown(struct socket *sock, int how);
2337int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb);
2338int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2339 int __user *optlen, unsigned len);
2340int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid);
2341int security_sk_alloc(struct sock *sk, int family, gfp_t priority);
2342void security_sk_free(struct sock *sk);
2343void security_sk_clone(const struct sock *sk, struct sock *newsk);
2344void security_sk_classify_flow(struct sock *sk, struct flowi *fl);
2345void security_req_classify_flow(const struct request_sock *req, struct flowi *fl);
2346void security_sock_graft(struct sock*sk, struct socket *parent);
2347int security_inet_conn_request(struct sock *sk,
2348 struct sk_buff *skb, struct request_sock *req);
2349void security_inet_csk_clone(struct sock *newsk,
2350 const struct request_sock *req);
2351void security_inet_conn_established(struct sock *sk,
2352 struct sk_buff *skb);
6b877699 2353
1da177e4
LT
2354#else /* CONFIG_SECURITY_NETWORK */
2355static inline int security_unix_stream_connect(struct socket * sock,
6b877699 2356 struct socket * other,
1da177e4
LT
2357 struct sock * newsk)
2358{
2359 return 0;
2360}
2361
2362static inline int security_unix_may_send(struct socket * sock,
2363 struct socket * other)
2364{
2365 return 0;
2366}
2367
2368static inline int security_socket_create (int family, int type,
2369 int protocol, int kern)
2370{
2371 return 0;
2372}
2373
7420ed23
VY
2374static inline int security_socket_post_create(struct socket * sock,
2375 int family,
2376 int type,
2377 int protocol, int kern)
1da177e4 2378{
7420ed23 2379 return 0;
1da177e4
LT
2380}
2381
2382static inline int security_socket_bind(struct socket * sock,
2383 struct sockaddr * address,
2384 int addrlen)
2385{
2386 return 0;
2387}
2388
2389static inline int security_socket_connect(struct socket * sock,
2390 struct sockaddr * address,
2391 int addrlen)
2392{
2393 return 0;
2394}
2395
2396static inline int security_socket_listen(struct socket * sock, int backlog)
2397{
2398 return 0;
2399}
2400
2401static inline int security_socket_accept(struct socket * sock,
2402 struct socket * newsock)
2403{
2404 return 0;
2405}
2406
2407static inline void security_socket_post_accept(struct socket * sock,
2408 struct socket * newsock)
2409{
2410}
2411
2412static inline int security_socket_sendmsg(struct socket * sock,
2413 struct msghdr * msg, int size)
2414{
2415 return 0;
2416}
2417
2418static inline int security_socket_recvmsg(struct socket * sock,
2419 struct msghdr * msg, int size,
2420 int flags)
2421{
2422 return 0;
2423}
2424
2425static inline int security_socket_getsockname(struct socket * sock)
2426{
2427 return 0;
2428}
2429
2430static inline int security_socket_getpeername(struct socket * sock)
2431{
2432 return 0;
2433}
2434
2435static inline int security_socket_getsockopt(struct socket * sock,
2436 int level, int optname)
2437{
2438 return 0;
2439}
2440
2441static inline int security_socket_setsockopt(struct socket * sock,
2442 int level, int optname)
2443{
2444 return 0;
2445}
2446
2447static inline int security_socket_shutdown(struct socket * sock, int how)
2448{
2449 return 0;
2450}
2451static inline int security_sock_rcv_skb (struct sock * sk,
2452 struct sk_buff * skb)
2453{
2454 return 0;
2455}
2456
2c7946a7
CZ
2457static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2458 int __user *optlen, unsigned len)
2459{
2460 return -ENOPROTOOPT;
2461}
2462
dc49c1f9 2463static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
1da177e4
LT
2464{
2465 return -ENOPROTOOPT;
2466}
2467
dd0fc66f 2468static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
1da177e4
LT
2469{
2470 return 0;
2471}
2472
2473static inline void security_sk_free(struct sock *sk)
892c141e
VY
2474{
2475}
2476
2477static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
1da177e4
LT
2478{
2479}
df71837d 2480
beb8d13b 2481static inline void security_sk_classify_flow(struct sock *sk, struct flowi *fl)
df71837d 2482{
df71837d 2483}
4237c75c
VY
2484
2485static inline void security_req_classify_flow(const struct request_sock *req, struct flowi *fl)
2486{
2487}
2488
2489static inline void security_sock_graft(struct sock* sk, struct socket *parent)
2490{
2491}
2492
2493static inline int security_inet_conn_request(struct sock *sk,
2494 struct sk_buff *skb, struct request_sock *req)
2495{
2496 return 0;
2497}
2498
2499static inline void security_inet_csk_clone(struct sock *newsk,
2500 const struct request_sock *req)
2501{
2502}
6b877699
VY
2503
2504static inline void security_inet_conn_established(struct sock *sk,
2505 struct sk_buff *skb)
2506{
2507}
1da177e4
LT
2508#endif /* CONFIG_SECURITY_NETWORK */
2509
df71837d 2510#ifdef CONFIG_SECURITY_NETWORK_XFRM
beb8d13b 2511
20510f2f
JM
2512int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx);
2513int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new);
2514void security_xfrm_policy_free(struct xfrm_policy *xp);
2515int security_xfrm_policy_delete(struct xfrm_policy *xp);
2516int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
2517int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
2518 struct xfrm_sec_ctx *polsec, u32 secid);
2519int security_xfrm_state_delete(struct xfrm_state *x);
2520void security_xfrm_state_free(struct xfrm_state *x);
2521int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir);
2522int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
2523 struct xfrm_policy *xp, struct flowi *fl);
2524int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid);
2525void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl);
beb8d13b 2526
df71837d 2527#else /* CONFIG_SECURITY_NETWORK_XFRM */
20510f2f 2528
df71837d
TJ
2529static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx)
2530{
2531 return 0;
2532}
2533
2534static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
2535{
2536 return 0;
2537}
2538
2539static inline void security_xfrm_policy_free(struct xfrm_policy *xp)
2540{
2541}
2542
c8c05a8e
CZ
2543static inline int security_xfrm_policy_delete(struct xfrm_policy *xp)
2544{
2545 return 0;
2546}
2547
e0d1caa7
VY
2548static inline int security_xfrm_state_alloc(struct xfrm_state *x,
2549 struct xfrm_user_sec_ctx *sec_ctx)
2550{
2551 return 0;
2552}
2553
2554static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
2555 struct xfrm_sec_ctx *polsec, u32 secid)
df71837d
TJ
2556{
2557 return 0;
2558}
2559
2560static inline void security_xfrm_state_free(struct xfrm_state *x)
2561{
2562}
2563
6f68dc37 2564static inline int security_xfrm_state_delete(struct xfrm_state *x)
c8c05a8e
CZ
2565{
2566 return 0;
2567}
2568
e0d1caa7 2569static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir)
df71837d
TJ
2570{
2571 return 0;
2572}
e0d1caa7
VY
2573
2574static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
2575 struct xfrm_policy *xp, struct flowi *fl)
2576{
2577 return 1;
2578}
2579
beb8d13b 2580static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
e0d1caa7
VY
2581{
2582 return 0;
2583}
2584
beb8d13b
VY
2585static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl)
2586{
2587}
2588
df71837d
TJ
2589#endif /* CONFIG_SECURITY_NETWORK_XFRM */
2590
29db9190
DH
2591#ifdef CONFIG_KEYS
2592#ifdef CONFIG_SECURITY
29db9190 2593
20510f2f
JM
2594int security_key_alloc(struct key *key, struct task_struct *tsk, unsigned long flags);
2595void security_key_free(struct key *key);
2596int security_key_permission(key_ref_t key_ref,
2597 struct task_struct *context, key_perm_t perm);
29db9190
DH
2598
2599#else
2600
d720024e 2601static inline int security_key_alloc(struct key *key,
7e047ef5
DH
2602 struct task_struct *tsk,
2603 unsigned long flags)
29db9190
DH
2604{
2605 return 0;
2606}
2607
2608static inline void security_key_free(struct key *key)
2609{
2610}
2611
2612static inline int security_key_permission(key_ref_t key_ref,
2613 struct task_struct *context,
2614 key_perm_t perm)
2615{
2616 return 0;
2617}
2618
2619#endif
2620#endif /* CONFIG_KEYS */
2621
1da177e4
LT
2622#endif /* ! __LINUX_SECURITY_H */
2623