* [PATCH] timekeeping: Fix timex status validation for auxiliary clocks
@ 2026-02-25 8:51 Miroslav Lichvar
2026-03-04 19:10 ` [tip: timers/urgent] " tip-bot2 for Miroslav Lichvar
0 siblings, 1 reply; 2+ messages in thread
From: Miroslav Lichvar @ 2026-02-25 8:51 UTC (permalink / raw)
To: Thomas Gleixner, linux-kernel; +Cc: Miroslav Lichvar
The timekeeping_validate_timex() function validated the timex status
of an auxiliary system clock even when the status is not to be changed,
which caused 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>
---
kernel/time/timekeeping.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 91fa2003351c..c07e562ee4c1 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -2653,7 +2653,8 @@ static int timekeeping_validate_timex(const struct __kernel_timex *txc, bool aux
if (aux_clock) {
/* Auxiliary clocks are similar to TAI and do not have leap seconds */
- if (txc->status & (STA_INS | STA_DEL))
+ if (txc->modes & ADJ_STATUS &&
+ txc->status & (STA_INS | STA_DEL))
return -EINVAL;
/* No TAI offset setting */
@@ -2661,7 +2662,8 @@ static int timekeeping_validate_timex(const struct __kernel_timex *txc, bool aux
return -EINVAL;
/* No PPS support either */
- if (txc->status & (STA_PPSFREQ | STA_PPSTIME))
+ if (txc->modes & ADJ_STATUS &&
+ txc->status & (STA_PPSFREQ | STA_PPSTIME))
return -EINVAL;
}
--
2.53.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* [tip: timers/urgent] timekeeping: Fix timex status validation for auxiliary clocks
2026-02-25 8:51 [PATCH] timekeeping: Fix timex status validation for auxiliary clocks Miroslav Lichvar
@ 2026-03-04 19:10 ` tip-bot2 for Miroslav Lichvar
0 siblings, 0 replies; 2+ messages in thread
From: tip-bot2 for Miroslav Lichvar @ 2026-03-04 19:10 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Miroslav Lichvar, Thomas Gleixner, x86, linux-kernel
The following commit has been merged into the timers/urgent branch of tip:
Commit-ID: e48a869957a70cc39b4090cd27c36a86f8db9b92
Gitweb: https://git.kernel.org/tip/e48a869957a70cc39b4090cd27c36a86f8db9b92
Author: Miroslav Lichvar <mlichvar@redhat.com>
AuthorDate: Wed, 25 Feb 2026 09:51:35 +01:00
Committer: Thomas Gleixner <tglx@kernel.org>
CommitterDate: Wed, 04 Mar 2026 20:05:37 +01:00
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
---
kernel/time/timekeeping.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 91fa200..c07e562 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -2653,7 +2653,8 @@ static int timekeeping_validate_timex(const struct __kernel_timex *txc, bool aux
if (aux_clock) {
/* Auxiliary clocks are similar to TAI and do not have leap seconds */
- if (txc->status & (STA_INS | STA_DEL))
+ if (txc->modes & ADJ_STATUS &&
+ txc->status & (STA_INS | STA_DEL))
return -EINVAL;
/* No TAI offset setting */
@@ -2661,7 +2662,8 @@ static int timekeeping_validate_timex(const struct __kernel_timex *txc, bool aux
return -EINVAL;
/* No PPS support either */
- if (txc->status & (STA_PPSFREQ | STA_PPSTIME))
+ if (txc->modes & ADJ_STATUS &&
+ txc->status & (STA_PPSFREQ | STA_PPSTIME))
return -EINVAL;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-04 19:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-25 8:51 [PATCH] timekeeping: Fix timex status validation for auxiliary clocks Miroslav Lichvar
2026-03-04 19:10 ` [tip: timers/urgent] " tip-bot2 for Miroslav Lichvar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®