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 6F86640D572 for ; Sun, 21 Jun 2026 13:17:03 +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=1782047824; cv=none; b=TxPja8R5FHMIdunK0UdOCHak2MB7mV6pRb2M22kBPgDkuFNqz4U2C4P6Mx5YtCZ+xvN1TjymQUJpUnJEmmR6ONeTWkncP6WrxaJnNb/I2+KkVLE/hrCxmFN7OdQ0K9YKjhTrzzLm3LXvjb5JAC1P50/BQxI7XNgA0/51FguIAdU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782047824; c=relaxed/simple; bh=dJbPRKzN7qn/5iOvm4wOKluKfGkDu2dFuCmSj+K8Xfs=; h=From:To:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=b1OfQMYMbWsevs71MfXblMRWCKTrOFdtlrwo0n30rlICd5CiuDrqvGygCShRE4P42EiBlg5u5hakXJQR6VPwDlzubs3t1EPZOFbSfOy4LkQdEv1l8nyWAgsysidqqHMoJD1B4nwIuRvM8DE/xd7FjUd/SXBKwGG7Mf7kLlcrvus= 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=SOCk2Qxs; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=e4XwdBDU; 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="SOCk2Qxs"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="e4XwdBDU" From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1782047821; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=GF94bL6vaAEXEabvFh+xwPNBKABx2LwgunyT6XVIEJY=; b=SOCk2QxsqJM6C56quVVz3gfvGU1/15UHlD31qgAbWRoR5jcY1iXXqjkSOka3qvQGUuJUlj Y6SHyLuQnb1htdksiJCIwtewOiKiX2NpBI7mZjXgt5hg7YJXpBaNU3UtCjsAdneEuJ97wz o3LjYrToXSFw4a85abKGLi8Fd/MEwvHpj4bBaOGlvwbw3wS+pMIZD1qzEzxVX8LJOvu8cN +693JQv8O8tJqEzvDbTwdXBPN9tP7SU4cvior1GA/TNnoJl95JI/7UsNPUTxOSQjklet4d J0K/XrHWEm52Onw7P8iX690SIexWl2jGsg6k5gcT998iHsgDT+98lLeBLWi4Nw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1782047821; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=GF94bL6vaAEXEabvFh+xwPNBKABx2LwgunyT6XVIEJY=; b=e4XwdBDUljc1YTQ1pDZF96Jki2eTfbXELIeLa0K330qKo1x6pO1295c8nl8BPZG5CfexOj 0aDAUzqMAV4gc9Aw== To: Dennis Moshegov , linux-kernel@vger.kernel.org Subject: Re: [PATCH] timekeeping: Use data_race() and READ_ONCE() in ktime_get_real_seconds() In-Reply-To: References: <874ijl8eb8.ffs@fw13> <871peo9485.ffs@fw13> Date: Sun, 21 Jun 2026 15:17:00 +0200 Message-ID: <87a4som3sj.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 Tue, Jun 16 2026 at 10:11, Dennis Moshegov wrote: > From: Dennis M > Subject: [PATCH v2] timekeeping: Use READ_ONCE/WRITE_ONCE for > xtime_sec to prevent tearing > > The timekeeper update path uses a bulk memcpy() to > synchronize the timekeeper structure, which is not guaranteed to be atomic. > This allows for torn reads in ktime_get_real_seconds() on 64-bit systems, > where the sequence counter protection is bypassed for performance. > > To prevent reading a torn 64-bit xtime_sec value, enforce atomic-like > access by using WRITE_ONCE() for the critical field before the bulk > memcpy() in timekeeping_update_from_shadow(). Correspondingly, use > READ_ONCE() in ktime_get_real_seconds() to ensure a fresh, consistent > load from memory. > > Reported-by: syzbot+72789cd1697965e714ca@syzkaller.appspotmail.com > Closes: https://syzkaller.appspotmail.com/bug?extid=72789cd1697965e714ca > Signed-off-by: Dennis Moshegov > --- > timekeeping.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/timekeeping.c b/timekeeping.c > index c493a40..461a68e 100644 > --- a/timekeeping.c > +++ b/timekeeping.c You need to create the patch in the top level directory so that this becomes a/kernel/time/timekeeping.c > @@ -826,6 +826,7 @@ static void timekeeping_update_from_shadow(struct > tk_data *tkd, unsigned int act There is a line break after 'struct', which makes the patch malformed and it can't be applied as is. Thanks, tglx