diff options
author | David Howells <dhowells@redhat.com> | 2008-11-13 18:39:17 -0500 |
---|---|---|
committer | James Morris <jmorris@namei.org> | 2008-11-13 18:39:17 -0500 |
commit | f1752eec6145c97163dbce62d17cf5d928e28a27 (patch) | |
tree | 16bc51166d38815092de36a461b845b0b4b522f9 /kernel/fork.c | |
parent | b6dff3ec5e116e3af6f537d4caedcad6b9e5082a (diff) |
CRED: Detach the credentials from task_struct
Detach the credentials from task_struct, duplicating them in copy_process()
and releasing them in __put_task_struct().
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: James Morris <jmorris@namei.org>
Acked-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'kernel/fork.c')
-rw-r--r-- | kernel/fork.c | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index 81fdc7733908..c932e283ddfc 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -146,9 +146,7 @@ void __put_task_struct(struct task_struct *tsk) | |||
146 | WARN_ON(atomic_read(&tsk->usage)); | 146 | WARN_ON(atomic_read(&tsk->usage)); |
147 | WARN_ON(tsk == current); | 147 | WARN_ON(tsk == current); |
148 | 148 | ||
149 | security_task_free(tsk); | 149 | put_cred(tsk->cred); |
150 | free_uid(tsk->__temp_cred.user); | ||
151 | put_group_info(tsk->__temp_cred.group_info); | ||
152 | delayacct_tsk_free(tsk); | 150 | delayacct_tsk_free(tsk); |
153 | 151 | ||
154 | if (!profile_handoff_task(tsk)) | 152 | if (!profile_handoff_task(tsk)) |
@@ -969,7 +967,6 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
969 | DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled); | 967 | DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled); |
970 | DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled); | 968 | DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled); |
971 | #endif | 969 | #endif |
972 | p->cred = &p->__temp_cred; | ||
973 | retval = -EAGAIN; | 970 | retval = -EAGAIN; |
974 | if (atomic_read(&p->cred->user->processes) >= | 971 | if (atomic_read(&p->cred->user->processes) >= |
975 | p->signal->rlim[RLIMIT_NPROC].rlim_cur) { | 972 | p->signal->rlim[RLIMIT_NPROC].rlim_cur) { |
@@ -978,9 +975,9 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
978 | goto bad_fork_free; | 975 | goto bad_fork_free; |
979 | } | 976 | } |
980 | 977 | ||
981 | atomic_inc(&p->cred->user->__count); | 978 | retval = copy_creds(p, clone_flags); |
982 | atomic_inc(&p->cred->user->processes); | 979 | if (retval < 0) |
983 | get_group_info(p->cred->group_info); | 980 | goto bad_fork_free; |
984 | 981 | ||
985 | /* | 982 | /* |
986 | * If multiple threads are within copy_process(), then this check | 983 | * If multiple threads are within copy_process(), then this check |
@@ -1035,9 +1032,6 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
1035 | do_posix_clock_monotonic_gettime(&p->start_time); | 1032 | do_posix_clock_monotonic_gettime(&p->start_time); |
1036 | p->real_start_time = p->start_time; | 1033 | p->real_start_time = p->start_time; |
1037 | monotonic_to_bootbased(&p->real_start_time); | 1034 | monotonic_to_bootbased(&p->real_start_time); |
1038 | #ifdef CONFIG_SECURITY | ||
1039 | p->cred->security = NULL; | ||
1040 | #endif | ||
1041 | p->io_context = NULL; | 1035 | p->io_context = NULL; |
1042 | p->audit_context = NULL; | 1036 | p->audit_context = NULL; |
1043 | cgroup_fork(p); | 1037 | cgroup_fork(p); |
@@ -1082,10 +1076,8 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
1082 | /* Perform scheduler related setup. Assign this task to a CPU. */ | 1076 | /* Perform scheduler related setup. Assign this task to a CPU. */ |
1083 | sched_fork(p, clone_flags); | 1077 | sched_fork(p, clone_flags); |
1084 | 1078 | ||
1085 | if ((retval = security_task_alloc(p))) | ||
1086 | goto bad_fork_cleanup_policy; | ||
1087 | if ((retval = audit_alloc(p))) | 1079 | if ((retval = audit_alloc(p))) |
1088 | goto bad_fork_cleanup_security; | 1080 | goto bad_fork_cleanup_policy; |
1089 | /* copy all the process information */ | 1081 | /* copy all the process information */ |
1090 | if ((retval = copy_semundo(clone_flags, p))) | 1082 | if ((retval = copy_semundo(clone_flags, p))) |
1091 | goto bad_fork_cleanup_audit; | 1083 | goto bad_fork_cleanup_audit; |
@@ -1284,8 +1276,6 @@ bad_fork_cleanup_semundo: | |||
1284 | exit_sem(p); | 1276 | exit_sem(p); |
1285 | bad_fork_cleanup_audit: | 1277 | bad_fork_cleanup_audit: |
1286 | audit_free(p); | 1278 | audit_free(p); |
1287 | bad_fork_cleanup_security: | ||
1288 | security_task_free(p); | ||
1289 | bad_fork_cleanup_policy: | 1279 | bad_fork_cleanup_policy: |
1290 | #ifdef CONFIG_NUMA | 1280 | #ifdef CONFIG_NUMA |
1291 | mpol_put(p->mempolicy); | 1281 | mpol_put(p->mempolicy); |
@@ -1298,9 +1288,7 @@ bad_fork_cleanup_cgroup: | |||
1298 | bad_fork_cleanup_put_domain: | 1288 | bad_fork_cleanup_put_domain: |
1299 | module_put(task_thread_info(p)->exec_domain->module); | 1289 | module_put(task_thread_info(p)->exec_domain->module); |
1300 | bad_fork_cleanup_count: | 1290 | bad_fork_cleanup_count: |
1301 | put_group_info(p->cred->group_info); | 1291 | put_cred(p->cred); |
1302 | atomic_dec(&p->cred->user->processes); | ||
1303 | free_uid(p->cred->user); | ||
1304 | bad_fork_free: | 1292 | bad_fork_free: |
1305 | free_task(p); | 1293 | free_task(p); |
1306 | fork_out: | 1294 | fork_out: |