diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/keys/keyring-type.h | 31 | ||||
-rw-r--r-- | include/linux/audit.h | 26 | ||||
-rw-r--r-- | include/linux/binfmts.h | 16 | ||||
-rw-r--r-- | include/linux/capability.h | 25 | ||||
-rw-r--r-- | include/linux/cred.h | 340 | ||||
-rw-r--r-- | include/linux/fs.h | 8 | ||||
-rw-r--r-- | include/linux/init_task.h | 13 | ||||
-rw-r--r-- | include/linux/key-ui.h | 66 | ||||
-rw-r--r-- | include/linux/key.h | 32 | ||||
-rw-r--r-- | include/linux/keyctl.h | 4 | ||||
-rw-r--r-- | include/linux/sched.h | 64 | ||||
-rw-r--r-- | include/linux/securebits.h | 2 | ||||
-rw-r--r-- | include/linux/security.h | 338 | ||||
-rw-r--r-- | include/net/scm.h | 4 |
14 files changed, 600 insertions, 369 deletions
diff --git a/include/keys/keyring-type.h b/include/keys/keyring-type.h new file mode 100644 index 000000000000..843f872a4b63 --- /dev/null +++ b/include/keys/keyring-type.h | |||
@@ -0,0 +1,31 @@ | |||
1 | /* Keyring key type | ||
2 | * | ||
3 | * Copyright (C) 2008 Red Hat, Inc. All Rights Reserved. | ||
4 | * Written by David Howells (dhowells@redhat.com) | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the License, or (at your option) any later version. | ||
10 | */ | ||
11 | |||
12 | #ifndef _KEYS_KEYRING_TYPE_H | ||
13 | #define _KEYS_KEYRING_TYPE_H | ||
14 | |||
15 | #include <linux/key.h> | ||
16 | #include <linux/rcupdate.h> | ||
17 | |||
18 | /* | ||
19 | * the keyring payload contains a list of the keys to which the keyring is | ||
20 | * subscribed | ||
21 | */ | ||
22 | struct keyring_list { | ||
23 | struct rcu_head rcu; /* RCU deletion hook */ | ||
24 | unsigned short maxkeys; /* max keys this list can hold */ | ||
25 | unsigned short nkeys; /* number of keys currently held */ | ||
26 | unsigned short delkey; /* key to be unlinked by RCU */ | ||
27 | struct key *keys[0]; | ||
28 | }; | ||
29 | |||
30 | |||
31 | #endif /* _KEYS_KEYRING_TYPE_H */ | ||
diff --git a/include/linux/audit.h b/include/linux/audit.h index 6272a395d43c..e8ce2c4c7ac7 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h | |||
@@ -99,6 +99,8 @@ | |||
99 | #define AUDIT_OBJ_PID 1318 /* ptrace target */ | 99 | #define AUDIT_OBJ_PID 1318 /* ptrace target */ |
100 | #define AUDIT_TTY 1319 /* Input on an administrative TTY */ | 100 | #define AUDIT_TTY 1319 /* Input on an administrative TTY */ |
101 | #define AUDIT_EOE 1320 /* End of multi-record event */ | 101 | #define AUDIT_EOE 1320 /* End of multi-record event */ |
102 | #define AUDIT_BPRM_FCAPS 1321 /* Information about fcaps increasing perms */ | ||
103 | #define AUDIT_CAPSET 1322 /* Record showing argument to sys_capset */ | ||
102 | 104 | ||
103 | #define AUDIT_AVC 1400 /* SE Linux avc denial or grant */ | 105 | #define AUDIT_AVC 1400 /* SE Linux avc denial or grant */ |
104 | #define AUDIT_SELINUX_ERR 1401 /* Internal SE Linux Errors */ | 106 | #define AUDIT_SELINUX_ERR 1401 /* Internal SE Linux Errors */ |
@@ -452,6 +454,10 @@ extern int __audit_mq_timedsend(mqd_t mqdes, size_t msg_len, unsigned int msg_pr | |||
452 | extern int __audit_mq_timedreceive(mqd_t mqdes, size_t msg_len, unsigned int __user *u_msg_prio, const struct timespec __user *u_abs_timeout); | 454 | extern int __audit_mq_timedreceive(mqd_t mqdes, size_t msg_len, unsigned int __user *u_msg_prio, const struct timespec __user *u_abs_timeout); |
453 | extern int __audit_mq_notify(mqd_t mqdes, const struct sigevent __user *u_notification); | 455 | extern int __audit_mq_notify(mqd_t mqdes, const struct sigevent __user *u_notification); |
454 | extern int __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat); | 456 | extern int __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat); |
457 | extern int __audit_log_bprm_fcaps(struct linux_binprm *bprm, | ||
458 | const struct cred *new, | ||
459 | const struct cred *old); | ||
460 | extern int __audit_log_capset(pid_t pid, const struct cred *new, const struct cred *old); | ||
455 | 461 | ||
456 | static inline int audit_ipc_obj(struct kern_ipc_perm *ipcp) | 462 | static inline int audit_ipc_obj(struct kern_ipc_perm *ipcp) |
457 | { | 463 | { |
@@ -501,6 +507,24 @@ static inline int audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat) | |||
501 | return __audit_mq_getsetattr(mqdes, mqstat); | 507 | return __audit_mq_getsetattr(mqdes, mqstat); |
502 | return 0; | 508 | return 0; |
503 | } | 509 | } |
510 | |||
511 | static inline int audit_log_bprm_fcaps(struct linux_binprm *bprm, | ||
512 | const struct cred *new, | ||
513 | const struct cred *old) | ||
514 | { | ||
515 | if (unlikely(!audit_dummy_context())) | ||
516 | return __audit_log_bprm_fcaps(bprm, new, old); | ||
517 | return 0; | ||
518 | } | ||
519 | |||
520 | static inline int audit_log_capset(pid_t pid, const struct cred *new, | ||
521 | const struct cred *old) | ||
522 | { | ||
523 | if (unlikely(!audit_dummy_context())) | ||
524 | return __audit_log_capset(pid, new, old); | ||
525 | return 0; | ||
526 | } | ||
527 | |||
504 | extern int audit_n_rules; | 528 | extern int audit_n_rules; |
505 | extern int audit_signals; | 529 | extern int audit_signals; |
506 | #else | 530 | #else |
@@ -532,6 +556,8 @@ extern int audit_signals; | |||
532 | #define audit_mq_timedreceive(d,l,p,t) ({ 0; }) | 556 | #define audit_mq_timedreceive(d,l,p,t) ({ 0; }) |
533 | #define audit_mq_notify(d,n) ({ 0; }) | 557 | #define audit_mq_notify(d,n) ({ 0; }) |
534 | #define audit_mq_getsetattr(d,s) ({ 0; }) | 558 | #define audit_mq_getsetattr(d,s) ({ 0; }) |
559 | #define audit_log_bprm_fcaps(b, ncr, ocr) ({ 0; }) | ||
560 | #define audit_log_capset(pid, ncr, ocr) ({ 0; }) | ||
535 | #define audit_ptrace(t) ((void)0) | 561 | #define audit_ptrace(t) ((void)0) |
536 | #define audit_n_rules 0 | 562 | #define audit_n_rules 0 |
537 | #define audit_signals 0 | 563 | #define audit_signals 0 |
diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h index 7394b5b349ff..6cbfbe297180 100644 --- a/include/linux/binfmts.h +++ b/include/linux/binfmts.h | |||
@@ -35,16 +35,20 @@ struct linux_binprm{ | |||
35 | struct mm_struct *mm; | 35 | struct mm_struct *mm; |
36 | unsigned long p; /* current top of mem */ | 36 | unsigned long p; /* current top of mem */ |
37 | unsigned int sh_bang:1, | 37 | unsigned int sh_bang:1, |
38 | misc_bang:1; | 38 | misc_bang:1, |
39 | cred_prepared:1,/* true if creds already prepared (multiple | ||
40 | * preps happen for interpreters) */ | ||
41 | cap_effective:1;/* true if has elevated effective capabilities, | ||
42 | * false if not; except for init which inherits | ||
43 | * its parent's caps anyway */ | ||
39 | #ifdef __alpha__ | 44 | #ifdef __alpha__ |
40 | unsigned int taso:1; | 45 | unsigned int taso:1; |
41 | #endif | 46 | #endif |
42 | unsigned int recursion_depth; | 47 | unsigned int recursion_depth; |
43 | struct file * file; | 48 | struct file * file; |
44 | int e_uid, e_gid; | 49 | struct cred *cred; /* new credentials */ |
45 | kernel_cap_t cap_post_exec_permitted; | 50 | int unsafe; /* how unsafe this exec is (mask of LSM_UNSAFE_*) */ |
46 | bool cap_effective; | 51 | unsigned int per_clear; /* bits to clear in current->personality */ |
47 | void *security; | ||
48 | int argc, envc; | 52 | int argc, envc; |
49 | char * filename; /* Name of binary as seen by procps */ | 53 | char * filename; /* Name of binary as seen by procps */ |
50 | char * interp; /* Name of the binary really executed. Most | 54 | char * interp; /* Name of the binary really executed. Most |
@@ -101,7 +105,7 @@ extern int setup_arg_pages(struct linux_binprm * bprm, | |||
101 | int executable_stack); | 105 | int executable_stack); |
102 | extern int bprm_mm_init(struct linux_binprm *bprm); | 106 | extern int bprm_mm_init(struct linux_binprm *bprm); |
103 | extern int copy_strings_kernel(int argc,char ** argv,struct linux_binprm *bprm); | 107 | extern int copy_strings_kernel(int argc,char ** argv,struct linux_binprm *bprm); |
104 | extern void compute_creds(struct linux_binprm *binprm); | 108 | extern void install_exec_creds(struct linux_binprm *bprm); |
105 | extern int do_coredump(long signr, int exit_code, struct pt_regs * regs); | 109 | extern int do_coredump(long signr, int exit_code, struct pt_regs * regs); |
106 | extern int set_binfmt(struct linux_binfmt *new); | 110 | extern int set_binfmt(struct linux_binfmt *new); |
107 | extern void free_bprm(struct linux_binprm *); | 111 | extern void free_bprm(struct linux_binprm *); |
diff --git a/include/linux/capability.h b/include/linux/capability.h index 9d1fe30b6f6c..e22f48c2a46f 100644 --- a/include/linux/capability.h +++ b/include/linux/capability.h | |||
@@ -53,6 +53,7 @@ typedef struct __user_cap_data_struct { | |||
53 | #define XATTR_NAME_CAPS XATTR_SECURITY_PREFIX XATTR_CAPS_SUFFIX | 53 | #define XATTR_NAME_CAPS XATTR_SECURITY_PREFIX XATTR_CAPS_SUFFIX |
54 | 54 | ||
55 | #define VFS_CAP_REVISION_MASK 0xFF000000 | 55 | #define VFS_CAP_REVISION_MASK 0xFF000000 |
56 | #define VFS_CAP_REVISION_SHIFT 24 | ||
56 | #define VFS_CAP_FLAGS_MASK ~VFS_CAP_REVISION_MASK | 57 | #define VFS_CAP_FLAGS_MASK ~VFS_CAP_REVISION_MASK |
57 | #define VFS_CAP_FLAGS_EFFECTIVE 0x000001 | 58 | #define VFS_CAP_FLAGS_EFFECTIVE 0x000001 |
58 | 59 | ||
@@ -68,6 +69,9 @@ typedef struct __user_cap_data_struct { | |||
68 | #define VFS_CAP_U32 VFS_CAP_U32_2 | 69 | #define VFS_CAP_U32 VFS_CAP_U32_2 |
69 | #define VFS_CAP_REVISION VFS_CAP_REVISION_2 | 70 | #define VFS_CAP_REVISION VFS_CAP_REVISION_2 |
70 | 71 | ||
72 | #ifdef CONFIG_SECURITY_FILE_CAPABILITIES | ||
73 | extern int file_caps_enabled; | ||
74 | #endif | ||
71 | 75 | ||
72 | struct vfs_cap_data { | 76 | struct vfs_cap_data { |
73 | __le32 magic_etc; /* Little endian */ | 77 | __le32 magic_etc; /* Little endian */ |
@@ -96,6 +100,13 @@ typedef struct kernel_cap_struct { | |||
96 | __u32 cap[_KERNEL_CAPABILITY_U32S]; | 100 | __u32 cap[_KERNEL_CAPABILITY_U32S]; |
97 | } kernel_cap_t; | 101 | } kernel_cap_t; |
98 | 102 | ||
103 | /* exact same as vfs_cap_data but in cpu endian and always filled completely */ | ||
104 | struct cpu_vfs_cap_data { | ||
105 | __u32 magic_etc; | ||
106 | kernel_cap_t permitted; | ||
107 | kernel_cap_t inheritable; | ||
108 | }; | ||
109 | |||
99 | #define _USER_CAP_HEADER_SIZE (sizeof(struct __user_cap_header_struct)) | 110 | #define _USER_CAP_HEADER_SIZE (sizeof(struct __user_cap_header_struct)) |
100 | #define _KERNEL_CAP_T_SIZE (sizeof(kernel_cap_t)) | 111 | #define _KERNEL_CAP_T_SIZE (sizeof(kernel_cap_t)) |
101 | 112 | ||
@@ -454,6 +465,13 @@ static inline int cap_isclear(const kernel_cap_t a) | |||
454 | return 1; | 465 | return 1; |
455 | } | 466 | } |
456 | 467 | ||
468 | /* | ||
469 | * Check if "a" is a subset of "set". | ||
470 | * return 1 if ALL of the capabilities in "a" are also in "set" | ||
471 | * cap_issubset(0101, 1111) will return 1 | ||
472 | * return 0 if ANY of the capabilities in "a" are not in "set" | ||
473 | * cap_issubset(1111, 0101) will return 0 | ||
474 | */ | ||
457 | static inline int cap_issubset(const kernel_cap_t a, const kernel_cap_t set) | 475 | static inline int cap_issubset(const kernel_cap_t a, const kernel_cap_t set) |
458 | { | 476 | { |
459 | kernel_cap_t dest; | 477 | kernel_cap_t dest; |
@@ -501,8 +519,6 @@ extern const kernel_cap_t __cap_empty_set; | |||
501 | extern const kernel_cap_t __cap_full_set; | 519 | extern const kernel_cap_t __cap_full_set; |
502 | extern const kernel_cap_t __cap_init_eff_set; | 520 | extern const kernel_cap_t __cap_init_eff_set; |
503 | 521 | ||
504 | kernel_cap_t cap_set_effective(const kernel_cap_t pE_new); | ||
505 | |||
506 | /** | 522 | /** |
507 | * has_capability - Determine if a task has a superior capability available | 523 | * has_capability - Determine if a task has a superior capability available |
508 | * @t: The task in question | 524 | * @t: The task in question |
@@ -514,9 +530,14 @@ kernel_cap_t cap_set_effective(const kernel_cap_t pE_new); | |||
514 | * Note that this does not set PF_SUPERPRIV on the task. | 530 | * Note that this does not set PF_SUPERPRIV on the task. |
515 | */ | 531 | */ |
516 | #define has_capability(t, cap) (security_capable((t), (cap)) == 0) | 532 | #define has_capability(t, cap) (security_capable((t), (cap)) == 0) |
533 | #define has_capability_noaudit(t, cap) (security_capable_noaudit((t), (cap)) == 0) | ||
517 | 534 | ||
518 | extern int capable(int cap); | 535 | extern int capable(int cap); |
519 | 536 | ||
537 | /* audit system wants to get cap info from files as well */ | ||
538 | struct dentry; | ||
539 | extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps); | ||
540 | |||
520 | #endif /* __KERNEL__ */ | 541 | #endif /* __KERNEL__ */ |
521 | 542 | ||
522 | #endif /* !_LINUX_CAPABILITY_H */ | 543 | #endif /* !_LINUX_CAPABILITY_H */ |
diff --git a/include/linux/cred.h b/include/linux/cred.h index b69222cc1fd2..26c1ab179946 100644 --- a/include/linux/cred.h +++ b/include/linux/cred.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* Credentials management | 1 | /* Credentials management - see Documentation/credentials.txt |
2 | * | 2 | * |
3 | * Copyright (C) 2008 Red Hat, Inc. All Rights Reserved. | 3 | * Copyright (C) 2008 Red Hat, Inc. All Rights Reserved. |
4 | * Written by David Howells (dhowells@redhat.com) | 4 | * Written by David Howells (dhowells@redhat.com) |
@@ -12,39 +12,333 @@ | |||
12 | #ifndef _LINUX_CRED_H | 12 | #ifndef _LINUX_CRED_H |
13 | #define _LINUX_CRED_H | 13 | #define _LINUX_CRED_H |
14 | 14 | ||
15 | #define get_current_user() (get_uid(current->user)) | 15 | #include <linux/capability.h> |
16 | #include <linux/key.h> | ||
17 | #include <asm/atomic.h> | ||
16 | 18 | ||
17 | #define task_uid(task) ((task)->uid) | 19 | struct user_struct; |
18 | #define task_gid(task) ((task)->gid) | 20 | struct cred; |
19 | #define task_euid(task) ((task)->euid) | 21 | struct inode; |
20 | #define task_egid(task) ((task)->egid) | ||
21 | 22 | ||
22 | #define current_uid() (current->uid) | 23 | /* |
23 | #define current_gid() (current->gid) | 24 | * COW Supplementary groups list |
24 | #define current_euid() (current->euid) | 25 | */ |
25 | #define current_egid() (current->egid) | 26 | #define NGROUPS_SMALL 32 |
26 | #define current_suid() (current->suid) | 27 | #define NGROUPS_PER_BLOCK ((unsigned int)(PAGE_SIZE / sizeof(gid_t))) |
27 | #define current_sgid() (current->sgid) | 28 | |
28 | #define current_fsuid() (current->fsuid) | 29 | struct group_info { |
29 | #define current_fsgid() (current->fsgid) | 30 | atomic_t usage; |
30 | #define current_cap() (current->cap_effective) | 31 | int ngroups; |
32 | int nblocks; | ||
33 | gid_t small_block[NGROUPS_SMALL]; | ||
34 | gid_t *blocks[0]; | ||
35 | }; | ||
36 | |||
37 | /** | ||
38 | * get_group_info - Get a reference to a group info structure | ||
39 | * @group_info: The group info to reference | ||
40 | * | ||
41 | * This gets a reference to a set of supplementary groups. | ||
42 | * | ||
43 | * If the caller is accessing a task's credentials, they must hold the RCU read | ||
44 | * lock when reading. | ||
45 | */ | ||
46 | static inline struct group_info *get_group_info(struct group_info *gi) | ||
47 | { | ||
48 | atomic_inc(&gi->usage); | ||
49 | return gi; | ||
50 | } | ||
51 | |||
52 | /** | ||
53 | * put_group_info - Release a reference to a group info structure | ||
54 | * @group_info: The group info to release | ||
55 | */ | ||
56 | #define put_group_info(group_info) \ | ||
57 | do { \ | ||
58 | if (atomic_dec_and_test(&(group_info)->usage)) \ | ||
59 | groups_free(group_info); \ | ||
60 | } while (0) | ||
61 | |||
62 | extern struct group_info *groups_alloc(int); | ||
63 | extern void groups_free(struct group_info *); | ||
64 | extern int set_current_groups(struct group_info *); | ||
65 | extern int set_groups(struct cred *, struct group_info *); | ||
66 | extern int groups_search(const struct group_info *, gid_t); | ||
67 | |||
68 | /* access the groups "array" with this macro */ | ||
69 | #define GROUP_AT(gi, i) \ | ||
70 | ((gi)->blocks[(i) / NGROUPS_PER_BLOCK][(i) % NGROUPS_PER_BLOCK]) | ||
71 | |||
72 | extern int in_group_p(gid_t); | ||
73 | extern int in_egroup_p(gid_t); | ||
74 | |||
75 | /* | ||
76 | * The common credentials for a thread group | ||
77 | * - shared by CLONE_THREAD | ||
78 | */ | ||
79 | #ifdef CONFIG_KEYS | ||
80 | struct thread_group_cred { | ||
81 | atomic_t usage; | ||
82 | pid_t tgid; /* thread group process ID */ | ||
83 | spinlock_t lock; | ||
84 | struct key *session_keyring; /* keyring inherited over fork */ | ||
85 | struct key *process_keyring; /* keyring private to this process */ | ||
86 | struct rcu_head rcu; /* RCU deletion hook */ | ||
87 | }; | ||
88 | #endif | ||
89 | |||
90 | /* | ||
91 | * The security context of a task | ||
92 | * | ||
93 | * The parts of the context break down into two categories: | ||
94 | * | ||
95 | * (1) The objective context of a task. These parts are used when some other | ||
96 | * task is attempting to affect this one. | ||
97 | * | ||
98 | * (2) The subjective context. These details are used when the task is acting | ||
99 | * upon another object, be that a file, a task, a key or whatever. | ||
100 | * | ||
101 | * Note that some members of this structure belong to both categories - the | ||
102 | * LSM security pointer for instance. | ||
103 | * | ||
104 | * A task has two security pointers. task->real_cred points to the objective | ||
105 | * context that defines that task's actual details. The objective part of this | ||
106 | * context is used whenever that task is acted upon. | ||
107 | * | ||
108 | * task->cred points to the subjective context that defines the details of how | ||
109 | * that task is going to act upon another object. This may be overridden | ||
110 | * temporarily to point to another security context, but normally points to the | ||
111 | * same context as task->real_cred. | ||
112 | */ | ||
113 | struct cred { | ||
114 | atomic_t usage; | ||
115 | uid_t uid; /* real UID of the task */ | ||
116 | gid_t gid; /* real GID of the task */ | ||
117 | uid_t suid; /* saved UID of the task */ | ||
118 | gid_t sgid; /* saved GID of the task */ | ||
119 | uid_t euid; /* effective UID of the task */ | ||
120 | gid_t egid; /* effective GID of the task */ | ||
121 | uid_t fsuid; /* UID for VFS ops */ | ||
122 | gid_t fsgid; /* GID for VFS ops */ | ||
123 | unsigned securebits; /* SUID-less security management */ | ||
124 | kernel_cap_t cap_inheritable; /* caps our children can inherit */ | ||
125 | kernel_cap_t cap_permitted; /* caps we're permitted */ | ||
126 | kernel_cap_t cap_effective; /* caps we can actually use */ | ||
127 | kernel_cap_t cap_bset; /* capability bounding set */ | ||
128 | #ifdef CONFIG_KEYS | ||
129 | unsigned char jit_keyring; /* default keyring to attach requested | ||
130 | * keys to */ | ||
131 | struct key *thread_keyring; /* keyring private to this thread */ | ||
132 | struct key *request_key_auth; /* assumed request_key authority */ | ||
133 | struct thread_group_cred *tgcred; /* thread-group shared credentials */ | ||
134 | #endif | ||
135 | #ifdef CONFIG_SECURITY | ||
136 | void *security; /* subjective LSM security */ | ||
137 | #endif | ||
138 | struct user_struct *user; /* real user ID subscription */ | ||
139 | struct group_info *group_info; /* supplementary groups for euid/fsgid */ | ||
140 | struct rcu_head rcu; /* RCU deletion hook */ | ||
141 | }; | ||
142 | |||
143 | extern void __put_cred(struct cred *); | ||
144 | extern int copy_creds(struct task_struct *, unsigned long); | ||
145 | extern struct cred *prepare_creds(void); | ||
146 | extern struct cred *prepare_exec_creds(void); | ||
147 | extern struct cred *prepare_usermodehelper_creds(void); | ||
148 | extern int commit_creds(struct cred *); | ||
149 | extern void abort_creds(struct cred *); | ||
150 | extern const struct cred *override_creds(const struct cred *); | ||
151 | extern void revert_creds(const struct cred *); | ||
152 | extern struct cred *prepare_kernel_cred(struct task_struct *); | ||
153 | extern int change_create_files_as(struct cred *, struct inode *); | ||
154 | extern int set_security_override(struct cred *, u32); | ||
155 | extern int set_security_override_from_ctx(struct cred *, const char *); | ||
156 | extern int set_create_files_as(struct cred *, struct inode *); | ||
157 | extern void __init cred_init(void); | ||
158 | |||
159 | /** | ||
160 | * get_new_cred - Get a reference on a new set of credentials | ||
161 | * @cred: The new credentials to reference | ||
162 | * | ||
163 | * Get a reference on the specified set of new credentials. The caller must | ||
164 | * release the reference. | ||
165 | */ | ||
166 | static inline struct cred *get_new_cred(struct cred *cred) | ||
167 | { | ||
168 | atomic_inc(&cred->usage); | ||
169 | return cred; | ||
170 | } | ||
171 | |||
172 | /** | ||
173 | * get_cred - Get a reference on a set of credentials | ||
174 | * @cred: The credentials to reference | ||
175 | * | ||
176 | * Get a reference on the specified set of credentials. The caller must | ||
177 | * release the reference. | ||
178 | * | ||
179 | * This is used to deal with a committed set of credentials. Although the | ||
180 | * pointer is const, this will temporarily discard the const and increment the | ||
181 | * usage count. The purpose of this is to attempt to catch at compile time the | ||
182 | * accidental alteration of a set of credentials that should be considered | ||
183 | * immutable. | ||
184 | */ | ||
185 | static inline const struct cred *get_cred(const struct cred *cred) | ||
186 | { | ||
187 | return get_new_cred((struct cred *) cred); | ||
188 | } | ||
189 | |||
190 | /** | ||
191 | * put_cred - Release a reference to a set of credentials | ||
192 | * @cred: The credentials to release | ||
193 | * | ||
194 | * Release a reference to a set of credentials, deleting them when the last ref | ||
195 | * is released. | ||
196 | * | ||
197 | * This takes a const pointer to a set of credentials because the credentials | ||
198 | * on task_struct are attached by const pointers to prevent accidental | ||
199 | * alteration of otherwise immutable credential sets. | ||
200 | */ | ||
201 | static inline void put_cred(const struct cred *_cred) | ||
202 | { | ||
203 | struct cred *cred = (struct cred *) _cred; | ||
204 | |||
205 | BUG_ON(atomic_read(&(cred)->usage) <= 0); | ||
206 | if (atomic_dec_and_test(&(cred)->usage)) | ||
207 | __put_cred(cred); | ||
208 | } | ||
209 | |||
210 | /** | ||
211 | * current_cred - Access the current task's subjective credentials | ||
212 | * | ||
213 | * Access the subjective credentials of the current task. | ||
214 | */ | ||
215 | #define current_cred() \ | ||
216 | (current->cred) | ||
217 | |||
218 | /** | ||
219 | * __task_cred - Access a task's objective credentials | ||
220 | * @task: The task to query | ||
221 | * | ||
222 | * Access the objective credentials of a task. The caller must hold the RCU | ||
223 | * readlock. | ||
224 | * | ||
225 | * The caller must make sure task doesn't go away, either by holding a ref on | ||
226 | * task or by holding tasklist_lock to prevent it from being unlinked. | ||
227 | */ | ||
228 | #define __task_cred(task) \ | ||
229 | ((const struct cred *)(rcu_dereference((task)->real_cred))) | ||
230 | |||
231 | /** | ||
232 | * get_task_cred - Get another task's objective credentials | ||
233 | * @task: The task to query | ||
234 | * | ||
235 | * Get the objective credentials of a task, pinning them so that they can't go | ||
236 | * away. Accessing a task's credentials directly is not permitted. | ||
237 | * | ||
238 | * The caller must make sure task doesn't go away, either by holding a ref on | ||
239 | * task or by holding tasklist_lock to prevent it from being unlinked. | ||
240 | */ | ||
241 | #define get_task_cred(task) \ | ||
242 | ({ \ | ||
243 | struct cred *__cred; \ | ||
244 | rcu_read_lock(); \ | ||
245 | __cred = (struct cred *) __task_cred((task)); \ | ||
246 | get_cred(__cred); \ | ||
247 | rcu_read_unlock(); \ | ||
248 | __cred; \ | ||
249 | }) | ||
250 | |||
251 | /** | ||
252 | * get_current_cred - Get the current task's subjective credentials | ||
253 | * | ||
254 | * Get the subjective credentials of the current task, pinning them so that | ||
255 | * they can't go away. Accessing the current task's credentials directly is | ||
256 | * not permitted. | ||
257 | */ | ||
258 | #define get_current_cred() \ | ||
259 | (get_cred(current_cred())) | ||
260 | |||
261 | /** | ||
262 | * get_current_user - Get the current task's user_struct | ||
263 | * | ||
264 | * Get the user record of the current task, pinning it so that it can't go | ||
265 | * away. | ||
266 | */ | ||
267 | #define get_current_user() \ | ||
268 | ({ \ | ||
269 | struct user_struct *__u; \ | ||
270 | struct cred *__cred; \ | ||
271 | __cred = (struct cred *) current_cred(); \ | ||
272 | __u = get_uid(__cred->user); \ | ||
273 | __u; \ | ||
274 | }) | ||
275 | |||
276 | /** | ||
277 | * get_current_groups - Get the current task's supplementary group list | ||
278 | * | ||
279 | * Get the supplementary group list of the current task, pinning it so that it | ||
280 | * can't go away. | ||
281 | */ | ||
282 | #define get_current_groups() \ | ||
283 | ({ \ | ||
284 | struct group_info *__groups; \ | ||
285 | struct cred *__cred; \ | ||
286 | __cred = (struct cred *) current_cred(); \ | ||
287 | __groups = get_group_info(__cred->group_info); \ | ||
288 | __groups; \ | ||
289 | }) | ||
290 | |||
291 | #define task_cred_xxx(task, xxx) \ | ||
292 | ({ \ | ||
293 | __typeof__(((struct cred *)NULL)->xxx) ___val; \ | ||
294 | rcu_read_lock(); \ | ||
295 | ___val = __task_cred((task))->xxx; \ | ||
296 | rcu_read_unlock(); \ | ||
297 | ___val; \ | ||
298 | }) | ||
299 | |||
300 | #define task_uid(task) (task_cred_xxx((task), uid)) | ||
301 | #define task_euid(task) (task_cred_xxx((task), euid)) | ||
302 | |||
303 | #define current_cred_xxx(xxx) \ | ||
304 | ({ \ | ||
305 | current->cred->xxx; \ | ||
306 | }) | ||
307 | |||
308 | #define current_uid() (current_cred_xxx(uid)) | ||
309 | #define current_gid() (current_cred_xxx(gid)) | ||
310 | #define current_euid() (current_cred_xxx(euid)) | ||
311 | #define current_egid() (current_cred_xxx(egid)) | ||
312 | #define current_suid() (current_cred_xxx(suid)) | ||
313 | #define current_sgid() (current_cred_xxx(sgid)) | ||
314 | #define current_fsuid() (current_cred_xxx(fsuid)) | ||
315 | #define current_fsgid() (current_cred_xxx(fsgid)) | ||
316 | #define current_cap() (current_cred_xxx(cap_effective)) | ||
317 | #define current_user() (current_cred_xxx(user)) | ||
318 | #define current_security() (current_cred_xxx(security)) | ||
31 | 319 | ||
32 | #define current_uid_gid(_uid, _gid) \ | 320 | #define current_uid_gid(_uid, _gid) \ |
33 | do { \ | 321 | do { \ |
34 | *(_uid) = current->uid; \ | 322 | const struct cred *__cred; \ |
35 | *(_gid) = current->gid; \ | 323 | __cred = current_cred(); \ |
324 | *(_uid) = __cred->uid; \ | ||
325 | *(_gid) = __cred->gid; \ | ||
36 | } while(0) | 326 | } while(0) |
37 | 327 | ||
38 | #define current_euid_egid(_uid, _gid) \ | 328 | #define current_euid_egid(_euid, _egid) \ |
39 | do { \ | 329 | do { \ |
40 | *(_uid) = current->euid; \ | 330 | const struct cred *__cred; \ |
41 | *(_gid) = current->egid; \ | 331 | __cred = current_cred(); \ |
332 | *(_euid) = __cred->euid; \ | ||
333 | *(_egid) = __cred->egid; \ | ||
42 | } while(0) | 334 | } while(0) |
43 | 335 | ||
44 | #define current_fsuid_fsgid(_uid, _gid) \ | 336 | #define current_fsuid_fsgid(_fsuid, _fsgid) \ |
45 | do { \ | 337 | do { \ |
46 | *(_uid) = current->fsuid; \ | 338 | const struct cred *__cred; \ |
47 | *(_gid) = current->fsgid; \ | 339 | __cred = current_cred(); \ |
340 | *(_fsuid) = __cred->fsuid; \ | ||
341 | *(_fsgid) = __cred->fsgid; \ | ||
48 | } while(0) | 342 | } while(0) |
49 | 343 | ||
50 | #endif /* _LINUX_CRED_H */ | 344 | #endif /* _LINUX_CRED_H */ |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 0dcdd9458f4b..c0fb6d81d89b 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -315,6 +315,7 @@ struct poll_table_struct; | |||
315 | struct kstatfs; | 315 | struct kstatfs; |
316 | struct vm_area_struct; | 316 | struct vm_area_struct; |
317 | struct vfsmount; | 317 | struct vfsmount; |
318 | struct cred; | ||
318 | 319 | ||
319 | extern void __init inode_init(void); | 320 | extern void __init inode_init(void); |
320 | extern void __init inode_init_early(void); | 321 | extern void __init inode_init_early(void); |
@@ -826,7 +827,7 @@ struct file { | |||
826 | fmode_t f_mode; | 827 | fmode_t f_mode; |
827 | loff_t f_pos; | 828 | loff_t f_pos; |
828 | struct fown_struct f_owner; | 829 | struct fown_struct f_owner; |
829 | unsigned int f_uid, f_gid; | 830 | const struct cred *f_cred; |
830 | struct file_ra_state f_ra; | 831 | struct file_ra_state f_ra; |
831 | 832 | ||
832 | u64 f_version; | 833 | u64 f_version; |
@@ -1193,7 +1194,7 @@ enum { | |||
1193 | #define has_fs_excl() atomic_read(¤t->fs_excl) | 1194 | #define has_fs_excl() atomic_read(¤t->fs_excl) |
1194 | 1195 | ||
1195 | #define is_owner_or_cap(inode) \ | 1196 | #define is_owner_or_cap(inode) \ |
1196 | ((current->fsuid == (inode)->i_uid) || capable(CAP_FOWNER)) | 1197 | ((current_fsuid() == (inode)->i_uid) || capable(CAP_FOWNER)) |
1197 | 1198 | ||
1198 | /* not quite ready to be deprecated, but... */ | 1199 | /* not quite ready to be deprecated, but... */ |
1199 | extern void lock_super(struct super_block *); | 1200 | extern void lock_super(struct super_block *); |
@@ -1673,7 +1674,8 @@ extern int do_truncate(struct dentry *, loff_t start, unsigned int time_attrs, | |||
1673 | extern long do_sys_open(int dfd, const char __user *filename, int flags, | 1674 | extern long do_sys_open(int dfd, const char __user *filename, int flags, |
1674 | int mode); | 1675 | int mode); |
1675 | extern struct file *filp_open(const char *, int, int); | 1676 | extern struct file *filp_open(const char *, int, int); |
1676 | extern struct file * dentry_open(struct dentry *, struct vfsmount *, int); | 1677 | extern struct file * dentry_open(struct dentry *, struct vfsmount *, int, |
1678 | const struct cred *); | ||
1677 | extern int filp_close(struct file *, fl_owner_t id); | 1679 | extern int filp_close(struct file *, fl_owner_t id); |
1678 | extern char * getname(const char __user *); | 1680 | extern char * getname(const char __user *); |
1679 | 1681 | ||
diff --git a/include/linux/init_task.h b/include/linux/init_task.h index 23fd8909b9e5..2597858035cd 100644 --- a/include/linux/init_task.h +++ b/include/linux/init_task.h | |||
@@ -113,6 +113,8 @@ extern struct group_info init_groups; | |||
113 | # define CAP_INIT_BSET CAP_INIT_EFF_SET | 113 | # define CAP_INIT_BSET CAP_INIT_EFF_SET |
114 | #endif | 114 | #endif |
115 | 115 | ||
116 | extern struct cred init_cred; | ||
117 | |||
116 | /* | 118 | /* |
117 | * INIT_TASK is used to set up the first task table, touch at | 119 | * INIT_TASK is used to set up the first task table, touch at |
118 | * your own risk!. Base=0, limit=0x1fffff (=2MB) | 120 | * your own risk!. Base=0, limit=0x1fffff (=2MB) |
@@ -147,13 +149,10 @@ extern struct group_info init_groups; | |||
147 | .children = LIST_HEAD_INIT(tsk.children), \ | 149 | .children = LIST_HEAD_INIT(tsk.children), \ |
148 | .sibling = LIST_HEAD_INIT(tsk.sibling), \ | 150 | .sibling = LIST_HEAD_INIT(tsk.sibling), \ |
149 | .group_leader = &tsk, \ | 151 | .group_leader = &tsk, \ |
150 | .group_info = &init_groups, \ | 152 | .real_cred = &init_cred, \ |
151 | .cap_effective = CAP_INIT_EFF_SET, \ | 153 | .cred = &init_cred, \ |
152 | .cap_inheritable = CAP_INIT_INH_SET, \ | 154 | .cred_exec_mutex = \ |
153 | .cap_permitted = CAP_FULL_SET, \ | 155 | __MUTEX_INITIALIZER(tsk.cred_exec_mutex), \ |
154 | .cap_bset = CAP_INIT_BSET, \ | ||
155 | .securebits = SECUREBITS_DEFAULT, \ | ||
156 | .user = INIT_USER, \ | ||
157 | .comm = "swapper", \ | 156 | .comm = "swapper", \ |
158 | .thread = INIT_THREAD, \ | 157 | .thread = INIT_THREAD, \ |
159 | .fs = &init_fs, \ | 158 | .fs = &init_fs, \ |
diff --git a/include/linux/key-ui.h b/include/linux/key-ui.h deleted file mode 100644 index e8b8a7a5c496..000000000000 --- a/include/linux/key-ui.h +++ /dev/null | |||
@@ -1,66 +0,0 @@ | |||
1 | /* key-ui.h: key userspace interface stuff | ||
2 | * | ||
3 | * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved. | ||
4 | * Written by David Howells (dhowells@redhat.com) | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the License, or (at your option) any later version. | ||
10 | */ | ||
11 | |||
12 | #ifndef _LINUX_KEY_UI_H | ||
13 | #define _LINUX_KEY_UI_H | ||
14 | |||
15 | #include <linux/key.h> | ||
16 | |||
17 | /* the key tree */ | ||
18 | extern struct rb_root key_serial_tree; | ||
19 | extern spinlock_t key_serial_lock; | ||
20 | |||
21 | /* required permissions */ | ||
22 | #define KEY_VIEW 0x01 /* require permission to view attributes */ | ||
23 | #define KEY_READ 0x02 /* require permission to read content */ | ||
24 | #define KEY_WRITE 0x04 /* require permission to update / modify */ | ||
25 | #define KEY_SEARCH 0x08 /* require permission to search (keyring) or find (key) */ | ||
26 | #define KEY_LINK 0x10 /* require permission to link */ | ||
27 | #define KEY_SETATTR 0x20 /* require permission to change attributes */ | ||
28 | #define KEY_ALL 0x3f /* all the above permissions */ | ||
29 | |||
30 | /* | ||
31 | * the keyring payload contains a list of the keys to which the keyring is | ||
32 | * subscribed | ||
33 | */ | ||
34 | struct keyring_list { | ||
35 | struct rcu_head rcu; /* RCU deletion hook */ | ||
36 | unsigned short maxkeys; /* max keys this list can hold */ | ||
37 | unsigned short nkeys; /* number of keys currently held */ | ||
38 | unsigned short delkey; /* key to be unlinked by RCU */ | ||
39 | struct key *keys[0]; | ||
40 | }; | ||
41 | |||
42 | /* | ||
43 | * check to see whether permission is granted to use a key in the desired way | ||
44 | */ | ||
45 | extern int key_task_permission(const key_ref_t key_ref, | ||
46 | struct task_struct *context, | ||
47 | key_perm_t perm); | ||
48 | |||
49 | static inline int key_permission(const key_ref_t key_ref, key_perm_t perm) | ||
50 | { | ||
51 | return key_task_permission(key_ref, current, perm); | ||
52 | } | ||
53 | |||
54 | extern key_ref_t lookup_user_key(struct task_struct *context, | ||
55 | key_serial_t id, int create, int partial, | ||
56 | key_perm_t perm); | ||
57 | |||
58 | extern long join_session_keyring(const char *name); | ||
59 | |||
60 | extern struct key_type *key_type_lookup(const char *type); | ||
61 | extern void key_type_put(struct key_type *ktype); | ||
62 | |||
63 | #define key_negative_timeout 60 /* default timeout on a negative key's existence */ | ||
64 | |||
65 | |||
66 | #endif /* _LINUX_KEY_UI_H */ | ||
diff --git a/include/linux/key.h b/include/linux/key.h index 1b70e35a71e3..21d32a142c00 100644 --- a/include/linux/key.h +++ b/include/linux/key.h | |||
@@ -73,6 +73,7 @@ struct key; | |||
73 | struct seq_file; | 73 | struct seq_file; |
74 | struct user_struct; | 74 | struct user_struct; |
75 | struct signal_struct; | 75 | struct signal_struct; |
76 | struct cred; | ||
76 | 77 | ||
77 | struct key_type; | 78 | struct key_type; |
78 | struct key_owner; | 79 | struct key_owner; |
@@ -181,7 +182,7 @@ struct key { | |||
181 | extern struct key *key_alloc(struct key_type *type, | 182 | extern struct key *key_alloc(struct key_type *type, |
182 | const char *desc, | 183 | const char *desc, |
183 | uid_t uid, gid_t gid, | 184 | uid_t uid, gid_t gid, |
184 | struct task_struct *ctx, | 185 | const struct cred *cred, |
185 | key_perm_t perm, | 186 | key_perm_t perm, |
186 | unsigned long flags); | 187 | unsigned long flags); |
187 | 188 | ||
@@ -249,7 +250,7 @@ extern int key_unlink(struct key *keyring, | |||
249 | struct key *key); | 250 | struct key *key); |
250 | 251 | ||
251 | extern struct key *keyring_alloc(const char *description, uid_t uid, gid_t gid, | 252 | extern struct key *keyring_alloc(const char *description, uid_t uid, gid_t gid, |
252 | struct task_struct *ctx, | 253 | const struct cred *cred, |
253 | unsigned long flags, | 254 | unsigned long flags, |
254 | struct key *dest); | 255 | struct key *dest); |
255 | 256 | ||
@@ -276,24 +277,11 @@ extern ctl_table key_sysctls[]; | |||
276 | /* | 277 | /* |
277 | * the userspace interface | 278 | * the userspace interface |
278 | */ | 279 | */ |
279 | extern void switch_uid_keyring(struct user_struct *new_user); | 280 | extern int install_thread_keyring_to_cred(struct cred *cred); |
280 | extern int copy_keys(unsigned long clone_flags, struct task_struct *tsk); | ||
281 | extern int copy_thread_group_keys(struct task_struct *tsk); | ||
282 | extern void exit_keys(struct task_struct *tsk); | ||
283 | extern void exit_thread_group_keys(struct signal_struct *tg); | ||
284 | extern int suid_keys(struct task_struct *tsk); | ||
285 | extern int exec_keys(struct task_struct *tsk); | ||
286 | extern void key_fsuid_changed(struct task_struct *tsk); | 281 | extern void key_fsuid_changed(struct task_struct *tsk); |
287 | extern void key_fsgid_changed(struct task_struct *tsk); | 282 | extern void key_fsgid_changed(struct task_struct *tsk); |
288 | extern void key_init(void); | 283 | extern void key_init(void); |
289 | 284 | ||
290 | #define __install_session_keyring(tsk, keyring) \ | ||
291 | ({ \ | ||
292 | struct key *old_session = tsk->signal->session_keyring; \ | ||
293 | tsk->signal->session_keyring = keyring; \ | ||
294 | old_session; \ | ||
295 | }) | ||
296 | |||
297 | #else /* CONFIG_KEYS */ | 285 | #else /* CONFIG_KEYS */ |
298 | 286 | ||
299 | #define key_validate(k) 0 | 287 | #define key_validate(k) 0 |
@@ -302,17 +290,9 @@ extern void key_init(void); | |||
302 | #define key_revoke(k) do { } while(0) | 290 | #define key_revoke(k) do { } while(0) |
303 | #define key_put(k) do { } while(0) | 291 | #define key_put(k) do { } while(0) |
304 | #define key_ref_put(k) do { } while(0) | 292 | #define key_ref_put(k) do { } while(0) |
305 | #define make_key_ref(k, p) ({ NULL; }) | 293 | #define make_key_ref(k, p) NULL |
306 | #define key_ref_to_ptr(k) ({ NULL; }) | 294 | #define key_ref_to_ptr(k) NULL |
307 | #define is_key_possessed(k) 0 | 295 | #define is_key_possessed(k) 0 |
308 | #define switch_uid_keyring(u) do { } while(0) | ||
309 | #define __install_session_keyring(t, k) ({ NULL; }) | ||
310 | #define copy_keys(f,t) 0 | ||
311 | #define copy_thread_group_keys(t) 0 | ||
312 | #define exit_keys(t) do { } while(0) | ||
313 | #define exit_thread_group_keys(tg) do { } while(0) | ||
314 | #define suid_keys(t) do { } while(0) | ||
315 | #define exec_keys(t) do { } while(0) | ||
316 | #define key_fsuid_changed(t) do { } while(0) | 296 | #define key_fsuid_changed(t) do { } while(0) |
317 | #define key_fsgid_changed(t) do { } while(0) | 297 | #define key_fsgid_changed(t) do { } while(0) |
318 | #define key_init() do { } while(0) | 298 | #define key_init() do { } while(0) |
diff --git a/include/linux/keyctl.h b/include/linux/keyctl.h index 656ee6b77a4a..c0688eb72093 100644 --- a/include/linux/keyctl.h +++ b/include/linux/keyctl.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* keyctl.h: keyctl command IDs | 1 | /* keyctl.h: keyctl command IDs |
2 | * | 2 | * |
3 | * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved. | 3 | * Copyright (C) 2004, 2008 Red Hat, Inc. All Rights Reserved. |
4 | * Written by David Howells (dhowells@redhat.com) | 4 | * Written by David Howells (dhowells@redhat.com) |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or | 6 | * This program is free software; you can redistribute it and/or |
@@ -20,6 +20,7 @@ | |||
20 | #define KEY_SPEC_USER_SESSION_KEYRING -5 /* - key ID for UID-session keyring */ | 20 | #define KEY_SPEC_USER_SESSION_KEYRING -5 /* - key ID for UID-session keyring */ |
21 | #define KEY_SPEC_GROUP_KEYRING -6 /* - key ID for GID-specific keyring */ | 21 | #define KEY_SPEC_GROUP_KEYRING -6 /* - key ID for GID-specific keyring */ |
22 | #define KEY_SPEC_REQKEY_AUTH_KEY -7 /* - key ID for assumed request_key auth key */ | 22 | #define KEY_SPEC_REQKEY_AUTH_KEY -7 /* - key ID for assumed request_key auth key */ |
23 | #define KEY_SPEC_REQUESTOR_KEYRING -8 /* - key ID for request_key() dest keyring */ | ||
23 | 24 | ||
24 | /* request-key default keyrings */ | 25 | /* request-key default keyrings */ |
25 | #define KEY_REQKEY_DEFL_NO_CHANGE -1 | 26 | #define KEY_REQKEY_DEFL_NO_CHANGE -1 |
@@ -30,6 +31,7 @@ | |||
30 | #define KEY_REQKEY_DEFL_USER_KEYRING 4 | 31 | #define KEY_REQKEY_DEFL_USER_KEYRING 4 |
31 | #define KEY_REQKEY_DEFL_USER_SESSION_KEYRING 5 | 32 | #define KEY_REQKEY_DEFL_USER_SESSION_KEYRING 5 |
32 | #define KEY_REQKEY_DEFL_GROUP_KEYRING 6 | 33 | #define KEY_REQKEY_DEFL_GROUP_KEYRING 6 |
34 | #define KEY_REQKEY_DEFL_REQUESTOR_KEYRING 7 | ||
33 | 35 | ||
34 | /* keyctl commands */ | 36 | /* keyctl commands */ |
35 | #define KEYCTL_GET_KEYRING_ID 0 /* ask for a keyring's ID */ | 37 | #define KEYCTL_GET_KEYRING_ID 0 /* ask for a keyring's ID */ |
diff --git a/include/linux/sched.h b/include/linux/sched.h index 644ffbda17ca..2036e9f26020 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -572,12 +572,6 @@ struct signal_struct { | |||
572 | */ | 572 | */ |
573 | struct rlimit rlim[RLIM_NLIMITS]; | 573 | struct rlimit rlim[RLIM_NLIMITS]; |
574 | 574 | ||
575 | /* keep the process-shared keyrings here so that they do the right | ||
576 | * thing in threads created with CLONE_THREAD */ | ||
577 | #ifdef CONFIG_KEYS | ||
578 | struct key *session_keyring; /* keyring inherited over fork */ | ||
579 | struct key *process_keyring; /* keyring private to this process */ | ||
580 | #endif | ||
581 | #ifdef CONFIG_BSD_PROCESS_ACCT | 575 | #ifdef CONFIG_BSD_PROCESS_ACCT |
582 | struct pacct_struct pacct; /* per-process accounting information */ | 576 | struct pacct_struct pacct; /* per-process accounting information */ |
583 | #endif | 577 | #endif |
@@ -661,6 +655,7 @@ extern struct user_struct *find_user(uid_t); | |||
661 | extern struct user_struct root_user; | 655 | extern struct user_struct root_user; |
662 | #define INIT_USER (&root_user) | 656 | #define INIT_USER (&root_user) |
663 | 657 | ||
658 | |||
664 | struct backing_dev_info; | 659 | struct backing_dev_info; |
665 | struct reclaim_state; | 660 | struct reclaim_state; |
666 | 661 | ||
@@ -884,38 +879,7 @@ partition_sched_domains(int ndoms_new, cpumask_t *doms_new, | |||
884 | #endif /* !CONFIG_SMP */ | 879 | #endif /* !CONFIG_SMP */ |
885 | 880 | ||
886 | struct io_context; /* See blkdev.h */ | 881 | struct io_context; /* See blkdev.h */ |
887 | #define NGROUPS_SMALL 32 | ||
888 | #define NGROUPS_PER_BLOCK ((unsigned int)(PAGE_SIZE / sizeof(gid_t))) | ||
889 | struct group_info { | ||
890 | int ngroups; | ||
891 | atomic_t usage; | ||
892 | gid_t small_block[NGROUPS_SMALL]; | ||
893 | int nblocks; | ||
894 | gid_t *blocks[0]; | ||
895 | }; | ||
896 | 882 | ||
897 | /* | ||
898 | * get_group_info() must be called with the owning task locked (via task_lock()) | ||
899 | * when task != current. The reason being that the vast majority of callers are | ||
900 | * looking at current->group_info, which can not be changed except by the | ||
901 | * current task. Changing current->group_info requires the task lock, too. | ||
902 | */ | ||
903 | #define get_group_info(group_info) do { \ | ||
904 | atomic_inc(&(group_info)->usage); \ | ||
905 | } while (0) | ||
906 | |||
907 | #define put_group_info(group_info) do { \ | ||
908 | if (atomic_dec_and_test(&(group_info)->usage)) \ | ||
909 | groups_free(group_info); \ | ||
910 | } while (0) | ||
911 | |||
912 | extern struct group_info *groups_alloc(int gidsetsize); | ||
913 | extern void groups_free(struct group_info *group_info); | ||
914 | extern int set_current_groups(struct group_info *group_info); | ||
915 | extern int groups_search(struct group_info *group_info, gid_t grp); | ||
916 | /* access the groups "array" with this macro */ | ||
917 | #define GROUP_AT(gi, i) \ | ||
918 | ((gi)->blocks[(i)/NGROUPS_PER_BLOCK][(i)%NGROUPS_PER_BLOCK]) | ||
919 | 883 | ||
920 | #ifdef ARCH_HAS_PREFETCH_SWITCH_STACK | 884 | #ifdef ARCH_HAS_PREFETCH_SWITCH_STACK |
921 | extern void prefetch_stack(struct task_struct *t); | 885 | extern void prefetch_stack(struct task_struct *t); |
@@ -1182,17 +1146,12 @@ struct task_struct { | |||
1182 | struct list_head cpu_timers[3]; | 1146 | struct list_head cpu_timers[3]; |
1183 | 1147 | ||
1184 | /* process credentials */ | 1148 | /* process credentials */ |
1185 | uid_t uid,euid,suid,fsuid; | 1149 | const struct cred *real_cred; /* objective and real subjective task |
1186 | gid_t gid,egid,sgid,fsgid; | 1150 | * credentials (COW) */ |
1187 | struct group_info *group_info; | 1151 | const struct cred *cred; /* effective (overridable) subjective task |
1188 | kernel_cap_t cap_effective, cap_inheritable, cap_permitted, cap_bset; | 1152 | * credentials (COW) */ |
1189 | struct user_struct *user; | 1153 | struct mutex cred_exec_mutex; /* execve vs ptrace cred calculation mutex */ |
1190 | unsigned securebits; | 1154 | |
1191 | #ifdef CONFIG_KEYS | ||
1192 | unsigned char jit_keyring; /* default keyring to attach requested keys to */ | ||
1193 | struct key *request_key_auth; /* assumed request_key authority */ | ||
1194 | struct key *thread_keyring; /* keyring private to this thread */ | ||
1195 | #endif | ||
1196 | char comm[TASK_COMM_LEN]; /* executable name excluding path | 1155 | char comm[TASK_COMM_LEN]; /* executable name excluding path |
1197 | - access with [gs]et_task_comm (which lock | 1156 | - access with [gs]et_task_comm (which lock |
1198 | it with task_lock()) | 1157 | it with task_lock()) |
@@ -1229,9 +1188,6 @@ struct task_struct { | |||
1229 | int (*notifier)(void *priv); | 1188 | int (*notifier)(void *priv); |
1230 | void *notifier_data; | 1189 | void *notifier_data; |
1231 | sigset_t *notifier_mask; | 1190 | sigset_t *notifier_mask; |
1232 | #ifdef CONFIG_SECURITY | ||
1233 | void *security; | ||
1234 | #endif | ||
1235 | struct audit_context *audit_context; | 1191 | struct audit_context *audit_context; |
1236 | #ifdef CONFIG_AUDITSYSCALL | 1192 | #ifdef CONFIG_AUDITSYSCALL |
1237 | uid_t loginuid; | 1193 | uid_t loginuid; |
@@ -1771,7 +1727,6 @@ static inline struct user_struct *get_uid(struct user_struct *u) | |||
1771 | return u; | 1727 | return u; |
1772 | } | 1728 | } |
1773 | extern void free_uid(struct user_struct *); | 1729 | extern void free_uid(struct user_struct *); |
1774 | extern void switch_uid(struct user_struct *); | ||
1775 | extern void release_uids(struct user_namespace *ns); | 1730 | extern void release_uids(struct user_namespace *ns); |
1776 | 1731 | ||
1777 | #include <asm/current.h> | 1732 | #include <asm/current.h> |
@@ -1790,9 +1745,6 @@ extern void wake_up_new_task(struct task_struct *tsk, | |||
1790 | extern void sched_fork(struct task_struct *p, int clone_flags); | 1745 | extern void sched_fork(struct task_struct *p, int clone_flags); |
1791 | extern void sched_dead(struct task_struct *p); | 1746 | extern void sched_dead(struct task_struct *p); |
1792 | 1747 | ||
1793 | extern int in_group_p(gid_t); | ||
1794 | extern int in_egroup_p(gid_t); | ||
1795 | |||
1796 | extern void proc_caches_init(void); | 1748 | extern void proc_caches_init(void); |
1797 | extern void flush_signals(struct task_struct *); | 1749 | extern void flush_signals(struct task_struct *); |
1798 | extern void ignore_signals(struct task_struct *); | 1750 | extern void ignore_signals(struct task_struct *); |
@@ -1924,6 +1876,8 @@ static inline unsigned long wait_task_inactive(struct task_struct *p, | |||
1924 | #define for_each_process(p) \ | 1876 | #define for_each_process(p) \ |
1925 | for (p = &init_task ; (p = next_task(p)) != &init_task ; ) | 1877 | for (p = &init_task ; (p = next_task(p)) != &init_task ; ) |
1926 | 1878 | ||
1879 | extern bool is_single_threaded(struct task_struct *); | ||
1880 | |||
1927 | /* | 1881 | /* |
1928 | * Careful: do_each_thread/while_each_thread is a double loop so | 1882 | * Careful: do_each_thread/while_each_thread is a double loop so |
1929 | * 'break' will not work as expected - use goto instead. | 1883 | * 'break' will not work as expected - use goto instead. |
diff --git a/include/linux/securebits.h b/include/linux/securebits.h index 92f09bdf1175..d2c5ed845bcc 100644 --- a/include/linux/securebits.h +++ b/include/linux/securebits.h | |||
@@ -32,7 +32,7 @@ | |||
32 | setting is locked or not. A setting which is locked cannot be | 32 | setting is locked or not. A setting which is locked cannot be |
33 | changed from user-level. */ | 33 | changed from user-level. */ |
34 | #define issecure_mask(X) (1 << (X)) | 34 | #define issecure_mask(X) (1 << (X)) |
35 | #define issecure(X) (issecure_mask(X) & current->securebits) | 35 | #define issecure(X) (issecure_mask(X) & current_cred_xxx(securebits)) |
36 | 36 | ||
37 | #define SECURE_ALL_BITS (issecure_mask(SECURE_NOROOT) | \ | 37 | #define SECURE_ALL_BITS (issecure_mask(SECURE_NOROOT) | \ |
38 | issecure_mask(SECURE_NO_SETUID_FIXUP) | \ | 38 | issecure_mask(SECURE_NO_SETUID_FIXUP) | \ |
diff --git a/include/linux/security.h b/include/linux/security.h index c13f1cec9abb..59a11e19b617 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 |
@@ -585,15 +575,31 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts) | |||
585 | * manual page for definitions of the @clone_flags. | 575 | * manual page for definitions of the @clone_flags. |
586 | * @clone_flags contains the flags indicating what should be shared. | 576 | * @clone_flags contains the flags indicating what should be shared. |
587 | * Return 0 if permission is granted. | 577 | * Return 0 if permission is granted. |
588 | * @task_alloc_security: | 578 | * @cred_free: |
589 | * @p contains the task_struct for child process. | 579 | * @cred points to the credentials. |
590 | * Allocate and attach a security structure to the p->security field. The | 580 | * Deallocate and clear the cred->security field in a set of credentials. |
591 | * security field is initialized to NULL when the task structure is | 581 | * @cred_prepare: |
592 | * allocated. | 582 | * @new points to the new credentials. |
593 | * Return 0 if operation was successful. | 583 | * @old points to the original credentials. |
594 | * @task_free_security: | 584 | * @gfp indicates the atomicity of any memory allocations. |
595 | * @p contains the task_struct for process. | 585 | * Prepare a new set of credentials by copying the data from the old set. |
596 | * Deallocate and clear the p->security field. | 586 | * @cred_commit: |
587 | * @new points to the new credentials. | ||
588 | * @old points to the original credentials. | ||
589 | * Install a new set of credentials. | ||
590 | * @kernel_act_as: | ||
591 | * Set the credentials for a kernel service to act as (subjective context). | ||
592 | * @new points to the credentials to be modified. | ||
593 | * @secid specifies the security ID to be set | ||
594 | * The current task must be the one that nominated @secid. | ||
595 | * Return 0 if successful. | ||
596 | * @kernel_create_files_as: | ||
597 | * Set the file creation context in a set of credentials to be the same as | ||
598 | * the objective context of the specified inode. | ||
599 | * @new points to the credentials to be modified. | ||
600 | * @inode points to the inode to use as a reference. | ||
601 | * The current task must be the one that nominated @inode. | ||
602 | * Return 0 if successful. | ||
597 | * @task_setuid: | 603 | * @task_setuid: |
598 | * Check permission before setting one or more of the user identity | 604 | * Check permission before setting one or more of the user identity |
599 | * attributes of the current process. The @flags parameter indicates | 605 | * attributes of the current process. The @flags parameter indicates |
@@ -606,15 +612,13 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts) | |||
606 | * @id2 contains a uid. | 612 | * @id2 contains a uid. |
607 | * @flags contains one of the LSM_SETID_* values. | 613 | * @flags contains one of the LSM_SETID_* values. |
608 | * Return 0 if permission is granted. | 614 | * Return 0 if permission is granted. |
609 | * @task_post_setuid: | 615 | * @task_fix_setuid: |
610 | * Update the module's state after setting one or more of the user | 616 | * Update the module's state after setting one or more of the user |
611 | * identity attributes of the current process. The @flags parameter | 617 | * identity attributes of the current process. The @flags parameter |
612 | * indicates which of the set*uid system calls invoked this hook. If | 618 | * 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 | 619 | * @new is the set of credentials that will be installed. Modifications |
614 | * parameters are not used. | 620 | * 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). | 621 | * @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. | 622 | * @flags contains one of the LSM_SETID_* values. |
619 | * Return 0 on success. | 623 | * Return 0 on success. |
620 | * @task_setgid: | 624 | * @task_setgid: |
@@ -717,13 +721,8 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts) | |||
717 | * @arg3 contains a argument. | 721 | * @arg3 contains a argument. |
718 | * @arg4 contains a argument. | 722 | * @arg4 contains a argument. |
719 | * @arg5 contains a argument. | 723 | * @arg5 contains a argument. |
720 | * @rc_p contains a pointer to communicate back the forced return code | 724 | * 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 | 725 | * 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: | 726 | * @task_to_inode: |
728 | * Set the security attributes for an inode based on an associated task's | 727 | * Set the security attributes for an inode based on an associated task's |
729 | * security attributes, e.g. for /proc/pid inodes. | 728 | * security attributes, e.g. for /proc/pid inodes. |
@@ -1000,7 +999,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 | 999 | * See whether a specific operational right is granted to a process on a |
1001 | * key. | 1000 | * key. |
1002 | * @key_ref refers to the key (key pointer + possession attribute bit). | 1001 | * @key_ref refers to the key (key pointer + possession attribute bit). |
1003 | * @context points to the process to provide the context against which to | 1002 | * @cred points to the credentials to provide the context against which to |
1004 | * evaluate the security data on the key. | 1003 | * evaluate the security data on the key. |
1005 | * @perm describes the combination of permissions required of this key. | 1004 | * @perm describes the combination of permissions required of this key. |
1006 | * Return 1 if permission granted, 0 if permission denied and -ve it the | 1005 | * Return 1 if permission granted, 0 if permission denied and -ve it the |
@@ -1162,6 +1161,7 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts) | |||
1162 | * @child process. | 1161 | * @child process. |
1163 | * Security modules may also want to perform a process tracing check | 1162 | * Security modules may also want to perform a process tracing check |
1164 | * during an execve in the set_security or apply_creds hooks of | 1163 | * during an execve in the set_security or apply_creds hooks of |
1164 | * 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 | 1165 | * binprm_security_ops if the process is being traced and its security |
1166 | * attributes would be changed by the execve. | 1166 | * attributes would be changed by the execve. |
1167 | * @child contains the task_struct structure for the target process. | 1167 | * @child contains the task_struct structure for the target process. |
@@ -1185,29 +1185,15 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts) | |||
1185 | * @inheritable contains the inheritable capability set. | 1185 | * @inheritable contains the inheritable capability set. |
1186 | * @permitted contains the permitted capability set. | 1186 | * @permitted contains the permitted capability set. |
1187 | * Return 0 if the capability sets were successfully obtained. | 1187 | * Return 0 if the capability sets were successfully obtained. |
1188 | * @capset_check: | 1188 | * @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 | 1189 | * Set the @effective, @inheritable, and @permitted capability sets for |
1202 | * the @target process. Since capset_check cannot always check permission | 1190 | * the current process. |
1203 | * to the real @target process, this hook may also perform permission | 1191 | * @new contains the new credentials structure for target process. |
1204 | * checking to determine if the current process is allowed to set the | 1192 | * @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. | 1193 | * @effective contains the effective capability set. |
1209 | * @inheritable contains the inheritable capability set. | 1194 | * @inheritable contains the inheritable capability set. |
1210 | * @permitted contains the permitted capability set. | 1195 | * @permitted contains the permitted capability set. |
1196 | * Return 0 and update @new if permission is granted. | ||
1211 | * @capable: | 1197 | * @capable: |
1212 | * Check whether the @tsk process has the @cap capability. | 1198 | * Check whether the @tsk process has the @cap capability. |
1213 | * @tsk contains the task_struct for the process. | 1199 | * @tsk contains the task_struct for the process. |
@@ -1299,15 +1285,12 @@ struct security_operations { | |||
1299 | int (*capget) (struct task_struct *target, | 1285 | int (*capget) (struct task_struct *target, |
1300 | kernel_cap_t *effective, | 1286 | kernel_cap_t *effective, |
1301 | kernel_cap_t *inheritable, kernel_cap_t *permitted); | 1287 | kernel_cap_t *inheritable, kernel_cap_t *permitted); |
1302 | int (*capset_check) (struct task_struct *target, | 1288 | int (*capset) (struct cred *new, |
1303 | kernel_cap_t *effective, | 1289 | const struct cred *old, |
1304 | kernel_cap_t *inheritable, | 1290 | const kernel_cap_t *effective, |
1305 | kernel_cap_t *permitted); | 1291 | const kernel_cap_t *inheritable, |
1306 | void (*capset_set) (struct task_struct *target, | 1292 | const kernel_cap_t *permitted); |
1307 | kernel_cap_t *effective, | 1293 | 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); | 1294 | int (*acct) (struct file *file); |
1312 | int (*sysctl) (struct ctl_table *table, int op); | 1295 | int (*sysctl) (struct ctl_table *table, int op); |
1313 | int (*quotactl) (int cmds, int type, int id, struct super_block *sb); | 1296 | int (*quotactl) (int cmds, int type, int id, struct super_block *sb); |
@@ -1316,13 +1299,11 @@ struct security_operations { | |||
1316 | int (*settime) (struct timespec *ts, struct timezone *tz); | 1299 | int (*settime) (struct timespec *ts, struct timezone *tz); |
1317 | int (*vm_enough_memory) (struct mm_struct *mm, long pages); | 1300 | int (*vm_enough_memory) (struct mm_struct *mm, long pages); |
1318 | 1301 | ||
1319 | int (*bprm_alloc_security) (struct linux_binprm *bprm); | 1302 | 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); | 1303 | int (*bprm_check_security) (struct linux_binprm *bprm); |
1325 | int (*bprm_secureexec) (struct linux_binprm *bprm); | 1304 | int (*bprm_secureexec) (struct linux_binprm *bprm); |
1305 | void (*bprm_committing_creds) (struct linux_binprm *bprm); | ||
1306 | void (*bprm_committed_creds) (struct linux_binprm *bprm); | ||
1326 | 1307 | ||
1327 | int (*sb_alloc_security) (struct super_block *sb); | 1308 | int (*sb_alloc_security) (struct super_block *sb); |
1328 | void (*sb_free_security) (struct super_block *sb); | 1309 | void (*sb_free_security) (struct super_block *sb); |
@@ -1406,14 +1387,18 @@ struct security_operations { | |||
1406 | int (*file_send_sigiotask) (struct task_struct *tsk, | 1387 | int (*file_send_sigiotask) (struct task_struct *tsk, |
1407 | struct fown_struct *fown, int sig); | 1388 | struct fown_struct *fown, int sig); |
1408 | int (*file_receive) (struct file *file); | 1389 | int (*file_receive) (struct file *file); |
1409 | int (*dentry_open) (struct file *file); | 1390 | int (*dentry_open) (struct file *file, const struct cred *cred); |
1410 | 1391 | ||
1411 | int (*task_create) (unsigned long clone_flags); | 1392 | int (*task_create) (unsigned long clone_flags); |
1412 | int (*task_alloc_security) (struct task_struct *p); | 1393 | void (*cred_free) (struct cred *cred); |
1413 | void (*task_free_security) (struct task_struct *p); | 1394 | int (*cred_prepare)(struct cred *new, const struct cred *old, |
1395 | gfp_t gfp); | ||
1396 | void (*cred_commit)(struct cred *new, const struct cred *old); | ||
1397 | int (*kernel_act_as)(struct cred *new, u32 secid); | ||
1398 | 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); | 1399 | 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 */ , | 1400 | int (*task_fix_setuid) (struct cred *new, const struct cred *old, |
1416 | uid_t old_euid, uid_t old_suid, int flags); | 1401 | int flags); |
1417 | int (*task_setgid) (gid_t id0, gid_t id1, gid_t id2, int flags); | 1402 | 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); | 1403 | int (*task_setpgid) (struct task_struct *p, pid_t pgid); |
1419 | int (*task_getpgid) (struct task_struct *p); | 1404 | int (*task_getpgid) (struct task_struct *p); |
@@ -1433,8 +1418,7 @@ struct security_operations { | |||
1433 | int (*task_wait) (struct task_struct *p); | 1418 | int (*task_wait) (struct task_struct *p); |
1434 | int (*task_prctl) (int option, unsigned long arg2, | 1419 | int (*task_prctl) (int option, unsigned long arg2, |
1435 | unsigned long arg3, unsigned long arg4, | 1420 | unsigned long arg3, unsigned long arg4, |
1436 | unsigned long arg5, long *rc_p); | 1421 | 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); | 1422 | void (*task_to_inode) (struct task_struct *p, struct inode *inode); |
1439 | 1423 | ||
1440 | int (*ipc_permission) (struct kern_ipc_perm *ipcp, short flag); | 1424 | int (*ipc_permission) (struct kern_ipc_perm *ipcp, short flag); |
@@ -1539,10 +1523,10 @@ struct security_operations { | |||
1539 | 1523 | ||
1540 | /* key management security hooks */ | 1524 | /* key management security hooks */ |
1541 | #ifdef CONFIG_KEYS | 1525 | #ifdef CONFIG_KEYS |
1542 | int (*key_alloc) (struct key *key, struct task_struct *tsk, unsigned long flags); | 1526 | int (*key_alloc) (struct key *key, const struct cred *cred, unsigned long flags); |
1543 | void (*key_free) (struct key *key); | 1527 | void (*key_free) (struct key *key); |
1544 | int (*key_permission) (key_ref_t key_ref, | 1528 | int (*key_permission) (key_ref_t key_ref, |
1545 | struct task_struct *context, | 1529 | const struct cred *cred, |
1546 | key_perm_t perm); | 1530 | key_perm_t perm); |
1547 | int (*key_getsecurity)(struct key *key, char **_buffer); | 1531 | int (*key_getsecurity)(struct key *key, char **_buffer); |
1548 | #endif /* CONFIG_KEYS */ | 1532 | #endif /* CONFIG_KEYS */ |
@@ -1568,15 +1552,12 @@ int security_capget(struct task_struct *target, | |||
1568 | kernel_cap_t *effective, | 1552 | kernel_cap_t *effective, |
1569 | kernel_cap_t *inheritable, | 1553 | kernel_cap_t *inheritable, |
1570 | kernel_cap_t *permitted); | 1554 | kernel_cap_t *permitted); |
1571 | int security_capset_check(struct task_struct *target, | 1555 | int security_capset(struct cred *new, const struct cred *old, |
1572 | kernel_cap_t *effective, | 1556 | const kernel_cap_t *effective, |
1573 | kernel_cap_t *inheritable, | 1557 | const kernel_cap_t *inheritable, |
1574 | kernel_cap_t *permitted); | 1558 | 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); | 1559 | int security_capable(struct task_struct *tsk, int cap); |
1560 | int security_capable_noaudit(struct task_struct *tsk, int cap); | ||
1580 | int security_acct(struct file *file); | 1561 | int security_acct(struct file *file); |
1581 | int security_sysctl(struct ctl_table *table, int op); | 1562 | int security_sysctl(struct ctl_table *table, int op); |
1582 | int security_quotactl(int cmds, int type, int id, struct super_block *sb); | 1563 | int security_quotactl(int cmds, int type, int id, struct super_block *sb); |
@@ -1586,12 +1567,10 @@ int security_settime(struct timespec *ts, struct timezone *tz); | |||
1586 | int security_vm_enough_memory(long pages); | 1567 | int security_vm_enough_memory(long pages); |
1587 | int security_vm_enough_memory_mm(struct mm_struct *mm, long pages); | 1568 | int security_vm_enough_memory_mm(struct mm_struct *mm, long pages); |
1588 | int security_vm_enough_memory_kern(long pages); | 1569 | int security_vm_enough_memory_kern(long pages); |
1589 | int security_bprm_alloc(struct linux_binprm *bprm); | 1570 | 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); | 1571 | int security_bprm_check(struct linux_binprm *bprm); |
1572 | void security_bprm_committing_creds(struct linux_binprm *bprm); | ||
1573 | void security_bprm_committed_creds(struct linux_binprm *bprm); | ||
1595 | int security_bprm_secureexec(struct linux_binprm *bprm); | 1574 | int security_bprm_secureexec(struct linux_binprm *bprm); |
1596 | int security_sb_alloc(struct super_block *sb); | 1575 | int security_sb_alloc(struct super_block *sb); |
1597 | void security_sb_free(struct super_block *sb); | 1576 | void security_sb_free(struct super_block *sb); |
@@ -1663,13 +1642,16 @@ int security_file_set_fowner(struct file *file); | |||
1663 | int security_file_send_sigiotask(struct task_struct *tsk, | 1642 | int security_file_send_sigiotask(struct task_struct *tsk, |
1664 | struct fown_struct *fown, int sig); | 1643 | struct fown_struct *fown, int sig); |
1665 | int security_file_receive(struct file *file); | 1644 | int security_file_receive(struct file *file); |
1666 | int security_dentry_open(struct file *file); | 1645 | int security_dentry_open(struct file *file, const struct cred *cred); |
1667 | int security_task_create(unsigned long clone_flags); | 1646 | int security_task_create(unsigned long clone_flags); |
1668 | int security_task_alloc(struct task_struct *p); | 1647 | void security_cred_free(struct cred *cred); |
1669 | void security_task_free(struct task_struct *p); | 1648 | int security_prepare_creds(struct cred *new, const struct cred *old, gfp_t gfp); |
1649 | void security_commit_creds(struct cred *new, const struct cred *old); | ||
1650 | int security_kernel_act_as(struct cred *new, u32 secid); | ||
1651 | 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); | 1652 | 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, | 1653 | int security_task_fix_setuid(struct cred *new, const struct cred *old, |
1672 | uid_t old_suid, int flags); | 1654 | int flags); |
1673 | int security_task_setgid(gid_t id0, gid_t id1, gid_t id2, int flags); | 1655 | 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); | 1656 | int security_task_setpgid(struct task_struct *p, pid_t pgid); |
1675 | int security_task_getpgid(struct task_struct *p); | 1657 | int security_task_getpgid(struct task_struct *p); |
@@ -1688,8 +1670,7 @@ int security_task_kill(struct task_struct *p, struct siginfo *info, | |||
1688 | int sig, u32 secid); | 1670 | int sig, u32 secid); |
1689 | int security_task_wait(struct task_struct *p); | 1671 | int security_task_wait(struct task_struct *p); |
1690 | int security_task_prctl(int option, unsigned long arg2, unsigned long arg3, | 1672 | int security_task_prctl(int option, unsigned long arg2, unsigned long arg3, |
1691 | unsigned long arg4, unsigned long arg5, long *rc_p); | 1673 | 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); | 1674 | void security_task_to_inode(struct task_struct *p, struct inode *inode); |
1694 | int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag); | 1675 | int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag); |
1695 | void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid); | 1676 | void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid); |
@@ -1764,25 +1745,23 @@ static inline int security_capget(struct task_struct *target, | |||
1764 | return cap_capget(target, effective, inheritable, permitted); | 1745 | return cap_capget(target, effective, inheritable, permitted); |
1765 | } | 1746 | } |
1766 | 1747 | ||
1767 | static inline int security_capset_check(struct task_struct *target, | 1748 | static inline int security_capset(struct cred *new, |
1768 | kernel_cap_t *effective, | 1749 | const struct cred *old, |
1769 | kernel_cap_t *inheritable, | 1750 | const kernel_cap_t *effective, |
1770 | kernel_cap_t *permitted) | 1751 | const kernel_cap_t *inheritable, |
1752 | const kernel_cap_t *permitted) | ||
1771 | { | 1753 | { |
1772 | return cap_capset_check(target, effective, inheritable, permitted); | 1754 | return cap_capset(new, old, effective, inheritable, permitted); |
1773 | } | 1755 | } |
1774 | 1756 | ||
1775 | static inline void security_capset_set(struct task_struct *target, | 1757 | 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 | { | 1758 | { |
1780 | cap_capset_set(target, effective, inheritable, permitted); | 1759 | return cap_capable(tsk, cap, SECURITY_CAP_AUDIT); |
1781 | } | 1760 | } |
1782 | 1761 | ||
1783 | static inline int security_capable(struct task_struct *tsk, int cap) | 1762 | static inline int security_capable_noaudit(struct task_struct *tsk, int cap) |
1784 | { | 1763 | { |
1785 | return cap_capable(tsk, cap); | 1764 | return cap_capable(tsk, cap, SECURITY_CAP_NOAUDIT); |
1786 | } | 1765 | } |
1787 | 1766 | ||
1788 | static inline int security_acct(struct file *file) | 1767 | static inline int security_acct(struct file *file) |
@@ -1831,32 +1810,22 @@ static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages) | |||
1831 | return cap_vm_enough_memory(mm, pages); | 1810 | return cap_vm_enough_memory(mm, pages); |
1832 | } | 1811 | } |
1833 | 1812 | ||
1834 | static inline int security_bprm_alloc(struct linux_binprm *bprm) | 1813 | static inline int security_bprm_set_creds(struct linux_binprm *bprm) |
1835 | { | ||
1836 | return 0; | ||
1837 | } | ||
1838 | |||
1839 | static inline void security_bprm_free(struct linux_binprm *bprm) | ||
1840 | { } | ||
1841 | |||
1842 | static inline void security_bprm_apply_creds(struct linux_binprm *bprm, int unsafe) | ||
1843 | { | 1814 | { |
1844 | cap_bprm_apply_creds(bprm, unsafe); | 1815 | return cap_bprm_set_creds(bprm); |
1845 | } | 1816 | } |
1846 | 1817 | ||
1847 | static inline void security_bprm_post_apply_creds(struct linux_binprm *bprm) | 1818 | static inline int security_bprm_check(struct linux_binprm *bprm) |
1848 | { | 1819 | { |
1849 | return; | 1820 | return 0; |
1850 | } | 1821 | } |
1851 | 1822 | ||
1852 | static inline int security_bprm_set(struct linux_binprm *bprm) | 1823 | static inline void security_bprm_committing_creds(struct linux_binprm *bprm) |
1853 | { | 1824 | { |
1854 | return cap_bprm_set_security(bprm); | ||
1855 | } | 1825 | } |
1856 | 1826 | ||
1857 | static inline int security_bprm_check(struct linux_binprm *bprm) | 1827 | static inline void security_bprm_committed_creds(struct linux_binprm *bprm) |
1858 | { | 1828 | { |
1859 | return 0; | ||
1860 | } | 1829 | } |
1861 | 1830 | ||
1862 | static inline int security_bprm_secureexec(struct linux_binprm *bprm) | 1831 | static inline int security_bprm_secureexec(struct linux_binprm *bprm) |
@@ -2173,7 +2142,8 @@ static inline int security_file_receive(struct file *file) | |||
2173 | return 0; | 2142 | return 0; |
2174 | } | 2143 | } |
2175 | 2144 | ||
2176 | static inline int security_dentry_open(struct file *file) | 2145 | static inline int security_dentry_open(struct file *file, |
2146 | const struct cred *cred) | ||
2177 | { | 2147 | { |
2178 | return 0; | 2148 | return 0; |
2179 | } | 2149 | } |
@@ -2183,13 +2153,31 @@ static inline int security_task_create(unsigned long clone_flags) | |||
2183 | return 0; | 2153 | return 0; |
2184 | } | 2154 | } |
2185 | 2155 | ||
2186 | static inline int security_task_alloc(struct task_struct *p) | 2156 | static inline void security_cred_free(struct cred *cred) |
2157 | { } | ||
2158 | |||
2159 | static inline int security_prepare_creds(struct cred *new, | ||
2160 | const struct cred *old, | ||
2161 | gfp_t gfp) | ||
2187 | { | 2162 | { |
2188 | return 0; | 2163 | return 0; |
2189 | } | 2164 | } |
2190 | 2165 | ||
2191 | static inline void security_task_free(struct task_struct *p) | 2166 | static inline void security_commit_creds(struct cred *new, |
2192 | { } | 2167 | const struct cred *old) |
2168 | { | ||
2169 | } | ||
2170 | |||
2171 | static inline int security_kernel_act_as(struct cred *cred, u32 secid) | ||
2172 | { | ||
2173 | return 0; | ||
2174 | } | ||
2175 | |||
2176 | static inline int security_kernel_create_files_as(struct cred *cred, | ||
2177 | struct inode *inode) | ||
2178 | { | ||
2179 | return 0; | ||
2180 | } | ||
2193 | 2181 | ||
2194 | static inline int security_task_setuid(uid_t id0, uid_t id1, uid_t id2, | 2182 | static inline int security_task_setuid(uid_t id0, uid_t id1, uid_t id2, |
2195 | int flags) | 2183 | int flags) |
@@ -2197,10 +2185,11 @@ static inline int security_task_setuid(uid_t id0, uid_t id1, uid_t id2, | |||
2197 | return 0; | 2185 | return 0; |
2198 | } | 2186 | } |
2199 | 2187 | ||
2200 | static inline int security_task_post_setuid(uid_t old_ruid, uid_t old_euid, | 2188 | static inline int security_task_fix_setuid(struct cred *new, |
2201 | uid_t old_suid, int flags) | 2189 | const struct cred *old, |
2190 | int flags) | ||
2202 | { | 2191 | { |
2203 | return cap_task_post_setuid(old_ruid, old_euid, old_suid, flags); | 2192 | return cap_task_fix_setuid(new, old, flags); |
2204 | } | 2193 | } |
2205 | 2194 | ||
2206 | static inline int security_task_setgid(gid_t id0, gid_t id1, gid_t id2, | 2195 | static inline int security_task_setgid(gid_t id0, gid_t id1, gid_t id2, |
@@ -2287,14 +2276,9 @@ static inline int security_task_wait(struct task_struct *p) | |||
2287 | static inline int security_task_prctl(int option, unsigned long arg2, | 2276 | static inline int security_task_prctl(int option, unsigned long arg2, |
2288 | unsigned long arg3, | 2277 | unsigned long arg3, |
2289 | unsigned long arg4, | 2278 | unsigned long arg4, |
2290 | unsigned long arg5, long *rc_p) | 2279 | unsigned long arg5) |
2291 | { | ||
2292 | return cap_task_prctl(option, arg2, arg3, arg3, arg5, rc_p); | ||
2293 | } | ||
2294 | |||
2295 | static inline void security_task_reparent_to_init(struct task_struct *p) | ||
2296 | { | 2280 | { |
2297 | cap_task_reparent_to_init(p); | 2281 | return cap_task_prctl(option, arg2, arg3, arg3, arg5); |
2298 | } | 2282 | } |
2299 | 2283 | ||
2300 | static inline void security_task_to_inode(struct task_struct *p, struct inode *inode) | 2284 | static inline void security_task_to_inode(struct task_struct *p, struct inode *inode) |
@@ -2720,16 +2704,16 @@ static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi | |||
2720 | #ifdef CONFIG_KEYS | 2704 | #ifdef CONFIG_KEYS |
2721 | #ifdef CONFIG_SECURITY | 2705 | #ifdef CONFIG_SECURITY |
2722 | 2706 | ||
2723 | int security_key_alloc(struct key *key, struct task_struct *tsk, unsigned long flags); | 2707 | int security_key_alloc(struct key *key, const struct cred *cred, unsigned long flags); |
2724 | void security_key_free(struct key *key); | 2708 | void security_key_free(struct key *key); |
2725 | int security_key_permission(key_ref_t key_ref, | 2709 | int security_key_permission(key_ref_t key_ref, |
2726 | struct task_struct *context, key_perm_t perm); | 2710 | const struct cred *cred, key_perm_t perm); |
2727 | int security_key_getsecurity(struct key *key, char **_buffer); | 2711 | int security_key_getsecurity(struct key *key, char **_buffer); |
2728 | 2712 | ||
2729 | #else | 2713 | #else |
2730 | 2714 | ||
2731 | static inline int security_key_alloc(struct key *key, | 2715 | static inline int security_key_alloc(struct key *key, |
2732 | struct task_struct *tsk, | 2716 | const struct cred *cred, |
2733 | unsigned long flags) | 2717 | unsigned long flags) |
2734 | { | 2718 | { |
2735 | return 0; | 2719 | return 0; |
@@ -2740,7 +2724,7 @@ static inline void security_key_free(struct key *key) | |||
2740 | } | 2724 | } |
2741 | 2725 | ||
2742 | static inline int security_key_permission(key_ref_t key_ref, | 2726 | static inline int security_key_permission(key_ref_t key_ref, |
2743 | struct task_struct *context, | 2727 | const struct cred *cred, |
2744 | key_perm_t perm) | 2728 | key_perm_t perm) |
2745 | { | 2729 | { |
2746 | return 0; | 2730 | return 0; |
diff --git a/include/net/scm.h b/include/net/scm.h index 33e9986beb86..f45bb6eca7d4 100644 --- a/include/net/scm.h +++ b/include/net/scm.h | |||
@@ -55,8 +55,8 @@ static __inline__ int scm_send(struct socket *sock, struct msghdr *msg, | |||
55 | struct scm_cookie *scm) | 55 | struct scm_cookie *scm) |
56 | { | 56 | { |
57 | struct task_struct *p = current; | 57 | struct task_struct *p = current; |
58 | scm->creds.uid = p->uid; | 58 | scm->creds.uid = current_uid(); |
59 | scm->creds.gid = p->gid; | 59 | scm->creds.gid = current_gid(); |
60 | scm->creds.pid = task_tgid_vnr(p); | 60 | scm->creds.pid = task_tgid_vnr(p); |
61 | scm->fp = NULL; | 61 | scm->fp = NULL; |
62 | scm->seq = 0; | 62 | scm->seq = 0; |