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