From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (mail.openvz.org [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id 47D1580031 for ; Tue, 1 Dec 2026 15:39:21 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6B1Fbx2w020011; Tue, 1 Dec 2026 18:38:00 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6B1Fbx2w020011 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="KVMKyHsk" Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6B1FbqoG019950 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Tue, 1 Dec 2026 18:37:53 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6B1FbqoG019950 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-c50b170ec5aso1013340466b.2 for ; Tue, 01 Dec 2026 07:37:53 -0800 (PST) X-Gm-Message-State: APuU4Z/IxR8UrEkUUuN5V2YPEJ5zZT3tg65HmAbL1DBsOCEFT/bvY82Z RBIvj1DYAwS0/mwoqoCKGFFPgN6sazt6e2vWc9f5/F4sEkF+rtybyFruhavxMGxm3yoDvx54YZp F2WM0K8ZWSjGJ8Ry6e8mRdoBH7NwsMGORYh78ob8qCqB7r33u3j0V5g== X-Gm-Gg: AZFdTZdgBxTMiRX6Us2aZ3l4n07i3F4uiWgJqMyM1fnvT2ByWSugrcE4nKPeOgI/3vA h3zPoiCZAjnX1pQdek9KZdUo+vdQao+q2q+G+KVNIAox9zuEAKFNuqXKYVuCMjjo744rllYZ34R 36T1h+PE/kmzACwGgrhC2CKBwSsCxdkaDK3icduiuVVdV8dvoPdmgna8KDkrYqx1RmKE99nTIh7 i75AVx1XCKgYc3Zu9qMvRAR0Ct3hFJIoE74oSJOulo2YZlwnoLIS71jvyGrdAelelcwDcOYD/N5 IKqBwy9u5zrol2RVyOVc04554Z/iIvJbTqhAHiKv6AG8RxTytp+dBbgQtpjA7ASoxUhdsovAUaC uxOBc+DvZSmiXM7czy6TGCJoqwQ== X-Received: by 2002:a17:906:f9d2:b0:c50:4a71:cb3 with SMTP id a640c23a62f3a-c513aade1f6mr2225946066b.48.1796139472722; Tue, 01 Dec 2026 07:37:52 -0800 (PST) X-Received: by 2002:a17:906:f9d2:b0:c50:4a71:cb3 with SMTP id a640c23a62f3a-c513aade1f6mr2225943666b.48.1796139472121; Tue, 01 Dec 2026 07:37:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1796139472; cv=none; d=google.com; s=arc-20260327; b=ZjYAsueYdEpBd5JtUC8kAtyU5Ruym+PmnPA5IcYjlgF5haJY39Xc3WNe+8ZJOHOnGx hBdoeXKSKYp8IMhwDWpq252CjndWxHhzmghCk/hGr2d2KVhgJsx8gGXfin1mWXIo4xmQ 4Aov5ddo0NJORdI0GKVWX18SSSZE6zFwj47gOFWXsyd0Hc83BLMYU3FIAtayaQm2MO/f 4jxkp5zsC+3hkkB6jmweyI3L2+Nv6SDG4/pAqAK10gsWak9hHzPYgsxBgkXL+MlTBtlK M89xUGLwVy/w/lxLJ9EaZuJK6aD4p6EHh8aQYg+2RZGXC0Eb/PQMRPj01radJziaV3VN oqeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=mWYSzxGO5YM5/V0ySDbX/8uai9V+UkJap5zFp4XovlM=; fh=/QSWnKFFIPNLStgUoDwCQRaXnWcMIG7fyKJgHY+VEpU=; b=OJtLHfbGMESJjz/2Y0fp7fZHJMjLD9n0M8xHsKZo9u3eQeoCFTRbLWXEigUjdqw044 IO1XfbpTgJr6Fe8GjOCCF7Aukp15nXirvt5v36NJ+KXyEfEvPj5sM8I9h71QRcWmBPLU pezHv6h7umY5QkxL8o3oUyRfRQWKbBpOhQ3g6GBAQk4tMv+yRjs9358h4McNYQyyDCs0 qpV8YqG0xlSxUUUzu6canLmizyskICCPFyqbTyFPHxYLWY+3sFuUWXcAnmFJKlHlIx7I CSlcLB/ncJCqUQmUdK+KdambKEHZNKHLCmF0RJ9wAkcN9/ew7YPI9L41epAgyzcRzKkF rKfQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=KVMKyHsk; spf=pass (google.com: domain of eva.kurchatova@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=eva.kurchatova@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: from relay.virtuozzo.com (relay.virtuozzo.com. [130.117.225.111]) by mx.google.com with ESMTPS id a640c23a62f3a-c513afe4f56si2269121566b.100.2026.12.01.07.37.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 07:37:52 -0800 (PST) Received-SPF: pass (google.com: domain of eva.kurchatova@virtuozzo.com designates 130.117.225.111 as permitted sender) client-ip=130.117.225.111; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=KVMKyHsk; spf=pass (google.com: domain of eva.kurchatova@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=eva.kurchatova@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=mWYSzxGO5YM5/V0ySDbX/8uai9V+UkJap5zFp4XovlM=; b=KVMKyHskJqZk 4JBW4h72uT7jU9kIr0hUJqiIArWMcAYMUVFZU/kNxaSNAG7LADkp2xNwmnbys9AMZcbju1MTMtIZP tS1cgtmkUydQVo6GZpDMUSyqKSNnBALtnAA8CUFGjDTTJFBbh7+0zTLfV6xwB5zDkpRGAC4rPf4iQ ZT7agj8vIJpGLTD4D2lwlyk5sSyAA+p8rD+pZ/oQ+F28YCJZxnyMjaSA5LmJYtj6JupBaFvsJxJ3+ qOshQA/Ll6PgrVgvvq2itZ/iU+ormiJCjOamfCY42lhJA0htE/40iaqCR+OTu4XnX8DLzqLyjW4pW gbD99NaBZU7mqRMBDDxtWQ==; Received: from ch-vpn.virtuozzo.com ([130.117.225.6] helo=LekKit-T14) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1xYPv9-0081OE-0Z; Tue, 01 Dec 2026 16:37:41 +0100 From: Eva Kurchatova To: khorenko@virtuozzo.com, vladimir.riabchun@virtuozzo.com Date: Tue, 1 Dec 2026 14:10:16 +0200 Message-ID: <20261201153749.2872789-2-eva.kurchatova@virtuozzo.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261201153749.2872789-1-eva.kurchatova@virtuozzo.com> References: <20261201153749.2872789-1-eva.kurchatova@virtuozzo.com> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.2 v2 01/15] ms/tcp: clear sock_ops cb flags before force-closing a child socket X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org From: Sechang Lim [ Upstream commit 990348e5bb457697c2f1f7f7b65154a3334d9d2b ] A child socket inherits the listener's bpf_sock_ops_cb_flags via sk_clone_lock(). If its setup fails in tcp_v4_syn_recv_sock() / tcp_v6_syn_recv_sock(), the child is freed through put_and_exit, where inet_csk_prepare_forced_close() drops the socket lock and tcp_done() runs without it. If BPF_SOCK_OPS_STATE_CB_FLAG was inherited, tcp_done() -> tcp_set_state() calls tcp_call_bpf(), which expects the lock and trips sock_owned_by_me(): WARNING: include/net/sock.h:1799 at tcp_set_state+0x433/0x550 RIP: 0010:tcp_set_state+0x433/0x550 include/net/sock.h:1799 Call Trace: tcp_done+0xba/0x250 net/ipv4/tcp.c:5095 tcp_v4_syn_recv_sock+0x850/0xa50 net/ipv4/tcp_ipv4.c:1787 tcp_check_req+0xf30/0x1360 net/ipv4/tcp_minisocks.c:926 tcp_v4_rcv+0x1047/0x1b50 net/ipv4/tcp_ipv4.c:2164 The child is freed before it is ever established, so it should run no sock_ops callback. Clear its cb flags in inet_csk_prepare_for_destroy_sock(), the common point for the IPv4, IPv6 and chtls forced-close paths and for the MPTCP ->syn_recv_sock() failure path (dispose_child), which reaches tcp_done() on a child that was never established too. Suggested-by: Jiayuan Chen Fixes: d44874910a26 ("bpf: Add BPF_SOCK_OPS_STATE_CB") Signed-off-by: Sechang Lim Reviewed-by: Jiayuan Chen Reviewed-by: Kuniyuki Iwashima Reviewed-by: Eric Dumazet Link: https://patch.msgid.link/20260611092923.1895982-1-rhkrqnwk98@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin [ Moved inet_csk_prepare_for_destroy_sock() to inet_connection_sock.c due to header dependency, Added a guard arount the call to tcp_clear_sock_ops_cb_flags to avoid calling it for DDCP sockets.] Signed-off-by: Miguel Gazquez (Schneider Electric) Signed-off-by: Sasha Levin (cherry picked from commit fe23d56e9266d58ba5c380f1970118eedeee0b68) https://virtuozzo.atlassian.net/browse/VSTOR-157577 Feature: fix ms/net Signed-off-by: Eva Kurchatova Reviewed-by: Sashiko --- include/net/inet_connection_sock.h | 8 +------- include/net/tcp.h | 9 +++++++++ net/ipv4/inet_connection_sock.c | 9 +++++++++ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h index b607c8e72d88..86aa914a2502 100644 --- a/include/net/inet_connection_sock.h +++ b/include/net/inet_connection_sock.h @@ -299,14 +299,8 @@ reqsk_timeout(struct request_sock *req, unsigned long max_timeout) return (unsigned long)min_t(u64, timeout, max_timeout); } -static inline void inet_csk_prepare_for_destroy_sock(struct sock *sk) -{ - /* The below has to be done to allow calling inet_csk_destroy_sock */ - sock_set_flag(sk, SOCK_DEAD); - this_cpu_inc(*sk->sk_prot->orphan_count); -} - void inet_csk_destroy_sock(struct sock *sk); +void inet_csk_prepare_for_destroy_sock(struct sock *sk); void inet_csk_prepare_forced_close(struct sock *sk); /* diff --git a/include/net/tcp.h b/include/net/tcp.h index a88c3faf6ed5..e27daa5cf878 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -2704,6 +2704,11 @@ static inline int tcp_call_bpf_3arg(struct sock *sk, int op, u32 arg1, u32 arg2, return tcp_call_bpf(sk, op, 3, args); } +static inline void tcp_clear_sock_ops_cb_flags(struct sock *sk) +{ + tcp_sk(sk)->bpf_sock_ops_cb_flags = 0; +} + #else static inline int tcp_call_bpf(struct sock *sk, int op, u32 nargs, u32 *args) { @@ -2721,6 +2726,10 @@ static inline int tcp_call_bpf_3arg(struct sock *sk, int op, u32 arg1, u32 arg2, return -EPERM; } +static inline void tcp_clear_sock_ops_cb_flags(struct sock *sk) +{ +} + #endif static inline u32 tcp_timeout_init(struct sock *sk) diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index 47e09a61335d..21334e0c015e 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c @@ -1294,6 +1294,15 @@ void inet_csk_destroy_sock(struct sock *sk) } EXPORT_SYMBOL(inet_csk_destroy_sock); +void inet_csk_prepare_for_destroy_sock(struct sock *sk) +{ + /* The below has to be done to allow calling inet_csk_destroy_sock */ + if (sk->sk_protocol == IPPROTO_TCP) + tcp_clear_sock_ops_cb_flags(sk); + sock_set_flag(sk, SOCK_DEAD); + this_cpu_inc(*sk->sk_prot->orphan_count); +} + /* This function allows to force a closure of a socket after the call to * tcp/dccp_create_openreq_child(). */ -- 2.56.1 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel