From: no-reply@sashiko.virtuozzo.com
To: Eva Kurchatova <eva.kurchatova@virtuozzo.com>, khorenko@virtuozzo.com
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.1 4/4] timens: freeze the offsets on the first join without the vDSO too
Date: Fri, 9 Oct 2026 14:06:12 +0000 [thread overview]
Message-ID: <010701a120fc5f3a-a034c724-bc8c-4671-a83e-f5f305870fa3-000000@eu-central-1.amazonses.com> (raw)
In-Reply-To: <20261009135929.3274885-5-eva.kurchatova@virtuozzo.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] timens: lockless frozen_offsets fast path lacks acquire/release ordering
--
commit 0c3eee5060109c37a2e00993e54d077407012d3c
Author: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
timens: freeze the offsets on the first join without the vDSO too
This moves the freezing of a time namespace's offsets out of the vDSO
page setup code and into timens_commit(), so that kernels without a
generic vDSO also freeze the offsets on the first task join. The vDSO
page is now filled from the same place, where one exists.
Link: https://virtuozzo.atlassian.net/browse/VSTOR-148112
> diff --git a/kernel/time/namespace.c b/kernel/time/namespace.c
> --- a/kernel/time/namespace.c
> +++ b/kernel/time/namespace.c
[ ... ]
> +static void timens_freeze_offsets(struct time_namespace *ns)
> +{
> + if (ns == &init_time_ns)
> + return;
> +
> + /* Fast-path, taken by every task in namespace except the first. */
> + if (likely(ns->frozen_offsets))
> + return;
> +
> + guard(mutex)(&timens_offset_lock);
> + if (ns->frozen_offsets)
> + return;
> +
> + timens_vdso_setup_vvar_page(ns);
> + ns->frozen_offsets = true;
> +}
[Severity: Low]
Is the lockless fast path in timens_freeze_offsets() ordered against the
vvar page setup on weakly ordered CPUs?
The first joiner runs timens_vdso_setup_vvar_page() and then publishes the
flag with a plain store:
timens_vdso_setup_vvar_page(ns);
ns->frozen_offsets = true;
A second task joining the same namespace (via timens_on_fork() or
commit_nsset()) reads the flag without taking the mutex:
if (likely(ns->frozen_offsets))
return;
Neither side has release/acquire semantics. On arm64, powerpc or riscv,
could the second task observe frozen_offsets == true before the stores done
in timens_vdso_setup_vvar_page() (seq, clock_mode and the offsets set up by
timens_setup_vdso_clock_data()) are visible to it?
If so, that task would go on to read an un-namespaced or zeroed vvar page,
and its clocks would be wrong. This would be wrong output rather than
memory corruption. The window is very small and incidental
synchronisation, such as passing the namespace reference between tasks,
probably hides it in practice, so this may be speculative.
Would it make sense to use smp_store_release(&ns->frozen_offsets, true) for
the publication and smp_load_acquire(&ns->frozen_offsets) on the fast path?
> diff --git a/kernel/time/namespace_vdso.c b/kernel/time/namespace_vdso.c
> --- a/kernel/time/namespace_vdso.c
> +++ b/kernel/time/namespace_vdso.c
[ ... ]
> +/* Called once per namespace, under timens_offset_lock, before any task reads */
> +void timens_vdso_setup_vvar_page(struct time_namespace *ns)
> {
> + struct vdso_time_data *vdata = page_address(ns->vvar_page);
> + struct vdso_clock *vc = vdata->clock_data;
> unsigned int i;
>
> for (i = 0; i < CS_BASES; i++)
> timens_setup_vdso_clock_data(&vc[i], ns);
> }
[Severity: Low]
These are the plain stores to the shared vvar page that must be visible to
any task that sees frozen_offsets set through the lockless fast path in
timens_freeze_offsets(), as described above.
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261009135929.3274885-1-eva.kurchatova@virtuozzo.com?part=4
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
prev parent reply other threads:[~2026-10-09 14:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 13:58 [Devel] [PATCH hci-8.1 0/4] timens: Remove dependency on the vDSO Eva Kurchatova
2026-10-09 13:58 ` [Devel] [PATCH hci-8.1 1/4] ms/vdso: Drop Kconfig GENERIC_VDSO_TIME_NS Eva Kurchatova
2026-10-09 14:04 ` no-reply
2026-10-09 13:58 ` [Devel] [PATCH hci-8.1 2/4] ms/vdso/timens: Move functions to new file Eva Kurchatova
2026-10-09 14:03 ` no-reply
2026-10-09 13:58 ` [Devel] [PATCH hci-8.1 3/4] ms/timens: Remove dependency on the vDSO Eva Kurchatova
2026-10-09 14:06 ` no-reply
2026-10-09 13:58 ` [Devel] [PATCH hci-8.1 4/4] timens: freeze the offsets on the first join without the vDSO too Eva Kurchatova
2026-10-09 14:06 ` no-reply [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=010701a120fc5f3a-a034c724-bc8c-4671-a83e-f5f305870fa3-000000@eu-central-1.amazonses.com \
--to=no-reply@sashiko.virtuozzo.com \
--cc=devel@openvz.org \
--cc=eva.kurchatova@virtuozzo.com \
--cc=khorenko@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox