Article View: linux.kernel.netdev
Article #12023Re: [PATCH net] net: protect negative destination advice with RCU
From: Jiayuan Chen
Date: Fri, 06 Nov 2026 06:15
Date: Fri, 06 Nov 2026 06:15
52 lines
10077 bytes
10077 bytes
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)
Technical Details
Message-ID:
<e0f76fe6-dc65-4053-b949-b34d90adbf5d@linux.dev>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-357778-linux-kernel-netdev=dewy.ruReferences:
<20261104131744.1056562-1-edumazet@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-357778-linux-kernel-netdev=dewy.ru From: jiayuan.chen@linux.dev (Jiayuan Chen) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] net: protect negative destination advice with RCU Date: Fri, 6 Nov 2026 14:15:56 +0800 Organization: Usenet Network Message-ID: <e0f76fe6-dc65-4053-b949-b34d90adbf5d@linux.dev> References: <20261104131744.1056562-1-edumazet@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="3807882"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:2xmC6GQIHnf5xWCs5VD4uL+IjoU= sha256:JCfqL3fy2zG7yMVNdWiIbPy0itMP+47kI4ExK6eRw2M= sha1:vOdZ8fLgbvM3WACmsbZrBIr165I= sha256:+5A5fI9DCvkf1yHk2S8dpMUy8r1Vuqc1oNoHCHl6zzc= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 0843C113179; Fri, 6 Nov 2026 09:19:30 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.051 X-Spam-Status: No, score=-2.051 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, HK_RANDOM_FROM=1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=linux.dev X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BEj6UX8KuTAy; Fri, 6 Nov 2026 09:19:26 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-357778-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id 05CB3113176; Fri, 6 Nov 2026 09:19:17 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id AE78D26C3F; Fri, 6 Nov 2026 06:16:17 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1793945773; b=a7sLKB6pBee2WQxgDxhtOQFdvLWxcbhpeKbls0ibstqnqKXuTdLeLB+StGqijBvN7FT7 EzZxoX/S/SYk5UcMh/zW0rh5RO3RIgCiPIPBoii4BZT18O+w4D689SBb//RTbPxroIZN7 mNaXy1nPocEU8MxRCexK9VT2yLWScLtSOUzx81/hrYOfeu3RtS5JVw2dZ5xRIMceRII4N 1eIOz04ZkN16SbboqU1/cWKXXCB45hdkHTOTrCudQFnbSA3hlQhnyyueMfIIknJZh9voC 3mNYf6oW0/Hm8lCh5lh/JchivRktUApK5c3YiZRzZTtydVWu9g/LE90+Bz9zybys6IQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793945773; h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature: X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:User-Agent: Subject:To:Cc:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=QkdmBPlNQnGu105wggpDIUpINN7JTcBrIEM5l8eU7vE=; b=oZJ7T50dpUOqwNU7MgFzvPoBv/NDw4Wa9B31c5IKkT4VmUgALgm4YqAXyZyZDLa+YSZT j7OXmPafA97UuCclqxOEiqj1p78B1CksYfU+d3VDKoobJz2UHJTxLaV51o5Qf10OXQzPA z7cG9Tc7J/6p4nMLr5bz0evGXjazN3YiQvSb8m3fLyL1TdQyP+unSn/xRjvvFBnuuuhZW TOcq4rMtU1hguqYXVRL1Vvui5RB3Z7sag4vyWX6IqthLoOI8XTcVlDvXyn24o6Zggfu7i l3am95oSKXBmcogKhfwDooUJLF4P5br4a9IQMMt7D9dEIG8FoT6fOtQvSSB3pwADNPg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=WN+AaxYC; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8A741606A334; Fri, 6 Nov 2026 06:16:13 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=WN+AaxYC X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.83 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793945772; b=2GnUWa885/Hgpw//fpb9/WlrbLCONWr16jVepWHrqoiTfQqFNKsiq3X4SzHu0//KEE/W wGSVtQrkeZnZi75OyTGCQCdPfLWifcdPLAZ3EtjfafEmSwYkUcyJDye5WjBH+Cih4LAhP xJ34xTIWaYwV0C2LThWJ+XhWZ9SaICkOIeAZzM9ywEXljsu7Omb2tEMOgNuISCyPRZUrJ l0jeFgVsHtkHfJPYhXGkbkhGj4/h1aL+ecfyN+J4QBUndU2Y3LyN+K5zV21KRAbkNw4u4 lhWj305W6IgzOOLiHnaa/Q6dLdc8LhUFJoTzPdGFK5q6sBvrd7hwldHjcYqfKvS3lNQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793945772; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=QkdmBPlNQnGu105wggpDIUpINN7JTcBrIEM5l8eU7vE=; b=y1lTIq3STgSCVV4fk/K4Yaygczb0LgEnzNrcD+AGwoipVIxXOGR9QI6KN0MXw6p4xDn/ FHsgHiXttGC6cnSD/rY3sZoXesjdEWIVdxDOplvM7FGHo4lnbZdtB1vppUf2Yf1ii8UbI +Ok8e6aiVneEQG5yX3X+eESAPYXBOHFTRnsJkAr1FFOzhBEUbVE59gKJI0+rcL+ldCzT3 EsqwqYiT4CrMDYaX7ELqkkv0AWo7INowgSBmfKUeTFtmicOoVHuzTKNtZM6dCQL6a+CwB f5Cs8/Rjjz1ZorNk+SpCZMbt3E5iKvrkTcAHK4UzfzjUgYLy9BN7zFH67QEIW1R3RjA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=WN+AaxYC; arc=none smtp.remote-ip=95.215.58.83 X-Received: from mta1.migadu.com (out-83.mta1.migadu.com [95.215.58.83]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EFBB3606A328 for <netdev@vger.kernel.org>; Fri, 6 Nov 2026 06:16:11 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EFBB3606A328 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Envelope-To: netdev@vger.kernel.org X-DKIM-Signature: a=rsa-sha256; bh=0SyDJ5tj5ftKMDHZLP0MehFmcA6JD/wW/tkhPu9aV8M=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1793945770; v=1; x=1794550570; b=WN+AaxYCgfkarFaymWhLI7abi+6MLVriGz67Sr6FSM3pi7CqkvtgVdUxjnE1UVZDdx+GapAL 8KGR78Y1Xmiz2mDhrtd1ejsVThNux5S9dBjedwD+NfDNSy2e/ze23gJyHhGtgZi12CCZ0BsU/+e PIQWopAdx98UF6UElahndwgc= X-Envelope-To: netdev@vger.kernel.org X-Received: by smtp.migadu.com with ESMTPS id 1b0a039608d9a9ea; Fri, 06 Nov 2026 06:16:09 +0000 X-Mizu-Trace-ID: 1b0a039608d9a9ea X-Migadu-Flow: FLOW_OUT X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-User-Agent: Mozilla Thunderbird X-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> X-In-Reply-To: <20261104131744.1056562-1-edumazet@kernel.org>