diff mbox series

syscalls/timer_getoverrun01: initialize timer variable

Message ID fae6ad10f98ab50a1a3e362706d65ea13fdda3ff.1711044800.git.jstancek@redhat.com
State Superseded
Headers show
Series syscalls/timer_getoverrun01: initialize timer variable | expand

Commit Message

Jan Stancek March 21, 2024, 6:14 p.m. UTC
Testcase is failing on s390x, with glibc-2.39 and 6.9-rc0 (git commit
a4145ce1e7bc). Userspace defines timer_t as void * (8 bytes), while
__kernel_timer_t is defined as int (4 bytes).  This means that kernel
only populates 4 bytes, and other 4 can remain uninitialized, possibly
containing some non-zero garbage, e.g.:

  timer_create(CLOCK_REALTIME, {sigev_signo=SIGALRM, sigev_notify=SIGEV_SIGNAL},  <unfinished ...>
  <... timer_create resumed>[0]) = 0
  timer_getoverrun(1 <unfinished ...>
  timer_getoverrun resumed>) = -1 EINVAL (Invalid argument)
  timer_delete(1)    = -1 EINVAL (Invalid argument)

Initialize entire "timer" variable to 0.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
 testcases/kernel/syscalls/timer_getoverrun/timer_getoverrun01.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/timer_getoverrun/timer_getoverrun01.c b/testcases/kernel/syscalls/timer_getoverrun/timer_getoverrun01.c
index 5c444857aaa7..897bf65a2480 100644
--- a/testcases/kernel/syscalls/timer_getoverrun/timer_getoverrun01.c
+++ b/testcases/kernel/syscalls/timer_getoverrun/timer_getoverrun01.c
@@ -25,6 +25,7 @@  static void run(void)
 	timer_t timer;
 	struct sigevent ev;
 
+	memset(&timer, 0, sizeof(timer_t));
 	ev.sigev_value = (union sigval) 0;
 	ev.sigev_notify = SIGEV_SIGNAL;
 	ev.sigev_signo = SIGALRM;