From: Maoyi Xie <maoyixie.tju@gmail.com>
To: Thomas Gleixner <tglx@kernel.org>,
Anna-Maria Behnsen <anna-maria@linutronix.de>,
Frederic Weisbecker <frederic@kernel.org>,
Elizabeth Figura <zfigura@codeweavers.com>,
Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, Maoyi Xie <maoyixie.tju@gmail.com>
Subject: [PATCH 0/2] ntsync: honour time namespace offset in absolute MONOTONIC timeouts
Date: Thu, 28 May 2026 14:33:09 +0800 [thread overview]
Message-ID: <20260528063311.3300393-1-maoyixie.tju@gmail.com> (raw)
ntsync_schedule() hands an absolute MONOTONIC timeout from userspace
to schedule_hrtimeout_range_clock() without applying the caller's
time namespace offset. Inside a CLOCK_MONOTONIC time namespace, the
timeout fires too early or too late by the offset. Elizabeth Figura
confirmed the bug on the inquiry thread [1] and said whoever gets to
it first can fix it.
The fix calls timens_ktime_to_host() before hrtimer. That helper is
an inline in <linux/time_namespace.h> and references init_time_ns
and do_timens_ktime_to_host. All current users are in the kernel
itself, so neither symbol is exported. ntsync is the first module
user, so 1/2 exports both with EXPORT_SYMBOL_GPL.
I considered two alternatives for the export. Flipping CONFIG_NTSYNC
to bool would break module users. A new exported out of line wrapper
that hides init_time_ns is a cleaner ABI but adds a helper for one
caller. If a different export shape is preferred, please let me know
and I will follow that.
Routing: 1/2 touches kernel/time/, 2/2 touches drivers/misc/. A
timens Ack on 1/2 would let the series go through char-misc, or
both can go via tip. Either works.
Reproducer: unshare --user --time, monotonic offset -10s,
NTSYNC_IOC_WAIT_ANY with a 100 ms absolute MONOTONIC timeout.
Before, the run inside the namespace elapses about 0 ms. After,
about 100 ms. Full PoC and logs available on request.
I raised the export plan on linux-kernel on 2026-05-21 [2] and got
no reply, so I am sending the series for concrete review.
[1] https://lore.kernel.org/lkml/53921477.W1JGFHXlht@camazotz/
[2] https://lore.kernel.org/lkml/20260521153928.3724328-1-maoyixie.tju@gmail.com/
Maoyi Xie (2):
time/namespace: export init_time_ns and do_timens_ktime_to_host
ntsync: honour caller's time namespace for absolute MONOTONIC timeouts
drivers/misc/ntsync.c | 3 +++
kernel/time/namespace.c | 2 ++
2 files changed, 5 insertions(+)
--
2.34.1
next reply other threads:[~2026-05-28 6:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-28 6:33 Maoyi Xie [this message]
2026-05-28 6:33 ` [PATCH 1/2] time/namespace: export init_time_ns and do_timens_ktime_to_host Maoyi Xie
2026-06-02 19:08 ` [tip: timers/core] time/namespace: Export init_time_ns and do_timens_ktime_to_host() tip-bot2 for Maoyi Xie
2026-05-28 6:33 ` [PATCH 2/2] ntsync: honour caller's time namespace for absolute MONOTONIC timeouts Maoyi Xie
2026-06-01 22:12 ` Elizabeth Figura
2026-06-02 19:08 ` [tip: timers/core] ntsync: Honour " tip-bot2 for Maoyi Xie
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=20260528063311.3300393-1-maoyixie.tju@gmail.com \
--to=maoyixie.tju@gmail.com \
--cc=anna-maria@linutronix.de \
--cc=arnd@arndb.de \
--cc=frederic@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@kernel.org \
--cc=zfigura@codeweavers.com \
/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 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®