From 64dc66c29fa783bcaaace17b58d65b845fed8c3e Mon Sep 17 00:00:00 2001 From: Filipe Brandenburger Date: Wed, 25 Jun 2014 19:35:00 +0400 Subject: [PATCH] dump: do not fail dump when robust_lists are disabled Robust lists may be disabled, for example if the "futex_cmpxchg_enabled" variable in the kernel is unset. Detect that case by checking that both "get_robust_list" and "set_robust_list" syscalls return ENOSYS and do not make criu dump fail in that case, but simply assume an empty list, which is consistent with the syscalls not being available. Tested: Successfully ran the zdtm test suite on a kernel where the "get_robust_list" and "set_robust_list" syscalls are disabled. Signed-off-by: Filipe Brandenburger Acked-by: Cyrill Gorcunov Signed-off-by: Pavel Emelyanov --- cr-dump.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/cr-dump.c b/cr-dump.c index 86dedce89..c4c9777b1 100644 --- a/cr-dump.c +++ b/cr-dump.c @@ -539,15 +539,35 @@ static int get_task_futex_robust_list(pid_t pid, ThreadCoreEntry *info) int ret; ret = sys_get_robust_list(pid, &head, &len); - if (ret) { - pr_err("Failed obtaining futex robust list on %d\n", pid); - return -1; + if (ret == -ENOSYS) { + /* + * If the kernel says get_robust_list is not implemented, then + * check whether set_robust_list is also not implemented, in + * that case we can assume it is empty, since set_robust_list + * is the only way to populate it. This case is possible when + * "futex_cmpxchg_enabled" is unset in the kernel. + * + * The following system call should always fail, even if it is + * implemented, in which case it will return -EINVAL because + * len should be greater than zero. + */ + if (sys_set_robust_list(NULL, 0) != -ENOSYS) + goto err; + + head = NULL; + len = 0; + } else if (ret) { + goto err; } info->futex_rla = encode_pointer(head); info->futex_rla_len = (u32)len; return 0; + +err: + pr_err("Failed obtaining futex robust list on %d\n", pid); + return -1; } static int get_task_personality(pid_t pid, u32 *personality)