files: don't use PROC_SELF during restoring file descriptors

open_proc_pid(PROC_SELF) returns a non-service file descriptor,
but it can take a place of a target file descriptor.

Signed-off-by: Andrei Vagin <avagin@gmail.com>
This commit is contained in:
Andrei Vagin 2019-01-01 23:06:39 -08:00
parent 42bc32f6c0
commit 8800da2b77

View file

@ -1593,7 +1593,11 @@ int open_path(struct file_desc *d,
tmp = inherit_fd_lookup_id(rfi->rfe->name);
if (tmp >= 0) {
inh_fd = tmp;
mntns_root = open_pid_proc(PROC_SELF);
/*
* PROC_SELF isn't used, because only service
* descriptors can be used here.
*/
mntns_root = open_pid_proc(getpid());
snprintf(path, sizeof(path), "fd/%d", tmp);
orig_path = rfi->path;
rfi->path = path;