[CRIU] [PATCH 1/2] autofs: fix double close of pid ns fd

Stanislav Kinsburskiy skinsbursky at virtuozzo.com
Mon May 16 03:31:32 PDT 2016


Restore_ns helper closes passed namepsace fd unconditionally.
Thus new_pid_ns must be invalidated in any case after calling for it.

Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
---
 criu/autofs.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/criu/autofs.c b/criu/autofs.c
index c540d1b..1a8876b 100644
--- a/criu/autofs.c
+++ b/criu/autofs.c
@@ -371,11 +371,12 @@ static int access_autofs_mount(struct mount_info *pm)
 		goto close_old_pid_ns;
 	}
 
-	if (restore_ns(new_pid_ns, &pid_ns_desc)) {
+	err = restore_ns(new_pid_ns, &pid_ns_desc);
+	new_pid_ns = -1;
+	if (err) {
 		pr_err("failed to restore pid namespace\n");
 		goto restore_mnt_ns;
 	}
-	new_pid_ns = -1;
 
 	autofs_mnt = autofs_mnt_open(mnt_path, dev_id);
 	if (autofs_mnt < 0)



More information about the CRIU mailing list