[Devel] [PATCH RH9 13/26] proc connector: use generic event helper for comm event

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Thu Oct 7 15:53:53 MSK 2021


From: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>

Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin at virtuozzo.com>

(cherry picked from vz8 commit 40a636406378386a7b035a5e7af4de474da017a1)
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 drivers/connector/cn_proc.c | 25 +++++++------------------
 1 file changed, 7 insertions(+), 18 deletions(-)

diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c
index 3d163aa0883e..a954ba98b222 100644
--- a/drivers/connector/cn_proc.c
+++ b/drivers/connector/cn_proc.c
@@ -207,29 +207,18 @@ void proc_ptrace_connector(struct task_struct *task, int ptrace_id)
 			     fill_ptrace_event);
 }
 
-void proc_comm_connector(struct task_struct *task)
+static bool fill_comm_event(struct proc_event *ev, struct task_struct *task,
+			    int unused)
 {
-	struct cn_msg *msg;
-	struct proc_event *ev;
-	__u8 buffer[CN_PROC_MSG_SIZE] __aligned(8);
-
-	if (atomic_read(&proc_event_num_listeners) < 1)
-		return;
-
-	msg = buffer_to_cn_msg(buffer);
-	ev = (struct proc_event *)msg->data;
-	memset(&ev->event_data, 0, sizeof(ev->event_data));
-	ev->timestamp_ns = ktime_get_ns();
-	ev->what = PROC_EVENT_COMM;
 	ev->event_data.comm.process_pid  = task->pid;
 	ev->event_data.comm.process_tgid = task->tgid;
 	get_task_comm(ev->event_data.comm.comm, task);
+	return true;
+}
 
-	memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
-	msg->ack = 0; /* not used */
-	msg->len = sizeof(*ev);
-	msg->flags = 0; /* not used */
-	send_msg(msg);
+void proc_comm_connector(struct task_struct *task)
+{
+	proc_event_connector(task, PROC_EVENT_COMM, 0, fill_comm_event);
 }
 
 void proc_coredump_connector(struct task_struct *task)
-- 
2.31.1



More information about the Devel mailing list