BPF List
 help / color / mirror / Atom feed
From: Stanislav Fomichev <sdf.kernel@gmail.com>
To: Jiayuan Chen <jiayuan.chen@linux.dev>
Cc: bpf@vger.kernel.org, kpsingh@kernel.org, matt@bobrowski.net,
	 Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	 John Fastabend <john.fastabend@gmail.com>,
	Andrii Nakryiko <andrii@kernel.org>,
	 Eduard Zingerman <eddyz87@gmail.com>,
	Kumar Kartikeya Dwivedi <memxor@gmail.com>,
	 Martin KaFai Lau <martin.lau@linux.dev>,
	Song Liu <song@kernel.org>,
	 Yonghong Song <yonghong.song@linux.dev>,
	Jiri Olsa <jolsa@kernel.org>,
	 Emil Tsalapatis <emil@etsalapatis.com>,
	Ihor Solodrai <ihor.solodrai@linux.dev>,
	 Stanislav Fomichev <sdf@fomichev.me>,
	"David S. Miller" <davem@davemloft.net>,
	 Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
	Shuah Khan <shuah@kernel.org>,  Xu Kuohai <xukuohai@huawei.com>,
	netdev@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH bpf v2 1/2] bpf, lsm: fix bpf_setsockopt() on a half set up child in inet_csk_clone
Date: Wed, 25 Nov 2026 09:04:13 -0800	[thread overview]
Message-ID: <awcUm4PvuYb3nGxM@devvm16445.scu0.facebook.com> (raw)
In-Reply-To: <20261125070330.16625-1-jiayuan.chen@linux.dev>

On 11/25, Jiayuan Chen wrote:
> security_inet_csk_clone() is called at the end of inet_csk_clone_lock().
> The child is locked, which is why the hook is in
> bpf_lsm_locked_sockopt_hooks, but it is not set up yet:
> icsk->icsk_ca_ops and the ipv6_pinfo still point to the ones of the
> listener, and the timers are not initialized.
> 
> So bpf_setsockopt() from a lsm_cgroup prog is wrong there for:
> 
>  - TCP_CONGESTION: puts icsk->icsk_ca_ops, which the child holds no
>    reference on.
>  - IPV6_TCLASS: writes to the ipv6_pinfo of the listener.
>  - SO_KEEPALIVE, TCP_KEEPIDLE: arm the keepalive timer before
>    tcp_init_xmit_timers() sets it up.
> 
> Options considered:
>  1. Remove the hook from bpf_lsm_locked_sockopt_hooks, as commit
>     5416c9aea832 ("bpf: Fix the kernel crash caused by bpf_setsockopt().")
>     did for socket_sock_rcv_skb. Not done, setting options like
>     SO_PRIORITY on the child is what the hook is used for and it works.

[..]

>  2. Make these options work. This needs the child set up before the
>     hook, too much for a fix.

What is too much? Moving security_inet_csk_clone to happen at the end of
tcp_create_openreq_child? Or is it more involved?

  parent reply	other threads:[~2026-11-25 17:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25  7:03 [PATCH bpf v2 1/2] bpf, lsm: fix bpf_setsockopt() on a half set up child in inet_csk_clone Jiayuan Chen
2026-11-25  7:03 ` [PATCH bpf v2 2/2] selftests/bpf: test rejected bpf_setsockopt() in inet_csk_clone hook Jiayuan Chen
2026-11-25 17:04 ` Stanislav Fomichev [this message]
2026-11-26 12:02   ` [PATCH bpf v2 1/2] bpf, lsm: fix bpf_setsockopt() on a half set up child in inet_csk_clone Jiayuan Chen

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=awcUm4PvuYb3nGxM@devvm16445.scu0.facebook.com \
    --to=sdf.kernel@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=eddyz87@gmail.com \
    --cc=edumazet@kernel.org \
    --cc=emil@etsalapatis.com \
    --cc=horms@kernel.org \
    --cc=ihor.solodrai@linux.dev \
    --cc=jiayuan.chen@linux.dev \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=matt@bobrowski.net \
    --cc=memxor@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=xukuohai@huawei.com \
    --cc=yonghong.song@linux.dev \
    /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