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