[CRIU] [PATCHv2 30/30] vdso: suppress not ELF vDSO error

Dmitry Safonov dsafonov at virtuozzo.com
Fri Jun 24 08:10:44 PDT 2016


When mapping compatible vDSO in restorer blob (with vdso_map_compat),
we don't know if the kernel will map firstly vvar pages or vdso pages.
So we attempt search by checking ELF header magic on those pages.
Which leads to following "errors", which this patch hides:
pie: 1: Error (pie/util-vdso-elf32.c:87): vdso: Elf header magic misma>
pie: 1: Error (pie/util-vdso-elf32.c:87): vdso: Elf header magic misma>
pie: 7: Error (pie/util-vdso-elf32.c:87): vdso: Elf header magic misma>
pie: 7: Error (pie/util-vdso-elf32.c:87): vdso: Elf header magic misma>
pie: 6: Error (pie/util-vdso-elf32.c:87): vdso: Elf header magic misma>
pie: 6: Error (pie/util-vdso-elf32.c:87): vdso: Elf header magic misma>
pie: 4: Error (pie/util-vdso-elf32.c:87): vdso: Elf header magic misma>
pie: 5: Error (pie/util-vdso-elf32.c:87): vdso: Elf header magic misma>
pie: 4: Error (pie/util-vdso-elf32.c:87): vdso: Elf header magic misma>
pie: 5: Error (pie/util-vdso-elf32.c:87): vdso: Elf header magic misma>
(for two vvar pages and 5 processes being restored).

Cc: Cyrill Gorcunov <gorcunov at openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
 criu/include/util-vdso.h |  3 ++-
 criu/pie/parasite-vdso.c | 10 +++++-----
 criu/pie/parasite.c      |  3 ++-
 criu/pie/util-vdso.c     | 14 ++++++++------
 criu/vdso.c              |  2 +-
 5 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/criu/include/util-vdso.h b/criu/include/util-vdso.h
index 63bc70d79f3e..decfedbb45b5 100644
--- a/criu/include/util-vdso.h
+++ b/criu/include/util-vdso.h
@@ -92,6 +92,7 @@ static inline unsigned long vvar_vma_size(struct vdso_symtable *t)
 # define vdso_fill_symtable vdso_fill_symtable_compat
 #endif
 
-extern int vdso_fill_symtable(uintptr_t mem, size_t size, struct vdso_symtable *t);
+extern int vdso_fill_symtable(uintptr_t mem, size_t size,
+		struct vdso_symtable *t, bool suppress_not_elf_err);
 
 #endif /* __CR_UTIL_VDSO_H__ */
diff --git a/criu/pie/parasite-vdso.c b/criu/pie/parasite-vdso.c
index f838f826d24c..3966dcaf0c7d 100644
--- a/criu/pie/parasite-vdso.c
+++ b/criu/pie/parasite-vdso.c
@@ -74,7 +74,7 @@ int vdso_do_park(struct vdso_symtable *sym_rt, unsigned long park_at, unsigned l
 # define ARCH_MAP_VDSO_32	0x2002
 #endif
 extern int vdso_fill_symtable_compat(uintptr_t mem, size_t size,
-		struct vdso_symtable *t);
+		struct vdso_symtable *t, bool suppress_not_elf_err);
 
 int vdso_map_compat(unsigned long map_at, unsigned long park_size,
 		struct vdso_symtable *sym_rt)
@@ -96,7 +96,7 @@ int vdso_map_compat(unsigned long map_at, unsigned long park_size,
 			search_vdso += PAGE_SIZE)
 	{
 		ret = vdso_fill_symtable_compat(search_vdso,
-			map_at + park_size - search_vdso, sym_rt);
+			map_at + park_size - search_vdso, sym_rt, true);
 		if (!ret)
 			return 0;
 	}
