Skip to content

Commit

Permalink
test/waitid: test invalid infop pointer
Browse files Browse the repository at this point in the history
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
axboe committed Aug 30, 2024
1 parent c1a4213 commit 7e713e4
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/waitid.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,38 @@ static void child(long usleep_time)
exit(0);
}

static int test_invalid_infop(struct io_uring *ring)
{
struct io_uring_sqe *sqe;
struct io_uring_cqe *cqe;
siginfo_t *si = (siginfo_t *) (uintptr_t) 0x1234;
pid_t pid;
int ret;

pid = fork();
if (!pid) {
child(200000);
exit(0);
}

sqe = io_uring_get_sqe(ring);
io_uring_prep_waitid(sqe, P_PID, pid, si, WEXITED, 0);
sqe->user_data = 1;
io_uring_submit(ring);

ret = io_uring_wait_cqe(ring, &cqe);
if (ret) {
fprintf(stderr, "cqe wait: %d\n", ret);
return T_EXIT_FAIL;
}
if (cqe->res != -EFAULT) {
fprintf(stderr, "Bad return on invalid infop: %d\n", cqe->res);
return T_EXIT_FAIL;
}
io_uring_cqe_seen(ring, cqe);
return T_EXIT_PASS;
}

/*
* Test linked timeout with child not exiting in time
*/
Expand Down Expand Up @@ -360,6 +392,12 @@ int main(int argc, char *argv[])
return T_EXIT_FAIL;
}

ret = test_invalid_infop(&ring);
if (ret == T_EXIT_FAIL) {
fprintf(stderr, "test_invalid_infop failed\n");
return T_EXIT_FAIL;
}

for (i = 0; i < 1000; i++) {
ret = test_cancel_race(&ring, i & 1);
if (ret == T_EXIT_FAIL) {
Expand Down

0 comments on commit 7e713e4

Please sign in to comment.