syscalls/munmap04: Check errno while trying to exhaust VMA count
PATCH v2 1/1 syscalls/munmap04: Check errno while trying to exhaust VMA count
From: Ricardo B. Marlière <[email protected]>
In the loop that exhausts the amount of VMAs we must check not only for MAP_FAILED return from mmap() but also if the error was EEXIST. In that case, keep retrying with increasing addresses. While at it, add a sanity check if no regions were mapped.
---
Changes in v2:
- EDITME: describe what is new in this series revision.
- EDITME: use bulletpoints and terse descriptions.
- Link to v1: https://lore.kernel.org/r/[email protected]
--- testcases/kernel/syscalls/munmap/munmap04.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/munmap/munmap04.c +5 -2
@@ -40,14 +40,17 @@ static void setup(void) vma_size,PROT_NONE ,MAP_PRIVATE |MAP_ANONYMOUS |MAP_FIXED_NOREPLACE , -1, 0); +if (p ==MAP_FAILED && errno ==EEXIST ) +continue ;if (p ==MAP_FAILED )break ; maps[map_count++] = p; }if (map_count ==MAP_MAX_COUNT ) -tst_brk (TBROK ,"Mapped all %d regions, expected less" , - map_count); +tst_brk (TBROK ,"Mapped all %d regions, expected less" , map_count); +if (map_count ==0 ) +tst_brk (TBROK ,"Mapped 0 regions" );tst_res (TINFO ,"Mapped %d regions" , map_count); }
---
base-commit: 6af619552ce7676171e47b88964ffb5b08499b36
change-id: 20250728-fixes-munmap04-02083c550c6b
Best regards,
Signature · 5 lines
Ricardo B. Marlière <[email protected]> -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 7 lines · Ricardo B. Marlière
From: Ricardo B. Marlière <[email protected]>
In the loop that exhausts the amount of VMAs we must check not only for
MAP_FAILEDreturn frommmap()but also if the error was EEXIST. In that case, keep retrying with increasing addresses. While at it, add a sanity check if no regions were mapped.
Quoted 7 lines
Suggested-by Cyril Hrubis <[email protected]>Signed-off-by Ricardo B. Marlière <[email protected]>---
Changes in v2:
- EDITME: describe what is new in this series revision.
- EDITME: use bulletpoints and terse descriptions.
- Link to v1: https://lore.kernel.org/r/[email protected]
Oops, forgot to edit this:
Changes in v2:
- Check for errno == EEXIST instead of removing MAP_FIXED_NOREPLACE flag
Quoted 34 lines
--- testcases/kernel/syscalls/munmap/munmap04.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)testcases/kernel/syscalls/munmap/munmap04.c +5
-3@@ -40,14 +40,17 @@ static void setup(void) vma_size,PROT_NONE ,MAP_PRIVATE |MAP_ANONYMOUS |MAP_FIXED_NOREPLACE , -1, 0); +if (p ==MAP_FAILED && errno ==EEXIST ) +continue ;if (p ==MAP_FAILED )break ; maps[map_count++] = p; }if (map_count ==MAP_MAX_COUNT ) -tst_brk (TBROK ,"Mapped all %d regions, expected less" , - map_count); +tst_brk (TBROK ,"Mapped all %d regions, expected less" , map_count); +if (map_count ==0 ) +tst_brk (TBROK ,"Mapped 0 regions" );tst_res (TINFO ,"Mapped %d regions" , map_count); } ---base-commit:
6af619552ce7676171e47b88964ffb5b08499b36
change-id: 20250728-fixes-munmap04-02083c550c6bBest regards,
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Applied, thanks.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp