Netdev List
 help / color / mirror / Atom feed
From: Kuniyuki Iwashima <kuniyu@google.com>
To: Eric Dumazet <edumazet@kernel.org>
Cc: "David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>,
	Neal Cardwell <ncardwell@google.com>,
	 Simon Horman <horms@kernel.org>,
	netdev@vger.kernel.org, Kyle Zeng <kylebot@openai.com>
Subject: Re: [PATCH net] tcp: avoid double destroy in tcp_abort() of an unaccepted child
Date: Wed, 28 Oct 2026 19:54:46 +0000	[thread overview]
Message-ID: <auJS_SXcIln-iJxd@google.com> (raw)
In-Reply-To: <20261028160847.2170959-1-edumazet@kernel.org>

On Wed, 28 Oct 2026 17:08:47 +0100, Eric Dumazet wrote:
> From: Kyle Zeng <kylebot@openai.com>
> 
> tcp_abort() checks for TCP_CLOSE while only owning the socket lock,
> then grabs the BH lock before calling tcp_done_with_error().
> 
> For a child still sitting in a listener accept queue (which can be
> reached via SOCK_DESTROY or bpf_sock_destroy()), inet_csk_listen_stop()
> can run in this window: it only holds the child BH lock, and calls
> inet_child_forget(), which disconnects, orphans and destroys the child.
> 
> tcp_abort() then calls tcp_done_with_error() -> tcp_done(), which sees
> SOCK_DEAD and calls inet_csk_destroy_sock() a second time, leading to
> a double sock_put() and a use-after-free.
> 
> Recheck TCP_CLOSE after acquiring the BH lock, unless we just closed
> a listener ourselves, in which case tcp_done_with_error() must still
> run to report the error.
> 
> Note that the WARN_ON(sock_owned_by_user(child)) in
> inet_csk_listen_stop() can still trigger in this window.
> 
> Fixes: bac76cf89816 ("tcp: fix forever orphan socket caused by tcp_abort")
> Signed-off-by: Kyle Zeng <kylebot@openai.com>
> [edumazet: recheck TCP_CLOSE under the BH lock instead of moving the test, smaller diff]
> Signed-off-by: Eric Dumazet <edumazet@kernel.org>

Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>

      parent reply	other threads:[~2026-10-28 19:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-28 16:08 [PATCH net] tcp: avoid double destroy in tcp_abort() of an unaccepted child Eric Dumazet
2026-10-28 16:11 ` netdev-bot+sinfo
2026-10-28 19:54 ` Kuniyuki Iwashima [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=auJS_SXcIln-iJxd@google.com \
    --to=kuniyu@google.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kylebot@openai.com \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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