diff options
| author | christos <christos@NetBSD.org> | 2020-11-27 16:50:02 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2020-11-27 16:50:02 +0000 |
| commit | 20f9fbe9a8fa414ba854677c8fcf7c1e3998cf3d (patch) | |
| tree | 35e61a67cb4569c6bcd07bc3575dce681794f2b1 /tests/lib/libc/string | |
| parent | 6505c49c3b74dcb1ce7bdfe485119f2ae7247037 (diff) | |
map enough space for both the page we write and the guard so that we make
sure we own the guard page before we set its protection to none. This fixes
random SEGVs where the page we set protection to none probably belonged to
the dynamic linker. Reported by gson@
Diffstat (limited to 'tests/lib/libc/string')
| -rw-r--r-- | tests/lib/libc/string/t_memmem.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/tests/lib/libc/string/t_memmem.c b/tests/lib/libc/string/t_memmem.c index 5edf353518e..c64f4151a24 100644 --- a/tests/lib/libc/string/t_memmem.c +++ b/tests/lib/libc/string/t_memmem.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_memmem.c,v 1.5 2020/11/27 15:37:06 gson Exp $ */ +/* $NetBSD: t_memmem.c,v 1.6 2020/11/27 16:50:02 christos Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -105,11 +105,12 @@ ATF_TC_BODY(memmem_oob, tc) { static const char str[] = "abcde"; size_t pg = getpagesize(); - char *src = mmap(NULL, pg, PROT_READ|PROT_WRITE, + char *src = mmap(NULL, 2 * pg, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, (off_t)0); ATF_CHECK(src != MAP_FAILED); char *guard = mmap(src + pg, pg, PROT_NONE, MAP_ANON|MAP_PRIVATE|MAP_FIXED, -1, (off_t)0); +printf("%p\n", guard); for (size_t i = 2; i < 5; i++) { char *search = src + pg - i; char match[sizeof(str)]; |
