From: sashiko-bot@kernel.org
To: "Zhenwen Liang" <zhenwenliang@google.com>, bpf@vger.kernel.org
Subject: Re: [PATCH bpf] bpf: Order map writecnt against frozen for read-only maps
Date: Sat, 05 Dec 2026 21:03:05 +0000 [thread overview]
Message-ID: <sashiko-outbox-251899@kernel.org> (raw)
In-Reply-To: <20261205204758.954959-1-zhenwenliang@google.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] bpf: inaccurate commit message claim that RWC race needs both
reorderings
--
commit ac10bb0a7f54106e48572a1161df774277051ed1
Author: Zhenwen Liang <zhenwenliang@google.com>
bpf: Order map writecnt against frozen for read-only maps
This commit adds smp_mb__after_atomic() to bpf_map_write_active_inc() and
smp_mb() to bpf_map_is_rdonly() to order accesses to map->writecnt and
map->frozen on weakly ordered architectures.
Link: https://lore.kernel.org/all/20260707195600.5C2851F000E9@smtp.kernel.org/ [1]
> guaranteed to be exactly the same at a later point when the program is
> executed". It needs both reorderings at once and was not reproduced.
[Severity: Low]
Is it accurate that this race requires both reorderings at once?
With three CPUs (updater, freezer, verifier), either reordering alone lets
the updater see frozen == false while the verifier sees frozen == true and
writecnt == 0. For example, if only bpf_map_is_rdonly() reorders its
reads while the updater executes in program order:
CPU0 (updater) CPU1 (freezer) CPU2 (verifier)
read writecnt == 0 (reordered)
writecnt = 1
smp_mb__after_atomic()
read frozen == false
frozen = true
read frozen == true
Symmetrically, if only the updater reorders reading frozen before
incrementing writecnt, the same outcome occurs even with smp_mb() in
bpf_map_is_rdonly().
Because either reordering alone triggers the race, both barriers are
strictly needed; saying both reorderings are required could mislead
readers into thinking a single barrier on the updater side is enough for
other readers such as bpf_prog_verify_signature().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261205204758.954959-1-zhenwenliang@google.com?part=1
prev parent reply other threads:[~2026-12-05 21:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 20:47 [PATCH bpf] bpf: Order map writecnt against frozen for read-only maps Zhenwen Liang
2026-12-05 21:03 ` sashiko-bot [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=sashiko-outbox-251899@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=zhenwenliang@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.