[PATCH] vdso: x86 -- Make sure the mark version matches

Cyrill Gorcunov gorcunov at openvz.org
Tue Jun 17 00:03:32 PDT 2014


Otherwise we're meeting somehow corrupted mark and
must abort dumping.

Reported-by: Pavel Emelyanov <xemul at parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 arch/x86/include/asm/vdso.h | 5 +++--
 pie/parasite.c              | 8 ++++++++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/vdso.h b/arch/x86/include/asm/vdso.h
index e367ebd95b81..27c687344b10 100644
--- a/arch/x86/include/asm/vdso.h
+++ b/arch/x86/include/asm/vdso.h
@@ -103,6 +103,7 @@ struct vdso_mark {
 
 #define VDSO_MARK_SIGNATURE	(0x6f73647675697263ULL)	/* Magic number (criuvdso) */
 #define VDSO_MARK_SIGNATURE_V2	(0x4f53447675697263ULL)	/* Magic number (criuvDSO) */
+#define VDSO_MARK_CUR_VERSION	(2)
 
 static inline void vdso_put_mark(void *where, unsigned long proxy_vdso_addr, unsigned long proxy_vvar_addr)
 {
@@ -110,7 +111,7 @@ static inline void vdso_put_mark(void *where, unsigned long proxy_vdso_addr, uns
 
 	m->signature		= VDSO_MARK_SIGNATURE_V2;
 	m->proxy_vdso_addr	= proxy_vdso_addr;
-	m->version		= 2;
+	m->version		= VDSO_MARK_CUR_VERSION;
 	m->proxy_vvar_addr	= proxy_vvar_addr;
 }
 
@@ -122,7 +123,7 @@ static inline bool is_vdso_mark(void *addr)
 		/*
 		 * New format
 		 */
-		return m->version == 2;
+		return true;
 	} else if (m->signature == VDSO_MARK_SIGNATURE) {
 		/*
 		 * Old format -- simply extend the mark up
diff --git a/pie/parasite.c b/pie/parasite.c
index 972229b9b6b9..be46bfce2640 100644
--- a/pie/parasite.c
+++ b/pie/parasite.c
@@ -331,6 +331,14 @@ static int parasite_check_vdso_mark(struct parasite_vdso_vma_entry *args)
 	struct vdso_mark *m = (void *)args->start;
 
 	if (is_vdso_mark(m)) {
+		/*
+		 * Make sure we don't meet some corrupted entry
+		 * where signature matches but verions is not!
+		 */
+		if (m->version != VDSO_MARK_CUR_VERSION) {
+			pr_err("vdso: Mark version mismatch!\n");
+			return -EINVAL;
+		}
 		args->is_marked = 1;
 		args->proxy_vdso_addr = m->proxy_vdso_addr;
 		args->proxy_vvar_addr = m->proxy_vvar_addr;
-- 
1.9.3


--0F1p//8PRICkK4MW--


More information about the CRIU mailing list