Skip to content

Commit 2db9dbf

Browse files
bernd-edlingerebiederm
authored andcommitted
proc: Use new infrastructure to fix deadlocks in execve
This changes lock_trace to use the new exec_update_mutex instead of cred_guard_mutex. This fixes possible deadlocks when the trace is accessing /proc/$pid/stack for instance. This should be safe, as the credentials are only used for reading, and task->mm is updated on execve under the new exec_update_mutex. Signed-off-by: Bernd Edlinger <[email protected]> Signed-off-by: Eric W. Biederman <[email protected]>
1 parent 454e312 commit 2db9dbf

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/proc/base.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -405,19 +405,19 @@ static int proc_pid_wchan(struct seq_file *m, struct pid_namespace *ns,
405405

406406
static int lock_trace(struct task_struct *task)
407407
{
408-
int err = mutex_lock_killable(&task->signal->cred_guard_mutex);
408+
int err = mutex_lock_killable(&task->signal->exec_update_mutex);
409409
if (err)
410410
return err;
411411
if (!ptrace_may_access(task, PTRACE_MODE_ATTACH_FSCREDS)) {
412-
mutex_unlock(&task->signal->cred_guard_mutex);
412+
mutex_unlock(&task->signal->exec_update_mutex);
413413
return -EPERM;
414414
}
415415
return 0;
416416
}
417417

418418
static void unlock_trace(struct task_struct *task)
419419
{
420-
mutex_unlock(&task->signal->cred_guard_mutex);
420+
mutex_unlock(&task->signal->exec_update_mutex);
421421
}
422422

423423
#ifdef CONFIG_STACKTRACE

0 commit comments

Comments
 (0)