All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls/timer_getoverrun01: initialize timer variable
@ 2024-03-21 18:14 Jan Stancek
  2024-03-21 18:25 ` [LTP] [PATCH v2] syscalls/timer_getoverrun01: use kernel_timer_t type Jan Stancek
  0 siblings, 1 reply; 7+ messages in thread
From: Jan Stancek @ 2024-03-21 18:14 UTC (permalink / raw)
  To: ltp; +Cc: liwan

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 --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;
-- 
2.39.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-03-25  7:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-21 18:14 [LTP] [PATCH] syscalls/timer_getoverrun01: initialize timer variable Jan Stancek
2024-03-21 18:25 ` [LTP] [PATCH v2] syscalls/timer_getoverrun01: use kernel_timer_t type Jan Stancek
2024-03-22  1:32   ` Li Wang
2024-03-22  5:11   ` Petr Vorel
2024-03-22  8:51     ` Jan Stancek
2024-03-22  9:34       ` Petr Vorel
2024-03-25  7:40         ` Jan Stancek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.