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