[Devel] [PATCH v2 21/27] proc connector: pass VE to event fillers

Stanislav Kinsburskiy skinsbursky at virtuozzo.com
Thu Aug 17 17:00:48 MSK 2017


Precursor patch. VE will be used later to get proper pid and user namespaces
for correct event generation.

Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
---
 drivers/connector/cn_proc.c |   36 +++++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c
index ff99f06..b66fde8 100644
--- a/drivers/connector/cn_proc.c
+++ b/drivers/connector/cn_proc.c
@@ -64,6 +64,7 @@ static struct cn_msg *cn_msg_fill(__u8 *buffer, struct ve_struct *ve,
 				  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))
 {
@@ -85,7 +86,7 @@ static struct cn_msg *cn_msg_fill(__u8 *buffer, struct ve_struct *ve,
 	ev->timestamp_ns = timespec_to_ns(&ts);
 	ev->what = what;
 
-	return fill_event(ev, task, cookie) ? msg : NULL;
+	return fill_event(ev, ve, task, cookie) ? msg : NULL;
 }
 
 static int proc_event_num_listeners(struct ve_struct *ve)
@@ -98,6 +99,7 @@ static int proc_event_num_listeners(struct ve_struct *ve)
 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))
 {
@@ -116,8 +118,8 @@ static void proc_event_connector(struct task_struct *task,
 	cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
 }
 
-static bool fill_fork_event(struct proc_event *ev, struct task_struct *task,
-			    int unused)
+static bool fill_fork_event(struct proc_event *ev, struct ve_struct *ve,
+			    struct task_struct *task, int unused)
 {
 	struct task_struct *parent;
 
@@ -136,8 +138,8 @@ void proc_fork_connector(struct task_struct *task)
 	proc_event_connector(task, PROC_EVENT_FORK, 0, fill_fork_event);
 }
 
-static bool fill_exec_event(struct proc_event *ev, struct task_struct *task,
-			    int unused)
+static bool fill_exec_event(struct proc_event *ev, struct ve_struct *ve,
+			    struct task_struct *task, int unused)
 {
 	ev->event_data.exec.process_pid = task_pid_nr_ns(task, &init_pid_ns);
 	ev->event_data.exec.process_tgid = task_tgid_nr_ns(task, &init_pid_ns);
@@ -149,8 +151,8 @@ void proc_exec_connector(struct task_struct *task)
 	proc_event_connector(task, PROC_EVENT_EXEC, 0, fill_exec_event);
 }
 
-static bool fill_id_event(struct proc_event *ev, struct task_struct *task,
-			  int which_id)
+static bool fill_id_event(struct proc_event *ev, struct ve_struct *ve,
+			  struct task_struct *task, int which_id)
 {
 	const struct cred *cred;
 
@@ -177,8 +179,8 @@ void proc_id_connector(struct task_struct *task, int which_id)
 	proc_event_connector(task, which_id, which_id, fill_id_event);
 }
 
-static bool fill_sid_event(struct proc_event *ev, struct task_struct *task,
-			   int unused)
+static bool fill_sid_event(struct proc_event *ev, struct ve_struct *ve,
+			   struct task_struct *task, int unused)
 {
 	ev->event_data.sid.process_pid = task_pid_nr_ns(task, &init_pid_ns);
 	ev->event_data.sid.process_tgid = task_tgid_nr_ns(task, &init_pid_ns);
@@ -190,8 +192,8 @@ void proc_sid_connector(struct task_struct *task)
 	proc_event_connector(task, PROC_EVENT_SID, 0, fill_sid_event);
 }
 
-static bool fill_ptrace_event(struct proc_event *ev, struct task_struct *task,
-			   int ptrace_id)
+static bool fill_ptrace_event(struct proc_event *ev, struct ve_struct *ve,
+			      struct task_struct *task, int ptrace_id)
 {
 	ev->event_data.ptrace.process_pid  = task_pid_nr_ns(task, &init_pid_ns);
 	ev->event_data.ptrace.process_tgid = task_tgid_nr_ns(task, &init_pid_ns);
@@ -212,8 +214,8 @@ void proc_ptrace_connector(struct task_struct *task, int ptrace_id)
 			     fill_ptrace_event);
 }
 
-static bool fill_comm_event(struct proc_event *ev, struct task_struct *task,
-			    int unused)
+static bool fill_comm_event(struct proc_event *ev, struct ve_struct *ve,
+			    struct task_struct *task, int unused)
 {
 	ev->event_data.comm.process_pid  = task_pid_nr_ns(task, &init_pid_ns);
 	ev->event_data.comm.process_tgid = task_tgid_nr_ns(task, &init_pid_ns);
@@ -226,8 +228,8 @@ void proc_comm_connector(struct task_struct *task)
 	proc_event_connector(task, PROC_EVENT_COMM, 0, fill_comm_event);
 }
 
-static bool fill_coredump_event(struct proc_event *ev, struct task_struct *task,
-				int unused)
+static bool fill_coredump_event(struct proc_event *ev, struct ve_struct *ve,
+				struct task_struct *task, int unused)
 {
 	ev->event_data.coredump.process_pid = task_pid_nr_ns(task, &init_pid_ns);
 	ev->event_data.coredump.process_tgid = task_tgid_nr_ns(task, &init_pid_ns);
@@ -239,8 +241,8 @@ void proc_coredump_connector(struct task_struct *task)
 	proc_event_connector(task, PROC_EVENT_COREDUMP, 0, fill_coredump_event);
 }
 
-static bool fill_exit_event(struct proc_event *ev, struct task_struct *task,
-			    int unused)
+static bool fill_exit_event(struct proc_event *ev, struct ve_struct *ve,
+			    struct task_struct *task, int unused)
 {
 	ev->event_data.exit.process_pid = task_pid_nr_ns(task, &init_pid_ns);
 	ev->event_data.exit.process_tgid = task_tgid_nr_ns(task, &init_pid_ns);



More information about the Devel mailing list