[LTP] [PATCH 2/3] tst_memutils: Fix mapping overlap predicate
Andrea Cervesato
andrea.cervesato@suse.de
Tue Oct 6 15:02:38 CEST 2026
From: Andrea Cervesato <andrea.cervesato@suse.com>
tst_mapping_in_range() checks whether either mapping endpoint falls
inside [low, high). This misses existing mappings that completely
enclose the requested range, and falsely treats an adjacent mapping
ending exactly at low as an overlap.
Use the standard half-open interval overlap check
(start < high && end > low).
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
lib/tst_memutils.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/lib/tst_memutils.c b/lib/tst_memutils.c
index e49684ba1..81467fef7 100644
--- a/lib/tst_memutils.c
+++ b/lib/tst_memutils.c
@@ -202,11 +202,7 @@ int tst_mapping_in_range(unsigned long low, unsigned long high)
tst_brk(TBROK | TERRNO, "Couldn't parse /proc/self/maps line.");
}
- if ((start >= low) && (start < high)) {
- fclose(fp);
- return 1;
- }
- if ((end >= low) && (end < high)) {
+ if (start < high && end > low) {
fclose(fp);
return 1;
}
--
2.51.0
More information about the ltp
mailing list