git: 8fa2c020b8d1 - stable/14 - aio(4) tests: do not rely on (int *)-1 being invalid address

Alan Somers <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a72975c.37dfc.7a62d4b8__37582.3396419705$1785894762$gmane$org@gitrepo.freebsd.org>
The branch stable/14 has been updated by asomers:

URL: https://cgit.FreeBSD.org/src/commit/?id=8fa2c020b8d1bfae040a86dca2e8a77c7f74da25

commit 8fa2c020b8d1bfae040a86dca2e8a77c7f74da25
Author:     Alan Somers <[email protected]>
AuthorDate: 2026-02-17 00:27:02 +0000
Commit:     Alan Somers <[email protected]>
CommitDate: 2026-08-05 01:51:15 +0000

    aio(4) tests: do not rely on (int *)-1 being invalid address
    
    Explicitly mmap guard and use it as the invalid address instead.
    
    (cherry picked from commit dc9a8d300ba5c4c319589d78231e9d0e76576cbf)
---
 tests/sys/aio/aio_test.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tests/sys/aio/aio_test.c b/tests/sys/aio/aio_test.c
index 64939825ec66..1a4baf70b1e3 100644
--- a/tests/sys/aio/aio_test.c
+++ b/tests/sys/aio/aio_test.c
@@ -39,6 +39,7 @@
 
 #include <sys/param.h>
 #include <sys/event.h>
+#include <sys/mman.h>
 #include <sys/mdioctl.h>
 #include <sys/module.h>
 #include <sys/resource.h>
@@ -1689,6 +1690,7 @@ ATF_TC_BODY(aio_writev_efault, tc)
 	struct aiocb aio;
 	ssize_t buflen;
 	char *buffer;
+	void *unmapped;
 	struct iovec iov[2];
 	long seed;
 	int fd;
@@ -1698,13 +1700,16 @@ ATF_TC_BODY(aio_writev_efault, tc)
 
 	fd = aio_md_setup();
 
+	unmapped = mmap(NULL, PAGE_SIZE, PROT_NONE, MAP_GUARD, -1, 0);
+	ATF_REQUIRE(unmapped != MAP_FAILED);
+
 	seed = random();
 	buflen = 4096;
 	buffer = malloc(buflen);
 	aio_fill_buffer(buffer, buflen, seed);
 	iov[0].iov_base = buffer;
 	iov[0].iov_len = buflen;
-	iov[1].iov_base = (void*)-1;	/* Invalid! */
+	iov[1].iov_base = (void*)unmapped;	/* Invalid! */
 	iov[1].iov_len = buflen;
 	bzero(&aio, sizeof(aio));
 	aio.aio_fildes = fd;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.