Commit c327e175 authored by Konstantin Khlebnikov's avatar Konstantin Khlebnikov Committed by Pavel Emelyanov

zdtm: cmdlinenv00 -- fix false positive fail on 'auxv' corruption after 32-bit -> 64-bit migration

Content of /proc/$pid/auxv declared as array of long and this file hasn't compat layer.

https://jira.sw.ru/browse/PSBM-16280Signed-off-by: 's avatarKonstantin Khlebnikov <khlebnikov@openvz.org>
Reviewed-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent bf598fa2
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment