Article View: linux.kernel.netdev
Article #23062Re: [PATCH bpf v2 1/2] bpf, lsm: fix bpf_setsockopt() on a half set up child in inet_csk_clone
From: Jiayuan Chen
Date: Thu, 26 Nov 2026 12:02
Date: Thu, 26 Nov 2026 12:02
38 lines
10615 bytes
10615 bytes
On 11/26/26 1:04 AM, Stanislav Fomichev wrote:
> 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?
It is more involved. The end of tcp_create_openreq_child() only fixes
the timers. icsk_ca_ops is set by tcp_ca_openreq_child() and pinet6 is
switched in tcp_v6_syn_recv_sock(), both after
tcp_create_openreq_child() returns. For MPTCP, subflow->conn is set
even later, in subflow_syn_recv_sock().
Technical Details
Message-ID:
<eb8abbc0-3028-4bd6-9010-0a855305e294@linux.dev>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372084-linux-kernel-netdev=dewy.ruReferences:
<20261125070330.16625-1-jiayuan.chen@linux.dev> <awcUm4PvuYb3nGxM@devvm16445.scu0.facebook.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372084-linux-kernel-netdev=dewy.ru From: jiayuan.chen@linux.dev (Jiayuan Chen) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH bpf v2 1/2] bpf, lsm: fix bpf_setsockopt() on a half set up child in inet_csk_clone Date: Thu, 26 Nov 2026 20:02:54 +0800 Organization: Usenet Network Message-ID: <eb8abbc0-3028-4bd6-9010-0a855305e294@linux.dev> References: <20261125070330.16625-1-jiayuan.chen@linux.dev> <awcUm4PvuYb3nGxM@devvm16445.scu0.facebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="458221"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:UZ+9qaxxmrNmA9W/KP6u9DvZnus= sha256:TEoDQH83y12YvrCa1aXx8acCPsRkgw8dXG2OPF1x01Y= sha1:Kxxsz82RJjGseJmYn+uJYPI9cqA= sha256:QWT39Tqv0s9XvcKVciVT3xzAgpJESFCMiyK43gfmBh4= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 835A1125ED3; Thu, 26 Nov 2026 15:03:25 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.05 X-Spam-Status: No, score=-2.05 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, HK_RANDOM_FROM=1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=linux.dev X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2EkxfO0Pz6m6; Thu, 26 Nov 2026 15:03:22 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-372084-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id E1177125ED1; Thu, 26 Nov 2026 15:03:13 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 061B333924; Thu, 26 Nov 2026 12:03:11 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795694586; b=B8o2C+5PaP+Y9XBI5rhjKGy/dKhLFi4XOORQquEDSas2QIyh1YBIwkJT6gLXK0gMJGkG j594xrk2GdFB0tw1lQxRCpxgMGruNZJBMITtzsn5Hg3k4/I2oT5MA2yRAI51qOzPwiYQM hQ0WIUlVlAA87B0H4h0VWrJxFxC8Q2k0cZZxkk8UV/jHrXwIYh4GO541AA5/ZjoLqdKQ+ /FEmeTrxQHOgMmoUCq/QdvROnqm0VmX8VkGwArK0jB7JYd5yMSWzlnoj1SDK7Pj9z7Zb4 pIjpa2dYBqjiHF8kVK+nuCnvt+drKR41LFqzCB6ZvK93Uisfm8UTGrwNqnjv/WPxnpQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795694586; h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature: X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:User-Agent: Subject:To:Cc:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=qoA088dkvLhrSXa5HLwvBJYzOxS+97oQxq1vAdRFubo=; b=u81a+P1ty88peUspg5q8XzC0drZe0Z5ibqPhxaoKlh5W3vkOve9KyemAhWkUj3NbHTEe uKCtrUSC45u1AWSPuLUA0NlNZ8jAGM/rrQ6avDdi8RaBM31bo9keUlPmMaxyhdyK/covz W2px4G6YfMlkB5FAqzzfbNWmvHarHOcY0dR3V15naBwP0yIMoVc89ZmDGcjajkeTqNz9B 12x8voHHuYeosnxoshL0m8AxiK2c0IOZgFyWoX0cUFKR3UqlDCtzDPUjY1c4M2jhpiGkq JgJJ+jU2rIi8Hxzfj+4K9MWxsD8nvH0suCEEgDOuYaOnmgZ1Hw2zrEl60K8ipvMvEqQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=HyMa7aTX; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9C174606A32C; Thu, 26 Nov 2026 12:03:06 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=HyMa7aTX X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.126 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795694585; b=SJWBWipICVjPAvxSXH0oDH/e861juhFJmk9ujloFBSn6JTt11IB3GcQz9UNLofutsqA1 5ihJ+FfxAyB8o/TvGkj9o6wmu6mm9FcFzUWMdHV82e9h1C7ZB+tCIsWe8fJpC5Q1JC+QM nerHNA/Q6jwXUiJKtoiJw4IrPtEaikyYzENvfeQY4IMxpDFA/4uafzA3b+ZoImlfVdDE8 5ZL9kvPUoLJy60Izq8nETFOif7UrEeMNiMXYjwSQBrxd/I8RBEiovw0NUaJngMWREfFiC NC9OyLeSaxWw9/Yc1j6M0CcqXXolyAdkFLibDeJHcyQNrfBK6JHQqJBaGt7eNNkzFPA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795694585; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=qoA088dkvLhrSXa5HLwvBJYzOxS+97oQxq1vAdRFubo=; b=11BrqzpUZAwyc1Me/Dt6KkljiK6Zvq7I6DGiEGpwciH2J9LjJFma3oK9ynDzrIqm/LtV vpZYngVJuX8CZS1txIgghfgKydb+hhcXvDteCanYGClQwwyjARVsQZ0rmLVSwPGcXKhmT +1bobwgvfUy0b4YReL57nYykNubWYIhDs2JWl7YaAOJQ4VpcMN+g2rLxdnpK0DG6VRGuy HJfxmY9ySTJxM1nSM37hnMjZa3IsAoE/y1dr5902Blw8aI9/qyN/dZz4AdBdLaJ29GAte LvoaLtrpttnss46no9HQCvcipULWxw385FpfCDhW+vr5X08MY3WxS/cW2UGammrFq8A== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=HyMa7aTX; arc=none smtp.remote-ip=95.215.58.126 X-Received: from mta1.migadu.com (out-126.mta1.migadu.com [95.215.58.126]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0770606A32E for <netdev@vger.kernel.org>; Thu, 26 Nov 2026 12:03:04 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F0770606A32E X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Envelope-To: netdev@vger.kernel.org X-DKIM-Signature: a=rsa-sha256; bh=qpihMKwKeEshqRGiOU+LJxx2L01+RYwZPY1UI4N9uQ4=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1795694583; v=1; x=1796299383; b=HyMa7aTXe/NrTr9HLhd00TRaFsn7aIF5jCJgwtdB5x8XflIfc9C69TtPBrpMrf4tYEWfvyIv W/Fi9bdlGnpQGspXPlEowfjErVYOIFbZepprLKET93X2Clmh1yu1hMce8zXZv0Cc3dDODqbNWKg zi7lm33+fUzDqGlf244w100I= X-Envelope-To: netdev@vger.kernel.org X-Received: by smtp.migadu.com with ESMTPS id bff048c27b98143b; Thu, 26 Nov 2026 12:03:02 +0000 X-Mizu-Trace-ID: bff048c27b98143b X-Migadu-Flow: FLOW_OUT X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-User-Agent: Mozilla Thunderbird X-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 X-In-Reply-To: <awcUm4PvuYb3nGxM@devvm16445.scu0.facebook.com>