lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250720-timekeeping_uninit_crossts-v2-1-f513c885b7c2@blochl.de>
Date: Sun, 20 Jul 2025 15:54:51 +0200
From: Markus Blöchl <markus@...chl.de>
To: Thomas Gleixner <tglx@...utronix.de>, John Stultz <jstultz@...gle.com>
Cc: Stephen Boyd <sboyd@...nel.org>, 
 Lakshmi Sowjanya D <lakshmi.sowjanya.d@...el.com>, 
 "Christopher S. Hall" <christopher.s.hall@...el.com>, 
 netdev@...r.kernel.org, linux-kernel@...r.kernel.org, 
 markus.bloechl@...tronik.com, 
 Markus Blöchl <markus@...chl.de>
Subject: [PATCH v2] timekeeping: Always initialize use_nsecs when querying
 time from phc drivers

Most drivers only populate the fields cycles and cs_id in their
get_time_fn() callback for get_device_system_crosststamp() unless
they explicitly provide nanosecond values.
When this new use_nsecs field was added and used most drivers did not
care.
Clock sources other than CSID_GENERIC could then get converted in
convert_base_to_cs() based on an uninitialized use_nsecs which usually
results in -EINVAL during the following range check.

Pass in a fully initialized system_counterval_t.

Fixes: 6b2e29977518 ("timekeeping: Provide infrastructure for converting to/from a base clock")
Cc: stable@...r.kernel.org
Signed-off-by: Markus Blöchl <markus@...chl.de>
---
Changes in v2:
- Initialize entire system_counterval_t, not just use_nsecs
- Only initialize system_counterval_t once during instantiation instead
  of every iteration.
- Link to v1: https://lore.kernel.org/lkml/txyrr26hxe3xpq3ebqb5ewkgvhvp7xalotaouwludjtjifnah2@7tmgczln4aoo/
---
 kernel/time/timekeeping.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index a009c91f7b05fcb433073862a1b1a3de0345bffe..83c65f3afccaacff7a2e53e62f32657c201fbc8c 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -1256,7 +1256,7 @@ int get_device_system_crosststamp(int (*get_time_fn)
 				  struct system_time_snapshot *history_begin,
 				  struct system_device_crosststamp *xtstamp)
 {
-	struct system_counterval_t system_counterval;
+	struct system_counterval_t system_counterval = {};
 	struct timekeeper *tk = &tk_core.timekeeper;
 	u64 cycles, now, interval_start;
 	unsigned int clock_was_set_seq = 0;

---
base-commit: f4a40a4282f467ec99745c6ba62cb84346e42139
change-id: 20250720-timekeeping_uninit_crossts-c130ee69fb1e

Best regards,
-- 
Markus Blöchl <markus@...chl.de>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