From mboxrd@z Thu Jan 1 00:00:00 1970 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 EA326381B07 for ; Tue, 2 Jun 2026 09:46:53 +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=1780393615; cv=none; b=lNdxB+KDEzw0jUtd1UbFdAayS3HXuibjsKtIqcgKQpApJYsS0gRD5ao+sIYiFd2LCIO4zoeDEfQ1gZfB5bQQ6j1wJGDcOm2nu2vvX0LAcZ5tpHOz0Ie2Nc69Zl4jr4llFNwdbymvoQlTf1envjygAQ7+bHUQ6QPbKL0Q5PSDFVI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780393615; c=relaxed/simple; bh=Spn2Edl4ufnO1Dx72jLJ/JelgZJmMeIrUgZdFqMLTG8=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=ddg/Y5U//n74QAWac0TLUqiP4vTM07LhT7yRrHl0qcw/58MVN/WmkZSvmCdKF/vL0eter6KnQS/+q+JOF3v5rWmXoCIM+3HNPMWqaICJ79v+oUdugMbAS0JSdsATbWjh8qcYhHOzpgxpLAe8qHrkQD6rhpYXVsom8AvunO4e/xY= 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=tDS1kg3j; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=STHzglpi; 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="tDS1kg3j"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="STHzglpi" From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1780393612; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=JgRVa+5QTJJrPCqEOlKquXaCXUyiEeucayB+aCXZ/MY=; b=tDS1kg3j/oQVe/C822LdJ8ihcxa4IES0Bhc+F7dUw9FRYTRb61Lc3+BOx9U7eW8JhJ7c7e 57y+2XDhod1/XwV9U1y/DcnZULXm51U2ORO1RVCMzLBXYQn488C3ad1/ju3Y/+aID+ZPPt U244A2H2VgEbVZavigMBRmUD+zn804iVvPiS/fHgXpMXUk669xswh2F6LS6wfmWmjlhDiY I/dGaSNF4sNwtxk5KGsKqugHXJstV+5C5Q/3YYMa2RTILV1mrlW0kzPWeK8HUX6lrlwvEL cGXTD49oUcsjXBSN8SeZaxD1GonVXumSmXDVz5d4SZQOSshA0YJxRfGmr+bU3g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1780393612; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=JgRVa+5QTJJrPCqEOlKquXaCXUyiEeucayB+aCXZ/MY=; b=STHzglpi7Fy//vvMWSDSjG7slgNHypTzHw2ggYFPJJriD7B7ZsuWkREmQT7fcGiIR/SuXW jHEK5a3v0eMoaGBQ== To: Dennis Moshegov , john.stultz@linaro.org Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH] timekeeping: Use data_race() and READ_ONCE() in ktime_get_real_seconds() In-Reply-To: References: Date: Tue, 02 Jun 2026 11:46:51 +0200 Message-ID: <874ijl8eb8.ffs@fw13> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Sat, May 30 2026 at 18:38, Dennis Moshegov wrote: > From: Dennis Moshegov > Subject: [PATCH] timekeeping: Use data_race() and READ_ONCE() in > ktime_get_real_seconds() > > On 64-bit architectures, ktime_get_real_seconds() directly returns > tk_core.timekeeper.xtime_sec without acquiring a seqlock. This lockless > read is an intentional design choice optimized for ultra-fast, > approximate timestamping paths where a minor 1-second discrepancy is > acceptable. > > However, Kernel Concurrency Sanitizer (KCSAN) flags a data race here > because the timekeeper structure is updated concurrently via a bulk > structure copy inside timekeeping_update_from_shadow() during timer > interrupts. > > Since the 64-bit read is naturally aligned and atomic at the hardware > level, this data race is benign and does not cause data tearing. > Annotate the read path using data_race() combined with READ_ONCE() to > prevent compiler optimization anomalies and suppress the KCSAN warning. > > Reported-by: syzbot+72789cd1697965e714ca@syzkaller.appspotmail.com > Closes: https://syzkaller.appspotmail.com/bug?extid=72789cd1697965e714ca > Assisted-by: Gemini:3.5-flash > Signed-off-by: Dennis Moshegov > --- > kernel/time/timekeeping.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c > index 4fd3c70c1..b2e5a87da 100644 > --- a/kernel/time/timekeeping.c > +++ b/kernel/time/timekeeping.c > @@ -1153,7 +1153,7 @@ time64_t ktime_get_real_seconds(void) > time64_t ktime_get_real_seconds(void) > { > #if BITS_PER_LONG == 64 > - return tk_core.timekeeper.xtime_sec; > + return data_race(READ_ONCE(tk_core.timekeeper.xtime_sec)); Where is the corresponding WRITE_ONCE() and what guarantees that the memcpy(), which updates the timekeeper, will not result in a copy with a smaller granularity? Just suppressing the warning w/o validating that there is no way for store tearing to happen is not cutting it. Tell your AI buddy to make his homework. Thanks, tglx