@@ -108,9 +108,9 @@ int __vdso_fill_symtable(uintptr_t mem, size_t size,
 		struct vdso_symtable *t, bool compat_vdso)
 {
 	if (compat_vdso)
-		return vdso_fill_symtable_compat(mem, size, t);
+		return vdso_fill_symtable_compat(mem, size, t, false);
 	else
-		return vdso_fill_symtable(mem, size, t);
+		return vdso_fill_symtable(mem, size, t, false);
 }
 #else
 int vdso_map_compat(unsigned long __always_unused map_at,
@@ -122,7 +122,7 @@ int vdso_map_compat(unsigned long __always_unused map_at,
 int __vdso_fill_symtable(uintptr_t mem, size_t size,
 		struct vdso_symtable *t, bool __always_unused compat_vdso)
 {
-	return vdso_fill_symtable(mem, size, t);
+	return vdso_fill_symtable(mem, size, t, false);
 }
 #endif
 
diff --git a/criu/pie/parasite.c b/criu/pie/parasite.c
index b0dbafa6cfd5..50c80b12d966 100644
--- a/criu/pie/parasite.c
+++ b/criu/pie/parasite.c
@@ -509,7 +509,8 @@ static int parasite_check_vdso_mark(struct parasite_vdso_vma_entry *args)
 		if (args->try_fill_symtable) {
 			struct vdso_symtable t;
 
-			if (vdso_fill_symtable(args->start, args->len, &t))
+			if (vdso_fill_symtable(args->start,
+						args->len, &t, false))
 				args->is_vdso = false;
 			else
 				args->is_vdso = true;
diff --git a/criu/pie/util-vdso.c b/criu/pie/util-vdso.c
index 13b2e5316db7..7d50a530c402 100644
--- a/criu/pie/util-vdso.c
+++ b/criu/pie/util-vdso.c
@@ -64,7 +64,7 @@ static unsigned long elf_hash(const unsigned char *name)
 	return h;
 }
 
-static int has_elf_identity(Ehdr_t *ehdr)
+static int has_elf_identity(Ehdr_t *ehdr, bool suppress_not_elf_err)
 {
 	/*
 	 * See Elf specification for this magic values.
@@ -84,7 +84,8 @@ static int has_elf_identity(Ehdr_t *ehdr)
 	BUILD_BUG_ON(sizeof(elf_ident) != sizeof(ehdr->e_ident));
 
 	if (builtin_memcmp(ehdr->e_ident, elf_ident, sizeof(elf_ident))) {
-		pr_err("Elf header magic mismatch\n");
+		if (!suppress_not_elf_err)
+			pr_err("Elf header magic mismatch\n");
 		return false;
 	}
 
@@ -92,7 +93,7 @@ static int has_elf_identity(Ehdr_t *ehdr)
 }
 
 static int parse_elf_phdr(uintptr_t mem, size_t size,
-		Phdr_t **dynamic, Phdr_t **load)
+		Phdr_t **dynamic, Phdr_t **load, bool suppress_not_elf_err)
 {
 	Ehdr_t *ehdr = (void *)mem;
 	uintptr_t addr;
@@ -104,7 +105,7 @@ static int parse_elf_phdr(uintptr_t mem, size_t size,
 	/*
 	 * Make sure it's a file we support.
 	 */
-	if (!has_elf_identity(ehdr))
+	if (!has_elf_identity(ehdr, suppress_not_elf_err))
 		return -EINVAL;
 
 	addr = mem + ehdr->e_phoff;
@@ -253,7 +254,8 @@ static void parse_elf_symbols(uintptr_t mem, size_t size, Phdr_t *load,
 	}
 }
 
-int vdso_fill_symtable(uintptr_t mem, size_t size, struct vdso_symtable *t)
+int vdso_fill_symtable(uintptr_t mem, size_t size,
+		struct vdso_symtable *t, bool suppress_not_elf_err)
 {
 	Phdr_t *dynamic = NULL, *load = NULL;
 	Dyn_t *dyn_strtab = NULL;
@@ -270,7 +272,7 @@ int vdso_fill_symtable(uintptr_t mem, size_t size, struct vdso_symtable *t)
 	/*
 	 * We need PT_LOAD and PT_DYNAMIC here. Each once.
 	 */
-	ret = parse_elf_phdr(mem, size, &dynamic, &load);
+	ret = parse_elf_phdr(mem, size, &dynamic, &load, suppress_not_elf_err);
 	if (ret < 0)
 		return ret;
 	if (!load || !dynamic) {
diff --git a/criu/vdso.c b/criu/vdso.c
index 057b2adb4d74..f057386f04e2 100644
--- a/criu/vdso.c
+++ b/criu/vdso.c
@@ -264,7 +264,7 @@ static int vdso_fill_self_symtable(struct vdso_symtable *s)
 			s->vma_start = start;
 			s->vma_end = end;
 
-			ret = vdso_fill_symtable(start, end - start, s);
+			ret = vdso_fill_symtable(start, end - start, s, false);
 			if (ret)
 				goto err;
 		} else {
-- 
2.9.0



More information about the CRIU mailing list