Skip to contentSkip to conversation

timekeeping: Reject cross timestamps for invalid AUX clocks

PATCH Applied Avi Weiss 2 participants 2 messages Oct 31 – Nov 9

Subsystems (2)
lore
Share & tools
lore

Avi Weiss

author
#0 lore raw

PATCH 1/1 timekeeping: Reject cross timestamps for invalid AUX clocks

get_device_system_crosststamp() accepts AUX clock IDs even when the corresponding timekeeper is disabled. A never-enabled AUX timekeeper has no initialized clocksource, and a previously enabled one can retain stale timekeeping data.

Return -ENODEV before calling the device timestamp callback when the selected timekeeper is invalid.

Fixes 9aebde8af6fe ("timekeeping: Add support for AUX clock cross timestamping")
---
 kernel/time/timekeeping.c | 3 +++
 1 file changed, 3 insertions(+)
kernel/time/timekeeping.c +3 -0
index dcf47f1ffdcf..7817c97dab61 100644
@@ -1600,6 +1600,9 @@ int get_device_system_crosststamp(int (*get_time_fn)
 
 	do {
 		seq = read_seqcount_begin(&tkd->seq);
+		if (!tk->clock_valid)
+			return -ENODEV;
+
 		/*
 		 * Try to synchronously capture device time and a system
 		 * counter value calling back into the device driver

base-commit: 36aad21d50d1af3f6954bb0c988257a908202477

Signature · 1 line
2.53.0
merge bot Applied
#1 lore raw
The following commit has been merged into the timers/urgent branch of tip:

The following commit has been merged into the timers/urgent branch of tip:

Commit-ID:     67f1969e29b692ab3cfcc97ba175b9109212de00
Gitweb:        https://git.kernel.org/tip/67f1969e29b692ab3cfcc97ba175b9109212de00
Author:        Avi Weiss <[email protected]>
AuthorDate:    Sat, 31 Oct 2026 14:22:17 +02:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Mon, 09 Nov 2026 20:15:58 +01:00

timekeeping: Reject cross timestamps for invalid AUX clocks

get_device_system_crosststamp() accepts AUX clock IDs even when the corresponding timekeeper is disabled. A never-enabled AUX timekeeper has no initialized clocksource, and a previously enabled one can retain stale timekeeping data.

Return -ENODEV before calling the device timestamp callback when the selected timekeeper is invalid.

Fixes 9aebde8af6fe ("timekeeping: Add support for AUX clock cross timestamping")
---
 kernel/time/timekeeping.c | 3 +++
 1 file changed, 3 insertions(+)
kernel/time/timekeeping.c +3 -0
index 7d7a737..806ab91 100644
@@ -1600,6 +1600,9 @@ int get_device_system_crosststamp(int (*get_time_fn)
 
 	do {
 		seq = read_seqcount_begin(&tkd->seq);
+		if (!tk->clock_valid)
+			return -ENODEV;
+
 		/*
 		 * Try to synchronously capture device time and a system
 		 * counter value calling back into the device driver