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