[CRIU] [PATCH] zdtm: cmdlinenv00 -- fix false positive fail on 'auxv' corruption after 32-bit -> 64-bit migration
Konstantin Khlebnikov
khlebnikov at openvz.org
Fri Nov 30 09:07:41 EST 2012
Content of /proc/$pid/auxv declared as array of long and this file hasn't compat layer.
https://jira.sw.ru/browse/PSBM-16280
Signed-off-by: Konstantin Khlebnikov <khlebnikov at openvz.org>
---
test/zdtm/live/static/cmdlinenv00.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/test/zdtm/live/static/cmdlinenv00.c b/test/zdtm/live/static/cmdlinenv00.c
index 68787f0..dae1d97 100644
--- a/test/zdtm/live/static/cmdlinenv00.c
+++ b/test/zdtm/live/static/cmdlinenv00.c
@@ -44,6 +44,29 @@ static void read_from_proc(const char *path, char *buf, size_t size)
close(fd);
}
+static int cmp_auxv(const void *auxv_orig, const void *auxv, size_t size)
+{
+ const unsigned long long *new = auxv;
+ const unsigned int *old = auxv_orig;
+
+ if (!memcmp(auxv_orig, auxv, size))
+ return 0;
+
+ /*
+ * File /proc/$pid/auxv does not has compat layer, this "array of long"
+ * has different byte-representation between 32-bit and 64-bit host.
+ * We can migrate tasks only in one direction, thus check is simple.
+ */
+ while (size > 0) {
+ if (*new != *old)
+ return -1;
+ new++;
+ old++;
+ size -= sizeof(*new);
+ }
+ return 0;
+}
+
int main(int argc, char *argv[])
{
char cmdline_orig[4096];
@@ -89,7 +112,7 @@ int main(int argc, char *argv[])
exit(1);
}
- if (memcmp(auxv_orig, auxv, sizeof(auxv_orig))) {
+ if (cmp_auxv(auxv_orig, auxv, sizeof(auxv_orig))) {
fail("auxv corrupted on restore");
exit(1);
}
More information about the CRIU
mailing list