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