From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E57F30C150 for ; Thu, 28 May 2026 06:33:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779949998; cv=none; b=BBiyM0VEEeCcKIkzMxuI5lIJW73f4NZPHtloIwrlNyE5QQDi4KG1svkfFkKhodYveUx6sKbUsGhlcRgAwKrl5nUmetLXFTUyQNC9BSklSoq5nzjDZtAkwGVjEsPyPoYOlzBHloWC9ntdr7jnnC6YWSerJtkzCMd5Q6uJOY5FoxM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779949998; c=relaxed/simple; bh=U6zFt60Y9zZlYzOorMO994pZe5ZK0FoZcokBIeMOI/U=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=RN02LsEa7AGsQ50MBx0uqSXRIMaEtxbhE6jH8rVq1+c3O42xwG2e9hqcD6OB7uDS9rR+dAx0Xl+bZIOaKb+UVR3ynnANjCDdx+hfQQTmnGKMOtIiEsaXoASUoAW99IGdUNqCJePuGTkOM+/VLDff/hconPGYVKwpcOE3h6n6K9Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fqKBErNN; arc=none smtp.client-ip=209.85.210.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fqKBErNN" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-8413ac3d82fso6344554b3a.0 for ; Wed, 27 May 2026 23:33:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779949997; x=1780554797; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=fm92cyzfuI1DxRoi1Z6YDF0nF6OsDf3XF7BONTHM+Mc=; b=fqKBErNNyzey0UkT9+hG+Z2saCtUcbAzwJktNSJn/K4RECl2ToUJPF/sRoyEgr0wLn CmDuhYiQqFr9p/1MbDCvoW0/jB3GK+/Y3Be2b5MgjZpZSt2yYgjuo4T+Qz9XPLqjYjhs IvTe0hFJDgpLTkmmAY41vbbhB8nTv7nZMAaelInTX+G0uSJ2l8EnSchF+7iQO/LzRRO9 8MfBMfMDx2m8kTLjp0OwbcHKygnzd/Dp4Z+AZAuToVRaBUEnqbO9qTYvK5QJNmNdihoQ zvtAMEU6iTvzSpOuKsPP7+lGwEgHiFcxG1TuWp/f+fgBxmQKwjEsCklOh593w5jqCfhS yKbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779949997; x=1780554797; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=fm92cyzfuI1DxRoi1Z6YDF0nF6OsDf3XF7BONTHM+Mc=; b=sHJCyC4+bFfhuf5a4HKiBA0I0xHyH5X+erPOIqaqTbbnw9hOKD33hpztwznL9iof7k b3fO6RcESlab/SmIZG5pyk+qBfS0vZHmIF/qMVjJYeAvril+tH1dBtmG3eMb0WP3dOGT Is4H2Vs0n8i/+uYFx8vR/FJ7VHeItLCp5NrjeElJFo81IgWV+RXVuE3Z7g4DqtNkml72 4Fj06Wn2u8r1c8DWxPD7xLdaAJjtC/7Z7lLv3YaoVYi9TJz7VwezNaW1GW2VQBSoVTiW EGx1t7W+f4uet4ah95Zd3JOdFYoauMtZfsiyx3Y3SQJqVEiMKx24+Va0x9kTvTk0aCwD GO7A== X-Gm-Message-State: AOJu0YwyiDXTp9Myr9qNvuN9UCDgOxdo+Xi9snlHjInqo8d/LAT9grkC 77hDbuPvBopexGajlWaLbSE9kLm/YaGXIjBA7b52kj8r5wJgyFxOC9AC X-Gm-Gg: Acq92OHcQeLgqSPi9uaCm/es0MaOIqKD+Ho1VjJhEozA47wL/+1wwAK0ZT/41R4RgyA rWSrNHVYz2g9pFZD093D6/9s3yDmu/j1lUG0COcD2smU862QLYjQV428+HFt8TvFi9uY03o/x0w IY+E4qgpkpi21h5wvNhW8oT6gFCKpH7yek2FG/Zu7tE6zZs7I0zn11CtFyvskRJxvx89vcseeFp f3VNJl8D7d+TQyhna9tls26NHx1xeqGnTbr1zcXZD6l7qT0ECjJGFWYCnpvMYk5AHNMkGNveLNC yB+ZV3jSIMw7Krs/DKUd9snmdYgV8xGxjehc6pToAG3NotHi7PMY+g9AJGuksR9rBY2EzbSy+8c c4VD486SRqzGKYFCLXv8DeMNGiFHZVWhqYVI90SdI2vipJfkUZNt+TWfiZwk8pr9pKgabV4gdqs vkjfdUQiw7f+LgRCmid6RY1B2mOwuFUeA8E0ojDK0o0N8Vhft618uOjcC4WiU= X-Received: by 2002:a05:6a00:4b10:b0:835:532a:3468 with SMTP id d2e1a72fcca58-8415f15b648mr24786773b3a.20.1779949996422; Wed, 27 May 2026 23:33:16 -0700 (PDT) Received: from csl-conti-dell7858.ntu.edu.sg ([155.69.195.57]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-841d6d60d07sm5628781b3a.0.2026.05.27.23.33.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2026 23:33:15 -0700 (PDT) From: Maoyi Xie To: Thomas Gleixner , Anna-Maria Behnsen , Frederic Weisbecker , Elizabeth Figura , Arnd Bergmann , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, Maoyi Xie Subject: [PATCH 0/2] ntsync: honour time namespace offset in absolute MONOTONIC timeouts Date: Thu, 28 May 2026 14:33:09 +0800 Message-Id: <20260528063311.3300393-1-maoyixie.tju@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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