Skip to content

Commit

Permalink
pidfd: Use new infrastructure to fix deadlocks in execve
Browse files Browse the repository at this point in the history
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 <bernd.edlinger@hotmail.de>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
  • Loading branch information
bernd-edlinger authored and ebiederm committed Mar 25, 2020
1 parent 6914303 commit 501f932
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/pid.c
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ static struct file *__pidfd_fget(struct task_struct *task, int fd)
struct file *file;
int ret;

ret = mutex_lock_killable(&task->signal->cred_guard_mutex);
ret = mutex_lock_killable(&task->signal->exec_update_mutex);
if (ret)
return ERR_PTR(ret);

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

mutex_unlock(&task->signal->cred_guard_mutex);
mutex_unlock(&task->signal->exec_update_mutex);

return file ?: ERR_PTR(-EBADF);
}
Expand Down

0 comments on commit 501f932

Please sign in to comment.