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 B12DB80033 for ; Mon, 30 Nov 2026 18:49:52 +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 6AUImbes031111; Mon, 30 Nov 2026 21:48:38 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AUImbes031111 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="NAeNvM8U" Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AUImW3h031058 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Mon, 30 Nov 2026 21:48:33 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AUImW3h031058 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-c504bdea834so767767466b.1 for ; Mon, 30 Nov 2026 10:48:33 -0800 (PST) X-Gm-Message-State: APuU4Z8zzGRuCHaOSCJ9KjSp1vbkx+Dd7Y1brPl4hyfdLfGqUAuUNr1o eIydSDLE5DwO+zRJF1XExtDdmJ/L0rlYWaQ3nU2woPo305uUjQ4dsXGLOiFNeIKYGUFBJJMsINt qtuS/eN+79BLiFEnnF+SosFIYARa6mRlnXc2JrIxSYTzgg5djBXIaBg== X-Gm-Gg: AZFdTZcuWyapkfeFq6JrjjS++MLhNVtPE1k3lcQU/08WpsfK4mjV/zCpr2cGpGODAWJ 08d201s6jhm1eQQ5dZTQvPbHGrNaz+iV4M9/1u4eWejZHCBvY4E1MiqNMLzE6pNtJ1DEN+2n5ty jd6QCLHf6GPw0k7SOgtYESdfOTz6gS614eUs/xYmV6voX0Y2aMQtgmj+f8ubqesDfZrbFGW5WzU 8dmg+5DkwXzAy1sZkXO0L/JtL+1SF5XnTeaitPtbcsb5relDTjZuxnsFwtDFVH88VfjtP8vjpGM IN9A8IRkO89Qth8dPfc5kdNV8bomIf5jWSVfftfypcLbR2+CmAf2TMckhOvnb+I6jEg+Zp1eiXu dCkAConjp/0/Y1lydsV8eZnq4Ag== X-Received: by 2002:a17:907:9411:b0:c40:d920:747c with SMTP id a640c23a62f3a-c513a47d409mr2697433166b.7.1796064512571; Mon, 30 Nov 2026 10:48:32 -0800 (PST) X-Received: by 2002:a17:907:9411:b0:c40:d920:747c with SMTP id a640c23a62f3a-c513a47d409mr2697431766b.7.1796064512022; Mon, 30 Nov 2026 10:48:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1796064512; cv=none; d=google.com; s=arc-20260327; b=Mag8y7YOwBUoCv6jVQjG3cxK92+NNsoyGSNbpBTKXJqrb6d45xmqK9oM2ABe8zqKWJ MWL/FcY6EFZNWmDrB8GAG+I9K8Le0ZY/ltp5wohYJW+6xsy7ZNQ5KKTAeXxs+ZWUJ/8W 0Ka77MOEoEBN8oQhZ3cSeLelo4qJ/XYx10KSFXSOz0frj3tyyPdCCko3q0WJwhdanCCa xeVp+6hd6RwJaO5HUgzX9VJNdmtn/sav/NN6wutDwUTehT4DUXcSzuoYQ9JFvLKknc0G /NvB9SsOPd+lt2wk7vRYikPGCPr9GgG4cmjtSeE2VRsKnyWCa4Vd2zSX3NaC80hurhUa OJEQ== 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=5Ylko0S3aig6M/7xybr3nUa76yQCEwtBJzBu38PA+nE=; fh=/QSWnKFFIPNLStgUoDwCQRaXnWcMIG7fyKJgHY+VEpU=; b=JplVyP2VqpKaUSt3gMj2/TF3BRDw3wW8Bi1u2hTsfUKdKpesyHmdotEsNhVYnSZ8jr p7RNgD00Vf4HukQjgR6VyJ2hS+2KlDj14WG9upSswWg2yAOl2iDfJ+0J6wd60fojXZVC XG4ZtQ3fdkIk0pgk1sYP917LNELJcgo07h843lsAHdbx/YxfjJuQnRc3cApZ90AsiEB2 r+wcRM9IOE5i4VNLYQeAg00pyAjsp/vc23QQWZLgGzOAsqN3riMtYYxjIArzeW0LY6L5 IhT0hJDeFDhJT5mespMgvCkGjeaNmTgV+8/xiQp5GM5v6cHjoq/lFOsV5/rZ9wZ2UpYZ W9Hg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=NAeNvM8U; 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 4fb4d7f45d1cf-6ba5870e1e1si27096194a12.50.2026.11.30.10.48.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 10:48:31 -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=NAeNvM8U; 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=5Ylko0S3aig6M/7xybr3nUa76yQCEwtBJzBu38PA+nE=; b=NAeNvM8Uf63T 6axbtcxBEz4SgknIAQAhJ9I8qEGdK0wjlAJMXWNSX94QAfSQt6nMTnK9N7DIr8q6gcDAdkoFTk3CI FcEMZMDcxcSxwjiGRczqVuWbIHzhzVM6wv5ACZ8/7uD4tIPcAJ4YYNFAgxoVYqkmV/Za3+sGlylJR H+XpZPfu/vv2X1UpKN3fqSqZvcxGNXUrjmSomadOURPHhMJ33VN120bTbKLPZMmmNAy0+Rv14yjod 5dqYf7G5MsHhM2doyMfoGQ5IbCfFsZpLyWYGYIeJnn5VtUAAxMVxvi2YUe8ojR0thyQNMS9fEZO0Y kFnBXuQXfhtjjldMsvZzxg==; 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 1xY6Q8-001tKJ-1E; Mon, 30 Nov 2026 19:48:23 +0100 From: Eva Kurchatova To: khorenko@virtuozzo.com, vladimir.riabchun@virtuozzo.com Date: Mon, 30 Nov 2026 20:45:46 +0200 Message-ID: <20261130184822.2743885-2-eva.kurchatova@virtuozzo.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261130184822.2743885-1-eva.kurchatova@virtuozzo.com> References: <20261130184822.2743885-1-eva.kurchatova@virtuozzo.com> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.2 1/8] 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 --- 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 8af596b3e9e0..936b0435cfc1 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c @@ -1282,6 +1282,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