public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Lee Jones <lee@kernel.org>
Cc: stable@vger.kernel.org, Eric Dumazet <edumazet@google.com>,
	Clement Lecigne <clecigne@google.com>,
	Tom Herbert <tom@herbertland.com>,
	David Ahern <dsahern@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>
Subject: Re: [PATCH v2 4.19.y 1/1] net: fix __dst_negative_advice() race
Date: Thu, 13 Jun 2024 10:32:03 +0200	[thread overview]
Message-ID: <2024061354-endanger-earthworm-592e@gregkh> (raw)
In-Reply-To: <20240613081254.2492021-1-lee@kernel.org>

On Thu, Jun 13, 2024 at 09:12:44AM +0100, Lee Jones wrote:
> From: Eric Dumazet <edumazet@google.com>
> 
> __dst_negative_advice() does not enforce proper RCU rules when
> sk->dst_cache must be cleared, leading to possible UAF.
> 
> RCU rules are that we must first clear sk->sk_dst_cache,
> then call dst_release(old_dst).
> 
> Note that sk_dst_reset(sk) is implementing this protocol correctly,
> while __dst_negative_advice() uses the wrong order.
> 
> Given that ip6_negative_advice() has special logic
> against RTF_CACHE, this means each of the three ->negative_advice()
> existing methods must perform the sk_dst_reset() themselves.
> 
> Note the check against NULL dst is centralized in
> __dst_negative_advice(), there is no need to duplicate
> it in various callbacks.
> 
> Many thanks to Clement Lecigne for tracking this issue.
> 
> This old bug became visible after the blamed commit, using UDP sockets.
> 
> Fixes: a87cb3e48ee8 ("net: Facility to report route quality of connected sockets")
> Reported-by: Clement Lecigne <clecigne@google.com>
> Diagnosed-by: Clement Lecigne <clecigne@google.com>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Tom Herbert <tom@herbertland.com>
> Reviewed-by: David Ahern <dsahern@kernel.org>
> Link: https://lore.kernel.org/r/20240528114353.1794151-1-edumazet@google.com
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> (cherry picked from commit 92f1655aa2b2294d0b49925f3b875a634bd3b59e)
> [Lee: Stable backport]
> Signed-off-by: Lee Jones <lee@kernel.org>
> ---
>  include/net/dst_ops.h  |  2 +-
>  include/net/sock.h     | 13 +++----------
>  net/ipv4/route.c       | 22 ++++++++--------------
>  net/ipv6/route.c       | 29 +++++++++++++++--------------
>  net/xfrm/xfrm_policy.c | 11 +++--------
>  5 files changed, 30 insertions(+), 47 deletions(-)

All now queued up, thanks!

greg k-h

      parent reply	other threads:[~2024-06-13  8:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-13  8:12 [PATCH v2 4.19.y 1/1] net: fix __dst_negative_advice() race Lee Jones
2024-06-13  8:12 ` [PATCH v2 5.10.y " Lee Jones
2024-06-13  8:12 ` [PATCH v2 5.15.y " Lee Jones
2024-06-13  8:12 ` [PATCH v2 5.4.y " Lee Jones
2024-06-13  8:12 ` [PATCH v2 6.1.y " Lee Jones
2024-06-13  8:12 ` [PATCH v2 6.6.y " Lee Jones
2024-06-13  8:32 ` Greg KH [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=2024061354-endanger-earthworm-592e@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=clecigne@google.com \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=lee@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tom@herbertland.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