git: 7a1c336ab9d6 - stable/15 - pdrfork(2) tests: do not rely on (int *)-1 being invalid address
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 21 Feb 2026 09:49:51 UTC
The branch stable/15 has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=7a1c336ab9d6ac82ac0942f82449ac53319ce58b
commit 7a1c336ab9d6ac82ac0942f82449ac53319ce58b
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-02-15 15:09:48 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-02-21 09:48:58 +0000
pdrfork(2) tests: do not rely on (int *)-1 being invalid address
(cherry picked from commit d6bf2d14a941a88e27a82a3f91790353e134b8f6)
---
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 */