From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796385528; b=suKO4iLHSyd74/P0Yg7qUCEQGe6NZu3kWBIRxkpMQL4UUQSkFjmjg4KIAQHWf1IegtZg d91+AsuUN0FYJW2Fa6Dmtl+1tLyszVXzsmY4RHmYEGFyjNKlsb/Lmwd9o5tzGLb1H2ibP C4PdvytH1qhlPwu95GeNLAlxboZ95JapJnuGP27Zo39SXu7a4P5x+DXyxhhRbwpYCbWsZ c2woyi/+3Yr7eD/dI4dn0aaXbVXyvMuN7dLs/JwArAl2Kzr7sz5r36tkkasNOlf9rZoOs fS2XKttZEiFhY69It1Y4WwEw+2z5n86PJ6MNBxsl2xhgTT+GTQ8+bq/QKuRodb/7KFg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385528; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=nQAkfG2yKHbWvgiWnskyi/fyNk/HkyW2qwODGqNi39E=; b=5e/Z8L1JJlIjNZUuZv6UtA2ucDOVUqfcE/j6byztrpT7GbaokOiOvdkdxTr7U1t3SK/2 VbcHqisyHOHd1PuuXR0zSGiRmdiR88RrXubYhq00BuphXMM+qt7Etan1rZDFunQqjcegw yX1Wi00pfHRumgTseaCX09s/3du5d9eIsu2w3d7i6+e8aoZokSqmJ2jyoB/t0tX9pnJ62 HvEirrEhaIc9LEVN4CbfTGn28L2p1hfs/UFCp5XC5bBg3foiVfBERdhV5nCjqHXQzkhNJ LgBJer2r1UbMkoRth3HE3F/2Pl6+kb9lizvpMH2rhMn+QhPJ0+cPbU7ERIxasCHcE9Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=w0mpVvLm; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7CBF1606A32C; Fri, 4 Dec 2026 11:58:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=w0mpVvLm Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9FCEC1F000C2; Fri, 4 Dec 2026 11:58:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385528; bh=nQAkfG2yKHbWvgiWnskyi/fyNk/HkyW2qwODGqNi39E=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=w0mpVvLmyv6JZwGx339S4tc3KXD6OdbnL7WLmZBl07+DzIsX3W19RRXD+9V7NrTfU 8q9ImCZ/vEbaUkvWUZCqzclJwONUaY5GBKUaLCzMmYewoflMi0SczCjGRLvCd5YumI zamhKnS2BV77dJuKvqiOXd6ko4f5ccUaUQpuZFYk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Hungyu Lin , Thomas Gleixner , John Stultz Subject: [PATCH 6.6 0548/1167] timekeeping: Read getboottime64() offsets under the sequence counter Date: Fri, 4 Dec 2026 18:59:35 +0900 Message-ID: <20261204100716.330212199@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hungyu Lin commit 385b5ec1f31dd39297578eed42be74b07ae74017 upstream. getboottime64() computes the wall-clock boot timestamp from offs_real minus offs_boot without checking tk_core.seq. A concurrent timekeeping update can leave the reader with an inconsistent pair of offsets or, on 32-bit systems, a torn 64-bit offset, producing an incorrect boot timestamp. Read both offsets under tk_core.seq and retry if an update overlaps the sample. Convert the resulting local value to a timespec64 afterward. Fixes: 7c3f1a573237 ("Introduce boot based time") Signed-off-by: Hungyu Lin Signed-off-by: Thomas Gleixner Acked-by: John Stultz Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20261030054227.35453-2-dennylin0707@gmail.com Signed-off-by: Greg Kroah-Hartman --- kernel/time/timekeeping.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -2252,7 +2252,13 @@ void update_wall_time(void) void getboottime64(struct timespec64 *ts) { struct timekeeper *tk = &tk_core.timekeeper; - ktime_t t = ktime_sub(tk->offs_real, tk->offs_boot); + unsigned int seq; + ktime_t t; + + do { + seq = read_seqcount_begin(&tk_core.seq); + t = ktime_sub(tk->offs_real, tk->offs_boot); + } while (read_seqcount_retry(&tk_core.seq, seq)); *ts = ktime_to_timespec64(t); }