From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796012743; b=c6IoHZe3k8PubaZR2hREyYPg1Gc6C7mR+TFn79xwOhxBH069UAMCJFNWvAVN9N6sxq3T QIkT+fIMR14+Ils5pQ0ieVcxPyEc4I8JgTGPiC1ah81qqVNa7omJjVgEzMOQVmWSnZXls XSwPYvAlZxohBEqnM2EHnxHU22IdM/HRwdcrozRK8WEXZi0SnhMJYZQGTB26roKtOvp3f NDI6kH9z5PRf7nfjG0t45W/hvRkIgn4G9rjdV2v8TWAofWUWl0Zc/UwffJdTl8ii/8pUv NVpFh78V+WfDXq4vOSiNPETzFvOpZbwfjkIu1JVq7nrkySqTP/8ocVMAoNmjEKY+arw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796012743; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=k9vg8xImJJ6OokelZt+oRe+rHYw722wZBRxDpz0sg7M=; b=SY8YnZW2tn9ko+xget+Id8R6afpycs/r+H8KBNv3usdgM2Rncv+Wm+sevEgJUgoCLl1s 9DDlHjAMHfWZDpY+lho+IGsmgTKfGvklyCWranpb4MX5gk1l7guGyeYunefMCiIMTOiIR FnTCMJ8Tb/IJ/iNCBl7ootO8kXQotIZ2T5cwKgOkFiSHBVWvirAKW2SHWpK6i98WUoANp W5sYsO9U94z0YcfB6WDrBPspAH7A7m7iaC2GQ2qj7WiXfMb3JImV+KF2L0Xz3SSPJQim/ u0e/CfbZRQDVZuWmoNvoPkRMPSlUK6mn6qvROygnY6JH9+y26IWKqy8XmTn42In9WeQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=oPHkXPdo; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8EE9606A31C; Mon, 30 Nov 2026 04:25:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=oPHkXPdo Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B7D71F000C1; Mon, 30 Nov 2026 04:25:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796012743; bh=k9vg8xImJJ6OokelZt+oRe+rHYw722wZBRxDpz0sg7M=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=oPHkXPdoKhRnYqE37Hx77dtqNRe/lnaXJ8wKLXmF+R7GTsMdIlil8dlzVT4elxnk6 CYjHMtsz4aSJvb1FIKh5VlArHBCnoEbXEmQ9F8qCuCcsAZaop4oQKYYWLRvIG1kIwq 0CN1kZQZnyxvMQ9MQQ+ER7t4dPAaXO8x0Pu3B2VTZPm577ldcYRfKZO7ecbLjTBm4Q N/0dFqa1Mspa+wKpFibDRtrfyvBw074D3OzThZiRaB92mLik2iYkY/GtMKRjKHYNDV YJUX1VQ/9hlO3nCPNXs5Yej9ZtBiZ2zToDoBsfOtlUQF0n1cvnNWSNgZ0L2GDQpbkN OgP+vf0HH7Fqw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH bpf v3 1/2] bpf, lsm: fix bpf_setsockopt() on a half set up child in inet_csk_clone Reply-To: sashiko-reviews@lists.linux.dev To: "Jiayuan Chen" , bpf@vger.kernel.org Cc: mptcp@lists.linux.dev In-Reply-To: <20261130041156.295524-1-jiayuan.chen@linux.dev> References: <20261130041156.295524-1-jiayuan.chen@linux.dev> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 04:25:42 +0000 X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] bpf, lsm: malformed Fixes trailer with trailing inline comment -- commit f644a7db922e05a1990460caa80c5118da46a9eb Author: Jiayuan Chen > bpf, lsm: fix bpf_setsockopt() on a half set up child in inet_csk_clone > > 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. So > bpf_setsockopt() from a lsm_cgroup prog is wrong there for: > > - SO_KEEPALIVE, TCP_KEEPIDLE: arm the keepalive timer before > tcp_init_xmit_timers() sets it up. > - IPV6_TCLASS: writes to the ipv6_pinfo of the listener. > - TCP_CONGESTION: puts icsk->icsk_ca_ops, which the child holds no > reference on. > > For example, SO_KEEPALIVE ends up with: > > Oops: general protection fault, probably for non-canonical address ... > KASAN: maybe wild-memory-access in range [0xdead000000000128-...] > RIP: 0010:__run_timers+0x5d2/0xab0 > Call Trace: > > run_timer_base+0x107/0x190 > run_timer_softirq+0x1a/0x40 > handle_softirqs+0x251/0xa70 > __irq_exit_rcu+0x1a8/0x260 > irq_exit_rcu+0xe/0x30 > sysvec_apic_timer_interrupt+0xc2/0x110 > > > 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. Reject these options in the hook. Not done, it is a deny list > that has to follow every change of the child set up. > 3. Call the hook after the child is set up. > > Go with 3, as V1 suggested. Call the hook right before > __inet_inherit_port() in tcp_v4_syn_recv_sock() and > tcp_v6_syn_recv_sock(), the two callers of tcp_create_openreq_child(). > The child is still locked and not in bhash and ehash yet. Options > like SO_MARK and IP_TOS now drop the dst the child just got, > tcp_init_transfer() looks it up again. > > MPTCP is not covered by the move. A passive subflow inherits > sk_write_space =3D subflow_write_space() from the listener, but its > subflow->conn is only set in subflow_syn_recv_sock() after the child > is in ehash, too late for the hook. SO_SNDBUF and TCP_NOTSENT_LOWAT > call sk->sk_write_space(), and subflow_write_space() derefs the NULL > conn. There is no msk to wake up yet, so return early there. > > A bpf CC hits the same NULL without the lsm hook, set_state() is > called from tcp_ca_openreq_child(): > > Oops: general protection fault, probably for non-canonical address ... > KASAN: null-ptr-deref in range [0x00000000000008c0-0x00000000000008c7] > RIP: 0010:subflow_write_space+0x142/0xb80 > Call Trace: > > do_tcp_setsockopt+0x18e0/0x2500 > sol_tcp_sockopt+0x415/0xaa0 > __bpf_setsockopt+0xd8/0x180 > _bpf_setsockopt+0x77/0x130 > bpf_sk_setsockopt_nodelay+0x41/0x60 > bpf_prog_47b652bba9e6db3d_repro_set_state+0x40/0x46 > bpf__tcp_congestion_ops_set_state+0x4c/0xac > tcp_set_ca_state+0xaf/0x250 > tcp_ca_openreq_child+0x126/0x460 > tcp_v4_syn_recv_sock+0x5b7/0x1240 > subflow_syn_recv_sock+0x2ae/0x1570 > tcp_check_req+0x531/0x2a30 > tcp_v4_rcv+0x142d/0x3e00 > ... > > > Fixes: 9113d7e48e91 ("bpf: expose bpf_{g,s}etsockopt to lsm cgroup") > Fixes: eb18b49ea758 ("bpf: tcp: Allow bpf-tcp-cc to call bpf_(get|set)soc= kopt") # MPTCP NULL deref > Signed-off-by: Jiayuan Chen [Severity: Low] The trailing "# MPTCP NULL deref" comment on the second Fixes: trailer breaks canonical Fixes: tag parsing. Should this be formatted as: Fixes: eb18b49ea758 ("bpf: tcp: Allow bpf-tcp-cc to call bpf_(get|set)soc= kopt") --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130041156.2955= 24-1-jiayuan.chen@linux.dev?part=3D1