Skip to content

Commit 501f932

Browse files
bernd-edlingerebiederm
authored andcommitted
pidfd: Use new infrastructure to fix deadlocks in execve
This changes __pidfd_fget to use the new exec_update_mutex instead of cred_guard_mutex. This should be safe, as the credentials do not change before exec_update_mutex is locked. Therefore whatever file access is possible with holding the cred_guard_mutex here is also possbile with the exec_update_mutex. Signed-off-by: Bernd Edlinger <[email protected]> Signed-off-by: Eric W. Biederman <[email protected]>
1 parent 6914303 commit 501f932

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/pid.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ static struct file *__pidfd_fget(struct task_struct *task, int fd)
577577
struct file *file;
578578
int ret;
579579

580-
ret = mutex_lock_killable(&task->signal->cred_guard_mutex);
580+
ret = mutex_lock_killable(&task->signal->exec_update_mutex);
581581
if (ret)
582582
return ERR_PTR(ret);
583583

@@ -586,7 +586,7 @@ static struct file *__pidfd_fget(struct task_struct *task, int fd)
586586
else
587587
file = ERR_PTR(-EPERM);
588588

589-
mutex_unlock(&task->signal->cred_guard_mutex);
589+
mutex_unlock(&task->signal->exec_update_mutex);
590590

591591
return file ?: ERR_PTR(-EBADF);
592592
}

0 commit comments

Comments
 (0)