]>
git.saurik.com Git - apple/xnu.git/blob - tests/fd_aio_fsync_uaf.c
2 * Proof of Concept / Test Case
3 * XNU: aio_work_thread use-after-free for AIO_FSYNC entries
15 #include <darwintest.h>
19 T_META_NAMESPACE("xnu.vfs"),
20 T_META_RUN_CONCURRENTLY(true));
27 struct aiocb ap
[NREQUESTS
];
31 for (n
= 0; n
< NREQUESTS
; ++n
) {
32 ap
[n
].aio_fildes
= fd
;
35 ap
[n
].aio_sigevent
.sigev_notify
= SIGEV_NONE
;
39 * fire them off and exit.
41 for (n
= 0; n
< NREQUESTS
; ++n
) {
42 aio_fsync((n
& 1) ? O_SYNC
: O_DSYNC
, &ap
[n
]);
48 T_DECL(lio_listio_race_63669270
, "test for the lightspeed/unc0ver UaF")
53 uint64_t end
= clock_gettime_nsec_np(CLOCK_UPTIME_RAW
) + 10 * NSEC_PER_SEC
;
55 /* we need a valid fd: */
56 strcpy(path
, "/tmp/aio_fsync_uaf.XXXXXX");
57 T_EXPECT_POSIX_SUCCESS(fd
= mkstemp(path
), "mkstemp");
58 T_EXPECT_POSIX_SUCCESS(unlink(path
), "unlink");
62 switch ((child
= fork())) {
63 case -1: T_FAIL("fork");
67 T_QUIET
; T_EXPECT_POSIX_SUCCESS(waitpid(child
, NULL
, 0), "waitpid");
68 } while (clock_gettime_nsec_np(CLOCK_UPTIME_RAW
) < end
);
70 T_PASS("the system didn't panic");