[CRIU] [PATCH kernel v3.3/ctools] restorer: Switch restoring of
/proc/pid/exe symlink to new kernel interface
Cyrill Gorcunov
gorcunov at openvz.org
Mon Mar 19 06:43:12 EDT 2012
Hi,
This patch makes crtools to work with new /proc/pid/exe symlink
restoration (the kernel part was reviewed by Oleg).
So this patch is for new shiny kernel only (!), thus I suggest
all developers to move on kernel crtools-3.3 (which can be
found at usual place) and pick up this patch for crtools itself.
(again, with this patch anything but crtools-3.3 will not work)
Thanks,
Cyrill
-------------- next part --------------
>From fd696b35f9365c9893a4ff55b3ebde03d161179b Mon Sep 17 00:00:00 2001
From: Cyrill Gorcunov <gorcunov at openvz.org>
Date: Thu, 8 Mar 2012 21:09:44 +0400
Subject: [PATCH] restorer: Switch restoring of /proc/pid/exe symlink to new
kernel interface
Note it requires crtools-v3.3-rc6 kernel to run.
Previous kernels wont work with it.
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
restorer.c | 24 ++++++++++++++++--------
1 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/restorer.c b/restorer.c
index 9f24e79..9ae798e 100644
--- a/restorer.c
+++ b/restorer.c
@@ -238,6 +238,7 @@ static long restore_self_exe_late(struct task_restore_core_args *args)
struct fdinfo_entry fe;
long ret = -1;
char *path;
+ int fd;
/*
* Path to exe file and its len is in image.
@@ -275,10 +276,20 @@ static long restore_self_exe_late(struct task_restore_core_args *args)
write_string(path);
write_string(")\n");
- ret = sys_prctl_safe(PR_SET_MM, PR_SET_MM_EXE_FILE, (long)path, fe.len + 1);
+ fd = sys_open(path, fe.flags, 0744);
+ if (fd >= 0) {
+ ret = sys_prctl_safe(PR_SET_MM, PR_SET_MM_EXE_FILE, fd, 0);
+ sys_close(fd);
+ } else {
+ write_string("sys_open failed\n");
+ write_num_n((long)fd);
+ ret = fd;
+ }
sys_munmap(path, fe.len + 1);
+ /* FIXME Once kernel side stabilized -- drop next line */
+ ret = 0;
return ret;
err:
@@ -513,13 +524,10 @@ long restore_task(struct task_restore_core_args *args)
goto core_restore_end;
/*
- * Restoring own /proc/pid/exe symlink is a bit
- * tricky -- we are to be sure no mmaps are
- * done over exec we're going to change, that's
- * why it's don that lately. Moreover, we are
- * to pass a path to new exec which means the
- * code should allocate memory enough for (maybe!)
- * pretty long file name.
+ * Because of requirements applied from kernel side
+ * we need to restore /proc/pid/exe symlink late,
+ * after old existing VMAs are superseded with
+ * new ones from image file.
*/
ret = restore_self_exe_late(args);
sys_close(args->fd_fdinfo);
--
1.7.7.6
More information about the CRIU
mailing list