[CRIU] [PATCH v2] dump: do not fail dump when robust_lists are disabled

Filipe Brandenburger filbranden at google.com
Wed Jun 25 08:35:31 PDT 2014


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 <filbranden at google.com>
---
 cr-dump.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/cr-dump.c b/cr-dump.c
index 86dedce8982a..c4c9777b108b 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)
-- 
1.9.3



More information about the CRIU mailing list