[LTP] [PATCH] syscalls/munmap04: Increase target map address in case of EEXIST

Ricardo B. Marlière rbm@suse.com
Thu Jul 31 11:51:33 CEST 2025


From: Ricardo B. Marlière <rbm@suse.com>

While trying to exhaust the amount of VMAs, the test should bump the
address for the next try in case of EEXIST. Otherwise, it might timeout in
an infinite loop.

Fixes: 7f70db39ec45 ("syscalls/munmap04: Check errno while trying to exhaust VMA count")
Signed-off-by: Ricardo B. Marlière <rbm@suse.com>
---
 testcases/kernel/syscalls/munmap/munmap04.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/munmap/munmap04.c b/testcases/kernel/syscalls/munmap/munmap04.c
index aeb905286e9d4214ac6423ef26e9570674b60530..106f99e27f813130558f5f51707642f22b1892e2 100644
--- a/testcases/kernel/syscalls/munmap/munmap04.c
+++ b/testcases/kernel/syscalls/munmap/munmap04.c
@@ -28,6 +28,8 @@ static void run(void)
 
 static void setup(void)
 {
+	uintptr_t addr = base;
+
 	page_sz = SAFE_SYSCONF(_SC_PAGESIZE);
 	vma_size = MEMSIZE * page_sz;
 
@@ -36,15 +38,18 @@ static void setup(void)
 		maps[i] = NULL;
 
 	while (1) {
-		void *p = mmap((void *)(base + PAD * vma_size * map_count),
+		void *p = mmap((void *) addr,
 			     vma_size, PROT_NONE,
 			     MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED_NOREPLACE,
 			     -1, 0);
-		if (p == MAP_FAILED && errno == EEXIST)
+		if (p == MAP_FAILED && errno == EEXIST) {
+			addr += PAD * vma_size;
 			continue;
+		}
 		if (p == MAP_FAILED)
 			break;
 		maps[map_count++] = p;
+		addr += PAD * vma_size;
 	}
 
 	if (map_count == MAP_MAX_COUNT)

---
base-commit: 91fa413eb521fde80d57c79bd3d2fb5cbe4ad3f4
change-id: 20250728-fixes-munmap04-02083c550c6b

Best regards,
-- 
Ricardo B. Marlière <rbm@suse.com>



More information about the ltp mailing list