[CRIU] [PATCH 2/3] fd: Close caches proc-pid stuff before restoring files

Pavel Emelyanov xemul at parallels.com
Tue Sep 23 09:33:18 PDT 2014


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: Pavel Emelyanov <xemul at parallels.com>
---
 files.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/files.c b/files.c
index 39d9914..6c8126e 100644
--- a/files.c
+++ b/files.c
@@ -947,6 +947,8 @@ int prepare_fds(struct pstree_item *me)
 
 	pr_info("Opening fdinfo-s\n");
 
+	close_pid_proc(); /* flush any proc cached fds we may have */
+
 	if (me->rst->fdt) {
 		struct fdt *fdt = me->rst->fdt;
 
-- 
1.8.4.2




More information about the CRIU mailing list