Skip to contentSkip to conversation

timekeeping: Refresh auxiliary base before offset validation

PATCH Applied Avi Weiss 2 participants 2 messages Nov 3 – Nov 9

Subsystems (2)
lore
Share & tools
lore

Avi Weiss

author
#0 lore raw

PATCH 1/1 timekeeping: Refresh auxiliary base before offset validation

timekeeping_forward_now() can advance an auxiliary timekeeper across a second boundary without refreshing tkr_mono.base. The negative-time check in __timekeeping_inject_offset() then uses the stale base and rejects valid ADJ_SETOFFSET adjustments with -EINVAL.

Refresh the derived timekeeper data before calculating the current auxiliary time, as aux_clock_set() already does.

On 7.4-rc1, a valid negative adjustment fails at the first second rollover. The patched kernel accepts all 12 tested rollover adjustments and continues to reject invalid negative offsets.

Fixes 2c8aea59c206 ("timekeeping: Add auxiliary clock support to __timekeeping_inject_offset()")
---
 kernel/time/timekeeping.c | 1 +
 1 file changed, 1 insertion(+)
kernel/time/timekeeping.c +1 -0
index dcf47f1ffdcf..6d55cecf86ee 100644
@@ -1775,6 +1775,7 @@ static int __timekeeping_inject_offset(struct tk_data *tkd, const struct timespe
 		struct tk_read_base *tkr_mono = &tks->tkr_mono;
 		ktime_t now, offs;
 
+		tk_update_ktime_data(tks);
 		/* Get the current time */
 		now = ktime_add_ns(tkr_mono->base, timekeeping_get_ns(tkr_mono));
 		/* Add the relative offset change */

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4

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:     c1b96ba87e3caaa701d6dba254e58db7cc3c99be
Gitweb:        https://git.kernel.org/tip/c1b96ba87e3caaa701d6dba254e58db7cc3c99be
Author:        Avi Weiss <[email protected]>
AuthorDate:    Tue, 03 Nov 2026 11:06:05 +02:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Mon, 09 Nov 2026 20:15:58 +01:00

timekeeping: Refresh auxiliary base before offset validation

timekeeping_forward_now() can advance an auxiliary timekeeper across a second boundary without refreshing tkr_mono.base. The negative-time check in __timekeeping_inject_offset() then uses the stale base and rejects valid ADJ_SETOFFSET adjustments with -EINVAL.

Refresh the derived timekeeper data before calculating the current auxiliary time, as aux_clock_set() already does.

On 7.4-rc1, a valid negative adjustment fails at the first second rollover. The patched kernel accepts all 12 tested rollover adjustments and continues to reject invalid negative offsets.

Fixes 2c8aea59c206 ("timekeeping: Add auxiliary clock support to __timekeeping_inject_offset()")
---
 kernel/time/timekeeping.c | 1 +
 1 file changed, 1 insertion(+)
kernel/time/timekeeping.c +1 -0
index 806ab91..be72cfd 100644
@@ -1778,6 +1778,7 @@ static int __timekeeping_inject_offset(struct tk_data *tkd, const struct timespe
 		struct tk_read_base *tkr_mono = &tks->tkr_mono;
 		ktime_t now, offs;
 
+		tk_update_ktime_data(tks);
 		/* Get the current time */
 		now = ktime_add_ns(tkr_mono->base, timekeeping_get_ns(tkr_mono));
 		/* Add the relative offset change */