[CRIU] [PATCH] s390: Fix off-by-one error for task size detection

Michael Holzheu holzheu at linux.vnet.ibm.com
Mon Aug 7 15:56:52 MSK 2017


The entries in /proc/<pid>/maps look like the following:

  3fffffdf000-40000000000 rw-p 00000000 00:00 0

The upper address is the first address that is *not* included in the
address range.

Our function max_mapped_addr() should return the last valid address
for a process, but currently returns the first invalid address.

This can lead to the following error message on kernel that have
kernel commit ee71d16d22bb:

 Error (criu/proc_parse.c:694): Can't dump high memory region
 1ffffffffff000-20000000000000 of task 24 because kernel commit ee71d16d22bb
 is missing

Fix this and make max_mapped_addr() the last valid address (first invalid
address - 1).

Reported-by: Adrian Reber <areber at redhat.com>
Signed-off-by: Michael Holzheu <holzheu at linux.vnet.ibm.com>
---
 compel/arch/s390/src/lib/infect.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/compel/arch/s390/src/lib/infect.c b/compel/arch/s390/src/lib/infect.c
index fcad338..1614fa6 100644
--- a/compel/arch/s390/src/lib/infect.c
+++ b/compel/arch/s390/src/lib/infect.c
@@ -393,7 +393,7 @@ static unsigned long max_mapped_addr(void)
 	}
 	fclose(fp);
 out:
-	return addr_max;
+	return addr_max - 1;
 }
 
 /*
@@ -454,7 +454,7 @@ static enum kernel_ts_level get_kernel_ts_level(void)
 	unsigned long criu_end_addr = max_mapped_addr();
 
 	/* Check for 5 levels */
-	if (criu_end_addr > TASK_SIZE_LEVEL_4)
+	if (criu_end_addr >= TASK_SIZE_LEVEL_4)
 		return KERNEL_TS_LEVEL_5;
 	else if (munmap((void *) TASK_SIZE_LEVEL_4, 0x1000) == 0)
 		return KERNEL_TS_LEVEL_5;
-- 
2.7.4



More information about the CRIU mailing list