From: Stanislav Kinsburskiy <skinsbur...@virtuozzo.com>

This is needed to preserve current behaviour, when process in initial pid and
user namespaces (i.e. in VE#0) can receive events from all the processes in
the system.

Signed-off-by: Stanislav Kinsburskiy <skinsbur...@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabi...@virtuozzo.com>

(cherry picked from vz8 commit cf171d6baf24b967796092bbc482aaddd0104d25)
Signed-off-by: Pavel Tikhomirov <ptikhomi...@virtuozzo.com>
---
 drivers/connector/cn_proc.c | 29 ++++++++++++++++++++++-------
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c
index c795a27e2a98..16091278ebb3 100644
--- a/drivers/connector/cn_proc.c
+++ b/drivers/connector/cn_proc.c
@@ -105,16 +105,16 @@ static int proc_event_num_listeners(struct ve_struct *ve)
        return 0;
 }
 
-static void proc_event_connector(struct task_struct *task,
-                                int what, int cookie,
-                                bool (*fill_event)(struct proc_event *ev,
-                                                   struct ve_struct *ve,
-                                                   struct task_struct *task,
-                                                   int cookie))
+static void proc_event_connector_ve(struct task_struct *task,
+                                   struct ve_struct *ve,
+                                   int what, int cookie,
+                                   bool (*fill_event)(struct proc_event *ev,
+                                                      struct ve_struct *ve,
+                                                      struct task_struct *task,
+                                                      int cookie))
 {
        struct cn_msg *msg;
        __u8 buffer[CN_PROC_MSG_SIZE] __aligned(8);
-       struct ve_struct *ve = task->task_ve;
 
        if (proc_event_num_listeners(ve) < 1)
                return;
@@ -127,6 +127,21 @@ static void proc_event_connector(struct task_struct *task,
        send_msg_ve(ve, msg);
 }
 
+static void proc_event_connector(struct task_struct *task,
+                                int what, int cookie,
+                                bool (*fill_event)(struct proc_event *ev,
+                                                   struct ve_struct *ve,
+                                                   struct task_struct *task,
+                                                   int cookie))
+{
+       struct ve_struct *ve = task->task_ve;
+
+       if (!ve_is_super(ve))
+               proc_event_connector_ve(task, ve, what, cookie, fill_event);
+
+       proc_event_connector_ve(task, get_ve0(), what, cookie, fill_event);
+}
+
 static bool fill_fork_event(struct proc_event *ev, struct ve_struct *ve,
                            struct task_struct *task, int unused)
 {
-- 
2.31.1

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to