All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Hang Nan" <2122295973@qq.com>
Cc: mptcp@lists.linux.dev
Subject: Re: [PATCH net v3 2/4] net: core: take the reuseport migration reference with acquire ordering
Date: Sun, 15 Nov 2026 13:09:56 +0000	[thread overview]
Message-ID: <sashiko-outbox-215514@kernel.org> (raw)
In-Reply-To: <tencent_BF4B5FE9E95165CF1734F65EC40D4FEB4808@qq.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] net: unnecessary refcount_inc_not_zero_acquire() in
  reuseport_migrate_sock()
--

commit 451ae80ccee42826773bf0a6549978307e27e9aa
Author: Hang Nan <2122295973@qq.com>

net: core: take the reuseport migration reference with acquire ordering

This commit switches reuseport_migrate_sock() from refcount_inc_not_zero()
to refcount_inc_not_zero_acquire() when taking a reference on the selected
listener socket.

> diff --git a/net/core/sock_reuseport.c b/net/core/sock_reuseport.c
> index b9e5648fa4c51..56230aa55a3e2 100644
> --- a/net/core/sock_reuseport.c
> +++ b/net/core/sock_reuseport.c
> @@ -667,7 +667,8 @@ struct sock *reuseport_migrate_sock(struct sock *sk,
>  	if (!nsk)
>  		nsk = reuseport_select_sock_by_hash(reuse, hash, socks);
>  
> -	if (IS_ERR_OR_NULL(nsk) || unlikely(!refcount_inc_not_zero(&nsk->sk_refcnt))) {
> +	if (IS_ERR_OR_NULL(nsk) ||
> +	    unlikely(!refcount_inc_not_zero_acquire(&nsk->sk_refcnt))) {
>  		nsk = NULL;
>  		goto failure;
>  	}

[Severity: Low]
Is refcount_inc_not_zero_acquire() needed here?

Listener teardown in __tcp_close() and tcp_disconnect() sets sk->sk_state
to TCP_CLOSE and runs inet_csk_listen_stop() while sk->sk_refcnt is still
non-zero, before the final sock_put().  An acquire barrier on
nsk->sk_refcnt only prevents reordering subsequent reads to before the
increment (which would observe older, pre-teardown state rather than
half-torn-down state), and does not serialize against concurrent listener
teardown; callers instead recheck sk->sk_state != TCP_LISTEN under
queue->rskq_lock in inet_csk_reqsk_queue_add().

Unlike the SLAB_TYPESAFE_BY_RCU lookups updated in 5b5d8f351dd9 ("net:
restore refcount ordering for lockless socket access"), sockets in a
reuseport group are freed via call_rcu() in sk_destruct() and cannot be
reallocated during the rcu_read_lock() section in reuseport_migrate_sock(),
nor does reuseport_migrate_sock() perform post-refcount validation checks
that need to be ordered after taking the reference.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/tencent_CCBF2706A4D1AFF8F48632FE8B56FB67E207@qq.com?part=2

  reply	other threads:[~2026-11-15 13:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20261114130927.91839-1-2122295973@qq.com>
2026-11-14 13:09 ` [PATCH net v3 1/4] net: mptcp: take token lookup references with acquire ordering Hang Nan
2026-11-14 13:09 ` [PATCH net v3 2/4] net: core: take the reuseport migration reference " Hang Nan
2026-11-15 13:09   ` sashiko-bot [this message]
2026-11-14 13:09 ` [PATCH net v3 3/4] net: mptcp: reject token 0 in mptcp_token_get_sock() Hang Nan
2026-11-14 13:09 ` [PATCH net v3 4/4] net: mptcp: verify the token slot in mptcp_token_iter_next() Hang Nan

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-215514@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=2122295973@qq.com \
    --cc=mptcp@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.