All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] timekeeping: Always initialize use_nsecs when querying time from phc drivers
@ 2025-07-08 16:46 Markus Blöchl
  2025-07-08 19:09 ` John Stultz
  0 siblings, 1 reply; 5+ messages in thread
From: Markus Blöchl @ 2025-07-08 16:46 UTC (permalink / raw)
  To: Thomas Gleixner, Christopher S. Hall, Lakshmi Sowjanya D
  Cc: John Stultz, Stephen Boyd, linux-kernel

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.

Fixes: 6b2e29977518 ("timekeeping: Provide infrastructure for converting to/from a base clock")
Cc: stable@vger.kernel.org
Signed-off-by: Markus Blöchl <markus.bloechl@ipetronik.com>
---

Notes:
    We observed this in the e1000e driver but at least stmmac and
    ptp_kvm also seem affected by this.
    ice was recently fixed by a5a441ae283d ("ice/ptp: fix crosstimestamp reporting").


 kernel/time/timekeeping.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index a009c91f7b05..be0da807329f 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -1269,6 +1269,8 @@ int get_device_system_crosststamp(int (*get_time_fn)

        do {
                seq = read_seqcount_begin(&tk_core.seq);
+               system_counterval.use_nsecs = false;
+
                /*
                 * Try to synchronously capture device time and a system
                 * counter value calling back into the device driver

base-commit: d7b8f8e20813f0179d8ef519541a3527e7661d3a
--
2.50.0


Impressum/Imprint: https://www.ipetronik.com/impressum

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

end of thread, other threads:[~2025-07-20 13:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-08 16:46 [PATCH] timekeeping: Always initialize use_nsecs when querying time from phc drivers Markus Blöchl
2025-07-08 19:09 ` John Stultz
2025-07-09  8:32   ` Markus Blöchl
2025-07-18 20:25     ` Thomas Gleixner
2025-07-20 13:51       ` Markus Blöchl

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.