All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Paul Moses" <p@1g4.org>
Cc: <bpf@vger.kernel.org>, <netdev@vger.kernel.org>,
	<daniel@iogearbox.net>, <martin.lau@linux.dev>,
	<edumazet@kernel.org>, <ncardwell@google.com>,
	<kuniyu@google.com>, <jiayuan.chen@linux.dev>
Subject: Re: [PATCH bpf v2 0/3] tcp, bpf: fix CA state on open and the TCP_CONGESTION name check
Date: Sat, 05 Dec 2026 02:36:31 +0000	[thread overview]
Message-ID: <DNCG6W97X6S5.20HJGVQ84C2FW@gmail.com> (raw)
In-Reply-To: <t7fsk0hbV-A2qnzjQnX34xQbAvJd3Yj8p5kbhA0zOCrIdWSfCSYkkVn-qQWagoYh8yDYUYvi7yvXHkkS7Cg0hdxW3phTyboXYEK1jo-W384=@1g4.org>

On Fri, Dec 04, 2026 at 06:22 PM Paul Moses <p@1g4.org> wrote:
> Yes, the refcount bug is independent. My concern is that patch 2 clears CA state
> already initialized by the hook.
>
>     unpatched (#14):          init=1 release=1
>     all patches without [2]:  init=2 release=1
>     all patches with [2]:     init=1 release=1
>
> Without [2], the child's CA is initialized twice without a release in between.

Yes. ->init() runs twice. It's harmless.
The second ->init() starts from zeroed icsk_ca_priv, like the first one.
Rows 1 and 2 have a real bug. They leak a reference on ca_count.
The lsm prog takes one. tcp_ca_openreq_child() takes one more, because
icsk_ca_setsockopt == 1. close() puts one.
So this prog needs [2] with and without patch 2.

> I can move the reset before the hook instead and drop the backport prereq note,
> but I feel like we're making this more complicated than it needs to be.

Pls don't move it. Without [2] the moved reset misses this case:

  inet_csk_clone_lock()
    reset
    lsm prog: bpf_setsockopt("vegas")   tcp_vegas_init()
                                        icsk_ca_initialized = 1
  tcp_ca_openreq_child()                route has "congctl cdg"
                                        icsk_ca_ops = cdg
  tcp_init_transfer()                   skips tcp_cdg_init()

cdg sees ca->gradients == 0x7fffffff7fffffff again.
The reset in tcp_ca_openreq_child() covers it with and without [2].

Keep patch 2 as-is. Drop the note only.

  reply	other threads:[~2026-12-05  2:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  9:01 [PATCH bpf v2 0/3] tcp, bpf: fix CA state on open and the TCP_CONGESTION name check Paul Moses
2026-12-04  9:01 ` [PATCH bpf v2 1/3] tcp: reset congestion-control state when the route selects a new CA Paul Moses
2026-12-04  9:01 ` [PATCH bpf v2 2/3] tcp: clear inherited congestion-control state for a cloned child Paul Moses
2026-12-04  9:01 ` [PATCH bpf v2 3/3] bpf: check and set TCP congestion control from the same name Paul Moses
2026-12-04 21:04 ` [PATCH bpf v2 0/3] tcp, bpf: fix CA state on open and the TCP_CONGESTION name check Alexei Starovoitov
2026-12-04 21:26   ` Paul Moses
2026-12-05  1:36     ` Alexei Starovoitov
2026-12-05  2:22       ` Paul Moses
2026-12-05  2:36         ` Alexei Starovoitov [this message]
2026-12-05  4:50           ` Paul Moses
2026-12-05  7:14             ` Alexei Starovoitov

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=DNCG6W97X6S5.20HJGVQ84C2FW@gmail.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=edumazet@kernel.org \
    --cc=jiayuan.chen@linux.dev \
    --cc=kuniyu@google.com \
    --cc=martin.lau@linux.dev \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=p@1g4.org \
    /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.