[CRIU] [PATCH] locks: Mask futexes aligned

Kirill Tkhai ktkhai at virtuozzo.com
Wed Feb 1 06:27:31 PST 2017


System call sys_futex() requires that (from futex(2)):

    "On all platforms, futexes are four-byte integers
     that must be aligned on a four-byte boundary".

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 include/common/lock.h |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/common/lock.h b/include/common/lock.h
index 49b1af149..4782b638f 100644
--- a/include/common/lock.h
+++ b/include/common/lock.h
@@ -7,6 +7,7 @@
 #include <limits.h>
 #include <errno.h>
 #include "common/asm/atomic.h"
+#include "common/compiler.h"
 
 #define LOCK_BUG_ON(condition)							\
 	if ((condition))							\
@@ -29,7 +30,7 @@ static inline long sys_futex (uint32_t *addr1, int op, uint32_t val1,
 
 typedef struct {
 	atomic_t raw;
-} futex_t;
+} __aligned(sizeof(int)) futex_t;
 
 #define FUTEX_ABORT_FLAG	(0x80000000)
 #define FUTEX_ABORT_RAW		(-1U)



More information about the CRIU mailing list