diff options
Diffstat (limited to 'include/linux/security.h')
| -rw-r--r-- | include/linux/security.h | 481 |
1 files changed, 301 insertions, 180 deletions
diff --git a/include/linux/security.h b/include/linux/security.h index e3d4ecda2673..b92b5e453f64 100644 --- a/include/linux/security.h +++ b/include/linux/security.h | |||
| @@ -37,6 +37,10 @@ | |||
| 37 | /* Maximum number of letters for an LSM name string */ | 37 | /* Maximum number of letters for an LSM name string */ |
| 38 | #define SECURITY_NAME_MAX 10 | 38 | #define SECURITY_NAME_MAX 10 |
| 39 | 39 | ||
| 40 | /* If capable should audit the security request */ | ||
| 41 | #define SECURITY_CAP_NOAUDIT 0 | ||
| 42 | #define SECURITY_CAP_AUDIT 1 | ||
| 43 | |||
| 40 | struct ctl_table; | 44 | struct ctl_table; |
| 41 | struct audit_krule; | 45 | struct audit_krule; |
| 42 | 46 | ||
| @@ -44,25 +48,25 @@ struct audit_krule; | |||
| 44 | * These functions are in security/capability.c and are used | 48 | * These functions are in security/capability.c and are used |
| 45 | * as the default capabilities functions | 49 | * as the default capabilities functions |
| 46 | */ | 50 | */ |
| 47 | extern int cap_capable(struct task_struct *tsk, int cap); | 51 | extern int cap_capable(struct task_struct *tsk, int cap, int audit); |
| 48 | extern int cap_settime(struct timespec *ts, struct timezone *tz); | 52 | extern int cap_settime(struct timespec *ts, struct timezone *tz); |
| 49 | extern int cap_ptrace_may_access(struct task_struct *child, unsigned int mode); | 53 | extern int cap_ptrace_may_access(struct task_struct *child, unsigned int mode); |
| 50 | extern int cap_ptrace_traceme(struct task_struct *parent); | 54 | extern int cap_ptrace_traceme(struct task_struct *parent); |
| 51 | extern int cap_capget(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted); | 55 | extern int cap_capget(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted); |
| 52 | extern int cap_capset_check(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted); | 56 | extern int cap_capset(struct cred *new, const struct cred *old, |
| 53 | extern void cap_capset_set(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted); | 57 | const kernel_cap_t *effective, |
| 54 | extern int cap_bprm_set_security(struct linux_binprm *bprm); | 58 | const kernel_cap_t *inheritable, |
| 55 | extern void cap_bprm_apply_creds(struct linux_binprm *bprm, int unsafe); | 59 | const kernel_cap_t *permitted); |
| 60 | extern int cap_bprm_set_creds(struct linux_binprm *bprm); | ||
| 56 | extern int cap_bprm_secureexec(struct linux_binprm *bprm); | 61 | extern int cap_bprm_secureexec(struct linux_binprm *bprm); |
| 57 | extern int cap_inode_setxattr(struct dentry *dentry, const char *name, | 62 | extern int cap_inode_setxattr(struct dentry *dentry, const char *name, |
| 58 | const void *value, size_t size, int flags); | 63 | const void *value, size_t size, int flags); |
| 59 | extern int cap_inode_removexattr(struct dentry *dentry, const char *name); | 64 | extern int cap_inode_removexattr(struct dentry *dentry, const char *name); |
| 60 | extern int cap_inode_need_killpriv(struct dentry *dentry); | 65 | extern int cap_inode_need_killpriv(struct dentry *dentry); |
| 61 | extern int cap_inode_killpriv(struct dentry *dentry); | 66 | extern int cap_inode_killpriv(struct dentry *dentry); |
| 62 | extern int cap_task_post_setuid(uid_t old_ruid, uid_t old_euid, uid_t old_suid, int flags); | 67 | extern int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags); |
| 63 | extern void cap_task_reparent_to_init(struct task_struct *p); | ||
| 64 | extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3, | 68 | extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3, |
| 65 | unsigned long arg4, unsigned long arg5, long *rc_p); | 69 | unsigned long arg4, unsigned long arg5); |
| 66 | extern int cap_task_setscheduler(struct task_struct *p, int policy, struct sched_param *lp); | 70 | extern int cap_task_setscheduler(struct task_struct *p, int policy, struct sched_param *lp); |
| 67 | extern int cap_task_setioprio(struct task_struct *p, int ioprio); | 71 | extern int cap_task_setioprio(struct task_struct *p, int ioprio); |
| 68 | extern int cap_task_setnice(struct task_struct *p, int nice); | 72 | extern int cap_task_setnice(struct task_struct *p, int nice); |
| @@ -105,7 +109,7 @@ extern unsigned long mmap_min_addr; | |||
| 105 | struct sched_param; | 109 | struct sched_param; |
| 106 | struct request_sock; | 110 | struct request_sock; |
| 107 | 111 | ||
| 108 | /* bprm_apply_creds unsafe reasons */ | 112 | /* bprm->unsafe reasons */ |
| 109 | #define LSM_UNSAFE_SHARE 1 | 113 | #define LSM_UNSAFE_SHARE 1 |
| 110 | #define LSM_UNSAFE_PTRACE 2 | 114 | #define LSM_UNSAFE_PTRACE 2 |
| 111 | #define LSM_UNSAFE_PTRACE_CAP 4 | 115 | #define LSM_UNSAFE_PTRACE_CAP 4 |
| @@ -149,36 +153,7 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts) | |||
| 149 | * | 153 | * |
| 150 | * Security hooks for program execution operations. | 154 | * Security hooks for program execution operations. |
| 151 | * | 155 | * |
| 152 | * @bprm_alloc_security: | 156 | * @bprm_set_creds: |
| 153 | * Allocate and attach a security structure to the @bprm->security field. | ||
| 154 | * The security field is initialized to NULL when the bprm structure is | ||
| 155 | * allocated. | ||
| 156 | * @bprm contains the linux_binprm structure to be modified. | ||
| 157 | * Return 0 if operation was successful. | ||
| 158 | * @bprm_free_security: | ||
| 159 | * @bprm contains the linux_binprm structure to be modified. | ||
| 160 | * Deallocate and clear the @bprm->security field. | ||
| 161 | * @bprm_apply_creds: | ||
| 162 | * Compute and set the security attributes of a process being transformed | ||
| 163 | * by an execve operation based on the old attributes (current->security) | ||
| 164 | * and the information saved in @bprm->security by the set_security hook. | ||
| 165 | * Since this hook function (and its caller) are void, this hook can not | ||
| 166 | * return an error. However, it can leave the security attributes of the | ||
| 167 | * process unchanged if an access failure occurs at this point. | ||
| 168 | * bprm_apply_creds is called under task_lock. @unsafe indicates various | ||
| 169 | * reasons why it may be unsafe to change security state. | ||
| 170 | * @bprm contains the linux_binprm structure. | ||
| 171 | * @bprm_post_apply_creds: | ||
| 172 | * Runs after bprm_apply_creds with the task_lock dropped, so that | ||
| 173 | * functions which cannot be called safely under the task_lock can | ||
| 174 | * be used. This hook is a good place to perform state changes on | ||
| 175 | * the process such as closing open file descriptors to which access | ||
| 176 | * is no longer granted if the attributes were changed. | ||
| 177 | * Note that a security module might need to save state between | ||
| 178 | * bprm_apply_creds and bprm_post_apply_creds to store the decision | ||
| 179 | * on whether the process may proceed. | ||
| 180 | * @bprm contains the linux_binprm structure. | ||
| 181 | * @bprm_set_security: | ||
| 182 | * Save security information in the bprm->security field, typically based | 157 | * Save security information in the bprm->security field, typically based |
| 183 | * on information about the bprm->file, for later use by the apply_creds | 158 | * on information about the bprm->file, for later use by the apply_creds |
| 184 | * hook. This hook may also optionally check permissions (e.g. for | 159 | * hook. This hook may also optionally check permissions (e.g. for |
| @@ -191,15 +166,30 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts) | |||
| 191 | * @bprm contains the linux_binprm structure. | 166 | * @bprm contains the linux_binprm structure. |
| 192 | * Return 0 if the hook is successful and permission is granted. | 167 | * Return 0 if the hook is successful and permission is granted. |
| 193 | * @bprm_check_security: | 168 | * @bprm_check_security: |
| 194 | * This hook mediates the point when a search for a binary handler will | 169 | * This hook mediates the point when a search for a binary handler will |
| 195 | * begin. It allows a check the @bprm->security value which is set in | 170 | * begin. It allows a check the @bprm->security value which is set in the |
| 196 | * the preceding set_security call. The primary difference from | 171 | * preceding set_creds call. The primary difference from set_creds is |
| 197 | * set_security is that the argv list and envp list are reliably | 172 | * that the argv list and envp list are reliably available in @bprm. This |
| 198 | * available in @bprm. This hook may be called multiple times | 173 | * hook may be called multiple times during a single execve; and in each |
| 199 | * during a single execve; and in each pass set_security is called | 174 | * pass set_creds is called first. |
| 200 | * first. | ||
| 201 | * @bprm contains the linux_binprm structure. | 175 | * @bprm contains the linux_binprm structure. |
| 202 | * Return 0 if the hook is successful and permission is granted. | 176 | * Return 0 if the hook is successful and permission is granted. |
| 177 | * @bprm_committing_creds: | ||
| 178 | * Prepare to install the new security attributes of a process being | ||
| 179 | * transformed by an execve operation, based on the old credentials | ||
| 180 | * pointed to by @current->cred and the information set in @bprm->cred by | ||
| 181 | * the bprm_set_creds hook. @bprm points to the linux_binprm structure. | ||
| 182 | * This hook is a good place to perform state changes on the process such | ||
| 183 | * as closing open file descriptors to which access will no longer be | ||
| 184 | * granted when the attributes are changed. This is called immediately | ||
| 185 | * before commit_creds(). | ||
| 186 | * @bprm_committed_creds: | ||
| 187 | * Tidy up after the installation of the new security attributes of a | ||
| 188 | * process being transformed by an execve operation. The new credentials | ||
| 189 | * have, by this point, been set to @current->cred. @bprm points to the | ||
| 190 | * linux_binprm structure. This hook is a good place to perform state | ||
| 191 | * changes on the process such as clearing out non-inheritable signal | ||
| 192 | * state. This is called immediately after commit_creds(). | ||
| 203 | * @bprm_secureexec: | 193 | * @bprm_secureexec: |
| 204 | * Return a boolean value (0 or 1) indicating whether a "secure exec" | 194 | * Return a boolean value (0 or 1) indicating whether a "secure exec" |
| 205 | * is required. The flag is passed in the auxiliary table | 195 | * is required. The flag is passed in the auxiliary table |
| @@ -345,17 +335,37 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts) | |||
| 345 | * @dir contains the inode structure of the parent directory of the new link. | 335 | * @dir contains the inode structure of the parent directory of the new link. |
| 346 | * @new_dentry contains the dentry structure for the new link. | 336 | * @new_dentry contains the dentry structure for the new link. |
| 347 | * Return 0 if permission is granted. | 337 | * Return 0 if permission is granted. |
| 338 | * @path_link: | ||
| 339 | * Check permission before creating a new hard link to a file. | ||
| 340 | * @old_dentry contains the dentry structure for an existing link | ||
| 341 | * to the file. | ||
| 342 | * @new_dir contains the path structure of the parent directory of | ||
| 343 | * the new link. | ||
| 344 | * @new_dentry contains the dentry structure for the new link. | ||
| 345 | * Return 0 if permission is granted. | ||
| 348 | * @inode_unlink: | 346 | * @inode_unlink: |
| 349 | * Check the permission to remove a hard link to a file. | 347 | * Check the permission to remove a hard link to a file. |
| 350 | * @dir contains the inode structure of parent directory of the file. | 348 | * @dir contains the inode structure of parent directory of the file. |
| 351 | * @dentry contains the dentry structure for file to be unlinked. | 349 | * @dentry contains the dentry structure for file to be unlinked. |
| 352 | * Return 0 if permission is granted. | 350 | * Return 0 if permission is granted. |
| 351 | * @path_unlink: | ||
| 352 | * Check the permission to remove a hard link to a file. | ||
| 353 | * @dir contains the path structure of parent directory of the file. | ||
| 354 | * @dentry contains the dentry structure for file to be unlinked. | ||
| 355 | * Return 0 if permission is granted. | ||
| 353 | * @inode_symlink: | 356 | * @inode_symlink: |
| 354 | * Check the permission to create a symbolic link to a file. | 357 | * Check the permission to create a symbolic link to a file. |
| 355 | * @dir contains the inode structure of parent directory of the symbolic link. | 358 | * @dir contains the inode structure of parent directory of the symbolic link. |
| 356 | * @dentry contains the dentry structure of the symbolic link. | 359 | * @dentry contains the dentry structure of the symbolic link. |
| 357 | * @old_name contains the pathname of file. | 360 | * @old_name contains the pathname of file. |
| 358 | * Return 0 if permission is granted. | 361 | * Return 0 if permission is granted. |
| 362 | * @path_symlink: | ||
| 363 | * Check the permission to create a symbolic link to a file. | ||
| 364 | * @dir contains the path structure of parent directory of | ||
| 365 | * the symbolic link. | ||
| 366 | * @dentry contains the dentry structure of the symbolic link. | ||
| 367 | * @old_name contains the pathname of file. | ||
| 368 | * Return 0 if permission is granted. | ||
| 359 | * @inode_mkdir: | 369 | * @inode_mkdir: |
| 360 | * Check permissions to create a new directory in the existing directory | 370 | * Check permissions to create a new directory in the existing directory |
| 361 | * associated with inode strcture @dir. | 371 | * associated with inode strcture @dir. |
| @@ -363,11 +373,25 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts) | |||
| 363 | * @dentry contains the dentry structure of new directory. | 373 | * @dentry contains the dentry structure of new directory. |
| 364 | * @mode contains the mode of new directory. | 374 | * @mode contains the mode of new directory. |
| 365 | * Return 0 if permission is granted. | 375 | * Return 0 if permission is granted. |
| 376 | * @path_mkdir: | ||
| 377 | * Check permissions to create a new directory in the existing directory | ||
| 378 | * associated with path strcture @path. | ||
| 379 | * @dir containst the path structure of parent of the directory | ||
| 380 | * to be created. | ||
| 381 | * @dentry contains the dentry structure of new directory. | ||
| 382 | * @mode contains the mode of new directory. | ||
| 383 | * Return 0 if permission is granted. | ||
| 366 | * @inode_rmdir: | 384 | * @inode_rmdir: |
| 367 | * Check the permission to remove a directory. | 385 | * Check the permission to remove a directory. |
| 368 | * @dir contains the inode structure of parent of the directory to be removed. | 386 | * @dir contains the inode structure of parent of the directory to be removed. |
| 369 | * @dentry contains the dentry structure of directory to be removed. | 387 | * @dentry contains the dentry structure of directory to be removed. |
| 370 | * Return 0 if permission is granted. | 388 | * Return 0 if permission is granted. |
| 389 | * @path_rmdir: | ||
| 390 | * Check the permission to remove a directory. | ||
| 391 | * @dir contains the path structure of parent of the directory to be | ||
| 392 | * removed. | ||
| 393 | * @dentry contains the dentry structure of directory to be removed. | ||
| 394 | * Return 0 if permission is granted. | ||
| 371 | * @inode_mknod: | 395 | * @inode_mknod: |
| 372 | * Check permissions when creating a special file (or a socket or a fifo | 396 | * Check permissions when creating a special file (or a socket or a fifo |
| 373 | * file created via the mknod system call). Note that if mknod operation | 397 | * file created via the mknod system call). Note that if mknod operation |
| @@ -378,6 +402,15 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts) | |||
| 378 | * @mode contains the mode of the new file. | 402 | * @mode contains the mode of the new file. |
| 379 | * @dev contains the device number. | 403 | * @dev contains the device number. |
| 380 | * Return 0 if permission is granted. | 404 | * Return 0 if permission is granted. |
| 405 | * @path_mknod: | ||
| 406 | * Check permissions when creating a file. Note that this hook is called | ||
| 407 | * even if mknod operation is being done for a regular file. | ||
| 408 | * @dir contains the path structure of parent of the new file. | ||
| 409 | * @dentry contains the dentry structure of the new file. | ||
| 410 | * @mode contains the mode of the new file. | ||
| 411 | * @dev contains the undecoded device number. Use new_decode_dev() to get | ||
| 412 | * the decoded device number. | ||
| 413 | * Return 0 if permission is granted. | ||
| 381 | * @inode_rename: | 414 | * @inode_rename: |
| 382 | * Check for permission to rename a file or directory. | 415 | * Check for permission to rename a file or directory. |
| 383 | * @old_dir contains the inode structure for parent of the old link. | 416 | * @old_dir contains the inode structure for parent of the old link. |
| @@ -385,6 +418,13 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts) | |||
| 385 | * @new_dir contains the inode structure for parent of the new link. | 418 | * @new_dir contains the inode structure for parent of the new link. |
| 386 | * @new_dentry contains the dentry structure of the new link. | 419 | * @new_dentry contains the dentry structure of the new link. |
| 387 | * Return 0 if permission is granted. | 420 | * Return 0 if permission is granted. |
| 421 | * @path_rename: | ||
| 422 | * Check for permission to rename a file or directory. | ||
| 423 | * @old_dir contains the path structure for parent of the old link. | ||
| 424 | * @old_dentry contains the dentry structure of the old link. | ||
| 425 | * @new_dir contains the path structure for parent of the new link. | ||
| 426 | * @new_dentry contains the dentry structure of the new link. | ||
| 427 | * Return 0 if permission is granted. | ||
| 388 | * @inode_readlink: | 428 | * @inode_readlink: |
| 389 | * Check the permission to read the symbolic link. | 429 | * Check the permission to read the symbolic link. |
| 390 | * @dentry contains the dentry structure for the file link. | 430 | * @dentry contains the dentry structure for the file link. |
| @@ -413,6 +453,12 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts) | |||
| 413 | * @dentry contains the dentry structure for the file. | 453 | * @dentry contains the dentry structure for the file. |
| 414 | * @attr is the iattr structure containing the new file attributes. | 454 | * @attr is the iattr structure containing the new file attributes. |
| 415 | * Return 0 if permission is granted. | 455 | * Return 0 if permission is granted. |
| 456 | * @path_truncate: | ||
| 457 | * Check permission before truncating a file. | ||
| 458 | * @path contains the path structure for the file. | ||
| 459 | * @length is the new length of the file. | ||
| 460 | * @time_attrs is the flags passed to do_truncate(). | ||
| 461 | * Return 0 if permission is granted. | ||
| 416 | * @inode_getattr: | 462 | * @inode_getattr: |
| 417 | * Check permission before obtaining file attributes. | 463 | * Check permission before obtaining file attributes. |
| 418 | * @mnt is the vfsmount where the dentry was looked up | 464 | * @mnt is the vfsmount where the dentry was looked up |
| @@ -585,15 +631,31 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts) | |||
| 585 | * manual page for definitions of the @clone_flags. | 631 | * manual page for definitions of the @clone_flags. |
| 586 | * @clone_flags contains the flags indicating what should be shared. | 632 | * @clone_flags contains the flags indicating what should be shared. |
| 587 | * Return 0 if permission is granted. | 633 | * Return 0 if permission is granted. |
| 588 | * @task_alloc_security: | 634 | * @cred_free: |
| 589 | * @p contains the task_struct for child process. | 635 | * @cred points to the credentials. |
| 590 | * Allocate and attach a security structure to the p->security field. The | 636 | * Deallocate and clear the cred->security field in a set of credentials. |
| 591 | * security field is initialized to NULL when the task structure is | 637 | * @cred_prepare: |
| 592 | * allocated. | 638 | * @new points to the new credentials. |
| 593 | * Return 0 if operation was successful. | 639 | * @old points to the original credentials. |
| 594 | * @task_free_security: | 640 | * @gfp indicates the atomicity of any memory allocations. |
| 595 | * @p contains the task_struct for process. | 641 | * Prepare a new set of credentials by copying the data from the old set. |
| 596 | * Deallocate and clear the p->security field. | 642 | * @cred_commit: |
| 643 | * @new points to the new credentials. | ||
| 644 | * @old points to the original credentials. | ||
| 645 | * Install a new set of credentials. | ||
| 646 | * @kernel_act_as: | ||
| 647 | * Set the credentials for a kernel service to act as (subjective context). | ||
| 648 | * @new points to the credentials to be modified. | ||
| 649 | * @secid specifies the security ID to be set | ||
| 650 | * The current task must be the one that nominated @secid. | ||
| 651 | * Return 0 if successful. | ||
| 652 | * @kernel_create_files_as: | ||
| 653 | * Set the file creation context in a set of credentials to be the same as | ||
| 654 | * the objective context of the specified inode. | ||
| 655 | * @new points to the credentials to be modified. | ||
| 656 | * @inode points to the inode to use as a reference. | ||
| 657 | * The current task must be the one that nominated @inode. | ||
| 658 | * Return 0 if successful. | ||
| 597 | * @task_setuid: | 659 | * @task_setuid: |
| 598 | * Check permission before setting one or more of the user identity | 660 | * Check permission before setting one or more of the user identity |
| 599 | * attributes of the current process. The @flags parameter indicates | 661 | * attributes of the current process. The @flags parameter indicates |
| @@ -606,15 +668,13 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts) | |||
| 606 | * @id2 contains a uid. | 668 | * @id2 contains a uid. |
| 607 | * @flags contains one of the LSM_SETID_* values. | 669 | * @flags contains one of the LSM_SETID_* values. |
| 608 | * Return 0 if permission is granted. | 670 | * Return 0 if permission is granted. |
| 609 | * @task_post_setuid: | 671 | * @task_fix_setuid: |
| 610 | * Update the module's state after setting one or more of the user | 672 | * Update the module's state after setting one or more of the user |
| 611 | * identity attributes of the current process. The @flags parameter | 673 | * identity attributes of the current process. The @flags parameter |
| 612 | * indicates which of the set*uid system calls invoked this hook. If | 674 | * indicates which of the set*uid system calls invoked this hook. If |
| 613 | * @flags is LSM_SETID_FS, then @old_ruid is the old fs uid and the other | 675 | * @new is the set of credentials that will be installed. Modifications |
| 614 | * parameters are not used. | 676 | * should be made to this rather than to @current->cred. |
| 615 | * @old_ruid contains the old real uid (or fs uid if LSM_SETID_FS). | 677 | * @old is the set of credentials that are being replaces |
| 616 | * @old_euid contains the old effective uid (or -1 if LSM_SETID_FS). | ||
| 617 | * @old_suid contains the old saved uid (or -1 if LSM_SETID_FS). | ||
| 618 | * @flags contains one of the LSM_SETID_* values. | 678 | * @flags contains one of the LSM_SETID_* values. |
| 619 | * Return 0 on success. | 679 | * Return 0 on success. |
| 620 | * @task_setgid: | 680 | * @task_setgid: |
| @@ -717,13 +777,8 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts) | |||
| 717 | * @arg3 contains a argument. | 777 | * @arg3 contains a argument. |
| 718 | * @arg4 contains a argument. | 778 | * @arg4 contains a argument. |
| 719 | * @arg5 contains a argument. | 779 | * @arg5 contains a argument. |
| 720 | * @rc_p contains a pointer to communicate back the forced return code | 780 | * Return -ENOSYS if no-one wanted to handle this op, any other value to |
| 721 | * Return 0 if permission is granted, and non-zero if the security module | 781 | * cause prctl() to return immediately with that value. |
| 722 | * has taken responsibility (setting *rc_p) for the prctl call. | ||
| 723 | * @task_reparent_to_init: | ||
| 724 | * Set the security attributes in @p->security for a kernel thread that | ||
| 725 | * is being reparented to the init task. | ||
| 726 | * @p contains the task_struct for the kernel thread. | ||
| 727 | * @task_to_inode: | 782 | * @task_to_inode: |
| 728 | * Set the security attributes for an inode based on an associated task's | 783 | * Set the security attributes for an inode based on an associated task's |
| 729 | * security attributes, e.g. for /proc/pid inodes. | 784 | * security attributes, e.g. for /proc/pid inodes. |
| @@ -1000,7 +1055,7 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts) | |||
| 1000 | * See whether a specific operational right is granted to a process on a | 1055 | * See whether a specific operational right is granted to a process on a |
| 1001 | * key. | 1056 | * key. |
| 1002 | * @key_ref refers to the key (key pointer + possession attribute bit). | 1057 | * @key_ref refers to the key (key pointer + possession attribute bit). |
| 1003 | * @context points to the process to provide the context against which to | 1058 | * @cred points to the credentials to provide the context against which to |
| 1004 | * evaluate the security data on the key. | 1059 | * evaluate the security data on the key. |
| 1005 | * @perm describes the combination of permissions required of this key. | 1060 | * @perm describes the combination of permissions required of this key. |
| 1006 | * Return 1 if permission granted, 0 if permission denied and -ve it the | 1061 | * Return 1 if permission granted, 0 if permission denied and -ve it the |
| @@ -1162,6 +1217,7 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts) | |||
| 1162 | * @child process. | 1217 | * @child process. |
| 1163 | * Security modules may also want to perform a process tracing check | 1218 | * Security modules may also want to perform a process tracing check |
| 1164 | * during an execve in the set_security or apply_creds hooks of | 1219 | * during an execve in the set_security or apply_creds hooks of |
| 1220 | * tracing check during an execve in the bprm_set_creds hook of | ||
| 1165 | * binprm_security_ops if the process is being traced and its security | 1221 | * binprm_security_ops if the process is being traced and its security |
| 1166 | * attributes would be changed by the execve. | 1222 | * attributes would be changed by the execve. |
| 1167 | * @child contains the task_struct structure for the target process. | 1223 | * @child contains the task_struct structure for the target process. |
| @@ -1185,29 +1241,15 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts) | |||
| 1185 | * @inheritable contains the inheritable capability set. | 1241 | * @inheritable contains the inheritable capability set. |
| 1186 | * @permitted contains the permitted capability set. | 1242 | * @permitted contains the permitted capability set. |
| 1187 | * Return 0 if the capability sets were successfully obtained. | 1243 | * Return 0 if the capability sets were successfully obtained. |
| 1188 | * @capset_check: | 1244 | * @capset: |
| 1189 | * Check permission before setting the @effective, @inheritable, and | ||
| 1190 | * @permitted capability sets for the @target process. | ||
| 1191 | * Caveat: @target is also set to current if a set of processes is | ||
| 1192 | * specified (i.e. all processes other than current and init or a | ||
| 1193 | * particular process group). Hence, the capset_set hook may need to | ||
| 1194 | * revalidate permission to the actual target process. | ||
| 1195 | * @target contains the task_struct structure for target process. | ||
| 1196 | * @effective contains the effective capability set. | ||
| 1197 | * @inheritable contains the inheritable capability set. | ||
| 1198 | * @permitted contains the permitted capability set. | ||
| 1199 | * Return 0 if permission is granted. | ||
| 1200 | * @capset_set: | ||
| 1201 | * Set the @effective, @inheritable, and @permitted capability sets for | 1245 | * Set the @effective, @inheritable, and @permitted capability sets for |
| 1202 | * the @target process. Since capset_check cannot always check permission | 1246 | * the current process. |
| 1203 | * to the real @target process, this hook may also perform permission | 1247 | * @new contains the new credentials structure for target process. |
| 1204 | * checking to determine if the current process is allowed to set the | 1248 | * @old contains the current credentials structure for target process. |
| 1205 | * capability sets of the @target process. However, this hook has no way | ||
| 1206 | * of returning an error due to the structure of the sys_capset code. | ||
| 1207 | * @target contains the task_struct structure for target process. | ||
| 1208 | * @effective contains the effective capability set. | 1249 | * @effective contains the effective capability set. |
| 1209 | * @inheritable contains the inheritable capability set. | 1250 | * @inheritable contains the inheritable capability set. |
| 1210 | * @permitted contains the permitted capability set. | 1251 | * @permitted contains the permitted capability set. |
| 1252 | * Return 0 and update @new if permission is granted. | ||
| 1211 | * @capable: | 1253 | * @capable: |
| 1212 | * Check whether the @tsk process has the @cap capability. | 1254 | * Check whether the @tsk process has the @cap capability. |
| 1213 | * @tsk contains the task_struct for the process. | 1255 | * @tsk contains the task_struct for the process. |
| @@ -1299,15 +1341,12 @@ struct security_operations { | |||
| 1299 | int (*capget) (struct task_struct *target, | 1341 | int (*capget) (struct task_struct *target, |
| 1300 | kernel_cap_t *effective, | 1342 | kernel_cap_t *effective, |
| 1301 | kernel_cap_t *inheritable, kernel_cap_t *permitted); | 1343 | kernel_cap_t *inheritable, kernel_cap_t *permitted); |
| 1302 | int (*capset_check) (struct task_struct *target, | 1344 | int (*capset) (struct cred *new, |
| 1303 | kernel_cap_t *effective, | 1345 | const struct cred *old, |
| 1304 | kernel_cap_t *inheritable, | 1346 | const kernel_cap_t *effective, |
| 1305 | kernel_cap_t *permitted); | 1347 | const kernel_cap_t *inheritable, |
| 1306 | void (*capset_set) (struct task_struct *target, | 1348 | const kernel_cap_t *permitted); |
| 1307 | kernel_cap_t *effective, | 1349 | int (*capable) (struct task_struct *tsk, int cap, int audit); |
| 1308 | kernel_cap_t *inheritable, | ||
| 1309 | kernel_cap_t *permitted); | ||
| 1310 | int (*capable) (struct task_struct *tsk, int cap); | ||
| 1311 | int (*acct) (struct file *file); | 1350 | int (*acct) (struct file *file); |
| 1312 | int (*sysctl) (struct ctl_table *table, int op); | 1351 | int (*sysctl) (struct ctl_table *table, int op); |
| 1313 | int (*quotactl) (int cmds, int type, int id, struct super_block *sb); | 1352 | int (*quotactl) (int cmds, int type, int id, struct super_block *sb); |
| @@ -1316,18 +1355,16 @@ struct security_operations { | |||
| 1316 | int (*settime) (struct timespec *ts, struct timezone *tz); | 1355 | int (*settime) (struct timespec *ts, struct timezone *tz); |
| 1317 | int (*vm_enough_memory) (struct mm_struct *mm, long pages); | 1356 | int (*vm_enough_memory) (struct mm_struct *mm, long pages); |
| 1318 | 1357 | ||
| 1319 | int (*bprm_alloc_security) (struct linux_binprm *bprm); | 1358 | int (*bprm_set_creds) (struct linux_binprm *bprm); |
| 1320 | void (*bprm_free_security) (struct linux_binprm *bprm); | ||
| 1321 | void (*bprm_apply_creds) (struct linux_binprm *bprm, int unsafe); | ||
| 1322 | void (*bprm_post_apply_creds) (struct linux_binprm *bprm); | ||
| 1323 | int (*bprm_set_security) (struct linux_binprm *bprm); | ||
| 1324 | int (*bprm_check_security) (struct linux_binprm *bprm); | 1359 | int (*bprm_check_security) (struct linux_binprm *bprm); |
| 1325 | int (*bprm_secureexec) (struct linux_binprm *bprm); | 1360 | int (*bprm_secureexec) (struct linux_binprm *bprm); |
| 1361 | void (*bprm_committing_creds) (struct linux_binprm *bprm); | ||
| 1362 | void (*bprm_committed_creds) (struct linux_binprm *bprm); | ||
| 1326 | 1363 | ||
| 1327 | int (*sb_alloc_security) (struct super_block *sb); | 1364 | int (*sb_alloc_security) (struct super_block *sb); |
| 1328 | void (*sb_free_security) (struct super_block *sb); | 1365 | void (*sb_free_security) (struct super_block *sb); |
| 1329 | int (*sb_copy_data) (char *orig, char *copy); | 1366 | int (*sb_copy_data) (char *orig, char *copy); |
| 1330 | int (*sb_kern_mount) (struct super_block *sb, void *data); | 1367 | int (*sb_kern_mount) (struct super_block *sb, int flags, void *data); |
| 1331 | int (*sb_show_options) (struct seq_file *m, struct super_block *sb); | 1368 | int (*sb_show_options) (struct seq_file *m, struct super_block *sb); |
| 1332 | int (*sb_statfs) (struct dentry *dentry); | 1369 | int (*sb_statfs) (struct dentry *dentry); |
| 1333 | int (*sb_mount) (char *dev_name, struct path *path, | 1370 | int (*sb_mount) (char *dev_name, struct path *path, |
| @@ -1350,6 +1387,22 @@ struct security_operations { | |||
| 1350 | struct super_block *newsb); | 1387 | struct super_block *newsb); |
| 1351 | int (*sb_parse_opts_str) (char *options, struct security_mnt_opts *opts); | 1388 | int (*sb_parse_opts_str) (char *options, struct security_mnt_opts *opts); |
| 1352 | 1389 | ||
| 1390 | #ifdef CONFIG_SECURITY_PATH | ||
| 1391 | int (*path_unlink) (struct path *dir, struct dentry *dentry); | ||
| 1392 | int (*path_mkdir) (struct path *dir, struct dentry *dentry, int mode); | ||
| 1393 | int (*path_rmdir) (struct path *dir, struct dentry *dentry); | ||
| 1394 | int (*path_mknod) (struct path *dir, struct dentry *dentry, int mode, | ||
| 1395 | unsigned int dev); | ||
| 1396 | int (*path_truncate) (struct path *path, loff_t length, | ||
| 1397 | unsigned int time_attrs); | ||
| 1398 | int (*path_symlink) (struct path *dir, struct dentry *dentry, | ||
| 1399 | const char *old_name); | ||
| 1400 | int (*path_link) (struct dentry *old_dentry, struct path *new_dir, | ||
| 1401 | struct dentry *new_dentry); | ||
| 1402 | int (*path_rename) (struct path *old_dir, struct dentry *old_dentry, | ||
| 1403 | struct path *new_dir, struct dentry *new_dentry); | ||
| 1404 | #endif | ||
| 1405 | |||
| 1353 | int (*inode_alloc_security) (struct inode *inode); | 1406 | int (*inode_alloc_security) (struct inode *inode); |
| 1354 | void (*inode_free_security) (struct inode *inode); | 1407 | void (*inode_free_security) (struct inode *inode); |
| 1355 | int (*inode_init_security) (struct inode *inode, struct inode *dir, | 1408 | int (*inode_init_security) (struct inode *inode, struct inode *dir, |
| @@ -1406,14 +1459,18 @@ struct security_operations { | |||
| 1406 | int (*file_send_sigiotask) (struct task_struct *tsk, | 1459 | int (*file_send_sigiotask) (struct task_struct *tsk, |
| 1407 | struct fown_struct *fown, int sig); | 1460 | struct fown_struct *fown, int sig); |
| 1408 | int (*file_receive) (struct file *file); | 1461 | int (*file_receive) (struct file *file); |
| 1409 | int (*dentry_open) (struct file *file); | 1462 | int (*dentry_open) (struct file *file, const struct cred *cred); |
| 1410 | 1463 | ||
| 1411 | int (*task_create) (unsigned long clone_flags); | 1464 | int (*task_create) (unsigned long clone_flags); |
| 1412 | int (*task_alloc_security) (struct task_struct *p); | 1465 | void (*cred_free) (struct cred *cred); |
| 1413 | void (*task_free_security) (struct task_struct *p); | 1466 | int (*cred_prepare)(struct cred *new, const struct cred *old, |
| 1467 | gfp_t gfp); | ||
| 1468 | void (*cred_commit)(struct cred *new, const struct cred *old); | ||
| 1469 | int (*kernel_act_as)(struct cred *new, u32 secid); | ||
| 1470 | int (*kernel_create_files_as)(struct cred *new, struct inode *inode); | ||
| 1414 | int (*task_setuid) (uid_t id0, uid_t id1, uid_t id2, int flags); | 1471 | int (*task_setuid) (uid_t id0, uid_t id1, uid_t id2, int flags); |
| 1415 | int (*task_post_setuid) (uid_t old_ruid /* or fsuid */ , | 1472 | int (*task_fix_setuid) (struct cred *new, const struct cred *old, |
| 1416 | uid_t old_euid, uid_t old_suid, int flags); | 1473 | int flags); |
| 1417 | int (*task_setgid) (gid_t id0, gid_t id1, gid_t id2, int flags); | 1474 | int (*task_setgid) (gid_t id0, gid_t id1, gid_t id2, int flags); |
| 1418 | int (*task_setpgid) (struct task_struct *p, pid_t pgid); | 1475 | int (*task_setpgid) (struct task_struct *p, pid_t pgid); |
| 1419 | int (*task_getpgid) (struct task_struct *p); | 1476 | int (*task_getpgid) (struct task_struct *p); |
| @@ -1433,8 +1490,7 @@ struct security_operations { | |||
| 1433 | int (*task_wait) (struct task_struct *p); | 1490 | int (*task_wait) (struct task_struct *p); |
| 1434 | int (*task_prctl) (int option, unsigned long arg2, | 1491 | int (*task_prctl) (int option, unsigned long arg2, |
| 1435 | unsigned long arg3, unsigned long arg4, | 1492 | unsigned long arg3, unsigned long arg4, |
| 1436 | unsigned long arg5, long *rc_p); | 1493 | unsigned long arg5); |
| 1437 | void (*task_reparent_to_init) (struct task_struct *p); | ||
| 1438 | void (*task_to_inode) (struct task_struct *p, struct inode *inode); | 1494 | void (*task_to_inode) (struct task_struct *p, struct inode *inode); |
| 1439 | 1495 | ||
| 1440 | int (*ipc_permission) (struct kern_ipc_perm *ipcp, short flag); | 1496 | int (*ipc_permission) (struct kern_ipc_perm *ipcp, short flag); |
| @@ -1539,10 +1595,10 @@ struct security_operations { | |||
| 1539 | 1595 | ||
| 1540 | /* key management security hooks */ | 1596 | /* key management security hooks */ |
| 1541 | #ifdef CONFIG_KEYS | 1597 | #ifdef CONFIG_KEYS |
| 1542 | int (*key_alloc) (struct key *key, struct task_struct *tsk, unsigned long flags); | 1598 | int (*key_alloc) (struct key *key, const struct cred *cred, unsigned long flags); |
| 1543 | void (*key_free) (struct key *key); | 1599 | void (*key_free) (struct key *key); |
| 1544 | int (*key_permission) (key_ref_t key_ref, | 1600 | int (*key_permission) (key_ref_t key_ref, |
| 1545 | struct task_struct *context, | 1601 | const struct cred *cred, |
| 1546 | key_perm_t perm); | 1602 | key_perm_t perm); |
| 1547 | int (*key_getsecurity)(struct key *key, char **_buffer); | 1603 | int (*key_getsecurity)(struct key *key, char **_buffer); |
| 1548 | #endif /* CONFIG_KEYS */ | 1604 | #endif /* CONFIG_KEYS */ |
| @@ -1568,15 +1624,12 @@ int security_capget(struct task_struct *target, | |||
| 1568 | kernel_cap_t *effective, | 1624 | kernel_cap_t *effective, |
| 1569 | kernel_cap_t *inheritable, | 1625 | kernel_cap_t *inheritable, |
| 1570 | kernel_cap_t *permitted); | 1626 | kernel_cap_t *permitted); |
| 1571 | int security_capset_check(struct task_struct *target, | 1627 | int security_capset(struct cred *new, const struct cred *old, |
| 1572 | kernel_cap_t *effective, | 1628 | const kernel_cap_t *effective, |
| 1573 | kernel_cap_t *inheritable, | 1629 | const kernel_cap_t *inheritable, |
| 1574 | kernel_cap_t *permitted); | 1630 | const kernel_cap_t *permitted); |
| 1575 | void security_capset_set(struct task_struct *target, | ||
| 1576 | kernel_cap_t *effective, | ||
| 1577 | kernel_cap_t *inheritable, | ||
| 1578 | kernel_cap_t *permitted); | ||
| 1579 | int security_capable(struct task_struct *tsk, int cap); | 1631 | int security_capable(struct task_struct *tsk, int cap); |
| 1632 | int security_capable_noaudit(struct task_struct *tsk, int cap); | ||
| 1580 | int security_acct(struct file *file); | 1633 | int security_acct(struct file *file); |
| 1581 | int security_sysctl(struct ctl_table *table, int op); | 1634 | int security_sysctl(struct ctl_table *table, int op); |
| 1582 | int security_quotactl(int cmds, int type, int id, struct super_block *sb); | 1635 | int security_quotactl(int cmds, int type, int id, struct super_block *sb); |
| @@ -1586,17 +1639,15 @@ int security_settime(struct timespec *ts, struct timezone *tz); | |||
| 1586 | int security_vm_enough_memory(long pages); | 1639 | int security_vm_enough_memory(long pages); |
| 1587 | int security_vm_enough_memory_mm(struct mm_struct *mm, long pages); | 1640 | int security_vm_enough_memory_mm(struct mm_struct *mm, long pages); |
| 1588 | int security_vm_enough_memory_kern(long pages); | 1641 | int security_vm_enough_memory_kern(long pages); |
| 1589 | int security_bprm_alloc(struct linux_binprm *bprm); | 1642 | int security_bprm_set_creds(struct linux_binprm *bprm); |
| 1590 | void security_bprm_free(struct linux_binprm *bprm); | ||
| 1591 | void security_bprm_apply_creds(struct linux_binprm *bprm, int unsafe); | ||
| 1592 | void security_bprm_post_apply_creds(struct linux_binprm *bprm); | ||
| 1593 | int security_bprm_set(struct linux_binprm *bprm); | ||
| 1594 | int security_bprm_check(struct linux_binprm *bprm); | 1643 | int security_bprm_check(struct linux_binprm *bprm); |
| 1644 | void security_bprm_committing_creds(struct linux_binprm *bprm); | ||
| 1645 | void security_bprm_committed_creds(struct linux_binprm *bprm); | ||
| 1595 | int security_bprm_secureexec(struct linux_binprm *bprm); | 1646 | int security_bprm_secureexec(struct linux_binprm *bprm); |
| 1596 | int security_sb_alloc(struct super_block *sb); | 1647 | int security_sb_alloc(struct super_block *sb); |
| 1597 | void security_sb_free(struct super_block *sb); | 1648 | void security_sb_free(struct super_block *sb); |
| 1598 | int security_sb_copy_data(char *orig, char *copy); | 1649 | int security_sb_copy_data(char *orig, char *copy); |
| 1599 | int security_sb_kern_mount(struct super_block *sb, void *data); | 1650 | int security_sb_kern_mount(struct super_block *sb, int flags, void *data); |
| 1600 | int security_sb_show_options(struct seq_file *m, struct super_block *sb); | 1651 | int security_sb_show_options(struct seq_file *m, struct super_block *sb); |
| 1601 | int security_sb_statfs(struct dentry *dentry); | 1652 | int security_sb_statfs(struct dentry *dentry); |
| 1602 | int security_sb_mount(char *dev_name, struct path *path, | 1653 | int security_sb_mount(char *dev_name, struct path *path, |
| @@ -1663,13 +1714,16 @@ int security_file_set_fowner(struct file *file); | |||
| 1663 | int security_file_send_sigiotask(struct task_struct *tsk, | 1714 | int security_file_send_sigiotask(struct task_struct *tsk, |
| 1664 | struct fown_struct *fown, int sig); | 1715 | struct fown_struct *fown, int sig); |
| 1665 | int security_file_receive(struct file *file); | 1716 | int security_file_receive(struct file *file); |
| 1666 | int security_dentry_open(struct file *file); | 1717 | int security_dentry_open(struct file *file, const struct cred *cred); |
| 1667 | int security_task_create(unsigned long clone_flags); | 1718 | int security_task_create(unsigned long clone_flags); |
| 1668 | int security_task_alloc(struct task_struct *p); | 1719 | void security_cred_free(struct cred *cred); |
| 1669 | void security_task_free(struct task_struct *p); | 1720 | int security_prepare_creds(struct cred *new, const struct cred *old, gfp_t gfp); |
| 1721 | void security_commit_creds(struct cred *new, const struct cred *old); | ||
| 1722 | int security_kernel_act_as(struct cred *new, u32 secid); | ||
| 1723 | int security_kernel_create_files_as(struct cred *new, struct inode *inode); | ||
| 1670 | int security_task_setuid(uid_t id0, uid_t id1, uid_t id2, int flags); | 1724 | int security_task_setuid(uid_t id0, uid_t id1, uid_t id2, int flags); |
| 1671 | int security_task_post_setuid(uid_t old_ruid, uid_t old_euid, | 1725 | int security_task_fix_setuid(struct cred *new, const struct cred *old, |
| 1672 | uid_t old_suid, int flags); | 1726 | int flags); |
| 1673 | int security_task_setgid(gid_t id0, gid_t id1, gid_t id2, int flags); | 1727 | int security_task_setgid(gid_t id0, gid_t id1, gid_t id2, int flags); |
| 1674 | int security_task_setpgid(struct task_struct *p, pid_t pgid); | 1728 | int security_task_setpgid(struct task_struct *p, pid_t pgid); |
| 1675 | int security_task_getpgid(struct task_struct *p); | 1729 | int security_task_getpgid(struct task_struct *p); |
| @@ -1688,8 +1742,7 @@ int security_task_kill(struct task_struct *p, struct siginfo *info, | |||
| 1688 | int sig, u32 secid); | 1742 | int sig, u32 secid); |
| 1689 | int security_task_wait(struct task_struct *p); | 1743 | int security_task_wait(struct task_struct *p); |
| 1690 | int security_task_prctl(int option, unsigned long arg2, unsigned long arg3, | 1744 | int security_task_prctl(int option, unsigned long arg2, unsigned long arg3, |
| 1691 | unsigned long arg4, unsigned long arg5, long *rc_p); | 1745 | unsigned long arg4, unsigned long arg5); |
| 1692 | void security_task_reparent_to_init(struct task_struct *p); | ||
| 1693 | void security_task_to_inode(struct task_struct *p, struct inode *inode); | 1746 | void security_task_to_inode(struct task_struct *p, struct inode *inode); |
| 1694 | int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag); | 1747 | int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag); |
| 1695 | void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid); | 1748 | void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid); |
| @@ -1764,25 +1817,23 @@ static inline int security_capget(struct task_struct *target, | |||
| 1764 | return cap_capget(target, effective, inheritable, permitted); | 1817 | return cap_capget(target, effective, inheritable, permitted); |
| 1765 | } | 1818 | } |
| 1766 | 1819 | ||
| 1767 | static inline int security_capset_check(struct task_struct *target, | 1820 | static inline int security_capset(struct cred *new, |
| 1768 | kernel_cap_t *effective, | 1821 | const struct cred *old, |
| 1769 | kernel_cap_t *inheritable, | 1822 | const kernel_cap_t *effective, |
| 1770 | kernel_cap_t *permitted) | 1823 | const kernel_cap_t *inheritable, |
| 1824 | const kernel_cap_t *permitted) | ||
| 1771 | { | 1825 | { |
| 1772 | return cap_capset_check(target, effective, inheritable, permitted); | 1826 | return cap_capset(new, old, effective, inheritable, permitted); |
| 1773 | } | 1827 | } |
| 1774 | 1828 | ||
| 1775 | static inline void security_capset_set(struct task_struct *target, | 1829 | static inline int security_capable(struct task_struct *tsk, int cap) |
| 1776 | kernel_cap_t *effective, | ||
| 1777 | kernel_cap_t *inheritable, | ||
| 1778 | kernel_cap_t *permitted) | ||
| 1779 | { | 1830 | { |
| 1780 | cap_capset_set(target, effective, inheritable, permitted); | 1831 | return cap_capable(tsk, cap, SECURITY_CAP_AUDIT); |
| 1781 | } | 1832 | } |
| 1782 | 1833 | ||
| 1783 | static inline int security_capable(struct task_struct *tsk, int cap) | 1834 | static inline int security_capable_noaudit(struct task_struct *tsk, int cap) |
| 1784 | { | 1835 | { |
| 1785 | return cap_capable(tsk, cap); | 1836 | return cap_capable(tsk, cap, SECURITY_CAP_NOAUDIT); |
| 1786 | } | 1837 | } |
| 1787 | 1838 | ||
| 1788 | static inline int security_acct(struct file *file) | 1839 | static inline int security_acct(struct file *file) |
| @@ -1835,32 +1886,22 @@ static inline int security_vm_enough_memory_kern(long pages) | |||
| 1835 | return cap_vm_enough_memory(current->mm, pages); | 1886 | return cap_vm_enough_memory(current->mm, pages); |
| 1836 | } | 1887 | } |
| 1837 | 1888 | ||
| 1838 | static inline int security_bprm_alloc(struct linux_binprm *bprm) | 1889 | static inline int security_bprm_set_creds(struct linux_binprm *bprm) |
| 1839 | { | ||
| 1840 | return 0; | ||
| 1841 | } | ||
| 1842 | |||
| 1843 | static inline void security_bprm_free(struct linux_binprm *bprm) | ||
| 1844 | { } | ||
| 1845 | |||
| 1846 | static inline void security_bprm_apply_creds(struct linux_binprm *bprm, int unsafe) | ||
| 1847 | { | 1890 | { |
| 1848 | cap_bprm_apply_creds(bprm, unsafe); | 1891 | return cap_bprm_set_creds(bprm); |
| 1849 | } | 1892 | } |
| 1850 | 1893 | ||
| 1851 | static inline void security_bprm_post_apply_creds(struct linux_binprm *bprm) | 1894 | static inline int security_bprm_check(struct linux_binprm *bprm) |
| 1852 | { | 1895 | { |
| 1853 | return; | 1896 | return 0; |
| 1854 | } | 1897 | } |
| 1855 | 1898 | ||
| 1856 | static inline int security_bprm_set(struct linux_binprm *bprm) | 1899 | static inline void security_bprm_committing_creds(struct linux_binprm *bprm) |
| 1857 | { | 1900 | { |
| 1858 | return cap_bprm_set_security(bprm); | ||
| 1859 | } | 1901 | } |
| 1860 | 1902 | ||
| 1861 | static inline int security_bprm_check(struct linux_binprm *bprm) | 1903 | static inline void security_bprm_committed_creds(struct linux_binprm *bprm) |
| 1862 | { | 1904 | { |
| 1863 | return 0; | ||
| 1864 | } | 1905 | } |
| 1865 | 1906 | ||
| 1866 | static inline int security_bprm_secureexec(struct linux_binprm *bprm) | 1907 | static inline int security_bprm_secureexec(struct linux_binprm *bprm) |
| @@ -1881,7 +1922,7 @@ static inline int security_sb_copy_data(char *orig, char *copy) | |||
| 1881 | return 0; | 1922 | return 0; |
| 1882 | } | 1923 | } |
| 1883 | 1924 | ||
| 1884 | static inline int security_sb_kern_mount(struct super_block *sb, void *data) | 1925 | static inline int security_sb_kern_mount(struct super_block *sb, int flags, void *data) |
| 1885 | { | 1926 | { |
| 1886 | return 0; | 1927 | return 0; |
| 1887 | } | 1928 | } |
| @@ -2177,7 +2218,8 @@ static inline int security_file_receive(struct file *file) | |||
| 2177 | return 0; | 2218 | return 0; |
| 2178 | } | 2219 | } |
| 2179 | 2220 | ||
| 2180 | static inline int security_dentry_open(struct file *file) | 2221 | static inline int security_dentry_open(struct file *file, |
| 2222 | const struct cred *cred) | ||
| 2181 | { | 2223 | { |
| 2182 | return 0; | 2224 | return 0; |
| 2183 | } | 2225 | } |
| @@ -2187,13 +2229,31 @@ static inline int security_task_create(unsigned long clone_flags) | |||
| 2187 | return 0; | 2229 | return 0; |
| 2188 | } | 2230 | } |
| 2189 | 2231 | ||
| 2190 | static inline int security_task_alloc(struct task_struct *p) | 2232 | static inline void security_cred_free(struct cred *cred) |
| 2233 | { } | ||
| 2234 | |||
| 2235 | static inline int security_prepare_creds(struct cred *new, | ||
| 2236 | const struct cred *old, | ||
| 2237 | gfp_t gfp) | ||
| 2191 | { | 2238 | { |
| 2192 | return 0; | 2239 | return 0; |
| 2193 | } | 2240 | } |
| 2194 | 2241 | ||
| 2195 | static inline void security_task_free(struct task_struct *p) | 2242 | static inline void security_commit_creds(struct cred *new, |
| 2196 | { } | 2243 | const struct cred *old) |
| 2244 | { | ||
| 2245 | } | ||
| 2246 | |||
| 2247 | static inline int security_kernel_act_as(struct cred *cred, u32 secid) | ||
| 2248 | { | ||
| 2249 | return 0; | ||
| 2250 | } | ||
| 2251 | |||
| 2252 | static inline int security_kernel_create_files_as(struct cred *cred, | ||
| 2253 | struct inode *inode) | ||
| 2254 | { | ||
| 2255 | return 0; | ||
| 2256 | } | ||
| 2197 | 2257 | ||
| 2198 | static inline int security_task_setuid(uid_t id0, uid_t id1, uid_t id2, | 2258 | static inline int security_task_setuid(uid_t id0, uid_t id1, uid_t id2, |
| 2199 | int flags) | 2259 | int flags) |
| @@ -2201,10 +2261,11 @@ static inline int security_task_setuid(uid_t id0, uid_t id1, uid_t id2, | |||
| 2201 | return 0; | 2261 | return 0; |
| 2202 | } | 2262 | } |
| 2203 | 2263 | ||
| 2204 | static inline int security_task_post_setuid(uid_t old_ruid, uid_t old_euid, | 2264 | static inline int security_task_fix_setuid(struct cred *new, |
| 2205 | uid_t old_suid, int flags) | 2265 | const struct cred *old, |
| 2266 | int flags) | ||
| 2206 | { | 2267 | { |
| 2207 | return cap_task_post_setuid(old_ruid, old_euid, old_suid, flags); | 2268 | return cap_task_fix_setuid(new, old, flags); |
| 2208 | } | 2269 | } |
| 2209 | 2270 | ||
| 2210 | static inline int security_task_setgid(gid_t id0, gid_t id1, gid_t id2, | 2271 | static inline int security_task_setgid(gid_t id0, gid_t id1, gid_t id2, |
| @@ -2291,14 +2352,9 @@ static inline int security_task_wait(struct task_struct *p) | |||
| 2291 | static inline int security_task_prctl(int option, unsigned long arg2, | 2352 | static inline int security_task_prctl(int option, unsigned long arg2, |
| 2292 | unsigned long arg3, | 2353 | unsigned long arg3, |
| 2293 | unsigned long arg4, | 2354 | unsigned long arg4, |
| 2294 | unsigned long arg5, long *rc_p) | 2355 | unsigned long arg5) |
| 2295 | { | 2356 | { |
| 2296 | return cap_task_prctl(option, arg2, arg3, arg3, arg5, rc_p); | 2357 | return cap_task_prctl(option, arg2, arg3, arg3, arg5); |
| 2297 | } | ||
| 2298 | |||
| 2299 | static inline void security_task_reparent_to_init(struct task_struct *p) | ||
| 2300 | { | ||
| 2301 | cap_task_reparent_to_init(p); | ||
| 2302 | } | 2358 | } |
| 2303 | 2359 | ||
| 2304 | static inline void security_task_to_inode(struct task_struct *p, struct inode *inode) | 2360 | static inline void security_task_to_inode(struct task_struct *p, struct inode *inode) |
| @@ -2721,19 +2777,84 @@ static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi | |||
| 2721 | 2777 | ||
| 2722 | #endif /* CONFIG_SECURITY_NETWORK_XFRM */ | 2778 | #endif /* CONFIG_SECURITY_NETWORK_XFRM */ |
| 2723 | 2779 | ||
| 2780 | #ifdef CONFIG_SECURITY_PATH | ||
| 2781 | int security_path_unlink(struct path *dir, struct dentry *dentry); | ||
| 2782 | int security_path_mkdir(struct path *dir, struct dentry *dentry, int mode); | ||
| 2783 | int security_path_rmdir(struct path *dir, struct dentry *dentry); | ||
| 2784 | int security_path_mknod(struct path *dir, struct dentry *dentry, int mode, | ||
| 2785 | unsigned int dev); | ||
| 2786 | int security_path_truncate(struct path *path, loff_t length, | ||
| 2787 | unsigned int time_attrs); | ||
| 2788 | int security_path_symlink(struct path *dir, struct dentry *dentry, | ||
| 2789 | const char *old_name); | ||
| 2790 | int security_path_link(struct dentry *old_dentry, struct path *new_dir, | ||
| 2791 | struct dentry *new_dentry); | ||
| 2792 | int security_path_rename(struct path *old_dir, struct dentry *old_dentry, | ||
| 2793 | struct path *new_dir, struct dentry *new_dentry); | ||
| 2794 | #else /* CONFIG_SECURITY_PATH */ | ||
| 2795 | static inline int security_path_unlink(struct path *dir, struct dentry *dentry) | ||
| 2796 | { | ||
| 2797 | return 0; | ||
| 2798 | } | ||
| 2799 | |||
| 2800 | static inline int security_path_mkdir(struct path *dir, struct dentry *dentry, | ||
| 2801 | int mode) | ||
| 2802 | { | ||
| 2803 | return 0; | ||
| 2804 | } | ||
| 2805 | |||
| 2806 | static inline int security_path_rmdir(struct path *dir, struct dentry *dentry) | ||
| 2807 | { | ||
| 2808 | return 0; | ||
| 2809 | } | ||
| 2810 | |||
| 2811 | static inline int security_path_mknod(struct path *dir, struct dentry *dentry, | ||
| 2812 | int mode, unsigned int dev) | ||
| 2813 | { | ||
| 2814 | return 0; | ||
| 2815 | } | ||
| 2816 | |||
| 2817 | static inline int security_path_truncate(struct path *path, loff_t length, | ||
| 2818 | unsigned int time_attrs) | ||
| 2819 | { | ||
| 2820 | return 0; | ||
| 2821 | } | ||
| 2822 | |||
| 2823 | static inline int security_path_symlink(struct path *dir, struct dentry *dentry, | ||
| 2824 | const char *old_name) | ||
| 2825 | { | ||
| 2826 | return 0; | ||
| 2827 | } | ||
| 2828 | |||
| 2829 | static inline int security_path_link(struct dentry *old_dentry, | ||
| 2830 | struct path *new_dir, | ||
| 2831 | struct dentry *new_dentry) | ||
| 2832 | { | ||
| 2833 | return 0; | ||
| 2834 | } | ||
| 2835 | |||
| 2836 | static inline int security_path_rename(struct path *old_dir, | ||
| 2837 | struct dentry *old_dentry, | ||
| 2838 | struct path *new_dir, | ||
| 2839 | struct dentry *new_dentry) | ||
| 2840 | { | ||
| 2841 | return 0; | ||
| 2842 | } | ||
| 2843 | #endif /* CONFIG_SECURITY_PATH */ | ||
| 2844 | |||
| 2724 | #ifdef CONFIG_KEYS | 2845 | #ifdef CONFIG_KEYS |
| 2725 | #ifdef CONFIG_SECURITY | 2846 | #ifdef CONFIG_SECURITY |
| 2726 | 2847 | ||
| 2727 | int security_key_alloc(struct key *key, struct task_struct *tsk, unsigned long flags); | 2848 | int security_key_alloc(struct key *key, const struct cred *cred, unsigned long flags); |
| 2728 | void security_key_free(struct key *key); | 2849 | void security_key_free(struct key *key); |
| 2729 | int security_key_permission(key_ref_t key_ref, | 2850 | int security_key_permission(key_ref_t key_ref, |
| 2730 | struct task_struct *context, key_perm_t perm); | 2851 | const struct cred *cred, key_perm_t perm); |
| 2731 | int security_key_getsecurity(struct key *key, char **_buffer); | 2852 | int security_key_getsecurity(struct key *key, char **_buffer); |
| 2732 | 2853 | ||
| 2733 | #else | 2854 | #else |
| 2734 | 2855 | ||
| 2735 | static inline int security_key_alloc(struct key *key, | 2856 | static inline int security_key_alloc(struct key *key, |
| 2736 | struct task_struct *tsk, | 2857 | const struct cred *cred, |
| 2737 | unsigned long flags) | 2858 | unsigned long flags) |
| 2738 | { | 2859 | { |
| 2739 | return 0; | 2860 | return 0; |
| @@ -2744,7 +2865,7 @@ static inline void security_key_free(struct key *key) | |||
| 2744 | } | 2865 | } |
| 2745 | 2866 | ||
| 2746 | static inline int security_key_permission(key_ref_t key_ref, | 2867 | static inline int security_key_permission(key_ref_t key_ref, |
| 2747 | struct task_struct *context, | 2868 | const struct cred *cred, |
| 2748 | key_perm_t perm) | 2869 | key_perm_t perm) |
| 2749 | { | 2870 | { |
| 2750 | return 0; | 2871 | return 0; |
