blob: 8e3dc6c51a6d8dad7b7a0d7dedb4acf33de6fc84 [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>
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -070034#include <linux/xfrm.h>
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -070035#include <net/flow.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
37struct ctl_table;
38
39/*
40 * These functions are in security/capability.c and are used
41 * as the default capabilities functions
42 */
43extern int cap_capable (struct task_struct *tsk, int cap);
44extern int cap_settime (struct timespec *ts, struct timezone *tz);
45extern int cap_ptrace (struct task_struct *parent, struct task_struct *child);
46extern int cap_capget (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
47extern int cap_capset_check (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
48extern void cap_capset_set (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
49extern int cap_bprm_set_security (struct linux_binprm *bprm);
50extern void cap_bprm_apply_creds (struct linux_binprm *bprm, int unsafe);
51extern int cap_bprm_secureexec(struct linux_binprm *bprm);
52extern int cap_inode_setxattr(struct dentry *dentry, char *name, void *value, size_t size, int flags);
53extern int cap_inode_removexattr(struct dentry *dentry, char *name);
54extern int cap_task_post_setuid (uid_t old_ruid, uid_t old_euid, uid_t old_suid, int flags);
55extern void cap_task_reparent_to_init (struct task_struct *p);
56extern int cap_syslog (int type);
57extern int cap_vm_enough_memory (long pages);
58
59struct msghdr;
60struct sk_buff;
61struct sock;
62struct sockaddr;
63struct socket;
Trent Jaegerdf718372005-12-13 23:12:27 -080064struct flowi;
65struct dst_entry;
66struct xfrm_selector;
67struct xfrm_policy;
68struct xfrm_state;
69struct xfrm_user_sec_ctx;
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
71extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
Darrel Goeddelc7bdb542006-06-27 13:26:11 -070072extern int cap_netlink_recv(struct sk_buff *skb, int cap);
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
74/*
75 * Values used in the task_security_ops calls
76 */
77/* setuid or setgid, id0 == uid or gid */
78#define LSM_SETID_ID 1
79
80/* setreuid or setregid, id0 == real, id1 == eff */
81#define LSM_SETID_RE 2
82
83/* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
84#define LSM_SETID_RES 4
85
86/* setfsuid or setfsgid, id0 == fsuid or fsgid */
87#define LSM_SETID_FS 8
88
89/* forward declares to avoid warnings */
90struct nfsctl_arg;
91struct sched_param;
92struct swap_info_struct;
93
94/* bprm_apply_creds unsafe reasons */
95#define LSM_UNSAFE_SHARE 1
96#define LSM_UNSAFE_PTRACE 2
97#define LSM_UNSAFE_PTRACE_CAP 4
98
99#ifdef CONFIG_SECURITY
100
101/**
102 * struct security_operations - main security structure
103 *
104 * Security hooks for program execution operations.
105 *
106 * @bprm_alloc_security:
107 * Allocate and attach a security structure to the @bprm->security field.
108 * The security field is initialized to NULL when the bprm structure is
109 * allocated.
110 * @bprm contains the linux_binprm structure to be modified.
111 * Return 0 if operation was successful.
112 * @bprm_free_security:
113 * @bprm contains the linux_binprm structure to be modified.
114 * Deallocate and clear the @bprm->security field.
115 * @bprm_apply_creds:
116 * Compute and set the security attributes of a process being transformed
117 * by an execve operation based on the old attributes (current->security)
118 * and the information saved in @bprm->security by the set_security hook.
119 * Since this hook function (and its caller) are void, this hook can not
120 * return an error. However, it can leave the security attributes of the
121 * process unchanged if an access failure occurs at this point.
122 * bprm_apply_creds is called under task_lock. @unsafe indicates various
123 * reasons why it may be unsafe to change security state.
124 * @bprm contains the linux_binprm structure.
125 * @bprm_post_apply_creds:
126 * Runs after bprm_apply_creds with the task_lock dropped, so that
127 * functions which cannot be called safely under the task_lock can
128 * be used. This hook is a good place to perform state changes on
129 * the process such as closing open file descriptors to which access
130 * is no longer granted if the attributes were changed.
131 * Note that a security module might need to save state between
132 * bprm_apply_creds and bprm_post_apply_creds to store the decision
133 * on whether the process may proceed.
134 * @bprm contains the linux_binprm structure.
135 * @bprm_set_security:
136 * Save security information in the bprm->security field, typically based
137 * on information about the bprm->file, for later use by the apply_creds
138 * hook. This hook may also optionally check permissions (e.g. for
139 * transitions between security domains).
140 * This hook may be called multiple times during a single execve, e.g. for
141 * interpreters. The hook can tell whether it has already been called by
142 * checking to see if @bprm->security is non-NULL. If so, then the hook
143 * may decide either to retain the security information saved earlier or
144 * to replace it.
145 * @bprm contains the linux_binprm structure.
146 * Return 0 if the hook is successful and permission is granted.
147 * @bprm_check_security:
148 * This hook mediates the point when a search for a binary handler will
149 * begin. It allows a check the @bprm->security value which is set in
150 * the preceding set_security call. The primary difference from
151 * set_security is that the argv list and envp list are reliably
152 * available in @bprm. This hook may be called multiple times
153 * during a single execve; and in each pass set_security is called
154 * first.
155 * @bprm contains the linux_binprm structure.
156 * Return 0 if the hook is successful and permission is granted.
157 * @bprm_secureexec:
158 * Return a boolean value (0 or 1) indicating whether a "secure exec"
159 * is required. The flag is passed in the auxiliary table
160 * on the initial stack to the ELF interpreter to indicate whether libc
161 * should enable secure mode.
162 * @bprm contains the linux_binprm structure.
163 *
164 * Security hooks for filesystem operations.
165 *
166 * @sb_alloc_security:
167 * Allocate and attach a security structure to the sb->s_security field.
168 * The s_security field is initialized to NULL when the structure is
169 * allocated.
170 * @sb contains the super_block structure to be modified.
171 * Return 0 if operation was successful.
172 * @sb_free_security:
173 * Deallocate and clear the sb->s_security field.
174 * @sb contains the super_block structure to be modified.
175 * @sb_statfs:
David Howells726c3342006-06-23 02:02:58 -0700176 * Check permission before obtaining filesystem statistics for the @mnt
177 * mountpoint.
178 * @dentry is a handle on the superblock for the filesystem.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 * Return 0 if permission is granted.
180 * @sb_mount:
181 * Check permission before an object specified by @dev_name is mounted on
182 * the mount point named by @nd. For an ordinary mount, @dev_name
183 * identifies a device if the file system type requires a device. For a
184 * remount (@flags & MS_REMOUNT), @dev_name is irrelevant. For a
185 * loopback/bind mount (@flags & MS_BIND), @dev_name identifies the
186 * pathname of the object being mounted.
187 * @dev_name contains the name for object being mounted.
188 * @nd contains the nameidata structure for mount point object.
189 * @type contains the filesystem type.
190 * @flags contains the mount flags.
191 * @data contains the filesystem-specific data.
192 * Return 0 if permission is granted.
193 * @sb_copy_data:
194 * Allow mount option data to be copied prior to parsing by the filesystem,
195 * so that the security module can extract security-specific mount
196 * options cleanly (a filesystem may modify the data e.g. with strsep()).
197 * This also allows the original mount data to be stripped of security-
198 * specific options to avoid having to make filesystems aware of them.
199 * @type the type of filesystem being mounted.
200 * @orig the original mount data copied from userspace.
201 * @copy copied data which will be passed to the security module.
202 * Returns 0 if the copy was successful.
203 * @sb_check_sb:
204 * Check permission before the device with superblock @mnt->sb is mounted
205 * on the mount point named by @nd.
206 * @mnt contains the vfsmount for device being mounted.
207 * @nd contains the nameidata object for the mount point.
208 * Return 0 if permission is granted.
209 * @sb_umount:
210 * Check permission before the @mnt file system is unmounted.
211 * @mnt contains the mounted file system.
212 * @flags contains the unmount flags, e.g. MNT_FORCE.
213 * Return 0 if permission is granted.
214 * @sb_umount_close:
215 * Close any files in the @mnt mounted filesystem that are held open by
216 * the security module. This hook is called during an umount operation
217 * prior to checking whether the filesystem is still busy.
218 * @mnt contains the mounted filesystem.
219 * @sb_umount_busy:
220 * Handle a failed umount of the @mnt mounted filesystem, e.g. re-opening
221 * any files that were closed by umount_close. This hook is called during
222 * an umount operation if the umount fails after a call to the
223 * umount_close hook.
224 * @mnt contains the mounted filesystem.
225 * @sb_post_remount:
226 * Update the security module's state when a filesystem is remounted.
227 * This hook is only called if the remount was successful.
228 * @mnt contains the mounted file system.
229 * @flags contains the new filesystem flags.
230 * @data contains the filesystem-specific data.
231 * @sb_post_mountroot:
232 * Update the security module's state when the root filesystem is mounted.
233 * This hook is only called if the mount was successful.
234 * @sb_post_addmount:
235 * Update the security module's state when a filesystem is mounted.
236 * This hook is called any time a mount is successfully grafetd to
237 * the tree.
238 * @mnt contains the mounted filesystem.
239 * @mountpoint_nd contains the nameidata structure for the mount point.
240 * @sb_pivotroot:
241 * Check permission before pivoting the root filesystem.
242 * @old_nd contains the nameidata structure for the new location of the current root (put_old).
243 * @new_nd contains the nameidata structure for the new root (new_root).
244 * Return 0 if permission is granted.
245 * @sb_post_pivotroot:
246 * Update module state after a successful pivot.
247 * @old_nd contains the nameidata structure for the old root.
248 * @new_nd contains the nameidata structure for the new root.
249 *
250 * Security hooks for inode operations.
251 *
252 * @inode_alloc_security:
253 * Allocate and attach a security structure to @inode->i_security. The
254 * i_security field is initialized to NULL when the inode structure is
255 * allocated.
256 * @inode contains the inode structure.
257 * Return 0 if operation was successful.
258 * @inode_free_security:
259 * @inode contains the inode structure.
260 * Deallocate the inode security structure and set @inode->i_security to
261 * NULL.
Stephen Smalley5e41ff92005-09-09 13:01:35 -0700262 * @inode_init_security:
263 * Obtain the security attribute name suffix and value to set on a newly
264 * created inode and set up the incore security field for the new inode.
265 * This hook is called by the fs code as part of the inode creation
266 * transaction and provides for atomic labeling of the inode, unlike
267 * the post_create/mkdir/... hooks called by the VFS. The hook function
268 * is expected to allocate the name and value via kmalloc, with the caller
269 * being responsible for calling kfree after using them.
270 * If the security module does not use security attributes or does
271 * not wish to put a security attribute on this particular inode,
272 * then it should return -EOPNOTSUPP to skip this processing.
273 * @inode contains the inode structure of the newly created inode.
274 * @dir contains the inode structure of the parent directory.
275 * @name will be set to the allocated name suffix (e.g. selinux).
276 * @value will be set to the allocated attribute value.
277 * @len will be set to the length of the value.
278 * Returns 0 if @name and @value have been successfully set,
279 * -EOPNOTSUPP if no security attribute is needed, or
280 * -ENOMEM on memory allocation failure.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281 * @inode_create:
282 * Check permission to create a regular file.
283 * @dir contains inode structure of the parent of the new file.
284 * @dentry contains the dentry structure for the file to be created.
285 * @mode contains the file mode of the file to be created.
286 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287 * @inode_link:
288 * Check permission before creating a new hard link to a file.
289 * @old_dentry contains the dentry structure for an existing link to the file.
290 * @dir contains the inode structure of the parent directory of the new link.
291 * @new_dentry contains the dentry structure for the new link.
292 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293 * @inode_unlink:
294 * Check the permission to remove a hard link to a file.
295 * @dir contains the inode structure of parent directory of the file.
296 * @dentry contains the dentry structure for file to be unlinked.
297 * Return 0 if permission is granted.
298 * @inode_symlink:
299 * Check the permission to create a symbolic link to a file.
300 * @dir contains the inode structure of parent directory of the symbolic link.
301 * @dentry contains the dentry structure of the symbolic link.
302 * @old_name contains the pathname of file.
303 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304 * @inode_mkdir:
305 * Check permissions to create a new directory in the existing directory
306 * associated with inode strcture @dir.
307 * @dir containst the inode structure of parent of the directory to be created.
308 * @dentry contains the dentry structure of new directory.
309 * @mode contains the mode of new directory.
310 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 * @inode_rmdir:
312 * Check the permission to remove a directory.
313 * @dir contains the inode structure of parent of the directory to be removed.
314 * @dentry contains the dentry structure of directory to be removed.
315 * Return 0 if permission is granted.
316 * @inode_mknod:
317 * Check permissions when creating a special file (or a socket or a fifo
318 * file created via the mknod system call). Note that if mknod operation
319 * is being done for a regular file, then the create hook will be called
320 * and not this hook.
321 * @dir contains the inode structure of parent of the new file.
322 * @dentry contains the dentry structure of the new file.
323 * @mode contains the mode of the new file.
324 * @dev contains the the device number.
325 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326 * @inode_rename:
327 * Check for permission to rename a file or directory.
328 * @old_dir contains the inode structure for parent of the old link.
329 * @old_dentry contains the dentry structure of the old link.
330 * @new_dir contains the inode structure for parent of the new link.
331 * @new_dentry contains the dentry structure of the new link.
332 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 * @inode_readlink:
334 * Check the permission to read the symbolic link.
335 * @dentry contains the dentry structure for the file link.
336 * Return 0 if permission is granted.
337 * @inode_follow_link:
338 * Check permission to follow a symbolic link when looking up a pathname.
339 * @dentry contains the dentry structure for the link.
340 * @nd contains the nameidata structure for the parent directory.
341 * Return 0 if permission is granted.
342 * @inode_permission:
343 * Check permission before accessing an inode. This hook is called by the
344 * existing Linux permission function, so a security module can use it to
345 * provide additional checking for existing Linux permission checks.
346 * Notice that this hook is called when a file is opened (as well as many
347 * other operations), whereas the file_security_ops permission hook is
348 * called when the actual read/write operations are performed.
349 * @inode contains the inode structure to check.
350 * @mask contains the permission mask.
351 * @nd contains the nameidata (may be NULL).
352 * Return 0 if permission is granted.
353 * @inode_setattr:
354 * Check permission before setting file attributes. Note that the kernel
355 * call to notify_change is performed from several locations, whenever
356 * file attributes change (such as when a file is truncated, chown/chmod
357 * operations, transferring disk quotas, etc).
358 * @dentry contains the dentry structure for the file.
359 * @attr is the iattr structure containing the new file attributes.
360 * Return 0 if permission is granted.
361 * @inode_getattr:
362 * Check permission before obtaining file attributes.
363 * @mnt is the vfsmount where the dentry was looked up
364 * @dentry contains the dentry structure for the file.
365 * Return 0 if permission is granted.
366 * @inode_delete:
367 * @inode contains the inode structure for deleted inode.
368 * This hook is called when a deleted inode is released (i.e. an inode
369 * with no hard links has its use count drop to zero). A security module
370 * can use this hook to release any persistent label associated with the
371 * inode.
372 * @inode_setxattr:
373 * Check permission before setting the extended attributes
374 * @value identified by @name for @dentry.
375 * Return 0 if permission is granted.
376 * @inode_post_setxattr:
377 * Update inode security field after successful setxattr operation.
378 * @value identified by @name for @dentry.
379 * @inode_getxattr:
380 * Check permission before obtaining the extended attributes
381 * identified by @name for @dentry.
382 * Return 0 if permission is granted.
383 * @inode_listxattr:
384 * Check permission before obtaining the list of extended attribute
385 * names for @dentry.
386 * Return 0 if permission is granted.
387 * @inode_removexattr:
388 * Check permission before removing the extended attribute
389 * identified by @name for @dentry.
390 * Return 0 if permission is granted.
391 * @inode_getsecurity:
392 * Copy the extended attribute representation of the security label
393 * associated with @name for @inode into @buffer. @buffer may be
394 * NULL to request the size of the buffer required. @size indicates
395 * the size of @buffer in bytes. Note that @name is the remainder
396 * of the attribute name after the security. prefix has been removed.
James Morrisd381d8a2005-10-30 14:59:22 -0800397 * @err is the return value from the preceding fs getxattr call,
398 * and can be used by the security module to determine whether it
399 * should try and canonicalize the attribute value.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 * Return number of bytes used/required on success.
401 * @inode_setsecurity:
402 * Set the security label associated with @name for @inode from the
403 * extended attribute value @value. @size indicates the size of the
404 * @value in bytes. @flags may be XATTR_CREATE, XATTR_REPLACE, or 0.
405 * Note that @name is the remainder of the attribute name after the
406 * security. prefix has been removed.
407 * Return 0 on success.
408 * @inode_listsecurity:
409 * Copy the extended attribute names for the security labels
410 * associated with @inode into @buffer. The maximum size of @buffer
411 * is specified by @buffer_size. @buffer may be NULL to request
412 * the size of the buffer required.
413 * Returns number of bytes used/required on success.
414 *
415 * Security hooks for file operations
416 *
417 * @file_permission:
418 * Check file permissions before accessing an open file. This hook is
419 * called by various operations that read or write files. A security
420 * module can use this hook to perform additional checking on these
421 * operations, e.g. to revalidate permissions on use to support privilege
422 * bracketing or policy changes. Notice that this hook is used when the
423 * actual read/write operations are performed, whereas the
424 * inode_security_ops hook is called when a file is opened (as well as
425 * many other operations).
426 * Caveat: Although this hook can be used to revalidate permissions for
427 * various system call operations that read or write files, it does not
428 * address the revalidation of permissions for memory-mapped files.
429 * Security modules must handle this separately if they need such
430 * revalidation.
431 * @file contains the file structure being accessed.
432 * @mask contains the requested permissions.
433 * Return 0 if permission is granted.
434 * @file_alloc_security:
435 * Allocate and attach a security structure to the file->f_security field.
436 * The security field is initialized to NULL when the structure is first
437 * created.
438 * @file contains the file structure to secure.
439 * Return 0 if the hook is successful and permission is granted.
440 * @file_free_security:
441 * Deallocate and free any security structures stored in file->f_security.
442 * @file contains the file structure being modified.
443 * @file_ioctl:
444 * @file contains the file structure.
445 * @cmd contains the operation to perform.
446 * @arg contains the operational arguments.
447 * Check permission for an ioctl operation on @file. Note that @arg can
448 * sometimes represents a user space pointer; in other cases, it may be a
449 * simple integer value. When @arg represents a user space pointer, it
450 * should never be used by the security module.
451 * Return 0 if permission is granted.
452 * @file_mmap :
453 * Check permissions for a mmap operation. The @file may be NULL, e.g.
454 * if mapping anonymous memory.
455 * @file contains the file structure for file to map (may be NULL).
456 * @reqprot contains the protection requested by the application.
457 * @prot contains the protection that will be applied by the kernel.
458 * @flags contains the operational flags.
459 * Return 0 if permission is granted.
460 * @file_mprotect:
461 * Check permissions before changing memory access permissions.
462 * @vma contains the memory region to modify.
463 * @reqprot contains the protection requested by the application.
464 * @prot contains the protection that will be applied by the kernel.
465 * Return 0 if permission is granted.
466 * @file_lock:
467 * Check permission before performing file locking operations.
468 * Note: this hook mediates both flock and fcntl style locks.
469 * @file contains the file structure.
470 * @cmd contains the posix-translated lock operation to perform
471 * (e.g. F_RDLCK, F_WRLCK).
472 * Return 0 if permission is granted.
473 * @file_fcntl:
474 * Check permission before allowing the file operation specified by @cmd
475 * from being performed on the file @file. Note that @arg can sometimes
476 * represents a user space pointer; in other cases, it may be a simple
477 * integer value. When @arg represents a user space pointer, it should
478 * never be used by the security module.
479 * @file contains the file structure.
480 * @cmd contains the operation to be performed.
481 * @arg contains the operational arguments.
482 * Return 0 if permission is granted.
483 * @file_set_fowner:
484 * Save owner security information (typically from current->security) in
485 * file->f_security for later use by the send_sigiotask hook.
486 * @file contains the file structure to update.
487 * Return 0 on success.
488 * @file_send_sigiotask:
489 * Check permission for the file owner @fown to send SIGIO or SIGURG to the
490 * process @tsk. Note that this hook is sometimes called from interrupt.
491 * Note that the fown_struct, @fown, is never outside the context of a
492 * struct file, so the file structure (and associated security information)
493 * can always be obtained:
494 * (struct file *)((long)fown - offsetof(struct file,f_owner));
495 * @tsk contains the structure of task receiving signal.
496 * @fown contains the file owner information.
497 * @sig is the signal that will be sent. When 0, kernel sends SIGIO.
498 * Return 0 if permission is granted.
499 * @file_receive:
500 * This hook allows security modules to control the ability of a process
501 * to receive an open file descriptor via socket IPC.
502 * @file contains the file structure being received.
503 * Return 0 if permission is granted.
504 *
505 * Security hooks for task operations.
506 *
507 * @task_create:
508 * Check permission before creating a child process. See the clone(2)
509 * manual page for definitions of the @clone_flags.
510 * @clone_flags contains the flags indicating what should be shared.
511 * Return 0 if permission is granted.
512 * @task_alloc_security:
513 * @p contains the task_struct for child process.
514 * Allocate and attach a security structure to the p->security field. The
515 * security field is initialized to NULL when the task structure is
516 * allocated.
517 * Return 0 if operation was successful.
518 * @task_free_security:
519 * @p contains the task_struct for process.
520 * Deallocate and clear the p->security field.
521 * @task_setuid:
522 * Check permission before setting one or more of the user identity
523 * attributes of the current process. The @flags parameter indicates
524 * which of the set*uid system calls invoked this hook and how to
525 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
526 * definitions at the beginning of this file for the @flags values and
527 * their meanings.
528 * @id0 contains a uid.
529 * @id1 contains a uid.
530 * @id2 contains a uid.
531 * @flags contains one of the LSM_SETID_* values.
532 * Return 0 if permission is granted.
533 * @task_post_setuid:
534 * Update the module's state after setting one or more of the user
535 * identity attributes of the current process. The @flags parameter
536 * indicates which of the set*uid system calls invoked this hook. If
537 * @flags is LSM_SETID_FS, then @old_ruid is the old fs uid and the other
538 * parameters are not used.
539 * @old_ruid contains the old real uid (or fs uid if LSM_SETID_FS).
540 * @old_euid contains the old effective uid (or -1 if LSM_SETID_FS).
541 * @old_suid contains the old saved uid (or -1 if LSM_SETID_FS).
542 * @flags contains one of the LSM_SETID_* values.
543 * Return 0 on success.
544 * @task_setgid:
545 * Check permission before setting one or more of the group identity
546 * attributes of the current process. The @flags parameter indicates
547 * which of the set*gid system calls invoked this hook and how to
548 * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
549 * definitions at the beginning of this file for the @flags values and
550 * their meanings.
551 * @id0 contains a gid.
552 * @id1 contains a gid.
553 * @id2 contains a gid.
554 * @flags contains one of the LSM_SETID_* values.
555 * Return 0 if permission is granted.
556 * @task_setpgid:
557 * Check permission before setting the process group identifier of the
558 * process @p to @pgid.
559 * @p contains the task_struct for process being modified.
560 * @pgid contains the new pgid.
561 * Return 0 if permission is granted.
562 * @task_getpgid:
563 * Check permission before getting the process group identifier of the
564 * process @p.
565 * @p contains the task_struct for the process.
566 * Return 0 if permission is granted.
567 * @task_getsid:
568 * Check permission before getting the session identifier of the process
569 * @p.
570 * @p contains the task_struct for the process.
571 * Return 0 if permission is granted.
David Quigleyf9008e42006-06-30 01:55:46 -0700572 * @task_getsecid:
573 * Retrieve the security identifier of the process @p.
574 * @p contains the task_struct for the process and place is into @secid.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 * @task_setgroups:
576 * Check permission before setting the supplementary group set of the
577 * current process.
578 * @group_info contains the new group information.
579 * Return 0 if permission is granted.
580 * @task_setnice:
581 * Check permission before setting the nice value of @p to @nice.
582 * @p contains the task_struct of process.
583 * @nice contains the new nice value.
584 * Return 0 if permission is granted.
James Morris03e68062006-06-23 02:03:58 -0700585 * @task_setioprio
586 * Check permission before setting the ioprio value of @p to @ioprio.
587 * @p contains the task_struct of process.
588 * @ioprio contains the new ioprio value
589 * Return 0 if permission is granted.
David Quigleya1836a42006-06-30 01:55:49 -0700590 * @task_getioprio
591 * Check permission before getting the ioprio value of @p.
592 * @p contains the task_struct of process.
593 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 * @task_setrlimit:
595 * Check permission before setting the resource limits of the current
596 * process for @resource to @new_rlim. The old resource limit values can
597 * be examined by dereferencing (current->signal->rlim + resource).
598 * @resource contains the resource whose limit is being set.
599 * @new_rlim contains the new limits for @resource.
600 * Return 0 if permission is granted.
601 * @task_setscheduler:
602 * Check permission before setting scheduling policy and/or parameters of
603 * process @p based on @policy and @lp.
604 * @p contains the task_struct for process.
605 * @policy contains the scheduling policy.
606 * @lp contains the scheduling parameters.
607 * Return 0 if permission is granted.
608 * @task_getscheduler:
609 * Check permission before obtaining scheduling information for process
610 * @p.
611 * @p contains the task_struct for process.
612 * Return 0 if permission is granted.
David Quigley35601542006-06-23 02:04:01 -0700613 * @task_movememory
614 * Check permission before moving memory owned by process @p.
615 * @p contains the task_struct for process.
616 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617 * @task_kill:
618 * Check permission before sending signal @sig to @p. @info can be NULL,
619 * the constant 1, or a pointer to a siginfo structure. If @info is 1 or
620 * SI_FROMKERNEL(info) is true, then the signal should be viewed as coming
621 * from the kernel and should typically be permitted.
622 * SIGIO signals are handled separately by the send_sigiotask hook in
623 * file_security_ops.
624 * @p contains the task_struct for process.
625 * @info contains the signal information.
626 * @sig contains the signal value.
David Quigleyf9008e42006-06-30 01:55:46 -0700627 * @secid contains the sid of the process where the signal originated
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628 * Return 0 if permission is granted.
629 * @task_wait:
630 * Check permission before allowing a process to reap a child process @p
631 * and collect its status information.
632 * @p contains the task_struct for process.
633 * Return 0 if permission is granted.
634 * @task_prctl:
635 * Check permission before performing a process control operation on the
636 * current process.
637 * @option contains the operation.
638 * @arg2 contains a argument.
639 * @arg3 contains a argument.
640 * @arg4 contains a argument.
641 * @arg5 contains a argument.
642 * Return 0 if permission is granted.
643 * @task_reparent_to_init:
644 * Set the security attributes in @p->security for a kernel thread that
645 * is being reparented to the init task.
646 * @p contains the task_struct for the kernel thread.
647 * @task_to_inode:
648 * Set the security attributes for an inode based on an associated task's
649 * security attributes, e.g. for /proc/pid inodes.
650 * @p contains the task_struct for the task.
651 * @inode contains the inode structure for the inode.
652 *
653 * Security hooks for Netlink messaging.
654 *
655 * @netlink_send:
656 * Save security information for a netlink message so that permission
657 * checking can be performed when the message is processed. The security
658 * information can be saved using the eff_cap field of the
659 * netlink_skb_parms structure. Also may be used to provide fine
660 * grained control over message transmission.
661 * @sk associated sock of task sending the message.,
662 * @skb contains the sk_buff structure for the netlink message.
663 * Return 0 if the information was successfully saved and message
664 * is allowed to be transmitted.
665 * @netlink_recv:
666 * Check permission before processing the received netlink message in
667 * @skb.
668 * @skb contains the sk_buff structure for the netlink message.
Darrel Goeddelc7bdb542006-06-27 13:26:11 -0700669 * @cap indicates the capability required
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670 * Return 0 if permission is granted.
671 *
672 * Security hooks for Unix domain networking.
673 *
674 * @unix_stream_connect:
675 * Check permissions before establishing a Unix domain stream connection
676 * between @sock and @other.
677 * @sock contains the socket structure.
678 * @other contains the peer socket structure.
679 * Return 0 if permission is granted.
680 * @unix_may_send:
681 * Check permissions before connecting or sending datagrams from @sock to
682 * @other.
683 * @sock contains the socket structure.
684 * @sock contains the peer socket structure.
685 * Return 0 if permission is granted.
686 *
687 * The @unix_stream_connect and @unix_may_send hooks were necessary because
688 * Linux provides an alternative to the conventional file name space for Unix
689 * domain sockets. Whereas binding and connecting to sockets in the file name
690 * space is mediated by the typical file permissions (and caught by the mknod
691 * and permission hooks in inode_security_ops), binding and connecting to
692 * sockets in the abstract name space is completely unmediated. Sufficient
693 * control of Unix domain sockets in the abstract name space isn't possible
694 * using only the socket layer hooks, since we need to know the actual target
695 * socket, which is not looked up until we are inside the af_unix code.
696 *
697 * Security hooks for socket operations.
698 *
699 * @socket_create:
700 * Check permissions prior to creating a new socket.
701 * @family contains the requested protocol family.
702 * @type contains the requested communications type.
703 * @protocol contains the requested protocol.
704 * @kern set to 1 if a kernel socket.
705 * Return 0 if permission is granted.
706 * @socket_post_create:
707 * This hook allows a module to update or allocate a per-socket security
708 * structure. Note that the security field was not added directly to the
709 * socket structure, but rather, the socket security information is stored
710 * in the associated inode. Typically, the inode alloc_security hook will
711 * allocate and and attach security information to
712 * sock->inode->i_security. This hook may be used to update the
713 * sock->inode->i_security field with additional information that wasn't
714 * available when the inode was allocated.
715 * @sock contains the newly created socket structure.
716 * @family contains the requested protocol family.
717 * @type contains the requested communications type.
718 * @protocol contains the requested protocol.
719 * @kern set to 1 if a kernel socket.
720 * @socket_bind:
721 * Check permission before socket protocol layer bind operation is
722 * performed and the socket @sock is bound to the address specified in the
723 * @address parameter.
724 * @sock contains the socket structure.
725 * @address contains the address to bind to.
726 * @addrlen contains the length of address.
727 * Return 0 if permission is granted.
728 * @socket_connect:
729 * Check permission before socket protocol layer connect operation
730 * attempts to connect socket @sock to a remote address, @address.
731 * @sock contains the socket structure.
732 * @address contains the address of remote endpoint.
733 * @addrlen contains the length of address.
734 * Return 0 if permission is granted.
735 * @socket_listen:
736 * Check permission before socket protocol layer listen operation.
737 * @sock contains the socket structure.
738 * @backlog contains the maximum length for the pending connection queue.
739 * Return 0 if permission is granted.
740 * @socket_accept:
741 * Check permission before accepting a new connection. Note that the new
742 * socket, @newsock, has been created and some information copied to it,
743 * but the accept operation has not actually been performed.
744 * @sock contains the listening socket structure.
745 * @newsock contains the newly created server socket for connection.
746 * Return 0 if permission is granted.
747 * @socket_post_accept:
748 * This hook allows a security module to copy security
749 * information into the newly created socket's inode.
750 * @sock contains the listening socket structure.
751 * @newsock contains the newly created server socket for connection.
752 * @socket_sendmsg:
753 * Check permission before transmitting a message to another socket.
754 * @sock contains the socket structure.
755 * @msg contains the message to be transmitted.
756 * @size contains the size of message.
757 * Return 0 if permission is granted.
758 * @socket_recvmsg:
759 * Check permission before receiving a message from a socket.
760 * @sock contains the socket structure.
761 * @msg contains the message structure.
762 * @size contains the size of message structure.
763 * @flags contains the operational flags.
764 * Return 0 if permission is granted.
765 * @socket_getsockname:
766 * Check permission before the local address (name) of the socket object
767 * @sock is retrieved.
768 * @sock contains the socket structure.
769 * Return 0 if permission is granted.
770 * @socket_getpeername:
771 * Check permission before the remote address (name) of a socket object
772 * @sock is retrieved.
773 * @sock contains the socket structure.
774 * Return 0 if permission is granted.
775 * @socket_getsockopt:
776 * Check permissions before retrieving the options associated with socket
777 * @sock.
778 * @sock contains the socket structure.
779 * @level contains the protocol level to retrieve option from.
780 * @optname contains the name of option to retrieve.
781 * Return 0 if permission is granted.
782 * @socket_setsockopt:
783 * Check permissions before setting the options associated with socket
784 * @sock.
785 * @sock contains the socket structure.
786 * @level contains the protocol level to set options for.
787 * @optname contains the name of the option to set.
788 * Return 0 if permission is granted.
789 * @socket_shutdown:
790 * Checks permission before all or part of a connection on the socket
791 * @sock is shut down.
792 * @sock contains the socket structure.
793 * @how contains the flag indicating how future sends and receives are handled.
794 * Return 0 if permission is granted.
795 * @socket_sock_rcv_skb:
796 * Check permissions on incoming network packets. This hook is distinct
797 * from Netfilter's IP input hooks since it is the first time that the
798 * incoming sk_buff @skb has been associated with a particular socket, @sk.
799 * @sk contains the sock (not socket) associated with the incoming sk_buff.
800 * @skb contains the incoming network data.
801 * @socket_getpeersec:
802 * This hook allows the security module to provide peer socket security
803 * state to userspace via getsockopt SO_GETPEERSEC.
804 * @sock is the local socket.
805 * @optval userspace memory where the security state is to be copied.
806 * @optlen userspace int where the module should copy the actual length
807 * of the security state.
808 * @len as input is the maximum length to copy to userspace provided
809 * by the caller.
810 * Return 0 if all is well, otherwise, typical getsockopt return
811 * values.
812 * @sk_alloc_security:
813 * Allocate and attach a security structure to the sk->sk_security field,
814 * which is used to copy security attributes between local stream sockets.
815 * @sk_free_security:
816 * Deallocate security structure.
Venkat Yekkirala892c1412006-08-04 23:08:56 -0700817 * @sk_clone_security:
818 * Clone/copy security structure.
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -0700819 * @sk_getsecid:
820 * Retrieve the LSM-specific secid for the sock to enable caching of network
Trent Jaegerdf718372005-12-13 23:12:27 -0800821 * authorizations.
822 *
823 * Security hooks for XFRM operations.
824 *
825 * @xfrm_policy_alloc_security:
826 * @xp contains the xfrm_policy being added to Security Policy Database
827 * used by the XFRM system.
828 * @sec_ctx contains the security context information being provided by
829 * the user-level policy update program (e.g., setkey).
Venkat Yekkiralacb969f02006-07-24 23:32:20 -0700830 * @sk refers to the sock from which to derive the security context.
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700831 * Allocate a security structure to the xp->security field; the security
Venkat Yekkiralacb969f02006-07-24 23:32:20 -0700832 * field is initialized to NULL when the xfrm_policy is allocated. Only
833 * one of sec_ctx or sock can be specified.
Trent Jaegerdf718372005-12-13 23:12:27 -0800834 * Return 0 if operation was successful (memory to allocate, legal context)
835 * @xfrm_policy_clone_security:
836 * @old contains an existing xfrm_policy in the SPD.
837 * @new contains a new xfrm_policy being cloned from old.
Catherine Zhangc8c05a82006-06-08 23:39:49 -0700838 * Allocate a security structure to the new->security field
839 * that contains the information from the old->security field.
Trent Jaegerdf718372005-12-13 23:12:27 -0800840 * Return 0 if operation was successful (memory to allocate).
841 * @xfrm_policy_free_security:
842 * @xp contains the xfrm_policy
Catherine Zhangc8c05a82006-06-08 23:39:49 -0700843 * Deallocate xp->security.
844 * @xfrm_policy_delete_security:
845 * @xp contains the xfrm_policy.
846 * Authorize deletion of xp->security.
Trent Jaegerdf718372005-12-13 23:12:27 -0800847 * @xfrm_state_alloc_security:
848 * @x contains the xfrm_state being added to the Security Association
849 * Database by the XFRM system.
850 * @sec_ctx contains the security context information being provided by
851 * the user-level SA generation program (e.g., setkey or racoon).
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700852 * @polsec contains the security context information associated with a xfrm
853 * policy rule from which to take the base context. polsec must be NULL
854 * when sec_ctx is specified.
855 * @secid contains the secid from which to take the mls portion of the context.
856 * Allocate a security structure to the x->security field; the security
857 * field is initialized to NULL when the xfrm_state is allocated. Set the
858 * context to correspond to either sec_ctx or polsec, with the mls portion
859 * taken from secid in the latter case.
Trent Jaegerdf718372005-12-13 23:12:27 -0800860 * Return 0 if operation was successful (memory to allocate, legal context).
861 * @xfrm_state_free_security:
862 * @x contains the xfrm_state.
Catherine Zhangc8c05a82006-06-08 23:39:49 -0700863 * Deallocate x->security.
864 * @xfrm_state_delete_security:
865 * @x contains the xfrm_state.
866 * Authorize deletion of x->security.
Trent Jaegerdf718372005-12-13 23:12:27 -0800867 * @xfrm_policy_lookup:
868 * @xp contains the xfrm_policy for which the access control is being
869 * checked.
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700870 * @fl_secid contains the flow security label that is used to authorize
Trent Jaegerdf718372005-12-13 23:12:27 -0800871 * access to the policy xp.
872 * @dir contains the direction of the flow (input or output).
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700873 * Check permission when a flow selects a xfrm_policy for processing
Trent Jaegerdf718372005-12-13 23:12:27 -0800874 * XFRMs on a packet. The hook is called when selecting either a
875 * per-socket policy or a generic xfrm policy.
876 * Return 0 if permission is granted.
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -0700877 * @xfrm_state_pol_flow_match:
878 * @x contains the state to match.
879 * @xp contains the policy to check for a match.
880 * @fl contains the flow to check for a match.
881 * Return 1 if there is a match.
882 * @xfrm_flow_state_match:
883 * @fl contains the flow key to match.
884 * @xfrm points to the xfrm_state to match.
885 * Return 1 if there is a match.
886 * @xfrm_decode_session:
887 * @skb points to skb to decode.
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -0700888 * @secid points to the flow key secid to set.
889 * @ckall says if all xfrms used should be checked for same secid.
890 * Return 0 if ckall is zero or all xfrms used have the same secid.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700891 *
David Howells29db9192005-10-30 15:02:44 -0800892 * Security hooks affecting all Key Management operations
893 *
894 * @key_alloc:
895 * Permit allocation of a key and assign security data. Note that key does
896 * not have a serial number assigned at this point.
897 * @key points to the key.
David Howells7e047ef2006-06-26 00:24:50 -0700898 * @flags is the allocation flags
David Howells29db9192005-10-30 15:02:44 -0800899 * Return 0 if permission is granted, -ve error otherwise.
900 * @key_free:
901 * Notification of destruction; free security data.
902 * @key points to the key.
903 * No return value.
904 * @key_permission:
905 * See whether a specific operational right is granted to a process on a
906 * key.
907 * @key_ref refers to the key (key pointer + possession attribute bit).
908 * @context points to the process to provide the context against which to
909 * evaluate the security data on the key.
910 * @perm describes the combination of permissions required of this key.
911 * Return 1 if permission granted, 0 if permission denied and -ve it the
912 * normal permissions model should be effected.
913 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700914 * Security hooks affecting all System V IPC operations.
915 *
916 * @ipc_permission:
917 * Check permissions for access to IPC
918 * @ipcp contains the kernel IPC permission structure
919 * @flag contains the desired (requested) permission set
920 * Return 0 if permission is granted.
921 *
922 * Security hooks for individual messages held in System V IPC message queues
923 * @msg_msg_alloc_security:
924 * Allocate and attach a security structure to the msg->security field.
925 * The security field is initialized to NULL when the structure is first
926 * created.
927 * @msg contains the message structure to be modified.
928 * Return 0 if operation was successful and permission is granted.
929 * @msg_msg_free_security:
930 * Deallocate the security structure for this message.
931 * @msg contains the message structure to be modified.
932 *
933 * Security hooks for System V IPC Message Queues
934 *
935 * @msg_queue_alloc_security:
936 * Allocate and attach a security structure to the
937 * msq->q_perm.security field. The security field is initialized to
938 * NULL when the structure is first created.
939 * @msq contains the message queue structure to be modified.
940 * Return 0 if operation was successful and permission is granted.
941 * @msg_queue_free_security:
942 * Deallocate security structure for this message queue.
943 * @msq contains the message queue structure to be modified.
944 * @msg_queue_associate:
945 * Check permission when a message queue is requested through the
946 * msgget system call. This hook is only called when returning the
947 * message queue identifier for an existing message queue, not when a
948 * new message queue is created.
949 * @msq contains the message queue to act upon.
950 * @msqflg contains the operation control flags.
951 * Return 0 if permission is granted.
952 * @msg_queue_msgctl:
953 * Check permission when a message control operation specified by @cmd
954 * is to be performed on the message queue @msq.
955 * The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO.
956 * @msq contains the message queue to act upon. May be NULL.
957 * @cmd contains the operation to be performed.
958 * Return 0 if permission is granted.
959 * @msg_queue_msgsnd:
960 * Check permission before a message, @msg, is enqueued on the message
961 * queue, @msq.
962 * @msq contains the message queue to send message to.
963 * @msg contains the message to be enqueued.
964 * @msqflg contains operational flags.
965 * Return 0 if permission is granted.
966 * @msg_queue_msgrcv:
967 * Check permission before a message, @msg, is removed from the message
968 * queue, @msq. The @target task structure contains a pointer to the
969 * process that will be receiving the message (not equal to the current
970 * process when inline receives are being performed).
971 * @msq contains the message queue to retrieve message from.
972 * @msg contains the message destination.
973 * @target contains the task structure for recipient process.
974 * @type contains the type of message requested.
975 * @mode contains the operational flags.
976 * Return 0 if permission is granted.
977 *
978 * Security hooks for System V Shared Memory Segments
979 *
980 * @shm_alloc_security:
981 * Allocate and attach a security structure to the shp->shm_perm.security
982 * field. The security field is initialized to NULL when the structure is
983 * first created.
984 * @shp contains the shared memory structure to be modified.
985 * Return 0 if operation was successful and permission is granted.
986 * @shm_free_security:
987 * Deallocate the security struct for this memory segment.
988 * @shp contains the shared memory structure to be modified.
989 * @shm_associate:
990 * Check permission when a shared memory region is requested through the
991 * shmget system call. This hook is only called when returning the shared
992 * memory region identifier for an existing region, not when a new shared
993 * memory region is created.
994 * @shp contains the shared memory structure to be modified.
995 * @shmflg contains the operation control flags.
996 * Return 0 if permission is granted.
997 * @shm_shmctl:
998 * Check permission when a shared memory control operation specified by
999 * @cmd is to be performed on the shared memory region @shp.
1000 * The @shp may be NULL, e.g. for IPC_INFO or SHM_INFO.
1001 * @shp contains shared memory structure to be modified.
1002 * @cmd contains the operation to be performed.
1003 * Return 0 if permission is granted.
1004 * @shm_shmat:
1005 * Check permissions prior to allowing the shmat system call to attach the
1006 * shared memory segment @shp to the data segment of the calling process.
1007 * The attaching address is specified by @shmaddr.
1008 * @shp contains the shared memory structure to be modified.
1009 * @shmaddr contains the address to attach memory region to.
1010 * @shmflg contains the operational flags.
1011 * Return 0 if permission is granted.
1012 *
1013 * Security hooks for System V Semaphores
1014 *
1015 * @sem_alloc_security:
1016 * Allocate and attach a security structure to the sma->sem_perm.security
1017 * field. The security field is initialized to NULL when the structure is
1018 * first created.
1019 * @sma contains the semaphore structure
1020 * Return 0 if operation was successful and permission is granted.
1021 * @sem_free_security:
1022 * deallocate security struct for this semaphore
1023 * @sma contains the semaphore structure.
1024 * @sem_associate:
1025 * Check permission when a semaphore is requested through the semget
1026 * system call. This hook is only called when returning the semaphore
1027 * identifier for an existing semaphore, not when a new one must be
1028 * created.
1029 * @sma contains the semaphore structure.
1030 * @semflg contains the operation control flags.
1031 * Return 0 if permission is granted.
1032 * @sem_semctl:
1033 * Check permission when a semaphore operation specified by @cmd is to be
1034 * performed on the semaphore @sma. The @sma may be NULL, e.g. for
1035 * IPC_INFO or SEM_INFO.
1036 * @sma contains the semaphore structure. May be NULL.
1037 * @cmd contains the operation to be performed.
1038 * Return 0 if permission is granted.
1039 * @sem_semop
1040 * Check permissions before performing operations on members of the
1041 * semaphore set @sma. If the @alter flag is nonzero, the semaphore set
1042 * may be modified.
1043 * @sma contains the semaphore structure.
1044 * @sops contains the operations to perform.
1045 * @nsops contains the number of operations to perform.
1046 * @alter contains the flag indicating whether changes are to be made.
1047 * Return 0 if permission is granted.
1048 *
1049 * @ptrace:
1050 * Check permission before allowing the @parent process to trace the
1051 * @child process.
1052 * Security modules may also want to perform a process tracing check
1053 * during an execve in the set_security or apply_creds hooks of
1054 * binprm_security_ops if the process is being traced and its security
1055 * attributes would be changed by the execve.
1056 * @parent contains the task_struct structure for parent process.
1057 * @child contains the task_struct structure for child process.
1058 * Return 0 if permission is granted.
1059 * @capget:
1060 * Get the @effective, @inheritable, and @permitted capability sets for
1061 * the @target process. The hook may also perform permission checking to
1062 * determine if the current process is allowed to see the capability sets
1063 * of the @target process.
1064 * @target contains the task_struct structure for target process.
1065 * @effective contains the effective capability set.
1066 * @inheritable contains the inheritable capability set.
1067 * @permitted contains the permitted capability set.
1068 * Return 0 if the capability sets were successfully obtained.
1069 * @capset_check:
1070 * Check permission before setting the @effective, @inheritable, and
1071 * @permitted capability sets for the @target process.
1072 * Caveat: @target is also set to current if a set of processes is
1073 * specified (i.e. all processes other than current and init or a
1074 * particular process group). Hence, the capset_set hook may need to
1075 * revalidate permission to the actual target process.
1076 * @target contains the task_struct structure for target process.
1077 * @effective contains the effective capability set.
1078 * @inheritable contains the inheritable capability set.
1079 * @permitted contains the permitted capability set.
1080 * Return 0 if permission is granted.
1081 * @capset_set:
1082 * Set the @effective, @inheritable, and @permitted capability sets for
1083 * the @target process. Since capset_check cannot always check permission
1084 * to the real @target process, this hook may also perform permission
1085 * checking to determine if the current process is allowed to set the
1086 * capability sets of the @target process. However, this hook has no way
1087 * of returning an error due to the structure of the sys_capset code.
1088 * @target contains the task_struct structure for target process.
1089 * @effective contains the effective capability set.
1090 * @inheritable contains the inheritable capability set.
1091 * @permitted contains the permitted capability set.
Chris Wright12b59892006-03-25 03:07:41 -08001092 * @capable:
1093 * Check whether the @tsk process has the @cap capability.
1094 * @tsk contains the task_struct for the process.
1095 * @cap contains the capability <include/linux/capability.h>.
1096 * Return 0 if the capability is granted for @tsk.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001097 * @acct:
1098 * Check permission before enabling or disabling process accounting. If
1099 * accounting is being enabled, then @file refers to the open file used to
1100 * store accounting records. If accounting is being disabled, then @file
1101 * is NULL.
1102 * @file contains the file structure for the accounting file (may be NULL).
1103 * Return 0 if permission is granted.
1104 * @sysctl:
1105 * Check permission before accessing the @table sysctl variable in the
1106 * manner specified by @op.
1107 * @table contains the ctl_table structure for the sysctl variable.
1108 * @op contains the operation (001 = search, 002 = write, 004 = read).
1109 * Return 0 if permission is granted.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001110 * @syslog:
1111 * Check permission before accessing the kernel message ring or changing
1112 * logging to the console.
1113 * See the syslog(2) manual page for an explanation of the @type values.
1114 * @type contains the type of action.
1115 * Return 0 if permission is granted.
1116 * @settime:
1117 * Check permission to change the system time.
1118 * struct timespec and timezone are defined in include/linux/time.h
1119 * @ts contains new time
1120 * @tz contains new timezone
1121 * Return 0 if permission is granted.
1122 * @vm_enough_memory:
1123 * Check permissions for allocating a new virtual mapping.
1124 * @pages contains the number of pages.
1125 * Return 0 if permission is granted.
1126 *
1127 * @register_security:
1128 * allow module stacking.
1129 * @name contains the name of the security module being stacked.
1130 * @ops contains a pointer to the struct security_operations of the module to stack.
1131 * @unregister_security:
1132 * remove a stacked module.
1133 * @name contains the name of the security module being unstacked.
1134 * @ops contains a pointer to the struct security_operations of the module to unstack.
1135 *
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07001136 * @secid_to_secctx:
1137 * Convert secid to security context.
1138 * @secid contains the security ID.
1139 * @secdata contains the pointer that stores the converted security context.
1140 *
1141 * @release_secctx:
1142 * Release the security context.
1143 * @secdata contains the security context.
1144 * @seclen contains the length of the security context.
1145 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001146 * This is the main security structure.
1147 */
1148struct security_operations {
1149 int (*ptrace) (struct task_struct * parent, struct task_struct * child);
1150 int (*capget) (struct task_struct * target,
1151 kernel_cap_t * effective,
1152 kernel_cap_t * inheritable, kernel_cap_t * permitted);
1153 int (*capset_check) (struct task_struct * target,
1154 kernel_cap_t * effective,
1155 kernel_cap_t * inheritable,
1156 kernel_cap_t * permitted);
1157 void (*capset_set) (struct task_struct * target,
1158 kernel_cap_t * effective,
1159 kernel_cap_t * inheritable,
1160 kernel_cap_t * permitted);
Chris Wright12b59892006-03-25 03:07:41 -08001161 int (*capable) (struct task_struct * tsk, int cap);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001162 int (*acct) (struct file * file);
1163 int (*sysctl) (struct ctl_table * table, int op);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001164 int (*quotactl) (int cmds, int type, int id, struct super_block * sb);
1165 int (*quota_on) (struct dentry * dentry);
1166 int (*syslog) (int type);
1167 int (*settime) (struct timespec *ts, struct timezone *tz);
1168 int (*vm_enough_memory) (long pages);
1169
1170 int (*bprm_alloc_security) (struct linux_binprm * bprm);
1171 void (*bprm_free_security) (struct linux_binprm * bprm);
1172 void (*bprm_apply_creds) (struct linux_binprm * bprm, int unsafe);
1173 void (*bprm_post_apply_creds) (struct linux_binprm * bprm);
1174 int (*bprm_set_security) (struct linux_binprm * bprm);
1175 int (*bprm_check_security) (struct linux_binprm * bprm);
1176 int (*bprm_secureexec) (struct linux_binprm * bprm);
1177
1178 int (*sb_alloc_security) (struct super_block * sb);
1179 void (*sb_free_security) (struct super_block * sb);
1180 int (*sb_copy_data)(struct file_system_type *type,
1181 void *orig, void *copy);
1182 int (*sb_kern_mount) (struct super_block *sb, void *data);
David Howells726c3342006-06-23 02:02:58 -07001183 int (*sb_statfs) (struct dentry *dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001184 int (*sb_mount) (char *dev_name, struct nameidata * nd,
1185 char *type, unsigned long flags, void *data);
1186 int (*sb_check_sb) (struct vfsmount * mnt, struct nameidata * nd);
1187 int (*sb_umount) (struct vfsmount * mnt, int flags);
1188 void (*sb_umount_close) (struct vfsmount * mnt);
1189 void (*sb_umount_busy) (struct vfsmount * mnt);
1190 void (*sb_post_remount) (struct vfsmount * mnt,
1191 unsigned long flags, void *data);
1192 void (*sb_post_mountroot) (void);
1193 void (*sb_post_addmount) (struct vfsmount * mnt,
1194 struct nameidata * mountpoint_nd);
1195 int (*sb_pivotroot) (struct nameidata * old_nd,
1196 struct nameidata * new_nd);
1197 void (*sb_post_pivotroot) (struct nameidata * old_nd,
1198 struct nameidata * new_nd);
1199
1200 int (*inode_alloc_security) (struct inode *inode);
1201 void (*inode_free_security) (struct inode *inode);
Stephen Smalley5e41ff92005-09-09 13:01:35 -07001202 int (*inode_init_security) (struct inode *inode, struct inode *dir,
1203 char **name, void **value, size_t *len);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001204 int (*inode_create) (struct inode *dir,
1205 struct dentry *dentry, int mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001206 int (*inode_link) (struct dentry *old_dentry,
1207 struct inode *dir, struct dentry *new_dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001208 int (*inode_unlink) (struct inode *dir, struct dentry *dentry);
1209 int (*inode_symlink) (struct inode *dir,
1210 struct dentry *dentry, const char *old_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001211 int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001212 int (*inode_rmdir) (struct inode *dir, struct dentry *dentry);
1213 int (*inode_mknod) (struct inode *dir, struct dentry *dentry,
1214 int mode, dev_t dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001215 int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
1216 struct inode *new_dir, struct dentry *new_dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001217 int (*inode_readlink) (struct dentry *dentry);
1218 int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
1219 int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd);
1220 int (*inode_setattr) (struct dentry *dentry, struct iattr *attr);
1221 int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
1222 void (*inode_delete) (struct inode *inode);
1223 int (*inode_setxattr) (struct dentry *dentry, char *name, void *value,
1224 size_t size, int flags);
1225 void (*inode_post_setxattr) (struct dentry *dentry, char *name, void *value,
1226 size_t size, int flags);
1227 int (*inode_getxattr) (struct dentry *dentry, char *name);
1228 int (*inode_listxattr) (struct dentry *dentry);
1229 int (*inode_removexattr) (struct dentry *dentry, char *name);
Dustin Kirkland7306a0b2005-11-16 15:53:13 +00001230 const char *(*inode_xattr_getsuffix) (void);
1231 int (*inode_getsecurity)(const struct inode *inode, const char *name, void *buffer, size_t size, int err);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001232 int (*inode_setsecurity)(struct inode *inode, const char *name, const void *value, size_t size, int flags);
1233 int (*inode_listsecurity)(struct inode *inode, char *buffer, size_t buffer_size);
1234
1235 int (*file_permission) (struct file * file, int mask);
1236 int (*file_alloc_security) (struct file * file);
1237 void (*file_free_security) (struct file * file);
1238 int (*file_ioctl) (struct file * file, unsigned int cmd,
1239 unsigned long arg);
1240 int (*file_mmap) (struct file * file,
1241 unsigned long reqprot,
1242 unsigned long prot, unsigned long flags);
1243 int (*file_mprotect) (struct vm_area_struct * vma,
1244 unsigned long reqprot,
1245 unsigned long prot);
1246 int (*file_lock) (struct file * file, unsigned int cmd);
1247 int (*file_fcntl) (struct file * file, unsigned int cmd,
1248 unsigned long arg);
1249 int (*file_set_fowner) (struct file * file);
1250 int (*file_send_sigiotask) (struct task_struct * tsk,
1251 struct fown_struct * fown, int sig);
1252 int (*file_receive) (struct file * file);
1253
1254 int (*task_create) (unsigned long clone_flags);
1255 int (*task_alloc_security) (struct task_struct * p);
1256 void (*task_free_security) (struct task_struct * p);
1257 int (*task_setuid) (uid_t id0, uid_t id1, uid_t id2, int flags);
1258 int (*task_post_setuid) (uid_t old_ruid /* or fsuid */ ,
1259 uid_t old_euid, uid_t old_suid, int flags);
1260 int (*task_setgid) (gid_t id0, gid_t id1, gid_t id2, int flags);
1261 int (*task_setpgid) (struct task_struct * p, pid_t pgid);
1262 int (*task_getpgid) (struct task_struct * p);
1263 int (*task_getsid) (struct task_struct * p);
David Quigleyf9008e42006-06-30 01:55:46 -07001264 void (*task_getsecid) (struct task_struct * p, u32 * secid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001265 int (*task_setgroups) (struct group_info *group_info);
1266 int (*task_setnice) (struct task_struct * p, int nice);
James Morris03e68062006-06-23 02:03:58 -07001267 int (*task_setioprio) (struct task_struct * p, int ioprio);
David Quigleya1836a42006-06-30 01:55:49 -07001268 int (*task_getioprio) (struct task_struct * p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001269 int (*task_setrlimit) (unsigned int resource, struct rlimit * new_rlim);
1270 int (*task_setscheduler) (struct task_struct * p, int policy,
1271 struct sched_param * lp);
1272 int (*task_getscheduler) (struct task_struct * p);
David Quigley35601542006-06-23 02:04:01 -07001273 int (*task_movememory) (struct task_struct * p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001274 int (*task_kill) (struct task_struct * p,
David Quigleyf9008e42006-06-30 01:55:46 -07001275 struct siginfo * info, int sig, u32 secid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001276 int (*task_wait) (struct task_struct * p);
1277 int (*task_prctl) (int option, unsigned long arg2,
1278 unsigned long arg3, unsigned long arg4,
1279 unsigned long arg5);
1280 void (*task_reparent_to_init) (struct task_struct * p);
1281 void (*task_to_inode)(struct task_struct *p, struct inode *inode);
1282
1283 int (*ipc_permission) (struct kern_ipc_perm * ipcp, short flag);
1284
1285 int (*msg_msg_alloc_security) (struct msg_msg * msg);
1286 void (*msg_msg_free_security) (struct msg_msg * msg);
1287
1288 int (*msg_queue_alloc_security) (struct msg_queue * msq);
1289 void (*msg_queue_free_security) (struct msg_queue * msq);
1290 int (*msg_queue_associate) (struct msg_queue * msq, int msqflg);
1291 int (*msg_queue_msgctl) (struct msg_queue * msq, int cmd);
1292 int (*msg_queue_msgsnd) (struct msg_queue * msq,
1293 struct msg_msg * msg, int msqflg);
1294 int (*msg_queue_msgrcv) (struct msg_queue * msq,
1295 struct msg_msg * msg,
1296 struct task_struct * target,
1297 long type, int mode);
1298
1299 int (*shm_alloc_security) (struct shmid_kernel * shp);
1300 void (*shm_free_security) (struct shmid_kernel * shp);
1301 int (*shm_associate) (struct shmid_kernel * shp, int shmflg);
1302 int (*shm_shmctl) (struct shmid_kernel * shp, int cmd);
1303 int (*shm_shmat) (struct shmid_kernel * shp,
1304 char __user *shmaddr, int shmflg);
1305
1306 int (*sem_alloc_security) (struct sem_array * sma);
1307 void (*sem_free_security) (struct sem_array * sma);
1308 int (*sem_associate) (struct sem_array * sma, int semflg);
1309 int (*sem_semctl) (struct sem_array * sma, int cmd);
1310 int (*sem_semop) (struct sem_array * sma,
1311 struct sembuf * sops, unsigned nsops, int alter);
1312
1313 int (*netlink_send) (struct sock * sk, struct sk_buff * skb);
Darrel Goeddelc7bdb542006-06-27 13:26:11 -07001314 int (*netlink_recv) (struct sk_buff * skb, int cap);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001315
1316 /* allow module stacking */
1317 int (*register_security) (const char *name,
1318 struct security_operations *ops);
1319 int (*unregister_security) (const char *name,
1320 struct security_operations *ops);
1321
1322 void (*d_instantiate) (struct dentry *dentry, struct inode *inode);
1323
1324 int (*getprocattr)(struct task_struct *p, char *name, void *value, size_t size);
1325 int (*setprocattr)(struct task_struct *p, char *name, void *value, size_t size);
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07001326 int (*secid_to_secctx)(u32 secid, char **secdata, u32 *seclen);
1327 void (*release_secctx)(char *secdata, u32 seclen);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001328
1329#ifdef CONFIG_SECURITY_NETWORK
1330 int (*unix_stream_connect) (struct socket * sock,
1331 struct socket * other, struct sock * newsk);
1332 int (*unix_may_send) (struct socket * sock, struct socket * other);
1333
1334 int (*socket_create) (int family, int type, int protocol, int kern);
1335 void (*socket_post_create) (struct socket * sock, int family,
1336 int type, int protocol, int kern);
1337 int (*socket_bind) (struct socket * sock,
1338 struct sockaddr * address, int addrlen);
1339 int (*socket_connect) (struct socket * sock,
1340 struct sockaddr * address, int addrlen);
1341 int (*socket_listen) (struct socket * sock, int backlog);
1342 int (*socket_accept) (struct socket * sock, struct socket * newsock);
1343 void (*socket_post_accept) (struct socket * sock,
1344 struct socket * newsock);
1345 int (*socket_sendmsg) (struct socket * sock,
1346 struct msghdr * msg, int size);
1347 int (*socket_recvmsg) (struct socket * sock,
1348 struct msghdr * msg, int size, int flags);
1349 int (*socket_getsockname) (struct socket * sock);
1350 int (*socket_getpeername) (struct socket * sock);
1351 int (*socket_getsockopt) (struct socket * sock, int level, int optname);
1352 int (*socket_setsockopt) (struct socket * sock, int level, int optname);
1353 int (*socket_shutdown) (struct socket * sock, int how);
1354 int (*socket_sock_rcv_skb) (struct sock * sk, struct sk_buff * skb);
Catherine Zhang2c7946a2006-03-20 22:41:23 -08001355 int (*socket_getpeersec_stream) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len);
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07001356 int (*socket_getpeersec_dgram) (struct socket *sock, struct sk_buff *skb, u32 *secid);
Al Viro7d877f32005-10-21 03:20:43 -04001357 int (*sk_alloc_security) (struct sock *sk, int family, gfp_t priority);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001358 void (*sk_free_security) (struct sock *sk);
Venkat Yekkirala892c1412006-08-04 23:08:56 -07001359 void (*sk_clone_security) (const struct sock *sk, struct sock *newsk);
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07001360 void (*sk_getsecid) (struct sock *sk, u32 *secid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001361#endif /* CONFIG_SECURITY_NETWORK */
David Howells29db9192005-10-30 15:02:44 -08001362
Trent Jaegerdf718372005-12-13 23:12:27 -08001363#ifdef CONFIG_SECURITY_NETWORK_XFRM
Venkat Yekkiralacb969f02006-07-24 23:32:20 -07001364 int (*xfrm_policy_alloc_security) (struct xfrm_policy *xp,
1365 struct xfrm_user_sec_ctx *sec_ctx, struct sock *sk);
Trent Jaegerdf718372005-12-13 23:12:27 -08001366 int (*xfrm_policy_clone_security) (struct xfrm_policy *old, struct xfrm_policy *new);
1367 void (*xfrm_policy_free_security) (struct xfrm_policy *xp);
Catherine Zhangc8c05a82006-06-08 23:39:49 -07001368 int (*xfrm_policy_delete_security) (struct xfrm_policy *xp);
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07001369 int (*xfrm_state_alloc_security) (struct xfrm_state *x,
1370 struct xfrm_user_sec_ctx *sec_ctx, struct xfrm_sec_ctx *polsec,
1371 u32 secid);
Trent Jaegerdf718372005-12-13 23:12:27 -08001372 void (*xfrm_state_free_security) (struct xfrm_state *x);
Catherine Zhangc8c05a82006-06-08 23:39:49 -07001373 int (*xfrm_state_delete_security) (struct xfrm_state *x);
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07001374 int (*xfrm_policy_lookup)(struct xfrm_policy *xp, u32 fl_secid, u8 dir);
1375 int (*xfrm_state_pol_flow_match)(struct xfrm_state *x,
1376 struct xfrm_policy *xp, struct flowi *fl);
1377 int (*xfrm_flow_state_match)(struct flowi *fl, struct xfrm_state *xfrm);
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07001378 int (*xfrm_decode_session)(struct sk_buff *skb, u32 *secid, int ckall);
Trent Jaegerdf718372005-12-13 23:12:27 -08001379#endif /* CONFIG_SECURITY_NETWORK_XFRM */
1380
David Howells29db9192005-10-30 15:02:44 -08001381 /* key management security hooks */
1382#ifdef CONFIG_KEYS
David Howells7e047ef2006-06-26 00:24:50 -07001383 int (*key_alloc)(struct key *key, struct task_struct *tsk, unsigned long flags);
David Howells29db9192005-10-30 15:02:44 -08001384 void (*key_free)(struct key *key);
1385 int (*key_permission)(key_ref_t key_ref,
1386 struct task_struct *context,
1387 key_perm_t perm);
1388
1389#endif /* CONFIG_KEYS */
1390
Linus Torvalds1da177e2005-04-16 15:20:36 -07001391};
1392
1393/* global variables */
1394extern struct security_operations *security_ops;
1395
1396/* inline stuff */
1397static inline int security_ptrace (struct task_struct * parent, struct task_struct * child)
1398{
1399 return security_ops->ptrace (parent, child);
1400}
1401
1402static inline int security_capget (struct task_struct *target,
1403 kernel_cap_t *effective,
1404 kernel_cap_t *inheritable,
1405 kernel_cap_t *permitted)
1406{
1407 return security_ops->capget (target, effective, inheritable, permitted);
1408}
1409
1410static inline int security_capset_check (struct task_struct *target,
1411 kernel_cap_t *effective,
1412 kernel_cap_t *inheritable,
1413 kernel_cap_t *permitted)
1414{
1415 return security_ops->capset_check (target, effective, inheritable, permitted);
1416}
1417
1418static inline void security_capset_set (struct task_struct *target,
1419 kernel_cap_t *effective,
1420 kernel_cap_t *inheritable,
1421 kernel_cap_t *permitted)
1422{
1423 security_ops->capset_set (target, effective, inheritable, permitted);
1424}
1425
Chris Wright12b59892006-03-25 03:07:41 -08001426static inline int security_capable(struct task_struct *tsk, int cap)
1427{
1428 return security_ops->capable(tsk, cap);
1429}
1430
Linus Torvalds1da177e2005-04-16 15:20:36 -07001431static inline int security_acct (struct file *file)
1432{
1433 return security_ops->acct (file);
1434}
1435
1436static inline int security_sysctl(struct ctl_table *table, int op)
1437{
1438 return security_ops->sysctl(table, op);
1439}
1440
1441static inline int security_quotactl (int cmds, int type, int id,
1442 struct super_block *sb)
1443{
1444 return security_ops->quotactl (cmds, type, id, sb);
1445}
1446
1447static inline int security_quota_on (struct dentry * dentry)
1448{
1449 return security_ops->quota_on (dentry);
1450}
1451
1452static inline int security_syslog(int type)
1453{
1454 return security_ops->syslog(type);
1455}
1456
1457static inline int security_settime(struct timespec *ts, struct timezone *tz)
1458{
1459 return security_ops->settime(ts, tz);
1460}
1461
1462
1463static inline int security_vm_enough_memory(long pages)
1464{
1465 return security_ops->vm_enough_memory(pages);
1466}
1467
1468static inline int security_bprm_alloc (struct linux_binprm *bprm)
1469{
1470 return security_ops->bprm_alloc_security (bprm);
1471}
1472static inline void security_bprm_free (struct linux_binprm *bprm)
1473{
1474 security_ops->bprm_free_security (bprm);
1475}
1476static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
1477{
1478 security_ops->bprm_apply_creds (bprm, unsafe);
1479}
1480static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
1481{
1482 security_ops->bprm_post_apply_creds (bprm);
1483}
1484static inline int security_bprm_set (struct linux_binprm *bprm)
1485{
1486 return security_ops->bprm_set_security (bprm);
1487}
1488
1489static inline int security_bprm_check (struct linux_binprm *bprm)
1490{
1491 return security_ops->bprm_check_security (bprm);
1492}
1493
1494static inline int security_bprm_secureexec (struct linux_binprm *bprm)
1495{
1496 return security_ops->bprm_secureexec (bprm);
1497}
1498
1499static inline int security_sb_alloc (struct super_block *sb)
1500{
1501 return security_ops->sb_alloc_security (sb);
1502}
1503
1504static inline void security_sb_free (struct super_block *sb)
1505{
1506 security_ops->sb_free_security (sb);
1507}
1508
1509static inline int security_sb_copy_data (struct file_system_type *type,
1510 void *orig, void *copy)
1511{
1512 return security_ops->sb_copy_data (type, orig, copy);
1513}
1514
1515static inline int security_sb_kern_mount (struct super_block *sb, void *data)
1516{
1517 return security_ops->sb_kern_mount (sb, data);
1518}
1519
David Howells726c3342006-06-23 02:02:58 -07001520static inline int security_sb_statfs (struct dentry *dentry)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001521{
David Howells726c3342006-06-23 02:02:58 -07001522 return security_ops->sb_statfs (dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001523}
1524
1525static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
1526 char *type, unsigned long flags,
1527 void *data)
1528{
1529 return security_ops->sb_mount (dev_name, nd, type, flags, data);
1530}
1531
1532static inline int security_sb_check_sb (struct vfsmount *mnt,
1533 struct nameidata *nd)
1534{
1535 return security_ops->sb_check_sb (mnt, nd);
1536}
1537
1538static inline int security_sb_umount (struct vfsmount *mnt, int flags)
1539{
1540 return security_ops->sb_umount (mnt, flags);
1541}
1542
1543static inline void security_sb_umount_close (struct vfsmount *mnt)
1544{
1545 security_ops->sb_umount_close (mnt);
1546}
1547
1548static inline void security_sb_umount_busy (struct vfsmount *mnt)
1549{
1550 security_ops->sb_umount_busy (mnt);
1551}
1552
1553static inline void security_sb_post_remount (struct vfsmount *mnt,
1554 unsigned long flags, void *data)
1555{
1556 security_ops->sb_post_remount (mnt, flags, data);
1557}
1558
1559static inline void security_sb_post_mountroot (void)
1560{
1561 security_ops->sb_post_mountroot ();
1562}
1563
1564static inline void security_sb_post_addmount (struct vfsmount *mnt,
1565 struct nameidata *mountpoint_nd)
1566{
1567 security_ops->sb_post_addmount (mnt, mountpoint_nd);
1568}
1569
1570static inline int security_sb_pivotroot (struct nameidata *old_nd,
1571 struct nameidata *new_nd)
1572{
1573 return security_ops->sb_pivotroot (old_nd, new_nd);
1574}
1575
1576static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
1577 struct nameidata *new_nd)
1578{
1579 security_ops->sb_post_pivotroot (old_nd, new_nd);
1580}
1581
1582static inline int security_inode_alloc (struct inode *inode)
1583{
Linus Torvalds1da177e2005-04-16 15:20:36 -07001584 return security_ops->inode_alloc_security (inode);
1585}
1586
1587static inline void security_inode_free (struct inode *inode)
1588{
Linus Torvalds1da177e2005-04-16 15:20:36 -07001589 security_ops->inode_free_security (inode);
1590}
Stephen Smalley5e41ff92005-09-09 13:01:35 -07001591
1592static inline int security_inode_init_security (struct inode *inode,
1593 struct inode *dir,
1594 char **name,
1595 void **value,
1596 size_t *len)
1597{
1598 if (unlikely (IS_PRIVATE (inode)))
1599 return -EOPNOTSUPP;
1600 return security_ops->inode_init_security (inode, dir, name, value, len);
1601}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001602
1603static inline int security_inode_create (struct inode *dir,
1604 struct dentry *dentry,
1605 int mode)
1606{
1607 if (unlikely (IS_PRIVATE (dir)))
1608 return 0;
1609 return security_ops->inode_create (dir, dentry, mode);
1610}
1611
Linus Torvalds1da177e2005-04-16 15:20:36 -07001612static inline int security_inode_link (struct dentry *old_dentry,
1613 struct inode *dir,
1614 struct dentry *new_dentry)
1615{
1616 if (unlikely (IS_PRIVATE (old_dentry->d_inode)))
1617 return 0;
1618 return security_ops->inode_link (old_dentry, dir, new_dentry);
1619}
1620
Linus Torvalds1da177e2005-04-16 15:20:36 -07001621static inline int security_inode_unlink (struct inode *dir,
1622 struct dentry *dentry)
1623{
1624 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1625 return 0;
1626 return security_ops->inode_unlink (dir, dentry);
1627}
1628
1629static inline int security_inode_symlink (struct inode *dir,
1630 struct dentry *dentry,
1631 const char *old_name)
1632{
1633 if (unlikely (IS_PRIVATE (dir)))
1634 return 0;
1635 return security_ops->inode_symlink (dir, dentry, old_name);
1636}
1637
Linus Torvalds1da177e2005-04-16 15:20:36 -07001638static inline int security_inode_mkdir (struct inode *dir,
1639 struct dentry *dentry,
1640 int mode)
1641{
1642 if (unlikely (IS_PRIVATE (dir)))
1643 return 0;
1644 return security_ops->inode_mkdir (dir, dentry, mode);
1645}
1646
Linus Torvalds1da177e2005-04-16 15:20:36 -07001647static inline int security_inode_rmdir (struct inode *dir,
1648 struct dentry *dentry)
1649{
1650 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1651 return 0;
1652 return security_ops->inode_rmdir (dir, dentry);
1653}
1654
1655static inline int security_inode_mknod (struct inode *dir,
1656 struct dentry *dentry,
1657 int mode, dev_t dev)
1658{
1659 if (unlikely (IS_PRIVATE (dir)))
1660 return 0;
1661 return security_ops->inode_mknod (dir, dentry, mode, dev);
1662}
1663
Linus Torvalds1da177e2005-04-16 15:20:36 -07001664static inline int security_inode_rename (struct inode *old_dir,
1665 struct dentry *old_dentry,
1666 struct inode *new_dir,
1667 struct dentry *new_dentry)
1668{
1669 if (unlikely (IS_PRIVATE (old_dentry->d_inode) ||
1670 (new_dentry->d_inode && IS_PRIVATE (new_dentry->d_inode))))
1671 return 0;
1672 return security_ops->inode_rename (old_dir, old_dentry,
1673 new_dir, new_dentry);
1674}
1675
Linus Torvalds1da177e2005-04-16 15:20:36 -07001676static inline int security_inode_readlink (struct dentry *dentry)
1677{
1678 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1679 return 0;
1680 return security_ops->inode_readlink (dentry);
1681}
1682
1683static inline int security_inode_follow_link (struct dentry *dentry,
1684 struct nameidata *nd)
1685{
1686 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1687 return 0;
1688 return security_ops->inode_follow_link (dentry, nd);
1689}
1690
1691static inline int security_inode_permission (struct inode *inode, int mask,
1692 struct nameidata *nd)
1693{
1694 if (unlikely (IS_PRIVATE (inode)))
1695 return 0;
1696 return security_ops->inode_permission (inode, mask, nd);
1697}
1698
1699static inline int security_inode_setattr (struct dentry *dentry,
1700 struct iattr *attr)
1701{
1702 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1703 return 0;
1704 return security_ops->inode_setattr (dentry, attr);
1705}
1706
1707static inline int security_inode_getattr (struct vfsmount *mnt,
1708 struct dentry *dentry)
1709{
1710 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1711 return 0;
1712 return security_ops->inode_getattr (mnt, dentry);
1713}
1714
1715static inline void security_inode_delete (struct inode *inode)
1716{
1717 if (unlikely (IS_PRIVATE (inode)))
1718 return;
1719 security_ops->inode_delete (inode);
1720}
1721
1722static inline int security_inode_setxattr (struct dentry *dentry, char *name,
1723 void *value, size_t size, int flags)
1724{
1725 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1726 return 0;
1727 return security_ops->inode_setxattr (dentry, name, value, size, flags);
1728}
1729
1730static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
1731 void *value, size_t size, int flags)
1732{
1733 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1734 return;
1735 security_ops->inode_post_setxattr (dentry, name, value, size, flags);
1736}
1737
1738static inline int security_inode_getxattr (struct dentry *dentry, char *name)
1739{
1740 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1741 return 0;
1742 return security_ops->inode_getxattr (dentry, name);
1743}
1744
1745static inline int security_inode_listxattr (struct dentry *dentry)
1746{
1747 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1748 return 0;
1749 return security_ops->inode_listxattr (dentry);
1750}
1751
1752static inline int security_inode_removexattr (struct dentry *dentry, char *name)
1753{
1754 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1755 return 0;
1756 return security_ops->inode_removexattr (dentry, name);
1757}
1758
Dustin Kirkland8c8570f2005-11-03 17:15:16 +00001759static inline const char *security_inode_xattr_getsuffix(void)
1760{
1761 return security_ops->inode_xattr_getsuffix();
1762}
1763
Dustin Kirkland7306a0b2005-11-16 15:53:13 +00001764static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void *buffer, size_t size, int err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001765{
1766 if (unlikely (IS_PRIVATE (inode)))
1767 return 0;
James Morrisd381d8a2005-10-30 14:59:22 -08001768 return security_ops->inode_getsecurity(inode, name, buffer, size, err);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001769}
1770
1771static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
1772{
1773 if (unlikely (IS_PRIVATE (inode)))
1774 return 0;
1775 return security_ops->inode_setsecurity(inode, name, value, size, flags);
1776}
1777
1778static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
1779{
1780 if (unlikely (IS_PRIVATE (inode)))
1781 return 0;
1782 return security_ops->inode_listsecurity(inode, buffer, buffer_size);
1783}
1784
1785static inline int security_file_permission (struct file *file, int mask)
1786{
1787 return security_ops->file_permission (file, mask);
1788}
1789
1790static inline int security_file_alloc (struct file *file)
1791{
1792 return security_ops->file_alloc_security (file);
1793}
1794
1795static inline void security_file_free (struct file *file)
1796{
1797 security_ops->file_free_security (file);
1798}
1799
1800static inline int security_file_ioctl (struct file *file, unsigned int cmd,
1801 unsigned long arg)
1802{
1803 return security_ops->file_ioctl (file, cmd, arg);
1804}
1805
1806static inline int security_file_mmap (struct file *file, unsigned long reqprot,
1807 unsigned long prot,
1808 unsigned long flags)
1809{
1810 return security_ops->file_mmap (file, reqprot, prot, flags);
1811}
1812
1813static inline int security_file_mprotect (struct vm_area_struct *vma,
1814 unsigned long reqprot,
1815 unsigned long prot)
1816{
1817 return security_ops->file_mprotect (vma, reqprot, prot);
1818}
1819
1820static inline int security_file_lock (struct file *file, unsigned int cmd)
1821{
1822 return security_ops->file_lock (file, cmd);
1823}
1824
1825static inline int security_file_fcntl (struct file *file, unsigned int cmd,
1826 unsigned long arg)
1827{
1828 return security_ops->file_fcntl (file, cmd, arg);
1829}
1830
1831static inline int security_file_set_fowner (struct file *file)
1832{
1833 return security_ops->file_set_fowner (file);
1834}
1835
1836static inline int security_file_send_sigiotask (struct task_struct *tsk,
1837 struct fown_struct *fown,
1838 int sig)
1839{
1840 return security_ops->file_send_sigiotask (tsk, fown, sig);
1841}
1842
1843static inline int security_file_receive (struct file *file)
1844{
1845 return security_ops->file_receive (file);
1846}
1847
1848static inline int security_task_create (unsigned long clone_flags)
1849{
1850 return security_ops->task_create (clone_flags);
1851}
1852
1853static inline int security_task_alloc (struct task_struct *p)
1854{
1855 return security_ops->task_alloc_security (p);
1856}
1857
1858static inline void security_task_free (struct task_struct *p)
1859{
1860 security_ops->task_free_security (p);
1861}
1862
1863static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
1864 int flags)
1865{
1866 return security_ops->task_setuid (id0, id1, id2, flags);
1867}
1868
1869static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
1870 uid_t old_suid, int flags)
1871{
1872 return security_ops->task_post_setuid (old_ruid, old_euid, old_suid, flags);
1873}
1874
1875static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
1876 int flags)
1877{
1878 return security_ops->task_setgid (id0, id1, id2, flags);
1879}
1880
1881static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
1882{
1883 return security_ops->task_setpgid (p, pgid);
1884}
1885
1886static inline int security_task_getpgid (struct task_struct *p)
1887{
1888 return security_ops->task_getpgid (p);
1889}
1890
1891static inline int security_task_getsid (struct task_struct *p)
1892{
1893 return security_ops->task_getsid (p);
1894}
1895
David Quigleyf9008e42006-06-30 01:55:46 -07001896static inline void security_task_getsecid (struct task_struct *p, u32 *secid)
1897{
1898 security_ops->task_getsecid (p, secid);
1899}
1900
Linus Torvalds1da177e2005-04-16 15:20:36 -07001901static inline int security_task_setgroups (struct group_info *group_info)
1902{
1903 return security_ops->task_setgroups (group_info);
1904}
1905
1906static inline int security_task_setnice (struct task_struct *p, int nice)
1907{
1908 return security_ops->task_setnice (p, nice);
1909}
1910
James Morris03e68062006-06-23 02:03:58 -07001911static inline int security_task_setioprio (struct task_struct *p, int ioprio)
1912{
1913 return security_ops->task_setioprio (p, ioprio);
1914}
1915
David Quigleya1836a42006-06-30 01:55:49 -07001916static inline int security_task_getioprio (struct task_struct *p)
1917{
1918 return security_ops->task_getioprio (p);
1919}
1920
Linus Torvalds1da177e2005-04-16 15:20:36 -07001921static inline int security_task_setrlimit (unsigned int resource,
1922 struct rlimit *new_rlim)
1923{
1924 return security_ops->task_setrlimit (resource, new_rlim);
1925}
1926
1927static inline int security_task_setscheduler (struct task_struct *p,
1928 int policy,
1929 struct sched_param *lp)
1930{
1931 return security_ops->task_setscheduler (p, policy, lp);
1932}
1933
1934static inline int security_task_getscheduler (struct task_struct *p)
1935{
1936 return security_ops->task_getscheduler (p);
1937}
1938
David Quigley35601542006-06-23 02:04:01 -07001939static inline int security_task_movememory (struct task_struct *p)
1940{
1941 return security_ops->task_movememory (p);
1942}
1943
Linus Torvalds1da177e2005-04-16 15:20:36 -07001944static inline int security_task_kill (struct task_struct *p,
David Quigleyf9008e42006-06-30 01:55:46 -07001945 struct siginfo *info, int sig,
1946 u32 secid)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001947{
David Quigleyf9008e42006-06-30 01:55:46 -07001948 return security_ops->task_kill (p, info, sig, secid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001949}
1950
1951static inline int security_task_wait (struct task_struct *p)
1952{
1953 return security_ops->task_wait (p);
1954}
1955
1956static inline int security_task_prctl (int option, unsigned long arg2,
1957 unsigned long arg3,
1958 unsigned long arg4,
1959 unsigned long arg5)
1960{
1961 return security_ops->task_prctl (option, arg2, arg3, arg4, arg5);
1962}
1963
1964static inline void security_task_reparent_to_init (struct task_struct *p)
1965{
1966 security_ops->task_reparent_to_init (p);
1967}
1968
1969static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
1970{
1971 security_ops->task_to_inode(p, inode);
1972}
1973
1974static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
1975 short flag)
1976{
1977 return security_ops->ipc_permission (ipcp, flag);
1978}
1979
1980static inline int security_msg_msg_alloc (struct msg_msg * msg)
1981{
1982 return security_ops->msg_msg_alloc_security (msg);
1983}
1984
1985static inline void security_msg_msg_free (struct msg_msg * msg)
1986{
1987 security_ops->msg_msg_free_security(msg);
1988}
1989
1990static inline int security_msg_queue_alloc (struct msg_queue *msq)
1991{
1992 return security_ops->msg_queue_alloc_security (msq);
1993}
1994
1995static inline void security_msg_queue_free (struct msg_queue *msq)
1996{
1997 security_ops->msg_queue_free_security (msq);
1998}
1999
2000static inline int security_msg_queue_associate (struct msg_queue * msq,
2001 int msqflg)
2002{
2003 return security_ops->msg_queue_associate (msq, msqflg);
2004}
2005
2006static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
2007{
2008 return security_ops->msg_queue_msgctl (msq, cmd);
2009}
2010
2011static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
2012 struct msg_msg * msg, int msqflg)
2013{
2014 return security_ops->msg_queue_msgsnd (msq, msg, msqflg);
2015}
2016
2017static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
2018 struct msg_msg * msg,
2019 struct task_struct * target,
2020 long type, int mode)
2021{
2022 return security_ops->msg_queue_msgrcv (msq, msg, target, type, mode);
2023}
2024
2025static inline int security_shm_alloc (struct shmid_kernel *shp)
2026{
2027 return security_ops->shm_alloc_security (shp);
2028}
2029
2030static inline void security_shm_free (struct shmid_kernel *shp)
2031{
2032 security_ops->shm_free_security (shp);
2033}
2034
2035static inline int security_shm_associate (struct shmid_kernel * shp,
2036 int shmflg)
2037{
2038 return security_ops->shm_associate(shp, shmflg);
2039}
2040
2041static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
2042{
2043 return security_ops->shm_shmctl (shp, cmd);
2044}
2045
2046static inline int security_shm_shmat (struct shmid_kernel * shp,
2047 char __user *shmaddr, int shmflg)
2048{
2049 return security_ops->shm_shmat(shp, shmaddr, shmflg);
2050}
2051
2052static inline int security_sem_alloc (struct sem_array *sma)
2053{
2054 return security_ops->sem_alloc_security (sma);
2055}
2056
2057static inline void security_sem_free (struct sem_array *sma)
2058{
2059 security_ops->sem_free_security (sma);
2060}
2061
2062static inline int security_sem_associate (struct sem_array * sma, int semflg)
2063{
2064 return security_ops->sem_associate (sma, semflg);
2065}
2066
2067static inline int security_sem_semctl (struct sem_array * sma, int cmd)
2068{
2069 return security_ops->sem_semctl(sma, cmd);
2070}
2071
2072static inline int security_sem_semop (struct sem_array * sma,
2073 struct sembuf * sops, unsigned nsops,
2074 int alter)
2075{
2076 return security_ops->sem_semop(sma, sops, nsops, alter);
2077}
2078
2079static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
2080{
2081 if (unlikely (inode && IS_PRIVATE (inode)))
2082 return;
2083 security_ops->d_instantiate (dentry, inode);
2084}
2085
2086static inline int security_getprocattr(struct task_struct *p, char *name, void *value, size_t size)
2087{
2088 return security_ops->getprocattr(p, name, value, size);
2089}
2090
2091static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2092{
2093 return security_ops->setprocattr(p, name, value, size);
2094}
2095
2096static inline int security_netlink_send(struct sock *sk, struct sk_buff * skb)
2097{
2098 return security_ops->netlink_send(sk, skb);
2099}
2100
Darrel Goeddelc7bdb542006-06-27 13:26:11 -07002101static inline int security_netlink_recv(struct sk_buff * skb, int cap)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002102{
Darrel Goeddelc7bdb542006-06-27 13:26:11 -07002103 return security_ops->netlink_recv(skb, cap);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002104}
2105
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07002106static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
2107{
2108 return security_ops->secid_to_secctx(secid, secdata, seclen);
2109}
2110
2111static inline void security_release_secctx(char *secdata, u32 seclen)
2112{
2113 return security_ops->release_secctx(secdata, seclen);
2114}
2115
Linus Torvalds1da177e2005-04-16 15:20:36 -07002116/* prototypes */
2117extern int security_init (void);
2118extern int register_security (struct security_operations *ops);
2119extern int unregister_security (struct security_operations *ops);
2120extern int mod_reg_security (const char *name, struct security_operations *ops);
2121extern int mod_unreg_security (const char *name, struct security_operations *ops);
Greg KHb67dbf92005-07-07 14:37:53 -07002122extern struct dentry *securityfs_create_file(const char *name, mode_t mode,
2123 struct dentry *parent, void *data,
2124 struct file_operations *fops);
2125extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
2126extern void securityfs_remove(struct dentry *dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002127
2128
2129#else /* CONFIG_SECURITY */
2130
2131/*
2132 * This is the default capabilities functionality. Most of these functions
2133 * are just stubbed out, but a few must call the proper capable code.
2134 */
2135
2136static inline int security_init(void)
2137{
2138 return 0;
2139}
2140
2141static inline int security_ptrace (struct task_struct *parent, struct task_struct * child)
2142{
2143 return cap_ptrace (parent, child);
2144}
2145
2146static inline int security_capget (struct task_struct *target,
2147 kernel_cap_t *effective,
2148 kernel_cap_t *inheritable,
2149 kernel_cap_t *permitted)
2150{
2151 return cap_capget (target, effective, inheritable, permitted);
2152}
2153
2154static inline int security_capset_check (struct task_struct *target,
2155 kernel_cap_t *effective,
2156 kernel_cap_t *inheritable,
2157 kernel_cap_t *permitted)
2158{
2159 return cap_capset_check (target, effective, inheritable, permitted);
2160}
2161
2162static inline void security_capset_set (struct task_struct *target,
2163 kernel_cap_t *effective,
2164 kernel_cap_t *inheritable,
2165 kernel_cap_t *permitted)
2166{
2167 cap_capset_set (target, effective, inheritable, permitted);
2168}
2169
Chris Wright12b59892006-03-25 03:07:41 -08002170static inline int security_capable(struct task_struct *tsk, int cap)
2171{
2172 return cap_capable(tsk, cap);
2173}
2174
Linus Torvalds1da177e2005-04-16 15:20:36 -07002175static inline int security_acct (struct file *file)
2176{
2177 return 0;
2178}
2179
2180static inline int security_sysctl(struct ctl_table *table, int op)
2181{
2182 return 0;
2183}
2184
2185static inline int security_quotactl (int cmds, int type, int id,
2186 struct super_block * sb)
2187{
2188 return 0;
2189}
2190
2191static inline int security_quota_on (struct dentry * dentry)
2192{
2193 return 0;
2194}
2195
2196static inline int security_syslog(int type)
2197{
2198 return cap_syslog(type);
2199}
2200
2201static inline int security_settime(struct timespec *ts, struct timezone *tz)
2202{
2203 return cap_settime(ts, tz);
2204}
2205
2206static inline int security_vm_enough_memory(long pages)
2207{
2208 return cap_vm_enough_memory(pages);
2209}
2210
2211static inline int security_bprm_alloc (struct linux_binprm *bprm)
2212{
2213 return 0;
2214}
2215
2216static inline void security_bprm_free (struct linux_binprm *bprm)
2217{ }
2218
2219static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
2220{
2221 cap_bprm_apply_creds (bprm, unsafe);
2222}
2223
2224static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
2225{
2226 return;
2227}
2228
2229static inline int security_bprm_set (struct linux_binprm *bprm)
2230{
2231 return cap_bprm_set_security (bprm);
2232}
2233
2234static inline int security_bprm_check (struct linux_binprm *bprm)
2235{
2236 return 0;
2237}
2238
2239static inline int security_bprm_secureexec (struct linux_binprm *bprm)
2240{
2241 return cap_bprm_secureexec(bprm);
2242}
2243
2244static inline int security_sb_alloc (struct super_block *sb)
2245{
2246 return 0;
2247}
2248
2249static inline void security_sb_free (struct super_block *sb)
2250{ }
2251
2252static inline int security_sb_copy_data (struct file_system_type *type,
2253 void *orig, void *copy)
2254{
2255 return 0;
2256}
2257
2258static inline int security_sb_kern_mount (struct super_block *sb, void *data)
2259{
2260 return 0;
2261}
2262
David Howells726c3342006-06-23 02:02:58 -07002263static inline int security_sb_statfs (struct dentry *dentry)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002264{
2265 return 0;
2266}
2267
2268static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
2269 char *type, unsigned long flags,
2270 void *data)
2271{
2272 return 0;
2273}
2274
2275static inline int security_sb_check_sb (struct vfsmount *mnt,
2276 struct nameidata *nd)
2277{
2278 return 0;
2279}
2280
2281static inline int security_sb_umount (struct vfsmount *mnt, int flags)
2282{
2283 return 0;
2284}
2285
2286static inline void security_sb_umount_close (struct vfsmount *mnt)
2287{ }
2288
2289static inline void security_sb_umount_busy (struct vfsmount *mnt)
2290{ }
2291
2292static inline void security_sb_post_remount (struct vfsmount *mnt,
2293 unsigned long flags, void *data)
2294{ }
2295
2296static inline void security_sb_post_mountroot (void)
2297{ }
2298
2299static inline void security_sb_post_addmount (struct vfsmount *mnt,
2300 struct nameidata *mountpoint_nd)
2301{ }
2302
2303static inline int security_sb_pivotroot (struct nameidata *old_nd,
2304 struct nameidata *new_nd)
2305{
2306 return 0;
2307}
2308
2309static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
2310 struct nameidata *new_nd)
2311{ }
2312
2313static inline int security_inode_alloc (struct inode *inode)
2314{
2315 return 0;
2316}
2317
2318static inline void security_inode_free (struct inode *inode)
2319{ }
Stephen Smalley5e41ff92005-09-09 13:01:35 -07002320
2321static inline int security_inode_init_security (struct inode *inode,
2322 struct inode *dir,
2323 char **name,
2324 void **value,
2325 size_t *len)
2326{
2327 return -EOPNOTSUPP;
2328}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002329
2330static inline int security_inode_create (struct inode *dir,
2331 struct dentry *dentry,
2332 int mode)
2333{
2334 return 0;
2335}
2336
Linus Torvalds1da177e2005-04-16 15:20:36 -07002337static inline int security_inode_link (struct dentry *old_dentry,
2338 struct inode *dir,
2339 struct dentry *new_dentry)
2340{
2341 return 0;
2342}
2343
Linus Torvalds1da177e2005-04-16 15:20:36 -07002344static inline int security_inode_unlink (struct inode *dir,
2345 struct dentry *dentry)
2346{
2347 return 0;
2348}
2349
2350static inline int security_inode_symlink (struct inode *dir,
2351 struct dentry *dentry,
2352 const char *old_name)
2353{
2354 return 0;
2355}
2356
Linus Torvalds1da177e2005-04-16 15:20:36 -07002357static inline int security_inode_mkdir (struct inode *dir,
2358 struct dentry *dentry,
2359 int mode)
2360{
2361 return 0;
2362}
2363
Linus Torvalds1da177e2005-04-16 15:20:36 -07002364static inline int security_inode_rmdir (struct inode *dir,
2365 struct dentry *dentry)
2366{
2367 return 0;
2368}
2369
2370static inline int security_inode_mknod (struct inode *dir,
2371 struct dentry *dentry,
2372 int mode, dev_t dev)
2373{
2374 return 0;
2375}
2376
Linus Torvalds1da177e2005-04-16 15:20:36 -07002377static inline int security_inode_rename (struct inode *old_dir,
2378 struct dentry *old_dentry,
2379 struct inode *new_dir,
2380 struct dentry *new_dentry)
2381{
2382 return 0;
2383}
2384
Linus Torvalds1da177e2005-04-16 15:20:36 -07002385static inline int security_inode_readlink (struct dentry *dentry)
2386{
2387 return 0;
2388}
2389
2390static inline int security_inode_follow_link (struct dentry *dentry,
2391 struct nameidata *nd)
2392{
2393 return 0;
2394}
2395
2396static inline int security_inode_permission (struct inode *inode, int mask,
2397 struct nameidata *nd)
2398{
2399 return 0;
2400}
2401
2402static inline int security_inode_setattr (struct dentry *dentry,
2403 struct iattr *attr)
2404{
2405 return 0;
2406}
2407
2408static inline int security_inode_getattr (struct vfsmount *mnt,
2409 struct dentry *dentry)
2410{
2411 return 0;
2412}
2413
2414static inline void security_inode_delete (struct inode *inode)
2415{ }
2416
2417static inline int security_inode_setxattr (struct dentry *dentry, char *name,
2418 void *value, size_t size, int flags)
2419{
2420 return cap_inode_setxattr(dentry, name, value, size, flags);
2421}
2422
2423static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
2424 void *value, size_t size, int flags)
2425{ }
2426
2427static inline int security_inode_getxattr (struct dentry *dentry, char *name)
2428{
2429 return 0;
2430}
2431
2432static inline int security_inode_listxattr (struct dentry *dentry)
2433{
2434 return 0;
2435}
2436
2437static inline int security_inode_removexattr (struct dentry *dentry, char *name)
2438{
2439 return cap_inode_removexattr(dentry, name);
2440}
2441
Dustin Kirkland8c8570f2005-11-03 17:15:16 +00002442static inline const char *security_inode_xattr_getsuffix (void)
2443{
2444 return NULL ;
2445}
2446
Dustin Kirkland7306a0b2005-11-16 15:53:13 +00002447static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void *buffer, size_t size, int err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002448{
2449 return -EOPNOTSUPP;
2450}
2451
2452static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
2453{
2454 return -EOPNOTSUPP;
2455}
2456
2457static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
2458{
2459 return 0;
2460}
2461
2462static inline int security_file_permission (struct file *file, int mask)
2463{
2464 return 0;
2465}
2466
2467static inline int security_file_alloc (struct file *file)
2468{
2469 return 0;
2470}
2471
2472static inline void security_file_free (struct file *file)
2473{ }
2474
2475static inline int security_file_ioctl (struct file *file, unsigned int cmd,
2476 unsigned long arg)
2477{
2478 return 0;
2479}
2480
2481static inline int security_file_mmap (struct file *file, unsigned long reqprot,
2482 unsigned long prot,
2483 unsigned long flags)
2484{
2485 return 0;
2486}
2487
2488static inline int security_file_mprotect (struct vm_area_struct *vma,
2489 unsigned long reqprot,
2490 unsigned long prot)
2491{
2492 return 0;
2493}
2494
2495static inline int security_file_lock (struct file *file, unsigned int cmd)
2496{
2497 return 0;
2498}
2499
2500static inline int security_file_fcntl (struct file *file, unsigned int cmd,
2501 unsigned long arg)
2502{
2503 return 0;
2504}
2505
2506static inline int security_file_set_fowner (struct file *file)
2507{
2508 return 0;
2509}
2510
2511static inline int security_file_send_sigiotask (struct task_struct *tsk,
2512 struct fown_struct *fown,
2513 int sig)
2514{
2515 return 0;
2516}
2517
2518static inline int security_file_receive (struct file *file)
2519{
2520 return 0;
2521}
2522
2523static inline int security_task_create (unsigned long clone_flags)
2524{
2525 return 0;
2526}
2527
2528static inline int security_task_alloc (struct task_struct *p)
2529{
2530 return 0;
2531}
2532
2533static inline void security_task_free (struct task_struct *p)
2534{ }
2535
2536static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
2537 int flags)
2538{
2539 return 0;
2540}
2541
2542static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
2543 uid_t old_suid, int flags)
2544{
2545 return cap_task_post_setuid (old_ruid, old_euid, old_suid, flags);
2546}
2547
2548static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
2549 int flags)
2550{
2551 return 0;
2552}
2553
2554static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
2555{
2556 return 0;
2557}
2558
2559static inline int security_task_getpgid (struct task_struct *p)
2560{
2561 return 0;
2562}
2563
2564static inline int security_task_getsid (struct task_struct *p)
2565{
2566 return 0;
2567}
2568
David Quigleyf9008e42006-06-30 01:55:46 -07002569static inline void security_task_getsecid (struct task_struct *p, u32 *secid)
2570{ }
2571
Linus Torvalds1da177e2005-04-16 15:20:36 -07002572static inline int security_task_setgroups (struct group_info *group_info)
2573{
2574 return 0;
2575}
2576
2577static inline int security_task_setnice (struct task_struct *p, int nice)
2578{
2579 return 0;
2580}
2581
James Morris03e68062006-06-23 02:03:58 -07002582static inline int security_task_setioprio (struct task_struct *p, int ioprio)
2583{
2584 return 0;
2585}
2586
David Quigleya1836a42006-06-30 01:55:49 -07002587static inline int security_task_getioprio (struct task_struct *p)
2588{
2589 return 0;
2590}
2591
Linus Torvalds1da177e2005-04-16 15:20:36 -07002592static inline int security_task_setrlimit (unsigned int resource,
2593 struct rlimit *new_rlim)
2594{
2595 return 0;
2596}
2597
2598static inline int security_task_setscheduler (struct task_struct *p,
2599 int policy,
2600 struct sched_param *lp)
2601{
2602 return 0;
2603}
2604
2605static inline int security_task_getscheduler (struct task_struct *p)
2606{
2607 return 0;
2608}
2609
David Quigley35601542006-06-23 02:04:01 -07002610static inline int security_task_movememory (struct task_struct *p)
2611{
2612 return 0;
2613}
2614
Linus Torvalds1da177e2005-04-16 15:20:36 -07002615static inline int security_task_kill (struct task_struct *p,
David Quigleyf9008e42006-06-30 01:55:46 -07002616 struct siginfo *info, int sig,
2617 u32 secid)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002618{
2619 return 0;
2620}
2621
2622static inline int security_task_wait (struct task_struct *p)
2623{
2624 return 0;
2625}
2626
2627static inline int security_task_prctl (int option, unsigned long arg2,
2628 unsigned long arg3,
2629 unsigned long arg4,
2630 unsigned long arg5)
2631{
2632 return 0;
2633}
2634
2635static inline void security_task_reparent_to_init (struct task_struct *p)
2636{
2637 cap_task_reparent_to_init (p);
2638}
2639
2640static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
2641{ }
2642
2643static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
2644 short flag)
2645{
2646 return 0;
2647}
2648
2649static inline int security_msg_msg_alloc (struct msg_msg * msg)
2650{
2651 return 0;
2652}
2653
2654static inline void security_msg_msg_free (struct msg_msg * msg)
2655{ }
2656
2657static inline int security_msg_queue_alloc (struct msg_queue *msq)
2658{
2659 return 0;
2660}
2661
2662static inline void security_msg_queue_free (struct msg_queue *msq)
2663{ }
2664
2665static inline int security_msg_queue_associate (struct msg_queue * msq,
2666 int msqflg)
2667{
2668 return 0;
2669}
2670
2671static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
2672{
2673 return 0;
2674}
2675
2676static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
2677 struct msg_msg * msg, int msqflg)
2678{
2679 return 0;
2680}
2681
2682static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
2683 struct msg_msg * msg,
2684 struct task_struct * target,
2685 long type, int mode)
2686{
2687 return 0;
2688}
2689
2690static inline int security_shm_alloc (struct shmid_kernel *shp)
2691{
2692 return 0;
2693}
2694
2695static inline void security_shm_free (struct shmid_kernel *shp)
2696{ }
2697
2698static inline int security_shm_associate (struct shmid_kernel * shp,
2699 int shmflg)
2700{
2701 return 0;
2702}
2703
2704static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
2705{
2706 return 0;
2707}
2708
2709static inline int security_shm_shmat (struct shmid_kernel * shp,
2710 char __user *shmaddr, int shmflg)
2711{
2712 return 0;
2713}
2714
2715static inline int security_sem_alloc (struct sem_array *sma)
2716{
2717 return 0;
2718}
2719
2720static inline void security_sem_free (struct sem_array *sma)
2721{ }
2722
2723static inline int security_sem_associate (struct sem_array * sma, int semflg)
2724{
2725 return 0;
2726}
2727
2728static inline int security_sem_semctl (struct sem_array * sma, int cmd)
2729{
2730 return 0;
2731}
2732
2733static inline int security_sem_semop (struct sem_array * sma,
2734 struct sembuf * sops, unsigned nsops,
2735 int alter)
2736{
2737 return 0;
2738}
2739
2740static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
2741{ }
2742
2743static inline int security_getprocattr(struct task_struct *p, char *name, void *value, size_t size)
2744{
2745 return -EINVAL;
2746}
2747
2748static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2749{
2750 return -EINVAL;
2751}
2752
2753static inline int security_netlink_send (struct sock *sk, struct sk_buff *skb)
2754{
2755 return cap_netlink_send (sk, skb);
2756}
2757
Darrel Goeddelc7bdb542006-06-27 13:26:11 -07002758static inline int security_netlink_recv (struct sk_buff *skb, int cap)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002759{
Darrel Goeddelc7bdb542006-06-27 13:26:11 -07002760 return cap_netlink_recv (skb, cap);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002761}
2762
Randy Dunlaped5a9272006-02-01 03:05:00 -08002763static inline struct dentry *securityfs_create_dir(const char *name,
2764 struct dentry *parent)
2765{
2766 return ERR_PTR(-ENODEV);
2767}
2768
2769static inline struct dentry *securityfs_create_file(const char *name,
2770 mode_t mode,
2771 struct dentry *parent,
2772 void *data,
2773 struct file_operations *fops)
2774{
2775 return ERR_PTR(-ENODEV);
2776}
2777
2778static inline void securityfs_remove(struct dentry *dentry)
2779{
2780}
2781
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07002782static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
2783{
2784 return -EOPNOTSUPP;
2785}
2786
2787static inline void security_release_secctx(char *secdata, u32 seclen)
2788{
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07002789}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002790#endif /* CONFIG_SECURITY */
2791
2792#ifdef CONFIG_SECURITY_NETWORK
2793static inline int security_unix_stream_connect(struct socket * sock,
2794 struct socket * other,
2795 struct sock * newsk)
2796{
2797 return security_ops->unix_stream_connect(sock, other, newsk);
2798}
2799
2800
2801static inline int security_unix_may_send(struct socket * sock,
2802 struct socket * other)
2803{
2804 return security_ops->unix_may_send(sock, other);
2805}
2806
2807static inline int security_socket_create (int family, int type,
2808 int protocol, int kern)
2809{
2810 return security_ops->socket_create(family, type, protocol, kern);
2811}
2812
2813static inline void security_socket_post_create(struct socket * sock,
2814 int family,
2815 int type,
2816 int protocol, int kern)
2817{
2818 security_ops->socket_post_create(sock, family, type,
2819 protocol, kern);
2820}
2821
2822static inline int security_socket_bind(struct socket * sock,
2823 struct sockaddr * address,
2824 int addrlen)
2825{
2826 return security_ops->socket_bind(sock, address, addrlen);
2827}
2828
2829static inline int security_socket_connect(struct socket * sock,
2830 struct sockaddr * address,
2831 int addrlen)
2832{
2833 return security_ops->socket_connect(sock, address, addrlen);
2834}
2835
2836static inline int security_socket_listen(struct socket * sock, int backlog)
2837{
2838 return security_ops->socket_listen(sock, backlog);
2839}
2840
2841static inline int security_socket_accept(struct socket * sock,
2842 struct socket * newsock)
2843{
2844 return security_ops->socket_accept(sock, newsock);
2845}
2846
2847static inline void security_socket_post_accept(struct socket * sock,
2848 struct socket * newsock)
2849{
2850 security_ops->socket_post_accept(sock, newsock);
2851}
2852
2853static inline int security_socket_sendmsg(struct socket * sock,
2854 struct msghdr * msg, int size)
2855{
2856 return security_ops->socket_sendmsg(sock, msg, size);
2857}
2858
2859static inline int security_socket_recvmsg(struct socket * sock,
2860 struct msghdr * msg, int size,
2861 int flags)
2862{
2863 return security_ops->socket_recvmsg(sock, msg, size, flags);
2864}
2865
2866static inline int security_socket_getsockname(struct socket * sock)
2867{
2868 return security_ops->socket_getsockname(sock);
2869}
2870
2871static inline int security_socket_getpeername(struct socket * sock)
2872{
2873 return security_ops->socket_getpeername(sock);
2874}
2875
2876static inline int security_socket_getsockopt(struct socket * sock,
2877 int level, int optname)
2878{
2879 return security_ops->socket_getsockopt(sock, level, optname);
2880}
2881
2882static inline int security_socket_setsockopt(struct socket * sock,
2883 int level, int optname)
2884{
2885 return security_ops->socket_setsockopt(sock, level, optname);
2886}
2887
2888static inline int security_socket_shutdown(struct socket * sock, int how)
2889{
2890 return security_ops->socket_shutdown(sock, how);
2891}
2892
2893static inline int security_sock_rcv_skb (struct sock * sk,
2894 struct sk_buff * skb)
2895{
2896 return security_ops->socket_sock_rcv_skb (sk, skb);
2897}
2898
Catherine Zhang2c7946a2006-03-20 22:41:23 -08002899static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2900 int __user *optlen, unsigned len)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002901{
Catherine Zhang2c7946a2006-03-20 22:41:23 -08002902 return security_ops->socket_getpeersec_stream(sock, optval, optlen, len);
2903}
2904
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07002905static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
Catherine Zhang2c7946a2006-03-20 22:41:23 -08002906{
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07002907 return security_ops->socket_getpeersec_dgram(sock, skb, secid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002908}
2909
Al Virodd0fc662005-10-07 07:46:04 +01002910static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002911{
2912 return security_ops->sk_alloc_security(sk, family, priority);
2913}
2914
2915static inline void security_sk_free(struct sock *sk)
2916{
2917 return security_ops->sk_free_security(sk);
2918}
Trent Jaegerdf718372005-12-13 23:12:27 -08002919
Venkat Yekkirala892c1412006-08-04 23:08:56 -07002920static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
2921{
2922 return security_ops->sk_clone_security(sk, newsk);
2923}
2924
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07002925static inline void security_sk_classify_flow(struct sock *sk, struct flowi *fl)
Trent Jaegerdf718372005-12-13 23:12:27 -08002926{
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07002927 security_ops->sk_getsecid(sk, &fl->secid);
Trent Jaegerdf718372005-12-13 23:12:27 -08002928}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002929#else /* CONFIG_SECURITY_NETWORK */
2930static inline int security_unix_stream_connect(struct socket * sock,
2931 struct socket * other,
2932 struct sock * newsk)
2933{
2934 return 0;
2935}
2936
2937static inline int security_unix_may_send(struct socket * sock,
2938 struct socket * other)
2939{
2940 return 0;
2941}
2942
2943static inline int security_socket_create (int family, int type,
2944 int protocol, int kern)
2945{
2946 return 0;
2947}
2948
2949static inline void security_socket_post_create(struct socket * sock,
2950 int family,
2951 int type,
2952 int protocol, int kern)
2953{
2954}
2955
2956static inline int security_socket_bind(struct socket * sock,
2957 struct sockaddr * address,
2958 int addrlen)
2959{
2960 return 0;
2961}
2962
2963static inline int security_socket_connect(struct socket * sock,
2964 struct sockaddr * address,
2965 int addrlen)
2966{
2967 return 0;
2968}
2969
2970static inline int security_socket_listen(struct socket * sock, int backlog)
2971{
2972 return 0;
2973}
2974
2975static inline int security_socket_accept(struct socket * sock,
2976 struct socket * newsock)
2977{
2978 return 0;
2979}
2980
2981static inline void security_socket_post_accept(struct socket * sock,
2982 struct socket * newsock)
2983{
2984}
2985
2986static inline int security_socket_sendmsg(struct socket * sock,
2987 struct msghdr * msg, int size)
2988{
2989 return 0;
2990}
2991
2992static inline int security_socket_recvmsg(struct socket * sock,
2993 struct msghdr * msg, int size,
2994 int flags)
2995{
2996 return 0;
2997}
2998
2999static inline int security_socket_getsockname(struct socket * sock)
3000{
3001 return 0;
3002}
3003
3004static inline int security_socket_getpeername(struct socket * sock)
3005{
3006 return 0;
3007}
3008
3009static inline int security_socket_getsockopt(struct socket * sock,
3010 int level, int optname)
3011{
3012 return 0;
3013}
3014
3015static inline int security_socket_setsockopt(struct socket * sock,
3016 int level, int optname)
3017{
3018 return 0;
3019}
3020
3021static inline int security_socket_shutdown(struct socket * sock, int how)
3022{
3023 return 0;
3024}
3025static inline int security_sock_rcv_skb (struct sock * sk,
3026 struct sk_buff * skb)
3027{
3028 return 0;
3029}
3030
Catherine Zhang2c7946a2006-03-20 22:41:23 -08003031static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
3032 int __user *optlen, unsigned len)
3033{
3034 return -ENOPROTOOPT;
3035}
3036
Catherine Zhangdc49c1f2006-08-02 14:12:06 -07003037static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003038{
3039 return -ENOPROTOOPT;
3040}
3041
Al Virodd0fc662005-10-07 07:46:04 +01003042static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003043{
3044 return 0;
3045}
3046
3047static inline void security_sk_free(struct sock *sk)
3048{
3049}
Trent Jaegerdf718372005-12-13 23:12:27 -08003050
Venkat Yekkirala892c1412006-08-04 23:08:56 -07003051static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
3052{
3053}
3054
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07003055static inline void security_sk_classify_flow(struct sock *sk, struct flowi *fl)
Trent Jaegerdf718372005-12-13 23:12:27 -08003056{
Trent Jaegerdf718372005-12-13 23:12:27 -08003057}
Linus Torvalds1da177e2005-04-16 15:20:36 -07003058#endif /* CONFIG_SECURITY_NETWORK */
3059
Trent Jaegerdf718372005-12-13 23:12:27 -08003060#ifdef CONFIG_SECURITY_NETWORK_XFRM
3061static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx)
3062{
Venkat Yekkiralacb969f02006-07-24 23:32:20 -07003063 return security_ops->xfrm_policy_alloc_security(xp, sec_ctx, NULL);
3064}
3065
3066static inline int security_xfrm_sock_policy_alloc(struct xfrm_policy *xp, struct sock *sk)
3067{
3068 return security_ops->xfrm_policy_alloc_security(xp, NULL, sk);
Trent Jaegerdf718372005-12-13 23:12:27 -08003069}
3070
3071static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
3072{
3073 return security_ops->xfrm_policy_clone_security(old, new);
3074}
3075
3076static inline void security_xfrm_policy_free(struct xfrm_policy *xp)
3077{
3078 security_ops->xfrm_policy_free_security(xp);
3079}
3080
Catherine Zhangc8c05a82006-06-08 23:39:49 -07003081static inline int security_xfrm_policy_delete(struct xfrm_policy *xp)
3082{
3083 return security_ops->xfrm_policy_delete_security(xp);
3084}
3085
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07003086static inline int security_xfrm_state_alloc(struct xfrm_state *x,
3087 struct xfrm_user_sec_ctx *sec_ctx)
Trent Jaegerdf718372005-12-13 23:12:27 -08003088{
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07003089 return security_ops->xfrm_state_alloc_security(x, sec_ctx, NULL, 0);
3090}
3091
3092static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
3093 struct xfrm_sec_ctx *polsec, u32 secid)
3094{
3095 if (!polsec)
3096 return 0;
3097 return security_ops->xfrm_state_alloc_security(x, NULL, polsec, secid);
Trent Jaegerdf718372005-12-13 23:12:27 -08003098}
3099
Catherine Zhangc8c05a82006-06-08 23:39:49 -07003100static inline int security_xfrm_state_delete(struct xfrm_state *x)
3101{
3102 return security_ops->xfrm_state_delete_security(x);
3103}
3104
Trent Jaegerdf718372005-12-13 23:12:27 -08003105static inline void security_xfrm_state_free(struct xfrm_state *x)
3106{
3107 security_ops->xfrm_state_free_security(x);
3108}
3109
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07003110static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir)
Trent Jaegerdf718372005-12-13 23:12:27 -08003111{
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07003112 return security_ops->xfrm_policy_lookup(xp, fl_secid, dir);
3113}
3114
3115static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
3116 struct xfrm_policy *xp, struct flowi *fl)
3117{
3118 return security_ops->xfrm_state_pol_flow_match(x, xp, fl);
3119}
3120
3121static inline int security_xfrm_flow_state_match(struct flowi *fl, struct xfrm_state *xfrm)
3122{
3123 return security_ops->xfrm_flow_state_match(fl, xfrm);
3124}
3125
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07003126static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07003127{
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07003128 return security_ops->xfrm_decode_session(skb, secid, 1);
3129}
3130
3131static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl)
3132{
3133 int rc = security_ops->xfrm_decode_session(skb, &fl->secid, 0);
3134
3135 BUG_ON(rc);
Trent Jaegerdf718372005-12-13 23:12:27 -08003136}
3137#else /* CONFIG_SECURITY_NETWORK_XFRM */
3138static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx)
3139{
3140 return 0;
3141}
3142
Venkat Yekkiralacb969f02006-07-24 23:32:20 -07003143static inline int security_xfrm_sock_policy_alloc(struct xfrm_policy *xp, struct sock *sk)
3144{
3145 return 0;
3146}
3147
Trent Jaegerdf718372005-12-13 23:12:27 -08003148static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
3149{
3150 return 0;
3151}
3152
3153static inline void security_xfrm_policy_free(struct xfrm_policy *xp)
3154{
3155}
3156
Catherine Zhangc8c05a82006-06-08 23:39:49 -07003157static inline int security_xfrm_policy_delete(struct xfrm_policy *xp)
3158{
3159 return 0;
3160}
3161
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07003162static inline int security_xfrm_state_alloc(struct xfrm_state *x,
3163 struct xfrm_user_sec_ctx *sec_ctx)
3164{
3165 return 0;
3166}
3167
3168static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
3169 struct xfrm_sec_ctx *polsec, u32 secid)
Trent Jaegerdf718372005-12-13 23:12:27 -08003170{
3171 return 0;
3172}
3173
3174static inline void security_xfrm_state_free(struct xfrm_state *x)
3175{
3176}
3177
David S. Miller6f68dc32006-06-08 23:58:52 -07003178static inline int security_xfrm_state_delete(struct xfrm_state *x)
Catherine Zhangc8c05a82006-06-08 23:39:49 -07003179{
3180 return 0;
3181}
3182
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07003183static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir)
Trent Jaegerdf718372005-12-13 23:12:27 -08003184{
3185 return 0;
3186}
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07003187
3188static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
3189 struct xfrm_policy *xp, struct flowi *fl)
3190{
3191 return 1;
3192}
3193
3194static inline int security_xfrm_flow_state_match(struct flowi *fl,
3195 struct xfrm_state *xfrm)
3196{
3197 return 1;
3198}
3199
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07003200static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
Venkat Yekkiralae0d1caa2006-07-24 23:29:07 -07003201{
3202 return 0;
3203}
3204
Venkat Yekkiralabeb8d132006-08-04 23:12:42 -07003205static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl)
3206{
3207}
3208
Trent Jaegerdf718372005-12-13 23:12:27 -08003209#endif /* CONFIG_SECURITY_NETWORK_XFRM */
3210
David Howells29db9192005-10-30 15:02:44 -08003211#ifdef CONFIG_KEYS
3212#ifdef CONFIG_SECURITY
Michael LeMayd7200242006-06-22 14:47:17 -07003213static inline int security_key_alloc(struct key *key,
David Howells7e047ef2006-06-26 00:24:50 -07003214 struct task_struct *tsk,
3215 unsigned long flags)
David Howells29db9192005-10-30 15:02:44 -08003216{
David Howells7e047ef2006-06-26 00:24:50 -07003217 return security_ops->key_alloc(key, tsk, flags);
David Howells29db9192005-10-30 15:02:44 -08003218}
3219
3220static inline void security_key_free(struct key *key)
3221{
3222 security_ops->key_free(key);
3223}
3224
3225static inline int security_key_permission(key_ref_t key_ref,
3226 struct task_struct *context,
3227 key_perm_t perm)
3228{
3229 return security_ops->key_permission(key_ref, context, perm);
3230}
3231
3232#else
3233
Michael LeMayd7200242006-06-22 14:47:17 -07003234static inline int security_key_alloc(struct key *key,
David Howells7e047ef2006-06-26 00:24:50 -07003235 struct task_struct *tsk,
3236 unsigned long flags)
David Howells29db9192005-10-30 15:02:44 -08003237{
3238 return 0;
3239}
3240
3241static inline void security_key_free(struct key *key)
3242{
3243}
3244
3245static inline int security_key_permission(key_ref_t key_ref,
3246 struct task_struct *context,
3247 key_perm_t perm)
3248{
3249 return 0;
3250}
3251
3252#endif
3253#endif /* CONFIG_KEYS */
3254
Linus Torvalds1da177e2005-04-16 15:20:36 -07003255#endif /* ! __LINUX_SECURITY_H */
3256