[CRIU] [PATCH 5/7] zdtm/static/sk-netlink: Fix endian issue

Michael Holzheu holzheu at linux.vnet.ibm.com
Wed Jun 28 19:12:03 MSK 2017


On x86 sk->groups[1] contains the most significant bits. On s390 it
contains the least significant bits. Therefore on x86 for groups below 32
sk->groups[1] is zero and on s390 it contains 0x80000000 for the testcase.

As workaround swap sk->groups[0/1] for big-endian systems.

Signed-off-by: Michael Holzheu <holzheu at linux.vnet.ibm.com>
---
 criu/sk-netlink.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/criu/sk-netlink.c b/criu/sk-netlink.c
index 44982a1..bfa6831 100644
--- a/criu/sk-netlink.c
+++ b/criu/sk-netlink.c
@@ -107,6 +107,22 @@ static int dump_one_netlink_fd(int lfd, u32 id, const struct fd_parms *p)
 		 * On 64-bit sk->gsize is multiple to 8 bytes (sizeof(long)),
 		 * so remove the last 4 bytes if they are empty.
 		 */
+#ifdef __ORDER_BIG_ENDIAN__
+		/*
+		 * Big endian swap: Ugly hack for zdtm/static/sk-netlink
+		 *
+		 * For big endian systems:
+		 *
+		 * - sk->groups[0] are bits 32-64
+		 * - sk->groups[1] are bits 0-32
+		 */
+		if (ne.n_groups == 2) {
+			uint32_t tmp = sk->groups[1];
+
+			sk->groups[1] = sk->groups[0];
+			sk->groups[0] = tmp;
+		}
+#endif
 		if (ne.n_groups && sk->groups[ne.n_groups - 1] == 0)
 			ne.n_groups -= 1;
 
-- 
2.7.4



More information about the CRIU mailing list