All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiayuan Chen <jiayuan.chen@linux.dev>
To: Eric Dumazet <edumazet@kernel.org>,
	"David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Kuniyuki Iwashima <kuniyu@google.com>,
	Willem de Bruijn <willemb@google.com>,
	Simon Horman <horms@kernel.org>,
	netdev@vger.kernel.org, Kyle Zeng <kylebot@openai.com>
Subject: Re: [PATCH net] net: protect negative destination advice with RCU
Date: Fri, 6 Nov 2026 14:15:56 +0800	[thread overview]
Message-ID: <e0f76fe6-dc65-4053-b949-b34d90adbf5d@linux.dev> (raw)
In-Reply-To: <20261104131744.1056562-1-edumazet@kernel.org>


On 11/4/26 9:17 PM, Eric Dumazet wrote:
> From: Kyle Zeng <kylebot@openai.com>
>
> SO_CNX_ADVICE calls __dst_negative_advice() while holding the socket
> lock. Connected UDP sends can still invalidate or replace sk_dst_cache
> without that lock. A concurrent sk_dst_check() can drop the final
> destination reference and allow an RCU callback to destroy it while
> __dst_negative_advice() retains only a borrowed pointer. This can cause
> a use-after-free while accessing dst->ops or running the negative_advice
> callback.
>
> The writer-side ordering fixed by commit 92f1655aa2b2 ("net: fix
> __dst_negative_advice() race") does not protect this reader from an
> independent cache replacement.
>
> Hold an RCU read-side critical section across the lookup and callback.
> This follows the datagram release callbacks and covers IPv4, IPv6, and
> XFRM advice without changing cache-reset or reference-ownership rules.
>
> Fixes: a87cb3e48ee8 ("net: Facility to report route quality of connected sockets")
> Signed-off-by: Kyle Zeng <kylebot@openai.com>
> Signed-off-by: Eric Dumazet <edumazet@kernel.org>


Reviewed-by: Jiayuan Chen <jiayuan.chen@linux.dev>


> ---
>  include/net/sock.h | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/include/net/sock.h b/include/net/sock.h
> index 173b37b2b8bb..0c1a6895d347 100644
> --- a/include/net/sock.h
> +++ b/include/net/sock.h
> @@ -2218,10 +2218,13 @@ sk_dst_get(const struct sock *sk)
>  
>  static inline void __dst_negative_advice(struct sock *sk)
>  {
> -	struct dst_entry *dst = __sk_dst_get(sk);
> +	struct dst_entry *dst;
>  
> +	rcu_read_lock();
> +	dst = __sk_dst_get(sk);
>  	if (dst && dst->ops->negative_advice)
>  		dst->ops->negative_advice(sk, dst);
> +	rcu_read_unlock();
>  }
>  
>  static inline void dst_negative_advice(struct sock *sk)

  parent reply	other threads:[~2026-11-06  6:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04 13:17 [PATCH net] net: protect negative destination advice with RCU Eric Dumazet
2026-11-04 13:23 ` netdev-bot+sinfo
2026-11-05 20:35 ` Kuniyuki Iwashima
2026-11-06  6:15 ` Jiayuan Chen [this message]
2026-11-10  2:54 ` patchwork-bot+netdevbpf

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=e0f76fe6-dc65-4053-b949-b34d90adbf5d@linux.dev \
    --to=jiayuan.chen@linux.dev \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=kylebot@openai.com \
    --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 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.