From: Hang Nan <2122295973@qq.com>
To: netdev@vger.kernel.org
Cc: mptcp@lists.linux.dev, matttbe@kernel.org, martineau@kernel.org,
geliang@kernel.org, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
kuniyu@google.com, willemb@google.com,
linux-kernel@vger.kernel.org, Hang Nan <2122295973@qq.com>
Subject: [PATCH net 0/2] net: restore acquire ordering for two remaining lockless lookups
Date: Thu, 12 Nov 2026 20:45:45 +0800 [thread overview]
Message-ID: <tencent_AFD2C75757FA5BD9D0C583FD1FB1C2133206@qq.com> (raw)
Hello,
commit 5b5d8f351dd9 ("net: restore refcount ordering for lockless socket access")
restored the acquire ordering that refcount_inc_not_zero() lost in the
2019 refcount_t consolidation fb041bb7c0a9, for the IPv4/IPv6
established lookups, inet_twsk_purge() and bpf_sk_assign().
The requirement is not the reference itself, but the second validation
that follows it: when a lookup takes a reference and then re-reads state
that the teardown path mutates, that re-read must not be reordered before
the acquisition, otherwise the lookup can hand back an object whose state
has already been cleared.
Two sites of that exact shape are left in net/. Both are one-line
changes and neither alters behaviour on strongly ordered CPUs:
net/mptcp/token.c mptcp_token_get_sock() re-reads msk->token
after taking the reference, while
mptcp_token_destroy() clears it with
WRITE_ONCE(msk->token, 0). The lookup is
driven by an inbound MP_JOIN SYN, so it is
remotely reachable on a listener with MPTCP
enabled. mptcp_token_iter_next() has the same
shape.
net/core/sock_reuseport.c reuseport_migrate_sock() hands a listener to
tcp_filter()/tcp_check_req(), which read its
fields immediately.
Both are converted to refcount_inc_not_zero_acquire().
For completeness: the other 90 refcount_inc_not_zero() sites in net/ are
either protected by an RCU section across the uses, or take the
reference only to pin the object alive and do not re-validate any field
afterwards (l2tp, nf_conntrack, cls_flower, tipc crypto...). The two
conntrack lookups that do re-validate already call
smp_acquire__after_ctrl_dep() explicitly.
This is an ordering fix, not a fix for an observed crash: I do not have a
syzbot report for either site, and on x86-64 the reordering is not
observable. Reviewers should treat it as making the existing
re-validation meaningful on weakly ordered CPUs, in line with the
accepted change above.
Hang Nan (2):
net: mptcp: take token lookup references with acquire ordering
net: core: take the reuseport migration reference with acquire ordering
net/core/sock_reuseport.c | 3 ++-
net/mptcp/token.c | 4 ++--
2 files changed, 4 insertions(+), 3 deletions(-)
--
2.53.0
reply other threads:[~2026-11-12 12:46 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=tencent_AFD2C75757FA5BD9D0C583FD1FB1C2133206@qq.com \
--to=2122295973@qq.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=geliang@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=martineau@kernel.org \
--cc=matttbe@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=willemb@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®