]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
perf: Use new infrastructure to fix deadlocks in execve
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Fri, 20 Mar 2020 20:27:55 +0000 (21:27 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 1 Oct 2020 11:17:48 +0000 (13:17 +0200)
[ Upstream commit 6914303824bb572278568330d72fc1f8f9814e67 ]

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: Bernd Edlinger <bernd.edlinger@hotmail.de>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/events/core.c

index db1f5aa755f225c6589303fdef642931e815ddbd..47646050efa0cd31067ad3879062a9f01f8c25eb 100644 (file)
@@ -1253,7 +1253,7 @@ static void put_ctx(struct perf_event_context *ctx)
  * function.
  *
  * Lock order:
- *    cred_guard_mutex
+ *    exec_update_mutex
  *     task_struct::perf_event_mutex
  *       perf_event_context::mutex
  *         perf_event::child_mutex;
@@ -11002,14 +11002,14 @@ SYSCALL_DEFINE5(perf_event_open,
        }
 
        if (task) {
-               err = mutex_lock_interruptible(&task->signal->cred_guard_mutex);
+               err = mutex_lock_interruptible(&task->signal->exec_update_mutex);
                if (err)
                        goto err_task;
 
                /*
                 * 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
                 * serialize against exec() altering our credentials (and the
                 * perf_event_exit_task() that could imply).
@@ -11298,7 +11298,7 @@ SYSCALL_DEFINE5(perf_event_open,
        mutex_unlock(&ctx->mutex);
 
        if (task) {
-               mutex_unlock(&task->signal->cred_guard_mutex);
+               mutex_unlock(&task->signal->exec_update_mutex);
                put_task_struct(task);
        }
 
@@ -11334,7 +11334,7 @@ err_alloc:
                free_event(event);
 err_cred:
        if (task)
-               mutex_unlock(&task->signal->cred_guard_mutex);
+               mutex_unlock(&task->signal->exec_update_mutex);
 err_task:
        if (task)
                put_task_struct(task);
@@ -11639,7 +11639,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.
  *
- * 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().
  */
 void perf_event_exit_task(struct task_struct *child)