Skip to content

Commit 6914303

Browse files
bernd-edlingerebiederm
authored andcommitted
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: Bernd Edlinger <[email protected]> Signed-off-by: Eric W. Biederman <[email protected]>
1 parent 76518d3 commit 6914303

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

kernel/events/core.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,7 @@ static void put_ctx(struct perf_event_context *ctx)
12491249
* function.
12501250
*
12511251
* Lock order:
1252-
* cred_guard_mutex
1252+
* exec_update_mutex
12531253
* task_struct::perf_event_mutex
12541254
* perf_event_context::mutex
12551255
* perf_event::child_mutex;
@@ -11263,14 +11263,14 @@ SYSCALL_DEFINE5(perf_event_open,
1126311263
}
1126411264

1126511265
if (task) {
11266-
err = mutex_lock_interruptible(&task->signal->cred_guard_mutex);
11266+
err = mutex_lock_interruptible(&task->signal->exec_update_mutex);
1126711267
if (err)
1126811268
goto err_task;
1126911269

1127011270
/*
1127111271
* Reuse ptrace permission checks for now.
1127211272
*
11273-
* We must hold cred_guard_mutex across this and any potential
11273+
* We must hold exec_update_mutex across this and any potential
1127411274
* perf_install_in_context() call for this new event to
1127511275
* serialize against exec() altering our credentials (and the
1127611276
* perf_event_exit_task() that could imply).
@@ -11559,7 +11559,7 @@ SYSCALL_DEFINE5(perf_event_open,
1155911559
mutex_unlock(&ctx->mutex);
1156011560

1156111561
if (task) {
11562-
mutex_unlock(&task->signal->cred_guard_mutex);
11562+
mutex_unlock(&task->signal->exec_update_mutex);
1156311563
put_task_struct(task);
1156411564
}
1156511565

@@ -11595,7 +11595,7 @@ SYSCALL_DEFINE5(perf_event_open,
1159511595
free_event(event);
1159611596
err_cred:
1159711597
if (task)
11598-
mutex_unlock(&task->signal->cred_guard_mutex);
11598+
mutex_unlock(&task->signal->exec_update_mutex);
1159911599
err_task:
1160011600
if (task)
1160111601
put_task_struct(task);
@@ -11900,7 +11900,7 @@ static void perf_event_exit_task_context(struct task_struct *child, int ctxn)
1190011900
/*
1190111901
* When a child task exits, feed back event values to parent events.
1190211902
*
11903-
* Can be called with cred_guard_mutex held when called from
11903+
* Can be called with exec_update_mutex held when called from
1190411904
* install_exec_creds().
1190511905
*/
1190611906
void perf_event_exit_task(struct task_struct *child)

0 commit comments

Comments
 (0)