[CRIU] [PATCH 1/3] parasite: align parasite args with 4 bytes

Dmitry Safonov dsafonov at virtuozzo.com
Tue Aug 16 12:11:24 PDT 2016


>From the commit 64e74fab05f1 ("parasite: handle errors while a transport
socket is being created"), we have futex in parasite init args to
synchronize parasite and criu during initialization.
And man futex(2): "On all platforms, futexes are four-byte integers that
must be aligned on a four-byte boundary."
This is checked by kernel in get_futex_key():
	if (unlikely((address % sizeof(u32)) != 0))
		return -EINVAL;

So, we need to align parasite arguments on four bytes, while mapping
of parasite blob on page-aligned address will guarantee that it'll
be aligned on four bytes in memory.

Fixes:
(00.013468) -----------------------
(00.013470) Putting tsock into pid 22043
(00.014024) Error (criu/parasite-syscall.c:541): futex() returned an unexpected error: -22
(00.014026) Error (criu/parasite-syscall.c:541): BUG at criu/parasite-syscall.c:541

Cc: Andrew Vagin <avagin at virtuozzo.com>
Cc: Cyrill Gorcunov <gorcunov at openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
 criu/pie/pie-reloc.lds.S.in | 3 +++
 criu/pie/pie.lds.S.in       | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/criu/pie/pie-reloc.lds.S.in b/criu/pie/pie-reloc.lds.S.in
index 051d1d42740d..c22a99e8f910 100644
--- a/criu/pie/pie-reloc.lds.S.in
+++ b/criu/pie/pie-reloc.lds.S.in
@@ -26,5 +26,8 @@ SECTIONS
 		*(.group*)
 		*(.eh_frame*)
 	}
+
+/* Parasite args should have 4 bytes align, as we have futex inside. */
+. = ALIGN(4);
 __export_parasite_args = .;
 }
diff --git a/criu/pie/pie.lds.S.in b/criu/pie/pie.lds.S.in
index 9e9c97f003c3..f745d355ef3d 100644
--- a/criu/pie/pie.lds.S.in
+++ b/criu/pie/pie.lds.S.in
@@ -25,5 +25,7 @@ SECTIONS
 		*(*)
 	}
 
+/* Parasite args should have 4 bytes align, as we have futex inside. */
+. = ALIGN(4);
 __export_parasite_args = .;
 }
-- 
2.9.0



More information about the CRIU mailing list