git: d6bf2d14a941 - main - pdrfork(2) tests: do not rely on (int *)-1 being invalid address
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 16 Feb 2026 17:58:14 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=d6bf2d14a941a88e27a82a3f91790353e134b8f6
commit d6bf2d14a941a88e27a82a3f91790353e134b8f6
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-02-15 15:09:48 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-02-16 17:57:52 +0000
pdrfork(2) tests: do not rely on (int *)-1 being invalid address
Explicitly mmap guard and use it as the invalid address instead.
Tested by: pho
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D55306
---
tests/sys/kern/pdrfork.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/tests/sys/kern/pdrfork.c b/tests/sys/kern/pdrfork.c
index 7a560e4fa08d..1003ad9dc746 100644
--- a/tests/sys/kern/pdrfork.c
+++ b/tests/sys/kern/pdrfork.c
@@ -26,8 +26,9 @@
*/
#include <sys/types.h>
-#include <sys/user.h>
+#include <sys/mman.h>
#include <sys/procdesc.h>
+#include <sys/user.h>
#include <sys/wait.h>
#include <atf-c.h>
@@ -93,7 +94,12 @@ ATF_TC_BODY(child_gets_no_pidfd, tc)
ATF_TC_WITHOUT_HEAD(efault);
ATF_TC_BODY(efault, tc)
{
- ATF_REQUIRE_ERRNO(EFAULT, pdrfork((int*)-1, 0, RFPROC | RFPROCDESC) < 0);
+ void *unmapped;
+
+ unmapped = mmap(NULL, PAGE_SIZE, PROT_NONE, MAP_GUARD, -1, 0);
+ ATF_REQUIRE(unmapped != MAP_FAILED);
+ ATF_REQUIRE_ERRNO(EFAULT, pdrfork(unmapped, 0, RFPROC |
+ RFPROCDESC) < 0);
}
/* Invalid combinations of flags should return EINVAL */