Commit 829d4332 authored by Pavel Emelyanov's avatar Pavel Emelyanov

fd: Close caches proc-pid stuff before restoring files

We have a bug. If someone opens proc with open_pid_proc or alike
with PROC_SELF of real PID before going to restore fds, then the
fd cached by proc helpers would be cached in fd 0 (we close all
fds beforehead) and it may clash with restored fds.

We don't hit this right now simply due to being too lucky -- we
call open_proc(PROC_GEN) on "locks" which first closes the cached
the per-pid descriptor and then reports back just the /proc one
which sits in service area.

But once we change this (next patch) things would get broken.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 1c8ab40e
...@@ -947,6 +947,8 @@ int prepare_fds(struct pstree_item *me) ...@@ -947,6 +947,8 @@ int prepare_fds(struct pstree_item *me)
pr_info("Opening fdinfo-s\n"); pr_info("Opening fdinfo-s\n");
close_pid_proc(); /* flush any proc cached fds we may have */
if (me->rst->fdt) { if (me->rst->fdt) {
struct fdt *fdt = me->rst->fdt; struct fdt *fdt = me->rst->fdt;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment