diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-07-22 18:06:50 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-07-22 18:06:50 -0400 |
| commit | 8209f53d79444747782a28520187abaf689761f2 (patch) | |
| tree | 726270ea29e037f026d77a99787b9d844531ac42 /drivers/connector | |
| parent | 22a3b9771117d566def0150ea787fcc95f16e724 (diff) | |
| parent | eac1b5e57d7abc836e78fd3fbcf77dbeed01edc9 (diff) | |
Merge branch 'ptrace' of git://git.kernel.org/pub/scm/linux/kernel/git/oleg/misc
* 'ptrace' of git://git.kernel.org/pub/scm/linux/kernel/git/oleg/misc: (39 commits)
ptrace: do_wait(traced_leader_killed_by_mt_exec) can block forever
ptrace: fix ptrace_signal() && STOP_DEQUEUED interaction
connector: add an event for monitoring process tracers
ptrace: dont send SIGSTOP on auto-attach if PT_SEIZED
ptrace: mv send-SIGSTOP from do_fork() to ptrace_init_task()
ptrace_init_task: initialize child->jobctl explicitly
has_stopped_jobs: s/task_is_stopped/SIGNAL_STOP_STOPPED/
ptrace: make former thread ID available via PTRACE_GETEVENTMSG after PTRACE_EVENT_EXEC stop
ptrace: wait_consider_task: s/same_thread_group/ptrace_reparented/
ptrace: kill real_parent_is_ptracer() in in favor of ptrace_reparented()
ptrace: ptrace_reparented() should check same_thread_group()
redefine thread_group_leader() as exit_signal >= 0
do not change dead_task->exit_signal
kill task_detached()
reparent_leader: check EXIT_DEAD instead of task_detached()
make do_notify_parent() __must_check, update the callers
__ptrace_detach: avoid task_detached(), check do_notify_parent()
kill tracehook_notify_death()
make do_notify_parent() return bool
ptrace: s/tracehook_tracer_task()/ptrace_parent()/
...
Diffstat (limited to 'drivers/connector')
| -rw-r--r-- | drivers/connector/cn_proc.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c index 2b46a7efa0ac..281902d3f7ec 100644 --- a/drivers/connector/cn_proc.c +++ b/drivers/connector/cn_proc.c | |||
| @@ -28,6 +28,7 @@ | |||
| 28 | #include <linux/init.h> | 28 | #include <linux/init.h> |
| 29 | #include <linux/connector.h> | 29 | #include <linux/connector.h> |
| 30 | #include <linux/gfp.h> | 30 | #include <linux/gfp.h> |
| 31 | #include <linux/ptrace.h> | ||
| 31 | #include <asm/atomic.h> | 32 | #include <asm/atomic.h> |
| 32 | #include <asm/unaligned.h> | 33 | #include <asm/unaligned.h> |
| 33 | 34 | ||
| @@ -166,6 +167,40 @@ void proc_sid_connector(struct task_struct *task) | |||
| 166 | cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL); | 167 | cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL); |
| 167 | } | 168 | } |
| 168 | 169 | ||
| 170 | void proc_ptrace_connector(struct task_struct *task, int ptrace_id) | ||
| 171 | { | ||
| 172 | struct cn_msg *msg; | ||
| 173 | struct proc_event *ev; | ||
| 174 | struct timespec ts; | ||
| 175 | __u8 buffer[CN_PROC_MSG_SIZE]; | ||
| 176 | struct task_struct *tracer; | ||
| 177 | |||
| 178 | if (atomic_read(&proc_event_num_listeners) < 1) | ||
| 179 | return; | ||
| 180 | |||
| 181 | msg = (struct cn_msg *)buffer; | ||
| 182 | ev = (struct proc_event *)msg->data; | ||
| 183 | get_seq(&msg->seq, &ev->cpu); | ||
| 184 | ktime_get_ts(&ts); /* get high res monotonic timestamp */ | ||
| 185 | put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); | ||
| 186 | ev->what = PROC_EVENT_PTRACE; | ||
| 187 | ev->event_data.ptrace.process_pid = task->pid; | ||
| 188 | ev->event_data.ptrace.process_tgid = task->tgid; | ||
| 189 | if (ptrace_id == PTRACE_ATTACH) { | ||
| 190 | ev->event_data.ptrace.tracer_pid = current->pid; | ||
| 191 | ev->event_data.ptrace.tracer_tgid = current->tgid; | ||
| 192 | } else if (ptrace_id == PTRACE_DETACH) { | ||
| 193 | ev->event_data.ptrace.tracer_pid = 0; | ||
| 194 | ev->event_data.ptrace.tracer_tgid = 0; | ||
| 195 | } else | ||
| 196 | return; | ||
| 197 | |||
| 198 | memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id)); | ||
| 199 | msg->ack = 0; /* not used */ | ||
| 200 | msg->len = sizeof(*ev); | ||
| 201 | cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL); | ||
| 202 | } | ||
| 203 | |||
| 169 | void proc_exit_connector(struct task_struct *task) | 204 | void proc_exit_connector(struct task_struct *task) |
| 170 | { | 205 | { |
| 171 | struct cn_msg *msg; | 206 | struct cn_msg *msg; |
