[CRIU] [PATCH 3/3] prctl: check -- Try new interface as well

Cyrill Gorcunov gorcunov at openvz.org
Fri Oct 24 03:10:48 PDT 2014


Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 cr-check.c | 40 ++++++++++++++++++++++++----------------
 1 file changed, 24 insertions(+), 16 deletions(-)

diff --git a/cr-check.c b/cr-check.c
index 2ac8ea680bfd..fe370ff32209 100644
--- a/cr-check.c
+++ b/cr-check.c
@@ -169,6 +169,7 @@ static int check_prctl(void)
 {
 	unsigned long user_auxv = 0;
 	unsigned int *tid_addr;
+	unsigned int size = 0;
 	int ret;
 
 	ret = sys_prctl(PR_GET_TID_ADDRESS, (unsigned long)&tid_addr, 0, 0, 0);
@@ -177,25 +178,32 @@ static int check_prctl(void)
 		return -1;
 	}
 
-	ret = sys_prctl(PR_SET_MM, PR_SET_MM_BRK, sys_brk(0), 0, 0);
+	/*
+	 * Either new or old interface must be supported in the kernel.
+	 */
+	ret = sys_prctl(PR_SET_MM, PR_SET_MM_MAP_SIZE, (unsigned long)&size, 0, 0);
 	if (ret) {
-		if (ret == -EPERM)
-			pr_msg("prctl: One needs CAP_SYS_RESOURCE capability to perform testing\n");
-		else
-			pr_msg("prctl: PR_SET_MM is not supported\n");
-		return -1;
-	}
 
-	ret = sys_prctl(PR_SET_MM, PR_SET_MM_EXE_FILE, -1, 0, 0);
-	if (ret != -EBADF) {
-		pr_msg("prctl: PR_SET_MM_EXE_FILE is not supported (%d)\n", ret);
-		return -1;
-	}
+		ret = sys_prctl(PR_SET_MM, PR_SET_MM_BRK, sys_brk(0), 0, 0);
+		if (ret) {
+			if (ret == -EPERM)
+				pr_msg("prctl: One needs CAP_SYS_RESOURCE capability to perform testing\n");
+			else
+				pr_msg("prctl: PR_SET_MM is not supported\n");
+			return -1;
+		}
 
-	ret = sys_prctl(PR_SET_MM, PR_SET_MM_AUXV, (long)&user_auxv, sizeof(user_auxv), 0);
-	if (ret) {
-		pr_msg("prctl: PR_SET_MM_AUXV is not supported\n");
-		return -1;
+		ret = sys_prctl(PR_SET_MM, PR_SET_MM_EXE_FILE, -1, 0, 0);
+		if (ret != -EBADF) {
+			pr_msg("prctl: PR_SET_MM_EXE_FILE is not supported (%d)\n", ret);
+			return -1;
+		}
+
+		ret = sys_prctl(PR_SET_MM, PR_SET_MM_AUXV, (long)&user_auxv, sizeof(user_auxv), 0);
+		if (ret) {
+			pr_msg("prctl: PR_SET_MM_AUXV is not supported\n");
+			return -1;
+		}
 	}
 
 	return 0;
-- 
1.9.3



More information about the CRIU mailing list