Skip to content

Commit e48a869

Browse files
mlichvarThomas Gleixner
authored andcommitted
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: 4eca49d ("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
1 parent 11439c4 commit e48a869

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

kernel/time/timekeeping.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2653,15 +2653,17 @@ static int timekeeping_validate_timex(const struct __kernel_timex *txc, bool aux
26532653

26542654
if (aux_clock) {
26552655
/* Auxiliary clocks are similar to TAI and do not have leap seconds */
2656-
if (txc->status & (STA_INS | STA_DEL))
2656+
if (txc->modes & ADJ_STATUS &&
2657+
txc->status & (STA_INS | STA_DEL))
26572658
return -EINVAL;
26582659

26592660
/* No TAI offset setting */
26602661
if (txc->modes & ADJ_TAI)
26612662
return -EINVAL;
26622663

26632664
/* No PPS support either */
2664-
if (txc->status & (STA_PPSFREQ | STA_PPSTIME))
2665+
if (txc->modes & ADJ_STATUS &&
2666+
txc->status & (STA_PPSFREQ | STA_PPSTIME))
26652667
return -EINVAL;
26662668
}
26672669

0 commit comments

Comments
 (0)