BPF List
 help / color / mirror / Atom feed
From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Paul Moses" <p@1g4.org>, <bpf@vger.kernel.org>
Cc: <netdev@vger.kernel.org>, <daniel@iogearbox.net>,
	<martin.lau@linux.dev>, <john.fastabend@gmail.com>,
	<sdf@fomichev.me>
Subject: Re: [PATCH bpf] bpf: Check and set TCP congestion control from the same name
Date: Thu, 03 Dec 2026 03:58:59 +0000	[thread overview]
Message-ID: <DNASOXUN4KAE.1IJL3LGF4E1DO@gmail.com> (raw)
In-Reply-To: <20261130065659.621451-1-p@1g4.org>

On Sun, Nov 29, 2026 at 10:57 PM Paul Moses <p@1g4.org> wrote:
> BUG: KASAN: invalid-free in tcp_cdg_release+0x38/0xac

A route with "congctl cdg" gives the same splat without a race.
tcp_ca_dst_init() replaces icsk_ca_ops and keeps the state of the old cc:

		bpf_module_put(icsk->icsk_ca_ops, icsk->icsk_ca_ops->owner);
		icsk->icsk_ca_dst_locked = tcp_ca_dst_locked(dst);
		WRITE_ONCE(icsk->icsk_ca_ops, ca);

icsk_ca_priv[2] is ca->gradients in cdg.
With TCP_FASTOPEN_CONNECT and TCP_FASTOPEN_NO_COOKIE:

  connect()              TCP_SYN_SENT, tcp_connect() is deferred
  setsockopt("bpf_cc")   ->init() sets icsk_ca_priv[2] = X
                         icsk_ca_initialized = 1
  write()                tcp_ca_dst_init() sets icsk_ca_ops = cdg
  SYN-ACK                tcp_init_transfer() skips tcp_cdg_init()
  close()                tcp_cdg_release() does kfree(X)

tcp_ca_openreq_child() doesn't clear icsk_ca_priv either.
bpf_cc->set_state() can write it in tcp_disconnect() before listen().
The child gets a copy and tcp_cdg_init() doesn't reset ca->tail.
With tail == 255 tcp_cdg_grad() writes past the end of ca->gradients.

Both should reset icsk_ca_priv and icsk_ca_initialized like
tcp_reinit_congestion_control() does.

pw-bot: cr

      reply	other threads:[~2026-12-03  3:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30  6:57 [PATCH bpf] bpf: Check and set TCP congestion control from the same name Paul Moses
2026-12-03  3:58 ` Alexei Starovoitov [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=DNASOXUN4KAE.1IJL3LGF4E1DO@gmail.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=john.fastabend@gmail.com \
    --cc=martin.lau@linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=p@1g4.org \
    --cc=sdf@fomichev.me \
    /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