[PATCH 1/5] connector: Use task pid helpers
From: Matt Bennett
Date: Wed Jul 01 2020 - 20:28:08 EST
In preparation for supporting the connector outside of the default
network namespace we switch to using these helpers now. As the connector
is still only supported in the default namespace this change is a no-op.
Signed-off-by: Matt Bennett <matt.bennett@xxxxxxxxxxxxxxxxxxx>
---
drivers/connector/cn_proc.c | 48 ++++++++++++++++++-------------------
1 file changed, 24 insertions(+), 24 deletions(-)
diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c
index 646ad385e490..36a7823c56ec 100644
--- a/drivers/connector/cn_proc.c
+++ b/drivers/connector/cn_proc.c
@@ -83,11 +83,11 @@ void proc_fork_connector(struct task_struct *task)
ev->what = PROC_EVENT_FORK;
rcu_read_lock();
parent = rcu_dereference(task->real_parent);
- ev->event_data.fork.parent_pid = parent->pid;
- ev->event_data.fork.parent_tgid = parent->tgid;
+ ev->event_data.fork.parent_pid = task_pid_vnr(parent);
+ ev->event_data.fork.parent_tgid = task_tgid_vnr(parent);
rcu_read_unlock();
- ev->event_data.fork.child_pid = task->pid;
- ev->event_data.fork.child_tgid = task->tgid;
+ ev->event_data.fork.child_pid = task_pid_vnr(task);
+ ev->event_data.fork.child_tgid = task_tgid_vnr(task);
memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
msg->ack = 0; /* not used */
@@ -110,8 +110,8 @@ void proc_exec_connector(struct task_struct *task)
memset(&ev->event_data, 0, sizeof(ev->event_data));
ev->timestamp_ns = ktime_get_ns();
ev->what = PROC_EVENT_EXEC;
- ev->event_data.exec.process_pid = task->pid;
- ev->event_data.exec.process_tgid = task->tgid;
+ ev->event_data.exec.process_pid = task_pid_vnr(task);
+ ev->event_data.exec.process_tgid = task_tgid_vnr(task);
memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
msg->ack = 0; /* not used */
@@ -134,8 +134,8 @@ void proc_id_connector(struct task_struct *task, int which_id)
ev = (struct proc_event *)msg->data;
memset(&ev->event_data, 0, sizeof(ev->event_data));
ev->what = which_id;
- ev->event_data.id.process_pid = task->pid;
- ev->event_data.id.process_tgid = task->tgid;
+ ev->event_data.id.process_pid = task_pid_vnr(task);
+ ev->event_data.id.process_tgid = task_tgid_vnr(task);
rcu_read_lock();
cred = __task_cred(task);
if (which_id == PROC_EVENT_UID) {
@@ -172,8 +172,8 @@ void proc_sid_connector(struct task_struct *task)
memset(&ev->event_data, 0, sizeof(ev->event_data));
ev->timestamp_ns = ktime_get_ns();
ev->what = PROC_EVENT_SID;
- ev->event_data.sid.process_pid = task->pid;
- ev->event_data.sid.process_tgid = task->tgid;
+ ev->event_data.sid.process_pid = task_pid_vnr(task);
+ ev->event_data.sid.process_tgid = task_tgid_vnr(task);
memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
msg->ack = 0; /* not used */
@@ -196,11 +196,11 @@ void proc_ptrace_connector(struct task_struct *task, int ptrace_id)
memset(&ev->event_data, 0, sizeof(ev->event_data));
ev->timestamp_ns = ktime_get_ns();
ev->what = PROC_EVENT_PTRACE;
- ev->event_data.ptrace.process_pid = task->pid;
- ev->event_data.ptrace.process_tgid = task->tgid;
+ ev->event_data.ptrace.process_pid = task_pid_vnr(task);
+ ev->event_data.ptrace.process_tgid = task_tgid_vnr(task);
if (ptrace_id == PTRACE_ATTACH) {
- ev->event_data.ptrace.tracer_pid = current->pid;
- ev->event_data.ptrace.tracer_tgid = current->tgid;
+ ev->event_data.ptrace.tracer_pid = task_pid_vnr(current);
+ ev->event_data.ptrace.tracer_tgid = task_tgid_vnr(current);
} else if (ptrace_id == PTRACE_DETACH) {
ev->event_data.ptrace.tracer_pid = 0;
ev->event_data.ptrace.tracer_tgid = 0;
@@ -228,8 +228,8 @@ void proc_comm_connector(struct task_struct *task)
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;
+ ev->event_data.comm.process_pid = task_pid_vnr(task);
+ ev->event_data.comm.process_tgid = task_tgid_vnr(task);
get_task_comm(ev->event_data.comm.comm, task);
memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
@@ -254,14 +254,14 @@ void proc_coredump_connector(struct task_struct *task)
memset(&ev->event_data, 0, sizeof(ev->event_data));
ev->timestamp_ns = ktime_get_ns();
ev->what = PROC_EVENT_COREDUMP;
- ev->event_data.coredump.process_pid = task->pid;
- ev->event_data.coredump.process_tgid = task->tgid;
+ ev->event_data.coredump.process_pid = task_pid_vnr(task);
+ ev->event_data.coredump.process_tgid = task_tgid_vnr(task);
rcu_read_lock();
if (pid_alive(task)) {
parent = rcu_dereference(task->real_parent);
- ev->event_data.coredump.parent_pid = parent->pid;
- ev->event_data.coredump.parent_tgid = parent->tgid;
+ ev->event_data.coredump.parent_pid = task_pid_vnr(parent);
+ ev->event_data.coredump.parent_tgid = task_tgid_vnr(parent);
}
rcu_read_unlock();
@@ -287,16 +287,16 @@ void proc_exit_connector(struct task_struct *task)
memset(&ev->event_data, 0, sizeof(ev->event_data));
ev->timestamp_ns = ktime_get_ns();
ev->what = PROC_EVENT_EXIT;
- ev->event_data.exit.process_pid = task->pid;
- ev->event_data.exit.process_tgid = task->tgid;
+ ev->event_data.exit.process_pid = task_pid_vnr(task);
+ ev->event_data.exit.process_tgid = task_tgid_vnr(task);
ev->event_data.exit.exit_code = task->exit_code;
ev->event_data.exit.exit_signal = task->exit_signal;
rcu_read_lock();
if (pid_alive(task)) {
parent = rcu_dereference(task->real_parent);
- ev->event_data.exit.parent_pid = parent->pid;
- ev->event_data.exit.parent_tgid = parent->tgid;
+ ev->event_data.exit.parent_pid = task_pid_vnr(parent);
+ ev->event_data.exit.parent_tgid = task_tgid_vnr(parent);
}
rcu_read_unlock();
--
2.27.0