[CRIU] [PATCH] dump: Make sure we're not dumping unsupported task

Cyrill Gorcunov gorcunov at openvz.org
Thu Feb 7 04:32:20 EST 2013


In case if we're going to dump x86-32 task on x86-64
node we will receive illegal operation signal, because
we don't support x86-32 tasks at all. So report problem
early.

https://bugzilla.openvz.org/show_bug.cgi?id=2505

Reported-by: Ashish Bijlani <ashish.bijlani at gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
CC: Andrey Vagin <avagin at openvz.org>
---
 ptrace.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/ptrace.c b/ptrace.c
index 0140918..c6d25b1 100644
--- a/ptrace.c
+++ b/ptrace.c
@@ -12,6 +12,7 @@
 #include <sys/time.h>
 #include <sys/resource.h>
 #include <sys/wait.h>
+#include <sys/stat.h>
 
 #include "crtools.h"
 #include "compiler.h"
@@ -20,6 +21,32 @@
 #include "ptrace.h"
 #include "proc_parse.h"
 
+static int check_auxv(pid_t pid)
+{
+	unsigned char buf[AT_VECTOR_SIZE];
+	char path[32];
+	int fd, ret;
+
+	snprintf(path, sizeof(path), "/proc/%d/auxv", pid);
+	fd = open(path, O_RDONLY);
+	if (fd < 0) {
+		pr_perror("Can't read %s", path);
+		return -1;
+	}
+
+	ret = read(fd, buf, sizeof(buf));
+	if (ret != sizeof(buf)) {
+		ret = -1;
+		pr_err("Aux vector size is %d while %d expected\n",
+		       ret, AT_VECTOR_SIZE);
+	} else
+		ret = 0;
+
+	close(fd);
+
+	return ret;
+}
+
 int unseize_task(pid_t pid, int st)
 {
 	pr_debug("\tUnseizeing %d into %d\n", pid, st);
@@ -79,6 +106,12 @@ int seize_task(pid_t pid, pid_t ppid, pid_t *pgid, pid_t *sid)
 		return TASK_DEAD;
 	}
 
+	ret = check_auxv(pid);
+	if (ret) {
+		pr_err("Task %d with unsupported architecture detected\n", pid);
+		goto err;
+	}
+
 	if ((ppid != -1) && (ps.ppid != ppid)) {
 		pr_err("Task pid reused while suspending (%d: %d -> %d)\n",
 				pid, ppid, ps.ppid);
-- 
1.8.1



More information about the CRIU mailing list