Commit 69143038 authored by Bernd Edlinger's avatar Bernd Edlinger Committed by Eric W. Biederman

perf: Use new infrastructure to fix deadlocks in execve

This changes perf_event_set_clock to use the new exec_update_mutex
instead of cred_guard_mutex.

This should be safe, as the credentials are only used for reading.
Signed-off-by: default avatarBernd Edlinger <bernd.edlinger@hotmail.de>
Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
parent 76518d37
...@@ -1249,7 +1249,7 @@ static void put_ctx(struct perf_event_context *ctx) ...@@ -1249,7 +1249,7 @@ static void put_ctx(struct perf_event_context *ctx)
* function. * function.
* *
* Lock order: * Lock order:
* cred_guard_mutex * exec_update_mutex
* task_struct::perf_event_mutex * task_struct::perf_event_mutex
* perf_event_context::mutex * perf_event_context::mutex
* perf_event::child_mutex; * perf_event::child_mutex;
...@@ -11263,14 +11263,14 @@ SYSCALL_DEFINE5(perf_event_open, ...@@ -11263,14 +11263,14 @@ SYSCALL_DEFINE5(perf_event_open,
} }
if (task) { if (task) {
err = mutex_lock_interruptible(&task->signal->cred_guard_mutex); err = mutex_lock_interruptible(&task->signal->exec_update_mutex);
if (err) if (err)
goto err_task; goto err_task;
/* /*
* Reuse ptrace permission checks for now. * Reuse ptrace permission checks for now.
* *
* We must hold cred_guard_mutex across this and any potential * We must hold exec_update_mutex across this and any potential
* perf_install_in_context() call for this new event to * perf_install_in_context() call for this new event to
* serialize against exec() altering our credentials (and the * serialize against exec() altering our credentials (and the
* perf_event_exit_task() that could imply). * perf_event_exit_task() that could imply).
...@@ -11559,7 +11559,7 @@ SYSCALL_DEFINE5(perf_event_open, ...@@ -11559,7 +11559,7 @@ SYSCALL_DEFINE5(perf_event_open,
mutex_unlock(&ctx->mutex); mutex_unlock(&ctx->mutex);
if (task) { if (task) {
mutex_unlock(&task->signal->cred_guard_mutex); mutex_unlock(&task->signal->exec_update_mutex);
put_task_struct(task); put_task_struct(task);
} }
...@@ -11595,7 +11595,7 @@ SYSCALL_DEFINE5(perf_event_open, ...@@ -11595,7 +11595,7 @@ SYSCALL_DEFINE5(perf_event_open,
free_event(event); free_event(event);
err_cred: err_cred:
if (task) if (task)
mutex_unlock(&task->signal->cred_guard_mutex); mutex_unlock(&task->signal->exec_update_mutex);
err_task: err_task:
if (task) if (task)
put_task_struct(task); put_task_struct(task);
...@@ -11900,7 +11900,7 @@ static void perf_event_exit_task_context(struct task_struct *child, int ctxn) ...@@ -11900,7 +11900,7 @@ static void perf_event_exit_task_context(struct task_struct *child, int ctxn)
/* /*
* When a child task exits, feed back event values to parent events. * When a child task exits, feed back event values to parent events.
* *
* Can be called with cred_guard_mutex held when called from * Can be called with exec_update_mutex held when called from
* install_exec_creds(). * install_exec_creds().
*/ */
void perf_event_exit_task(struct task_struct *child) void perf_event_exit_task(struct task_struct *child)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment