From nobody Wed Jun 17 04:14:28 2026 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 BFA73328B58 for ; Wed, 22 Apr 2026 09:42:51 +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=1776850973; cv=none; b=pec1JQCEQ2Xvk96ZKtmY1QUMesGrmf6NENrhdvzTW0ahAsgH6tf7wr08IOiGUVUtgbv8g49U/0WWcvUrXGJl7ItKFsmC6F1qc2AwQUlSAkpGGxkIvOQvEk5lerhQfMfh04m4OLKrDir7XO34RQcFYCrleo1w9nBPnNyaMnK1tdw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776850973; c=relaxed/simple; bh=E+cCbu8T1pYHy+cMBW/LdCgsC39zAhU1s6CU2HqV6Qs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=QdVrCDaplLxvGst5c8zPQ2U26/SaG0AF2fiiXfxBsAiWleeeLj7LAYiTxPZHI9ZWNOKoP1Y0nA5ARlxPrNjYwFfNLw2VZb3m+Gs/tXHk8pmYKBsBVaH8sZvHpIyZW4KjOrzBEu3Ma7uH4ni4w3nyeRmpGyp+C8xCjA/Z6ozmRxw= 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=VEjpohaG; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Xu4Pq+qI; 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="VEjpohaG"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Xu4Pq+qI" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1776850969; 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: content-transfer-encoding:content-transfer-encoding; bh=OAY2VijgEnAyNZTjKV1lnTEhJ07oBY8sURCW1+BAYxg=; b=VEjpohaGxqxOgnJH7iiVLcdB81hpDILfT0NCkyRBRRsmfETh5+mar7Zwd4V44cb/aCY9bp d2gIOiED4ZzXENmlEIj5Rro+Pz5rNO765kblU2JC8PSDlYQNA9L9AUARoxiNPx5YAlc94q qTHBLU2SlEL9Lf1dnao8mh9KRcMXh+7c8f87UgsEAMT/0IeapfsDXjDUcgcniUQeLGXGpc YvJT4Clm5ZaCwqLLUMPzIzZvoiJY9FS/u/rfHWzd95A/cD3Muy/ifgS7P0hrYDTimsFns/ v5O7FBeipLel6S1jwtUe+LK+kwCyBvRl2V2X1vFlCMZq69vvUi1Uk1h7dMqUAw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1776850969; 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: content-transfer-encoding:content-transfer-encoding; bh=OAY2VijgEnAyNZTjKV1lnTEhJ07oBY8sURCW1+BAYxg=; b=Xu4Pq+qIIH+GmTksTKrb91xiIb2P6G32BJdmJODKRELMv3+uPMsUP2IV83jnhA80DxP+/4 mU/xYZBOiA7Tb0AA== Date: Wed, 22 Apr 2026 11:42:32 +0200 Subject: [PATCH] vdso/gettimeofday: Reload sequence counter after switch to time page in do_aux() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260422-vdso-aux-timens-loop-v1-1-e2dd8c7164cc@linutronix.de> X-B4-Tracking: v=1; b=H4sIAAAAAAAC/x3MwQrCMAyA4VcZOS9QY/WwVxkeYhs1oG1p5iiUv bvF43f4/w4mVcVgmTpU2dU0p4HTPEF4cXoKahwGcnR1ngj3aBn523DTjyTDd84FOdyZL0z+7AV GWqo8tP236+04foZJaOpmAAAA X-Change-ID: 20260422-vdso-aux-timens-loop-acbaa5a2434e To: Andy Lutomirski , Thomas Gleixner , Vincenzo Frascino Cc: "Christophe Leroy (CS GROUP)" , linux-kernel@vger.kernel.org, Ricardo Ribalda , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1776850964; l=2022; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=E+cCbu8T1pYHy+cMBW/LdCgsC39zAhU1s6CU2HqV6Qs=; b=dkS91cK43ZjTXydUcgu4ubGVau5eDqX/tIH/pq2xVKR3XGYF2c6BrinM4h+NZKpOqmUlzC8tO qbpv/yukUF2Bd/jCDnOln0Dx58GlknEhIRIbzmZZuUSCdic6icGJAqb X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= After switching to the real data pages, the sequence counter needs to be reloaded from there. The code using vdso_read_begin_timens() assumed this worked by 'continue' jumping to the *beginning* of the do-while retry loop. However the 'continue' jumps to the *end* of said loop, evaluating the exit condition. If the data page has a sequence counter of '1' it will match the one from the time namespace page and prematurely exit the retry loop. This would result in garbage returned to the caller. Reload the sequence counter after switching the pages by using an inner while loop again, which will loop at most once. The loop generates slightly better code than an explicit reload through 'seq =3D vdso_read_begin()'. Reported-by: Ricardo Ribalda Closes: https://lore.kernel.org/lkml/CANiDSCsOy0P1if-gJZqOM5pTJ0RDcwVfru1B7= KFbTOEMqjPKJw@mail.gmail.com/ Fixes: ed78b7b2c5ae ("vdso/gettimeofday: Add a helper to read the sequence = lock of a time namespace aware clock") Signed-off-by: Thomas Wei=C3=9Fschuh Reviewed-by: Christophe Leroy (CS GROUP) Tested-by: Ricardo Ribalda --- lib/vdso/gettimeofday.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c index a5798bd26d20..da224011fafd 100644 --- a/lib/vdso/gettimeofday.c +++ b/lib/vdso/gettimeofday.c @@ -248,11 +248,10 @@ bool do_aux(const struct vdso_time_data *vd, clockid_= t clock, struct __kernel_ti vc =3D &vd->aux_clock_data[idx]; =20 do { - if (vdso_read_begin_timens(vc, &seq)) { + while (vdso_read_begin_timens(vc, &seq)) { + /* Re-read from the real time data page, reload seq by looping */ vd =3D __arch_get_vdso_u_timens_data(vd); vc =3D &vd->aux_clock_data[idx]; - /* Re-read from the real time data page */ - continue; } =20 /* Auxclock disabled? */ --- base-commit: aa70a22882fe51fadd2392b480864d15e1b9ab3d change-id: 20260422-vdso-aux-timens-loop-acbaa5a2434e Best regards, -- =20 Thomas Wei=C3=9Fschuh