From 0b3e7428a6cdadf2ed78d8ea3d24f323b22f5801 Mon Sep 17 00:00:00 2001 From: Delete228 <31237303+Delete228@users.noreply.github.com> Date: Tue, 20 Oct 2026 17:34:14 +0300 Subject: [PATCH] test: reject inaccessible readv descriptor arrays Cover unmapped, PROT_NONE, and partially accessible iovec arrays. The probe crashes with SIGSEGV before the descriptor-copy fix and returns EFAULT afterward. The Linux fakeinput suite and native ARM64 probe pass; Factorio was manually retested on the Thor with the updated library. --- tools/tests/test_fakeinput_ring.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tools/tests/test_fakeinput_ring.py b/tools/tests/test_fakeinput_ring.py index 42d6f85b6..af749d44a 100644 --- a/tools/tests/test_fakeinput_ring.py +++ b/tools/tests/test_fakeinput_ring.py @@ -91,6 +91,7 @@ READV_CHECKS = r""" #include #include #include +#include #include #include @@ -120,6 +121,22 @@ int main(void) return 7; if (invoke(fd, NULL, 1) != -1 || errno != EFAULT) return 8; + long page = sysconf(_SC_PAGESIZE); + void *area = mmap(NULL, 2 * page, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (area == MAP_FAILED) + return 10; + struct iovec *boundary = (struct iovec *)((char *)area + page - sizeof(struct iovec)); + *boundary = vector; + if (mprotect((char *)area + page, page, PROT_NONE)) + return 11; + if (invoke(fd, boundary, 2) != -1 || errno != EFAULT) + return 12; + if (invoke(fd, boundary + 1, 1) != -1 || errno != EFAULT) + return 13; + if (munmap(area, 2 * page)) + return 14; + if (invoke(fd, boundary, 1) != -1 || errno != EFAULT) + return 15; int pipefd[2]; char text[5] = {0}; struct iovec parts[2] = {{text, 1}, {text + 1, 3}};