[LTP] Syscall param clock_settime(tp) points to uninitialised byte(s)
Martin Cermak
mcermak@redhat.com
Mon Apr 13 17:57:30 CEST 2026
Hello there,
one LTP nit attached.
Cheers,
m.
-------------- next part --------------
>From 1acc76579c81b37814b0111044e1a1f8282cfbfb Mon Sep 17 00:00:00 2001
From: Martin Cermak <mcermak@redhat.com>
Date: Mon, 13 Apr 2026 17:48:43 +0200
Subject: [PATCH] Avoid Syscall param clock_settime(tp) points to uninitialised
byte(s)
Without this update, clock_settime03 fails under valgrind with an error like the following:
el10 x86_64 # ./vg-in-place --track-origins=yes ./auxprogs/auxchecks/ltp-full-20260130/testcases/kernel/syscalls/clock_settime/clock_settime03
==1638250== Memcheck, a memory error detector
==1638250== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al.
==1638250== Using Valgrind-3.27.0.GIT and LibVEX; rerun with -h for copyright info
==1638250== Command: ./auxprogs/auxchecks/ltp-full-20260130/testcases/kernel/syscalls/clock_settime/clock_settime03
==1638250==
tst_test.c:2047: TINFO: LTP version: 20260130
tst_test.c:2050: TINFO: Tested kernel: 6.12.0-218.el10.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Mar 31 08:07:36 EDT 2026 x86_64
tst_kconfig.c:88: TINFO: Parsing kernel config '/lib/modules/6.12.0-218.el10.x86_64/build/.config'
tst_test.c:1875: TINFO: Overall timeout per run is 0h 00m 34s
clock_settime03.c:35: TINFO: Testing variant: syscall with old kernel spec
clock_settime03.c:103: TPASS: clock_settime(): Y2038 test passed
==1638252==
==1638252== HEAP SUMMARY:
==1638252== in use at exit: 0 bytes in 0 blocks
==1638252== total heap usage: 17 allocs, 17 frees, 13,761 bytes allocated
==1638252==
==1638252== All heap blocks were freed -- no leaks are possible
==1638252==
==1638252== For lists of detected and suppressed errors, rerun with: -s
==1638252== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Summary:
passed 1
failed 0
broken 0
skipped 0
warnings 0
==1638250== Syscall param clock_settime(tp) points to uninitialised byte(s)
==1638250== at 0x496215D: syscall (in /usr/lib64/libc.so.6)
==1638250== by 0x416780: syscall_supported_by_kernel (tst_clocks.c:24)
==1638250== by 0x416780: tst_clock_settime (tst_clocks.c:104)
==1638250== by 0x40DB67: tst_wallclock_restore (tst_wallclock.c:63)
==1638250== by 0x407E06: do_cleanup (tst_test.c:1671)
==1638250== by 0x407E06: do_exit (tst_test.c:1054)
==1638250== by 0x40B280: run_tcases_per_fs (tst_test.c:2025)
==1638250== by 0x40B280: tst_run_tcases (tst_test.c:2065)
==1638250== by 0x404D8D: main (tst_test.h:755)
==1638250== Address 0x1ffefffbe0 is on thread 1's stack
==1638250== in frame #1, created by tst_clock_settime (tst_clocks.c:92)
==1638250== Uninitialised value was created by a stack allocation
==1638250== at 0x416710: tst_clock_settime (tst_clocks.c:92)
==1638250==
==1638250==
==1638250== HEAP SUMMARY:
==1638250== in use at exit: 0 bytes in 0 blocks
==1638250== total heap usage: 10 allocs, 10 frees, 10,552 bytes allocated
==1638250==
==1638250== All heap blocks were freed -- no leaks are possible
==1638250==
==1638250== For lists of detected and suppressed errors, rerun with: -s
==1638250== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
el10 x86_64 #
---
lib/tst_clocks.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/tst_clocks.c b/lib/tst_clocks.c
index 704ce9551..107938e4e 100644
--- a/lib/tst_clocks.c
+++ b/lib/tst_clocks.c
@@ -19,7 +19,7 @@ typedef int (*mysyscall)(clockid_t clk_id, void *ts);
int syscall_supported_by_kernel(long sysnr)
{
int ret;
- struct __kernel_timespec foo;
+ struct __kernel_timespec foo = { 0, };
ret = syscall(sysnr, 0, &foo);
if (ret == -1 && errno == ENOSYS)
--
2.53.0
More information about the ltp
mailing list