• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Description: Check to see if the asan checks catch an stack-use-after-free for prep_link_timeout
4  */
5 
6 #include <stdio.h>
7 #include <errno.h>
8 #include <sys/socket.h>
9 #include <sys/un.h>
10 #include <assert.h>
11 #include "liburing.h"
12 #include "helpers.h"
13 
14 #include <stdio.h>
15 
main(int argc,char * argv[])16 int main(int argc, char *argv[])
17 {
18 	struct io_uring ring;
19 	struct io_uring_sqe *sqe;
20 	int ret;
21 
22 	if (argc > 1)
23 		return T_EXIT_SKIP;
24 
25 	ret = io_uring_queue_init(8, &ring, 0);
26 	if (ret < 0) {
27 		printf("io_uring_queue_init ret %i\n", ret);
28 		return T_EXIT_PASS; // this test expects an inverted exit code
29 	}
30 
31 	// force timespec to go out of scope, test "passes" if asan catches this bug.
32 	{
33 		struct __kernel_timespec timespec;
34 		timespec.tv_sec = 0;
35 		timespec.tv_nsec = 5000;
36 
37 		sqe = io_uring_get_sqe(&ring);
38 		io_uring_prep_timeout(sqe, &timespec, 0, 0);
39 		io_uring_sqe_set_data(sqe, (void *) 1);
40 	}
41 
42 	ret = io_uring_submit_and_wait(&ring, 1);
43 	printf("submit_and_wait %i\n", ret);
44 
45 	return T_EXIT_PASS; // this test expects an inverted exit code
46 }
47