Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

timekeeping: Fix timex status validation for auxiliary clocks

The timekeeping_validate_timex() function validates the timex status
of an auxiliary system clock even when the status is not to be changed,
which causes unexpected errors for applications that make read-only
clock_adjtime() calls, or set some other timex fields, but without
clearing the status field.

Do the AUX-specific status validation only when the modes field contains
ADJ_STATUS, i.e. the application is actually trying to change the
status. This makes the AUX-specific clock_adjtime() behavior consistent
with CLOCK_REALTIME.

Fixes: 4eca49d0b621 ("timekeeping: Prepare do_adtimex() for auxiliary clocks")
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Link: https://patch.msgid.link/20260225085231.276751-1-mlichvar@redhat.com

authored by

Miroslav Lichvar and committed by
Thomas Gleixner
e48a8699 11439c46

+4 -2
+4 -2
kernel/time/timekeeping.c
··· 2653 2654 if (aux_clock) { 2655 /* Auxiliary clocks are similar to TAI and do not have leap seconds */ 2656 - if (txc->status & (STA_INS | STA_DEL)) 2657 return -EINVAL; 2658 2659 /* No TAI offset setting */ ··· 2662 return -EINVAL; 2663 2664 /* No PPS support either */ 2665 - if (txc->status & (STA_PPSFREQ | STA_PPSTIME)) 2666 return -EINVAL; 2667 } 2668
··· 2653 2654 if (aux_clock) { 2655 /* Auxiliary clocks are similar to TAI and do not have leap seconds */ 2656 + if (txc->modes & ADJ_STATUS && 2657 + txc->status & (STA_INS | STA_DEL)) 2658 return -EINVAL; 2659 2660 /* No TAI offset setting */ ··· 2661 return -EINVAL; 2662 2663 /* No PPS support either */ 2664 + if (txc->modes & ADJ_STATUS && 2665 + txc->status & (STA_PPSFREQ | STA_PPSTIME)) 2666 return -EINVAL; 2667 } 2668