diff options
author | KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> | 2010-10-27 18:34:08 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-27 21:03:12 -0400 |
commit | 9b1bf12d5d51bca178dea21b04a0805e29d60cf1 (patch) | |
tree | 902a2c0e5882a2152da59a589958d6426dc84643 /fs/exec.c | |
parent | b84011508360d6885a9d95a235ec77d56f133377 (diff) |
signals: move cred_guard_mutex from task_struct to signal_struct
Oleg Nesterov pointed out we have to prevent multiple-threads-inside-exec
itself and we can reuse ->cred_guard_mutex for it. Yes, concurrent
execve() has no worth.
Let's move ->cred_guard_mutex from task_struct to signal_struct. It
naturally prevent multiple-threads-inside-exec.
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Roland McGrath <roland@redhat.com>
Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/exec.c')
-rw-r--r-- | fs/exec.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -1083,14 +1083,14 @@ EXPORT_SYMBOL(setup_new_exec); | |||
1083 | */ | 1083 | */ |
1084 | int prepare_bprm_creds(struct linux_binprm *bprm) | 1084 | int prepare_bprm_creds(struct linux_binprm *bprm) |
1085 | { | 1085 | { |
1086 | if (mutex_lock_interruptible(¤t->cred_guard_mutex)) | 1086 | if (mutex_lock_interruptible(¤t->signal->cred_guard_mutex)) |
1087 | return -ERESTARTNOINTR; | 1087 | return -ERESTARTNOINTR; |
1088 | 1088 | ||
1089 | bprm->cred = prepare_exec_creds(); | 1089 | bprm->cred = prepare_exec_creds(); |
1090 | if (likely(bprm->cred)) | 1090 | if (likely(bprm->cred)) |
1091 | return 0; | 1091 | return 0; |
1092 | 1092 | ||
1093 | mutex_unlock(¤t->cred_guard_mutex); | 1093 | mutex_unlock(¤t->signal->cred_guard_mutex); |
1094 | return -ENOMEM; | 1094 | return -ENOMEM; |
1095 | } | 1095 | } |
1096 | 1096 | ||
@@ -1098,7 +1098,7 @@ void free_bprm(struct linux_binprm *bprm) | |||
1098 | { | 1098 | { |
1099 | free_arg_pages(bprm); | 1099 | free_arg_pages(bprm); |
1100 | if (bprm->cred) { | 1100 | if (bprm->cred) { |
1101 | mutex_unlock(¤t->cred_guard_mutex); | 1101 | mutex_unlock(¤t->signal->cred_guard_mutex); |
1102 | abort_creds(bprm->cred); | 1102 | abort_creds(bprm->cred); |
1103 | } | 1103 | } |
1104 | kfree(bprm); | 1104 | kfree(bprm); |
@@ -1119,13 +1119,13 @@ void install_exec_creds(struct linux_binprm *bprm) | |||
1119 | * credentials; any time after this it may be unlocked. | 1119 | * credentials; any time after this it may be unlocked. |
1120 | */ | 1120 | */ |
1121 | security_bprm_committed_creds(bprm); | 1121 | security_bprm_committed_creds(bprm); |
1122 | mutex_unlock(¤t->cred_guard_mutex); | 1122 | mutex_unlock(¤t->signal->cred_guard_mutex); |
1123 | } | 1123 | } |
1124 | EXPORT_SYMBOL(install_exec_creds); | 1124 | EXPORT_SYMBOL(install_exec_creds); |
1125 | 1125 | ||
1126 | /* | 1126 | /* |
1127 | * determine how safe it is to execute the proposed program | 1127 | * determine how safe it is to execute the proposed program |
1128 | * - the caller must hold current->cred_guard_mutex to protect against | 1128 | * - the caller must hold ->cred_guard_mutex to protect against |
1129 | * PTRACE_ATTACH | 1129 | * PTRACE_ATTACH |
1130 | */ | 1130 | */ |
1131 | int check_unsafe_exec(struct linux_binprm *bprm) | 1131 | int check_unsafe_exec(struct linux_binprm *bprm) |