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 96C3280033 for ; Tue, 1 Dec 2026 15:39:18 +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 6B1Fc4PH020026; Tue, 1 Dec 2026 18:38:05 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6B1Fc4PH020026 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="N5NcxWKJ" Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6B1Fbr6C019955 (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 6B1Fbr6C019955 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-6b879462421so4858406a12.1 for ; Tue, 01 Dec 2026 07:37:53 -0800 (PST) X-Gm-Message-State: APuU4Z8O6fyRQOhOdssVB2ZNbnYo1DPrVxWXkKzYKIRzY31blfTY7vhN FO92EKU+JYR9w60pGKgHtIGS1VlIN32lzcdOefv+eomJ/nFczMO797KJWWxlhHm6ZyiTxL8uEyd ywSJlVK9aPYOYM5k/kARy2ny4KTwdNV65g01GkbRJRZsWrdPflif3SA== X-Gm-Gg: AZFdTZfveXIOE+btMwbnsasmZ8Km+DXKPxKglCbTshgc4+cD2hhwMYfoFtsOatgqesq T2EkZLsqVYyiCJXnaWbEmKjp9t1s1lCp4/uKD2NYwTA5cQzaCO8a4189MG6uw5pVF0XqilTKr1Q Jva6E/h6IG1dA42M2uj12Zb57ivkBDHM6m7ewiqACirJG3e0163RqNWb7MMF4sJwBrCAnOteavq uZh6DFjmOv0scSNxyMFxRDeDN26E0I4Qlz7s4phYwYRmGpIdrSSzH0qbJuM5/73DKCVAw/D1H1z MOqI4a78F3aq0Qplut0EK3L4vR/mWvtGPv7b4J9NEXy3hADaN4qlVNuQbHeCelrBRixjotZRW3v 0UqEHXxlKQ3OmcvDwDmWOtBiSnA== X-Received: by 2002:aa7:c68d:0:b0:6bb:6d98:2408 with SMTP id 4fb4d7f45d1cf-6bb6d9826a9mr9326111a12.19.1796139472956; Tue, 01 Dec 2026 07:37:52 -0800 (PST) X-Received: by 2002:aa7:c68d:0:b0:6bb:6d98:2408 with SMTP id 4fb4d7f45d1cf-6bb6d9826a9mr9326098a12.19.1796139472403; 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=AW+XC+ihM3hvrvxCUIMxO2jLDOUmXaFWZr61iSEqieq0pWFvioN75TDvLQDlWQ1UdW 4nSd45xAQa2pf6+LmFs0Ikp1uWrYNKu+wkuL6FerRdiRY7m4vmlEwSnYSxRKczL/aQ+t H4hLRCx2eAECd2jSHthB42FyRWEAQGgnWZqm/grukLivcAgI1gM1qLZjKkH/ZVAQa0IZ JxOciLyxATxySJ+2NjPvRd9nov0KyFGozVyog81N2sLQA0jtgFIZN8hBnxkn0Wi8JeiA P8wj7g02/ySTUGcPb6eWge5N6BFPYNti0zm/J4+2cN2XXqxWTzU2+b7fiBavbXJI67FS PB0Q== 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=+Doz1ivfk5qNOSu51EG074D+IatoNqVJsY17DFySIL8=; fh=/QSWnKFFIPNLStgUoDwCQRaXnWcMIG7fyKJgHY+VEpU=; b=XOO22mnsjtTsoY2enjnYQLbXTY76utunYRaOxwPZsXB40omyo2bq/5/3+0xgg15KJW 3YhLvQmFJ5kjkSgO9rdVemoixQIKV2bAdvSSW/ST50JgzKz9StJ2vYfaB17g9ELI34Xd xh5tJlGbmK/YcO8wJFZYa6bPcw3HoMBa1c5MLRSlLcXnaMR8LaSprGUSDlHjVYeYy99c fYr6szAF+lNM2qbLyohZOM4eTGUgGGpZgVBvvMs5tF1i97IoaMnUbe4n0w09odrwJtRS x46z9FBjUR5sS3W3f6Xv8nKL/IdElK7T1WejuUK37XrNE7DHUH6txCyuxUN29m25rwMY KHug==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=N5NcxWKJ; 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-6bc0235803asi4621852a12.84.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=N5NcxWKJ; 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=+Doz1ivfk5qNOSu51EG074D+IatoNqVJsY17DFySIL8=; b=N5NcxWKJiIcb J+68vZ9CjXPAKdEDE1g9rmBn0fLDiGS4eFlIpgdyh7vJ7rkdxXZzWTrpfy4QrAOEwJDtYDbcmleF2 IlIl7M9uOUjAk3ceyacpIK5ePbQROm7C6Iytqo+E4IQulJKWFtAadiKelzPYMd3Kx6unCkBUrc7+4 6KAuvwutzjBi51DLa0Z9NXYccQCVmhHecCLiqP/CNLLFWxqcQ34/7lWY9Iau1dG3gXLTRRTCGth09 vnnYFug7aV3qDejtPArIHU/uhHAKwVbIlJ2C7UqegG9yQ5rAHAHoklPRW+4dlBu/NTdzxW8eVZofG 7g3igrdH+29IAfLM6Br8tQ==; 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-1V; Tue, 01 Dec 2026 16:37:42 +0100 From: Eva Kurchatova To: khorenko@virtuozzo.com, vladimir.riabchun@virtuozzo.com Date: Tue, 1 Dec 2026 14:10:17 +0200 Message-ID: <20261201153749.2872789-3-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 02/15] ms/tcp: Skip cond_resched() in inet_csk_listen_stop() under BPF context 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: Jiayuan Chen [ Upstream commit eaab8cab451b9502ce224cd202550375b894a467 ] bpf_sock_destroy() runs from the tcp iterator, under rcu_read_lock(). If the sock is a listener that still has children in its accept queue, tcp_abort() ends up in inet_csk_listen_stop() and the cond_resched() there trips the debug check: BUG: sleeping function called from invalid context at net/ipv4/inet_connection_sock.c:1523 in_atomic(): 0, irqs_disabled(): 0, non_block: 0, pid: 628, name: test_progs preempt_count: 0, expected: 0 RCU nest depth: 1, expected: 0 locks held by test_progs/628: 3, last CPU#3: #0: ffff8881158cee18 (&p->lock){+.+.}-{4:4}, at: bpf_seq_read+0x56/0x1210 #1: ffff8881106bb858 (sk_lock-AF_INET6){+.+.}-{0:0}, at: bpf_iter_tcp_seq_show+0x32b/0x4b0 #2: ffffffffb435af20 (rcu_read_lock){....}-{1:3}, at: bpf_iter_run_prog+0x46b/0xde0 CPU: 3 UID: 0 PID: 628 Comm: test_progs Tainted: G W 7.2.0+ #65 PREEMPT Tainted: [W]=WARN Call Trace: dump_stack_lvl+0xc1/0xf0 dump_stack+0x10/0x20 __might_resched+0x3d2/0x610 inet_csk_listen_stop+0x7b/0xbf0 tcp_abort+0x23b/0x3b0 bpf_sock_destroy+0xfc/0x140 bpf_prog_448133d24601754f_iter_tcp6_server+0x81/0x8a bpf_iter_run_prog+0x538/0xde0 bpf_iter_tcp_seq_show+0x26b/0x4b0 bpf_seq_read+0x424/0x1210 vfs_read+0x197/0xe40 ksys_read+0x119/0x240 __x64_sys_read+0x72/0xc0 x64_sys_call+0x647/0x27e0 do_syscall_64+0xe5/0x610 entry_SYSCALL_64_after_hwframe+0x76/0x7e RIP: 0033:0x7fad39b28aca RSP: 002b:00007ffc381c61c0 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 00007ffc381c6a88 RCX: 00007fad39b28aca RDX: 0000000000000032 RSI: 00007ffc381c6250 RDI: 0000000000000014 RBP: 00007ffc381c61e0 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000003 R13: 0000000000000000 R14: 000055f077c1bbb0 R15: 00007fad3a0f3000 The commit that added the kfunc already guards lock_sock() in tcp_abort() and udp_abort() with has_current_bpf_ctx(), but missed the listener path. Do the same for the cond_resched(). The loop runs inside the iterator's rcu_read_lock(), it must not reschedule or report a quiescent state there. Fixes: 4ddbcb886268 ("bpf: Add bpf_sock_destroy kfunc") Signed-off-by: Jiayuan Chen Link: https://lore.kernel.org/r/20260910112736.153710-1-jiayuan.chen@linux.dev Signed-off-by: Alexei Starovoitov Signed-off-by: Sasha Levin (cherry picked from commit 5b52417c6196e05618a3b5d9753dbed9adef0166) https://virtuozzo.atlassian.net/browse/VSTOR-157577 Feature: fix ms/net Signed-off-by: Eva Kurchatova Reviewed-by: Sashiko --- net/ipv4/inet_connection_sock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index 21334e0c015e..e8c2070ad7f0 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c @@ -1520,7 +1520,8 @@ void inet_csk_listen_stop(struct sock *sk) local_bh_enable(); sock_put(child); - cond_resched(); + if (!has_current_bpf_ctx()) + cond_resched(); } if (queue->fastopenq.rskq_rst_head) { /* Free all the reqs queued in rskq_rst_head. */ -- 2.56.1 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel