1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (c) International Business Machines Corp., 2001
4 * 03/2001 - Written by Wayne Boyer
5 *
6 */
7
8 /*\
9 * [Description]
10 *
11 * Check that a setitimer() call fails with EFAULT with invalid itimerval
12 * pointer.
13 */
14
15 #include <errno.h>
16 #include <sys/time.h>
17 #include <stdlib.h>
18 #include "tst_test.h"
19 #include "lapi/syscalls.h"
20
21 static struct itimerval *value;
22
sys_setitimer(int which,void * new_value,void * old_value)23 static int sys_setitimer(int which, void *new_value, void *old_value)
24 {
25 return tst_syscall(__NR_setitimer, which, new_value, old_value);
26 }
27
verify_setitimer(void)28 static void verify_setitimer(void)
29 {
30 TST_EXP_FAIL(sys_setitimer(ITIMER_REAL, value, (struct itimerval *)-1),
31 EFAULT);
32 }
33
setup(void)34 static void setup(void)
35 {
36 value->it_value.tv_sec = 30;
37 value->it_value.tv_usec = 0;
38 value->it_interval.tv_sec = 0;
39 value->it_interval.tv_usec = 0;
40 }
41
42 static struct tst_test test = {
43 .test_all = verify_setitimer,
44 .setup = setup,
45 .bufs = (struct tst_buffers[]) {
46 {&value, .size = sizeof(struct itimerval)},
47 {}
48 }
49 };
50