Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ptrace: s/tracehook_tracer_task()/ptrace_parent()/

tracehook.h is on the way out. Rename tracehook_tracer_task() to
ptrace_parent() and move it from tracehook.h to ptrace.h.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: John Johansen <john.johansen@canonical.com>
Cc: Stephen Smalley <sds@tycho.nsa.gov>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>

authored by

Tejun Heo and committed by
Oleg Nesterov
06d98473 4b9d33e6

+23 -23
+1 -1
fs/proc/array.c
··· 172 172 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0; 173 173 tpid = 0; 174 174 if (pid_alive(p)) { 175 - struct task_struct *tracer = tracehook_tracer_task(p); 175 + struct task_struct *tracer = ptrace_parent(p); 176 176 if (tracer) 177 177 tpid = task_pid_nr_ns(tracer, ns); 178 178 }
+1 -1
fs/proc/base.c
··· 216 216 if (task_is_stopped_or_traced(task)) { 217 217 int match; 218 218 rcu_read_lock(); 219 - match = (tracehook_tracer_task(task) == current); 219 + match = (ptrace_parent(task) == current); 220 220 rcu_read_unlock(); 221 221 if (match && ptrace_may_access(task, PTRACE_MODE_ATTACH)) 222 222 return mm;
+18
include/linux/ptrace.h
··· 151 151 unsigned long data); 152 152 153 153 /** 154 + * ptrace_parent - return the task that is tracing the given task 155 + * @task: task to consider 156 + * 157 + * Returns %NULL if no one is tracing @task, or the &struct task_struct 158 + * pointer to its tracer. 159 + * 160 + * Must called under rcu_read_lock(). The pointer returned might be kept 161 + * live only by RCU. During exec, this may be called with task_lock() held 162 + * on @task, still held from when check_unsafe_exec() was called. 163 + */ 164 + static inline struct task_struct *ptrace_parent(struct task_struct *task) 165 + { 166 + if (unlikely(task->ptrace)) 167 + return rcu_dereference(task->parent); 168 + return NULL; 169 + } 170 + 171 + /** 154 172 * ptrace_event_enabled - test whether a ptrace event is enabled 155 173 * @task: ptracee of interest 156 174 * @event: %PTRACE_EVENT_* to test
-18
include/linux/tracehook.h
··· 130 130 } 131 131 132 132 /** 133 - * tracehook_tracer_task - return the task that is tracing the given task 134 - * @tsk: task to consider 135 - * 136 - * Returns NULL if no one is tracing @task, or the &struct task_struct 137 - * pointer to its tracer. 138 - * 139 - * Must called under rcu_read_lock(). The pointer returned might be kept 140 - * live only by RCU. During exec, this may be called with task_lock() 141 - * held on @task, still held from when tracehook_unsafe_exec() was called. 142 - */ 143 - static inline struct task_struct *tracehook_tracer_task(struct task_struct *tsk) 144 - { 145 - if (tsk->ptrace & PT_PTRACED) 146 - return rcu_dereference(tsk->parent); 147 - return NULL; 148 - } 149 - 150 - /** 151 133 * tracehook_signal_handler - signal handler setup is complete 152 134 * @sig: number of signal being delivered 153 135 * @info: siginfo_t of signal being delivered
+1 -1
security/apparmor/domain.c
··· 67 67 int error = 0; 68 68 69 69 rcu_read_lock(); 70 - tracer = tracehook_tracer_task(task); 70 + tracer = ptrace_parent(task); 71 71 if (tracer) { 72 72 /* released below */ 73 73 cred = get_task_cred(tracer);
+2 -2
security/selinux/hooks.c
··· 2048 2048 u32 ptsid = 0; 2049 2049 2050 2050 rcu_read_lock(); 2051 - tracer = tracehook_tracer_task(current); 2051 + tracer = ptrace_parent(current); 2052 2052 if (likely(tracer != NULL)) { 2053 2053 sec = __task_cred(tracer)->security; 2054 2054 ptsid = sec->sid; ··· 5314 5314 Otherwise, leave SID unchanged and fail. */ 5315 5315 ptsid = 0; 5316 5316 task_lock(p); 5317 - tracer = tracehook_tracer_task(p); 5317 + tracer = ptrace_parent(p); 5318 5318 if (tracer) 5319 5319 ptsid = task_sid(tracer); 5320 5320 task_unlock(p);