[Devel] [PATCH v2 24/27] proc connector: send events to both VEs if not in VE#0

Stanislav Kinsburskiy skinsbursky at virtuozzo.com
Thu Aug 17 17:01:03 MSK 2017


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 <skinsbursky at 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 17e0247..81f2e56 100644
--- a/drivers/connector/cn_proc.c
+++ b/drivers/connector/cn_proc.c
@@ -96,16 +96,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;
@@ -118,6 +118,21 @@ static void proc_event_connector(struct task_struct *task,
 	cn_netlink_send_ve(ve, msg, CN_IDX_PROC, GFP_KERNEL);
 }
 
+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)
 {



More information about the Devel mailing list