diff options
| author | Thomas Weißschuh <thomas.weissschuh@linutronix.de> | 2026-09-03 09:11:47 +0200 |
|---|---|---|
| committer | Thomas Gleixner <tglx@kernel.org> | 2026-09-29 21:13:26 +0200 |
| commit | bc5b66c300b87544e6861b8dff8c45958603cba5 (patch) | |
| tree | 0c415d167c0c795e0b43fb730d7e854ce712dacd /scripts/Makefile.thinlto | |
| parent | bb41ece16463b76b4d73fc47e6648fd823236765 (diff) | |
| download | linux-bc5b66c300b87544e6861b8dff8c45958603cba5.tar.gz linux-bc5b66c300b87544e6861b8dff8c45958603cba5.zip | |
timekeeping: Use READ_ONCE/WRITE_ONCE() for ktime_sec to prevent tearing
The timekeeper update path uses a bulk memcpy() to synchronize the
timekeeper structure, which is not guaranteed to be atomic. This allows for
torn reads in ktime_get_seconds() which bypasses the sequence counter
protection for performance.
To prevent reading a torn ktime_sec value, enforce atomic-like
access by using WRITE_ONCE() for the critical field before the bulk
memcpy() in timekeeping_update_from_shadow(). Correspondingly, use
READ_ONCE() in ktime_get_seconds() to ensure a fresh, consistent load
from memory.
The same was done for xtime_sec and ktime_get_real_seconds() in commit
d7fc133bf91f ("timekeeping: Use READ_ONCE/WRITE_ONCE() for xtime_sec to
prevent tearing").
Signed-off-by: Thomas Weißschuh (Schneider Electric) <thomas.weissschuh@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Acked-by: John Stultz <jstultz@google.com>
Link: https://patch.msgid.link/20260903-timekeeping-ktime_sec-v1-1-b33017536aa9@linutronix.de
Diffstat (limited to 'scripts/Makefile.thinlto')
0 files changed, 0 insertions, 0 deletions
