From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (unknown [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id B9C3D80036 for ; Wed, 26 Aug 2026 13:10:48 +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 67QD9Vk1008358; Wed, 26 Aug 2026 16:09:32 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 67QD9Vk1008358 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="LiEMozK6" Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 67QD9FXj008328 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Wed, 26 Aug 2026 16:09:16 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 67QD9FXj008328 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-c20262b5e10so95630166b.1 for ; Wed, 26 Aug 2026 06:09:15 -0700 (PDT) X-Gm-Message-State: AFuF++nPX/XiPZcjfwcn/aZOZelOm9Bf/unfyXG7/gzwQRZlAoOe78Aa 8acOj2vpr4BtQmUB4xaKqmAXtIAk7K8pZtyjArwjlnZYl9iSuvgc+jQp98wdwxtSARllo1GFSh6 PBrWu21YtfM9EbYH5uNunDQ1ZTi0nm47hkVSEhg0yHFOdNqzrcRVqIA== X-Gm-Gg: AR+sD12lAsSiPx/BYf18lqlU8WJsq71OmndqHvC+NX61xfegM0ZDxTdBRGCJ4sXujSL y3prhaaubDwjNW2UzwqRcI3ezikNSoMOOtbYBfUTtpeq0kIGX+J7dHzxaCSF7nPHqhwJYKkDxcK dSNZFDkFvhe00xS5S8IEfxI2eaKULRb524eWb2fxLyFCAUzeIcouUn8MNv3cd2RshqwuvJ+YFz7 vegTxiDopHZzzPouTiwYAxJ/FMlGHsVmLPmRDJ+xIS1Cy3biglWBIUW69pkN/q6VZQInfq9wEfL xA/GCwmv6BZEFqIkT6Wr+XG/mzHJ3E0WOAt/HbjxYvuB1d1abfxLROa2LuzBR3q4IWOnN1NdGFi XPR1qIGGGqp6YmUQ2dQ== X-Received: by 2002:a17:907:e98b:b0:c15:ee0d:9a32 with SMTP id a640c23a62f3a-c250c2e545amr776072766b.21.1787749755591; Wed, 26 Aug 2026 06:09:15 -0700 (PDT) X-Received: by 2002:a17:907:e98b:b0:c15:ee0d:9a32 with SMTP id a640c23a62f3a-c250c2e545amr776059966b.21.1787749754807; Wed, 26 Aug 2026 06:09:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1787749754; cv=none; d=google.com; s=arc-20260327; b=cXF8klWiQ/443XKTE/DPLtS6bSxjqdJys24YfDxbsBfx0HGN0bOWwpdF1YLCFYtnyt CB/tcQrL9X4tgv3brs7j1sjf+En7VVV57PzbzRUFD6bPJIoEwe4p8JUIn+3YwmSYPNnu ZObFNzyTqx73E2iyp9q2jbn9G0xtYKvoj1vR7L5kINLEmWwWZoIOLJMS9nrG9cGgqAlQ 4Vq1BUplgxvl1yA+g6Utpqno3KirjNhS9ZlDc5osdysJkvzHTXhNR8iclL5YYpWpvA1n LY95ys23Ruk4c0QUyVbHKkEC0CA5wkuL3WM5D16q+w98ZKb54O8dwasTxyWBe1GbO+1T DCdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=subject:in-reply-to:cc:to:from:message-id:date:dkim-signature; bh=DqArtTIUYKuTbPqhG13+DSxKVjVToPXIDcKSe2PXV1o=; fh=UoUx/ScICNSLS7LR9gyUDsZM8Zuq0DvPxxrx16Z82mE=; b=DQ39I9cLaM/+UjkNb8NPN8akAlCXJf0w/K+90pRc1L7dhearOjihvSjx0/+2aCYFJZ M44HQ9L5ufADt4fryhEELSYTZblL6WhKoOpRSDBJGDy1CuinP457zVjiN3v2Nz7OQcLX q6RzyZTOorMzLXjMqrRoNJESDoLOn45dL0joKlg/2rV8dR7CIUgtpfnM0oWdKFifx1f+ wcWMJytZ49oIkXuKVPQutORSwUYHP4gh793i7HSqbmKcrPhX4blQVapkyVKyUUMd20XP I9zrr/nvfCMI/Lc42bwjfIIZ/B+V5BbAtaY+87eMQKk2LkG1yh56q/2vi88h65Zm5IRf cTDw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=LiEMozK6; spf=pass (google.com: domain of khorenko@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=khorenko@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-c250a9fadadsi339664766b.258.2026.08.26.06.09.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2026 06:09:14 -0700 (PDT) Received-SPF: pass (google.com: domain of khorenko@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=LiEMozK6; spf=pass (google.com: domain of khorenko@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=khorenko@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=Subject:From:Message-Id:Date:Content-Type: MIME-Version; bh=DqArtTIUYKuTbPqhG13+DSxKVjVToPXIDcKSe2PXV1o=; b=LiEMozK6HIt4 QgZuVPgW4P0A/F52MbpIaaxbWf9H0pt/uRDDFbWXYVpZUouE/5+cGj68cmQRpJSe0AJfX79IrvMyY m6kB9pBJWAh/5AWQsOEZxXbjLVfP+tof6kJ3L4uy4mXcB12QA9vKU2v2WcVJrWGuCWf+tJ1RQKC6B F8/vFQIahbjddoquHb2nU17KlIoMlfNAYqRB8ET6DD7CZSibsLzTFjamxcqNYJI2mmNTnA3etyqcq i3cIsahbJb9bicdV9DLm51LaSfDPNqDYkoMbFcS799f3TrMivFygMe+vGFGkNwTeGjoPOBEPp6CjT Cn0+MO2czUfT2a6pdxsz3Q==; Received: from ch-demo-asa.virtuozzo.com ([130.117.225.8] helo=f0.sw.ru) by relay.virtuozzo.com with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wzDLD-001rmh-2w; Wed, 26 Aug 2026 15:09:13 +0200 Received: from f0.sw.ru (localhost [127.0.0.1]) by f0.sw.ru (8.18.1/8.18.1/Debian-2) with ESMTP id 67QD9D1h890883; Wed, 26 Aug 2026 15:09:13 +0200 Received: (from kostja@localhost) by f0.sw.ru (8.18.1/8.18.1/Submit) id 67QD9DaH890882; Wed, 26 Aug 2026 15:09:13 +0200 Date: Wed, 26 Aug 2026 15:09:13 +0200 Message-Id: <202608261309.67QD9DaH890882@f0.sw.ru> X-Authentication-Warning: f0.sw.ru: kostja set sender to khorenko@virtuozzo.com using -f From: Konstantin Khorenko To: Vasileios Almpanis In-Reply-to: <20260825-connectors-v3-4-7b26773876a0@virtuozzo.com> X-OZ-Fwd: true Cc: OpenVZ devel Subject: Re: [Devel] [PATCH RHEL10 COMMIT] proc connector: pin task VE for the exit event notification 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: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org The commit is pushed to "branch-rh10-6.12.0-211.39.1.16.x.vz10-ovz" and will appear at git@bitbucket.org:openvz/vzkernel.git after rh10-6.12.0-211.39.1.16.10.vz10 ------> commit 5d93a033f4ceafc086a81687ac873c236e2f2d9e Author: Vasileios Almpanis Date: Tue Aug 25 16:19:54 2026 +0000 proc connector: pin task VE for the exit event notification The exit event is reported after exit_notify(), so the parent might have been woken up and reaped the exiting task via wait() -> release_task() -> exit_ve_namespace(), which resets tsk->task_ve to ve0. If that wins the race against the exiting task then the event will only be delivered to the host VE listeners and the in-VE listeners will be skipped. For a task inside a container this means the listener never receives an exit event. The issue is caught by the LTP suite_kernel_misc.exec.cn_pec_sh test: pec_listener terminates upon receiving the exit event of the pid given via -p. When the lost exit event is a child's one, the test fails: cn_pec 3 TFAIL: Event was not detected by the event listener: exit pid: 58388 exit_code: 0 exit_signal: 17 and when it is the event generator's own exit event, the listener polls the netlink socket forever and the test hangs until the LTP timeout kills it (~8h on coverage kernels): 22:51:37 cn_pec 2 TINFO: Testing exec event (nevents=10) 07:11:37 Test timed out, sending SIGTERM! The race was captured using kprobes on the connector send path: p:cnp/pexit proc_exit_connector task=$arg1:x64 p:cnp/vexit exit_ve_namespace task=$arg1:x64 p:cnp/pevcve proc_event_connector_ve what=$arg3:u32 r:cnp/cnsend cn_netlink_send_mult_ve ret=$retval:s64 A normal exit looks like: pexit -> pevcve(ve) -> cnsend ret=0 -> pevcve(ve0) The lost event (task 0xffff89a506d73980 is the exiting child, reaped by its parent pid 465820 in between): 465831 [001] pexit: (proc_exit_connector) task=0xffff89a506d73980 465820 [002] vexit: (exit_ve_namespace) task=0xffff89a506d73980 465831 [001] pevcve: (proc_event_connector_ve) what=2147483648 Only one proc_event_connector_ve() call fires (ve0, no listeners) and cn_netlink_send_mult_ve() is never reached: the event is dropped. This is the same race window that commit c565cc211694 ("proc connector: report proper pid/tgid of an exited process") closed for the task pid/tgid, but nothing pins the VE. Reproducer (fails within ~50 iterations in a CT on a coverage kernel): cd /opt/ltp/testcases/bin/ export PATH=$PATH:/opt/ltp/testcases/bin for i in $(seq 1 1024); do cn_pec.sh >/dev/null 2>&1 || break; done Solve this the same way. Pin the VE in do_exit() before exit_notify() is called and use it in proc_exit_connector() instead of re-reading task->task_ve. https://virtuozzo.atlassian.net/browse/VSTOR-140421 Fixes: 95fa2f096b72 ("ve: Introduce VE namespace") Feature: ve: ve generic structures Signed-off-by: Vasileios Almpanis Reviewed-by: Konstantin Khorenko --- drivers/connector/cn_proc.c | 10 ++++++++-- include/linux/cn_proc.h | 8 ++++++-- kernel/exit.c | 5 ++++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c index 6084308085489..8d8c538cc3cd4 100644 --- a/drivers/connector/cn_proc.c +++ b/drivers/connector/cn_proc.c @@ -401,9 +401,15 @@ static bool fill_exit_event(struct proc_event *ev, struct ve_struct *ve, return true; } -void proc_exit_connector(struct task_struct *task, struct pids *pids) +void proc_exit_connector(struct task_struct *task, struct pids *pids, + struct ve_struct *ve) { - proc_event_connector(task, PROC_EVENT_EXIT, (long)pids, fill_exit_event); + if (!ve_is_super(ve)) + proc_event_connector_ve(task, ve, PROC_EVENT_EXIT, (long)pids, + fill_exit_event); + + proc_event_connector_ve(task, get_ve0(), PROC_EVENT_EXIT, (long)pids, + fill_exit_event); } /* diff --git a/include/linux/cn_proc.h b/include/linux/cn_proc.h index 9701c13d82dfc..aa606192b5c2e 100644 --- a/include/linux/cn_proc.h +++ b/include/linux/cn_proc.h @@ -19,6 +19,8 @@ #include +struct ve_struct; + /* * The struct is used solely for pinning task pids for proc connector * notification on process exit. @@ -36,7 +38,8 @@ void proc_sid_connector(struct task_struct *task); void proc_ptrace_connector(struct task_struct *task, int which_id); void proc_comm_connector(struct task_struct *task); void proc_coredump_connector(struct task_struct *task); -void proc_exit_connector(struct task_struct *task, struct pids *pids); +void proc_exit_connector(struct task_struct *task, struct pids *pids, + struct ve_struct *ve); #else static inline void proc_fork_connector(struct task_struct *task) {} @@ -61,7 +64,8 @@ static inline void proc_ptrace_connector(struct task_struct *task, static inline void proc_coredump_connector(struct task_struct *task) {} -static inline void proc_exit_connector(struct task_struct *task, struct pids *pids) +static inline void proc_exit_connector(struct task_struct *task, struct pids *pids, + struct ve_struct *ve) {} #endif /* CONFIG_PROC_EVENTS */ #endif /* CN_PROC_H */ diff --git a/kernel/exit.c b/kernel/exit.c index 448a734270a7f..94d9bddae2b86 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -936,6 +936,7 @@ void __noreturn do_exit(long code) struct task_struct *tsk = current; int group_dead; struct pids pids; + struct ve_struct *ve; WARN_ON(irqs_disabled()); @@ -1021,8 +1022,10 @@ void __noreturn do_exit(long code) exit_tasks_rcu_start(); pids.pid = get_pid(task_pid(tsk)); pids.tgid = get_pid(task_tgid(tsk)); + ve = get_task_ve(tsk); exit_notify(tsk, group_dead); - proc_exit_connector(tsk, &pids); + proc_exit_connector(tsk, &pids, ve); + put_ve(ve); put_pid(pids.tgid); put_pid(pids.pid); mpol_put_task_policy(tsk); _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel