From: "tip-bot2 for Maoyi Xie" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Maoyi Xie <maoyixie.tju@gmail.com>,
Thomas Gleixner <tglx@kernel.org>,
Elizabeth Figura <zfigura@codeweavers.com>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: timers/core] ntsync: Honour caller's time namespace for absolute MONOTONIC timeouts
Date: Tue, 02 Jun 2026 19:08:14 -0000 [thread overview]
Message-ID: <178042729427.710.15185798755158424641.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20260528063311.3300393-3-maoyixie.tju@gmail.com>
The following commit has been merged into the timers/core branch of tip:
Commit-ID: 180a232ea78003d1dc869b217b4e49106fd58e8f
Gitweb: https://git.kernel.org/tip/180a232ea78003d1dc869b217b4e49106fd58e8f
Author: Maoyi Xie <maoyixie.tju@gmail.com>
AuthorDate: Thu, 28 May 2026 14:33:11 +08:00
Committer: Thomas Gleixner <tglx@kernel.org>
CommitterDate: Tue, 02 Jun 2026 21:05:36 +02:00
ntsync: Honour caller's time namespace for absolute MONOTONIC timeouts
ntsync_schedule() takes the absolute timeout from userspace and hands it to
schedule_hrtimeout_range_clock() with HRTIMER_MODE_ABS. For the default
CLOCK_MONOTONIC path, it does not call timens_ktime_to_host() first.
A process inside a CLOCK_MONOTONIC time namespace computes the absolute
timeout in its own clock view. The kernel reads the same value against the
host clock. The two differ by the namespace offset. The timeout then fires
too early or too late.
Other users of absolute timeouts run the ktime through
timens_ktime_to_host() before starting the hrtimer. ntsync was added later
and missed that step.
/dev/ntsync is mode 0666. Any user inside a time namespace that can
open it is affected. The visible effect is wrong timeout behaviour
for Wine in a container that sets a CLOCK_MONOTONIC offset.
Reproducer: unshare --user --time, set the monotonic offset to -10s,
issue NTSYNC_IOC_WAIT_ANY with a 100 ms absolute MONOTONIC timeout.
The baseline run elapses about 100 ms. The run inside the namespace
elapses about 0 ms.
Apply timens_ktime_to_host() to the parsed timeout when the caller
did not set NTSYNC_WAIT_REALTIME. The helper does nothing in the
initial time namespace, so the fast path is unchanged.
Fixes: b4a7b5fe3f51 ("ntsync: Introduce NTSYNC_IOC_WAIT_ANY.")
Signed-off-by: Maoyi Xie <maoyixie.tju@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Reviewed-by: Elizabeth Figura <zfigura@codeweavers.com>
Link: https://patch.msgid.link/20260528063311.3300393-3-maoyixie.tju@gmail.com
---
drivers/misc/ntsync.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c
index 30af282..02c9d11 100644
--- a/drivers/misc/ntsync.c
+++ b/drivers/misc/ntsync.c
@@ -19,6 +19,7 @@
#include <linux/sched/signal.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
+#include <linux/time_namespace.h>
#include <uapi/linux/ntsync.h>
#define NTSYNC_NAME "ntsync"
@@ -836,6 +837,8 @@ static int ntsync_schedule(const struct ntsync_q *q, const struct ntsync_wait_ar
if (args->flags & NTSYNC_WAIT_REALTIME)
clock = CLOCK_REALTIME;
+ else
+ timeout = timens_ktime_to_host(clock, timeout);
do {
if (signal_pending(current)) {
prev parent reply other threads:[~2026-06-02 19:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-28 6:33 [PATCH 0/2] ntsync: honour time namespace offset in " Maoyi Xie
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-bot2 for Maoyi Xie [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=178042729427.710.15185798755158424641.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=maoyixie.tju@gmail.com \
--cc=tglx@kernel.org \
--cc=x86@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®