mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 05:16:01 +00:00
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.
This commit is contained in:
1 parent
e2d6b5dabf
commit
0b3e7428a6
1 file changed
+17
@@ -91,6 +91,7 @@ READV_CHECKS = r"""
|
||||
#include <linux/input.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/uio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -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}};
|
||||
|
||||
Reference in new issue
Block a user