From: Thomas Gleixner <tglx@linutronix.de>
To: Dennis Moshegov <dennis@xzync.uk>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] timekeeping: Use data_race() and READ_ONCE() in ktime_get_real_seconds()
Date: Mon, 20 Jul 2026 16:03:48 +0200 [thread overview]
Message-ID: <87ik69n4fv.ffs@fw13> (raw)
In-Reply-To: <CAGqVGMoOasRgLgVZDyPGjzMA5gA1RXmJTFn=ZabM45XwrMVNvA@mail.gmail.com>
On Mon, Jul 20 2026 at 09:40, Dennis Moshegov wrote:
> From: Dennis M <dennismoshegov@gmail.com>
This from line mail address is not matching the
> Subject: [PATCH v3] timekeeping: Use READ_ONCE/WRITE_ONCE for
> xtime_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_real_seconds() on 64-bit systems,
> where the sequence counter protection is bypassed for performance.
>
> To prevent reading a torn 64-bit xtime_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_real_seconds() to ensure a fresh, consistent
> load from memory.
>
> Reported-by: syzbot+72789cd1697965e714ca@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspotmail.com/bug?extid=72789cd1697965e714ca
> Signed-off-by: Dennis Moshegov <dennis@xzync.uk>
one used here. Please make your mind up which of your personalities you
awant to use.
> ---
> timekeeping.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
> index c493a40..461a68e 100644
> --- a/kernel/time/timekeeping.c
> +++ b/kernel/time/timekeeping.c
> @@ -826,6 +826,7 @@ static void timekeeping_update_from_shadow(struct
> tk_data *tkd, unsigned int action)
> * the cacheline optimized data layout of the timekeeper and requires
> * another indirection.
> */
> + WRITE_ONCE(tkd->timekeeper.xtime_secy, tk->xtime_sec);
> memcpy(&tkd->timekeeper, tk, sizeof(*tk));
> write_seqcount_end(&tkd->seq);
Again you used copy & paste to get the patch into your mail client or
imported it and gmail mangled it.
patching file kernel/time/timekeeping.c
patch: **** malformed patch at line 34: tk_data *tkd, unsigned int action)
See Documentation/process/email-clients.rst
The only known way to send patches with the gmail web client is as
attachment, but that's a pain for reviewing, replying and applying.
But you can use git send-email with gmail smtp and that will do the
right thing.
Thanks,
tglx
prev parent reply other threads:[~2026-07-20 14:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-30 17:38 [PATCH] timekeeping: Use data_race() and READ_ONCE() in ktime_get_real_seconds() Dennis Moshegov
2026-06-02 9:46 ` Thomas Gleixner
[not found] ` <CAGqVGMp6z7VHvD6YGhgAL+2mffvM7FoFY1F__Xa2-u98YZRYeQ@mail.gmail.com>
[not found] ` <871peo9485.ffs@fw13>
[not found] ` <CAGqVGMrdhhVdCOQxNLtFkrDbeeEytJiiY+=2D7VYMue0xDD8DQ@mail.gmail.com>
2026-06-16 9:11 ` Dennis Moshegov
2026-06-21 13:17 ` Thomas Gleixner
2026-07-20 8:40 ` Dennis Moshegov
2026-07-20 14:03 ` Thomas Gleixner [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ik69n4fv.ffs@fw13 \
--to=tglx@linutronix.de \
--cc=dennis@xzync.uk \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.