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 /include | |
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 'include')
-rw-r--r-- | include/linux/init_task.h | 4 | ||||
-rw-r--r-- | include/linux/sched.h | 7 | ||||
-rw-r--r-- | include/linux/tracehook.h | 2 |
3 files changed, 7 insertions, 6 deletions
diff --git a/include/linux/init_task.h b/include/linux/init_task.h index 2fea6c8ef6ba..1f8c06ce0fa6 100644 --- a/include/linux/init_task.h +++ b/include/linux/init_task.h | |||
@@ -29,6 +29,8 @@ extern struct fs_struct init_fs; | |||
29 | .running = 0, \ | 29 | .running = 0, \ |
30 | .lock = __SPIN_LOCK_UNLOCKED(sig.cputimer.lock), \ | 30 | .lock = __SPIN_LOCK_UNLOCKED(sig.cputimer.lock), \ |
31 | }, \ | 31 | }, \ |
32 | .cred_guard_mutex = \ | ||
33 | __MUTEX_INITIALIZER(sig.cred_guard_mutex), \ | ||
32 | } | 34 | } |
33 | 35 | ||
34 | extern struct nsproxy init_nsproxy; | 36 | extern struct nsproxy init_nsproxy; |
@@ -145,8 +147,6 @@ extern struct cred init_cred; | |||
145 | .group_leader = &tsk, \ | 147 | .group_leader = &tsk, \ |
146 | RCU_INIT_POINTER(.real_cred, &init_cred), \ | 148 | RCU_INIT_POINTER(.real_cred, &init_cred), \ |
147 | RCU_INIT_POINTER(.cred, &init_cred), \ | 149 | RCU_INIT_POINTER(.cred, &init_cred), \ |
148 | .cred_guard_mutex = \ | ||
149 | __MUTEX_INITIALIZER(tsk.cred_guard_mutex), \ | ||
150 | .comm = "swapper", \ | 150 | .comm = "swapper", \ |
151 | .thread = INIT_THREAD, \ | 151 | .thread = INIT_THREAD, \ |
152 | .fs = &init_fs, \ | 152 | .fs = &init_fs, \ |
diff --git a/include/linux/sched.h b/include/linux/sched.h index 3ff5c8519abd..be7adb7588e5 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -626,6 +626,10 @@ struct signal_struct { | |||
626 | 626 | ||
627 | int oom_adj; /* OOM kill score adjustment (bit shift) */ | 627 | int oom_adj; /* OOM kill score adjustment (bit shift) */ |
628 | int oom_score_adj; /* OOM kill score adjustment */ | 628 | int oom_score_adj; /* OOM kill score adjustment */ |
629 | |||
630 | struct mutex cred_guard_mutex; /* guard against foreign influences on | ||
631 | * credential calculations | ||
632 | * (notably. ptrace) */ | ||
629 | }; | 633 | }; |
630 | 634 | ||
631 | /* Context switch must be unlocked if interrupts are to be enabled */ | 635 | /* Context switch must be unlocked if interrupts are to be enabled */ |
@@ -1305,9 +1309,6 @@ struct task_struct { | |||
1305 | * credentials (COW) */ | 1309 | * credentials (COW) */ |
1306 | const struct cred __rcu *cred; /* effective (overridable) subjective task | 1310 | const struct cred __rcu *cred; /* effective (overridable) subjective task |
1307 | * credentials (COW) */ | 1311 | * credentials (COW) */ |
1308 | struct mutex cred_guard_mutex; /* guard against foreign influences on | ||
1309 | * credential calculations | ||
1310 | * (notably. ptrace) */ | ||
1311 | struct cred *replacement_session_keyring; /* for KEYCTL_SESSION_TO_PARENT */ | 1312 | struct cred *replacement_session_keyring; /* for KEYCTL_SESSION_TO_PARENT */ |
1312 | 1313 | ||
1313 | char comm[TASK_COMM_LEN]; /* executable name excluding path | 1314 | char comm[TASK_COMM_LEN]; /* executable name excluding path |
diff --git a/include/linux/tracehook.h b/include/linux/tracehook.h index 10db0102a890..3a2e66d88a32 100644 --- a/include/linux/tracehook.h +++ b/include/linux/tracehook.h | |||
@@ -150,7 +150,7 @@ static inline void tracehook_report_syscall_exit(struct pt_regs *regs, int step) | |||
150 | * | 150 | * |
151 | * Return %LSM_UNSAFE_* bits applied to an exec because of tracing. | 151 | * Return %LSM_UNSAFE_* bits applied to an exec because of tracing. |
152 | * | 152 | * |
153 | * @task->cred_guard_mutex is held by the caller through the do_execve(). | 153 | * @task->signal->cred_guard_mutex is held by the caller through the do_execve(). |
154 | */ | 154 | */ |
155 | static inline int tracehook_unsafe_exec(struct task_struct *task) | 155 | static inline int tracehook_unsafe_exec(struct task_struct *task) |
156 | { | 156 | { |