From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 EABE03CD8A6 for ; Wed, 22 Apr 2026 09:49:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776851374; cv=none; b=c/+fUVXUjb2UqR+KKDVEmZgObY2W9vqZwFuX2KY4GApSL23lufdH+Q5SH8Grxu1m7YWulbcjG9aZRedSvqioNNlxOFsnfwR/YfKnJDbWsZss51U/tdy+AImQmz1ZOGJL3MfZGIh42q5X56Y+hVTFzxlEvv7Bbo8fafzUK3xfFV4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776851374; c=relaxed/simple; bh=9+s1mh465oEZvvCq97Guj21szuiKdrYoDRnK3592lrE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=JZaRcdWKFygAT2y37vkW5Zp6UzGU7YmrJihVoRLLBmrmkTC+U+jQGJOr9OnXC4RPJb7Jm3QeBGAe26knr/rel69Gh4WsXdNspupt2gz0yFdclK4e/3Xtae7WtvE330JTNURInncOF4i6fBtPlx2btTCMnAB2tKlnfkb1wov+Jrc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=h2AW2NfH; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="h2AW2NfH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43AE3C2BCB3; Wed, 22 Apr 2026 09:49:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776851373; bh=9+s1mh465oEZvvCq97Guj21szuiKdrYoDRnK3592lrE=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=h2AW2NfHPXZzAmb3OreiiGTEe7gA+V45BUa2ANp44h8SfFs4WXfApYIhLSf+lul8a nJrqpH7Dacu+sH9WFxNAKSKMy+wqb8Mud8saN88ttVakNu/lJIDADULvAnydyFR9fA ow8yHwy9ilNakcUjVHj9gvzeN1jNTb/gXQ7tU2k9CzCbTJyJ842P5RLlROm5Kz+YBE dG6LOP750VY/MRnqoKqa/9Y66JZy+MHwX4PgHtje41Q7GXUrLxgEr1QnQl+S5j1Ruf +faJlm7Zjvm721ekjHtCcrshRTAW+l4H1b5MjxTDeUqkk9pH8b1O+XzAlevtfz9qNr VPKkvMMPI9uEg== Message-ID: <55b5cab2-2752-4c00-8de5-9a0492284414@kernel.org> Date: Wed, 22 Apr 2026 11:49:30 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] vdso/gettimeofday: Reload sequence counter after switch to time page in do_aux() To: =?UTF-8?Q?Thomas_Wei=C3=9Fschuh?= , Andy Lutomirski , Thomas Gleixner , Vincenzo Frascino Cc: linux-kernel@vger.kernel.org, Ricardo Ribalda References: <20260422-vdso-aux-timens-loop-v1-1-e2dd8c7164cc@linutronix.de> Content-Language: fr-FR From: "Christophe Leroy (CS GROUP)" In-Reply-To: <20260422-vdso-aux-timens-loop-v1-1-e2dd8c7164cc@linutronix.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Le 22/04/2026 à 11:42, Thomas Weißschuh a écrit : > 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 = vdso_read_begin()'. > > Reported-by: Ricardo Ribalda > Closes: https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Flkml%2FCANiDSCsOy0P1if-gJZqOM5pTJ0RDcwVfru1B7KFbTOEMqjPKJw%40mail.gmail.com%2F&data=05%7C02%7Cchristophe.leroy%40csgroup.eu%7C8090d715bf644286a5e908dea0538801%7C8b87af7d86474dc78df45f69a2011bb5%7C0%7C0%7C639124477796711565%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=yQti2tvfaExxkn%2BoD7wzPhAkFTYQ7Sr%2FV3e3fRdJYVY%3D&reserved=0 > Fixes: ed78b7b2c5ae ("vdso/gettimeofday: Add a helper to read the sequence lock of a time namespace aware clock") > Signed-off-by: Thomas Weißschuh Reviewed-by: Christophe Leroy (CS GROUP) > --- > 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 = &vd->aux_clock_data[idx]; > > 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 = __arch_get_vdso_u_timens_data(vd); > vc = &vd->aux_clock_data[idx]; > - /* Re-read from the real time data page */ > - continue; > } > > /* Auxclock disabled? */ > > --- > base-commit: aa70a22882fe51fadd2392b480864d15e1b9ab3d > change-id: 20260422-vdso-aux-timens-loop-acbaa5a2434e > > Best regards, > -- > Thomas Weißschuh >