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=1796388197; b=JDYqLozxZG3XZj01pswj/FdzhREWb5H81XQhFRzir/AZNgkP4pwMtw89EvxnaD99N+d0 QEla+YZoWCPLwsrMio+rdtlq7y/tyiqT5vdP9a05z78EVLuMQrITJSKUNxxfpd4uyyWXz Lqh0jdHWCAHJNBw/c2C0Rs66F5jGIaATZHXf6ynowpOW53sVklUknh0lKteptzRSoARse gQ7VsgbgI4OP72rKk0Iaf8xakGXmhzf04HTZUwsWjQWgeXlfuQHeMwt5tTevhi5b++ve0 F+Bs2vpHjGGR1caeAO/vHOdu3hIzVxxg2zVlAaDTuphuLI7RCsMkBH967fXTjzuK+Ew== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388197; 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=JpJ2IvCccJflk8JLB0p9enTT5kq33HBgltnaSXFkwtA=; b=vLE+PswWUX4RzVM8bgjis3oUUZy5lup9IraZU0KmL3LtkPJd7Js0kIvnRdpVojPQzt9L T4UVxH+yQllhi6u14FMaQsG/oc9Db8hp29B5rUTSVGB6ydHCNZUhgak+hfAU1WMhDR8ke K2eo0IUSkf39rKylQ8xTLbrHE4msSuIfYA30fRk9iqwRtZ5zp7eK2UQocDshkmCDCKNNg 1GrEt0BAKgnxFdRCC+c1FgRKK+mnFVU5uItL2VdyyD0UtwS1NkT1e/JarkJAXpjvhoKs1 B36IRunloBEy0/CXAmZ9mfJnaZT5zRGR4Cp543yvnLgrM1T7ZufBugIddoQjeqOGZmQ== 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=MnuNa+zj; 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 BC603606A332; Fri, 4 Dec 2026 12:43:17 +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=MnuNa+zj Received: by smtp.kernel.org (Postfix) with ESMTPSA id 297421F0092C; Fri, 4 Dec 2026 12:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388197; bh=JpJ2IvCccJflk8JLB0p9enTT5kq33HBgltnaSXFkwtA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=MnuNa+zj51V5DZjDt1e/Ie/9kjGu/87T4QuK1XeDSeDUWFcxXY0bBUQdGo6yapXEE Z2SGLGifpkd4fAqNUdhAnvBVKZSk4JZsTNBELxXF1q4lrGq/5RU8Xew3GCX9X+02B+ Sc+cDSPJW2li7Mpo8VmcDQRiveK9ezZaqTDumxpc= 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.1 0521/1059] timekeeping: Read getboottime64() offsets under the sequence counter Date: Fri, 4 Dec 2026 19:00:52 +0900 Message-ID: <20261204100657.727856586@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-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); }