[Devel] [PATCH RH9 20/26] proc connector: pass VE to event fillers
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Thu Oct 7 15:54:00 MSK 2021
From: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
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>
Reviewed-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
(cherry picked from vz8 commit 18f93852ccecefdddf82b9aa07834e45503d986e)
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
drivers/connector/cn_proc.c | 40 +++++++++++++++++++------------------
1 file changed, 21 insertions(+), 19 deletions(-)
diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c
index 838aeae09fcd..455c84125251 100644
--- a/drivers/connector/cn_proc.c
+++ b/drivers/connector/cn_proc.c
@@ -72,10 +72,11 @@ static inline void send_msg_ve(struct ve_struct *ve, struct cn_msg *msg)
local_unlock(&ve->cn->local_event->lock);
}
-static struct cn_msg *cn_msg_fill(__u8 *buffer,
+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))
{
@@ -94,7 +95,7 @@ static struct cn_msg *cn_msg_fill(__u8 *buffer,
msg->len = sizeof(*ev);
msg->flags = 0; /* not used */
- 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)
@@ -107,6 +108,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))
{
@@ -117,7 +119,7 @@ static void proc_event_connector(struct task_struct *task,
if (proc_event_num_listeners(ve) < 1)
return;
- msg = cn_msg_fill(buffer, task, what, cookie, fill_event);
+ msg = cn_msg_fill(buffer, ve, task, what, cookie, fill_event);
if (!msg)
return;
@@ -125,8 +127,8 @@ static void proc_event_connector(struct task_struct *task,
send_msg_ve(ve, msg);
}
-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;
@@ -145,8 +147,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);
@@ -158,8 +160,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;
@@ -186,8 +188,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);
@@ -199,8 +201,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);
@@ -221,8 +223,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);
@@ -235,8 +237,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)
{
struct task_struct *parent;
@@ -262,8 +264,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)
{
struct task_struct *parent;
--
2.31.1
More information about the Devel
mailing list