From nobody Mon Jun 8 05:26:39 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7A1C390CB9; Tue, 2 Jun 2026 19:08:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780427304; cv=none; b=MpEar06Xek/9Ykt4LjpcX+zCRp8E97fBZN6WyFJOA99JH3iz+FS7NbFLyRc/XFLApvRP2yYCHGFkJLQYOXz7xdRDA6pm2j9Y6UtKMykIr2EU05XpLvvJIFV4BsxUqFAVRbbbzYz854qriu0e0Nh2QW7ZzJSX7i/Z4FxuApM5wkA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780427304; c=relaxed/simple; bh=WfR2gpXxcY4jUNh6al1wBGlV/iOSnD4DceJHcc/Vido=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=oi++IHwDyIxFMULlz+wu79wDu0iQAJEZ6qRW9f5f3aKznHptidjhOYETMWAC2HPm0cKk8qPTMahZ3zjqbmdUigm+QtqmCRHIRqpcu64/SzINk9I9qQw32qjC9G27htUkda8ONz/ES3jR+sw2rciIuGIxBPHlitnPnjumkzRCgdM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=G3w2ltjW; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=hUUvYvdJ; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="G3w2ltjW"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="hUUvYvdJ" Date: Tue, 02 Jun 2026 19:08:14 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1780427300; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WkkryfdJzdjPoWmTr8sNBNki3NKzOM2c6wZiDx0dEh8=; b=G3w2ltjWBOTCBctRShrErEpuL5IQsiEDeJPRGpKSnYnQLBUm0pI2Lb2waVnapTvjG2sFpu 6SXsIZvQ0zdu7CbUmqiUWXdhCgCy9sFhYx7k22hcSk1+S9PRxRg7EUXYOlT7FHHZaEPna/ 8E7btxOlNuHlmydei5Uj3iBSvvkEDVj95EtNgr/XSgKOKcLJ08NgMrxAjCL+Qtq8f+WFH3 59cqwA80Jy99PGDlx6RfkxqToAuaP/Fi1Kmp5aG8peC8Bp7VcfZLz8C2FRCeeCUHRNH5ue 84/fHN8ssfGEHUZMwiAcve9ldAAEOiI5V5txg6vC/3g3QLLzV/teLaRtKeaRcA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1780427300; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WkkryfdJzdjPoWmTr8sNBNki3NKzOM2c6wZiDx0dEh8=; b=hUUvYvdJGVLkirpFlJsitPCVrbDPAsqmr+VkUNyQXJEwjzD7z0LazQj/KfGHBWddLmkaw+ GCObowbyhq9kZ0BQ== From: "tip-bot2 for Maoyi Xie" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] ntsync: Honour caller's time namespace for absolute MONOTONIC timeouts Cc: Maoyi Xie , Thomas Gleixner , Elizabeth Figura , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260528063311.3300393-3-maoyixie.tju@gmail.com> References: <20260528063311.3300393-3-maoyixie.tju@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <178042729427.710.15185798755158424641.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the timers/core branch of tip: Commit-ID: 180a232ea78003d1dc869b217b4e49106fd58e8f Gitweb: https://git.kernel.org/tip/180a232ea78003d1dc869b217b4e49106= fd58e8f Author: Maoyi Xie AuthorDate: Thu, 28 May 2026 14:33:11 +08:00 Committer: Thomas Gleixner 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 Signed-off-by: Thomas Gleixner Reviewed-by: Elizabeth Figura 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 #include #include +#include #include =20 #define NTSYNC_NAME "ntsync" @@ -836,6 +837,8 @@ static int ntsync_schedule(const struct ntsync_q *q, co= nst struct ntsync_wait_ar =20 if (args->flags & NTSYNC_WAIT_REALTIME) clock =3D CLOCK_REALTIME; + else + timeout =3D timens_ktime_to_host(clock, timeout); =20 do { if (signal_pending(current)) {