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