| From c1b96ba87e3caaa701d6dba254e58db7cc3c99be Mon Sep 17 00:00:00 2001 | |
| From: Avi Weiss <thnkslprpt@gmail.com> | |
| Date: Tue, 3 Nov 2026 11:06:05 +0200 | |
| Subject: timekeeping: Refresh auxiliary base before offset validation | |
| From: Avi Weiss <thnkslprpt@gmail.com> | |
| commit c1b96ba87e3caaa701d6dba254e58db7cc3c99be upstream. | |
| 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()") | |
| Signed-off-by: Avi Weiss <thnkslprpt@gmail.com> | |
| Signed-off-by: Thomas Gleixner <tglx@kernel.org> | |
| Cc: stable@vger.kernel.org | |
| Link: https://patch.msgid.link/20261103090605.1292660-1-thnkslprpt@gmail.com | |
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
| --- | |
| kernel/time/timekeeping.c | 1 + | |
| 1 file changed, 1 insertion(+) | |
| --- a/kernel/time/timekeeping.c | |
| +++ b/kernel/time/timekeeping.c | |
| @@ -1776,6 +1776,7 @@ static int __timekeeping_inject_offset(s | |
| 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 */ |