diff options
Diffstat (limited to 'include/linux/ptrace.h')
| -rw-r--r-- | include/linux/ptrace.h | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h index c6f5f9dd0cee..fd31756e1a00 100644 --- a/include/linux/ptrace.h +++ b/include/linux/ptrace.h | |||
| @@ -121,6 +121,74 @@ static inline void ptrace_unlink(struct task_struct *child) | |||
| 121 | int generic_ptrace_peekdata(struct task_struct *tsk, long addr, long data); | 121 | int generic_ptrace_peekdata(struct task_struct *tsk, long addr, long data); |
| 122 | int generic_ptrace_pokedata(struct task_struct *tsk, long addr, long data); | 122 | int generic_ptrace_pokedata(struct task_struct *tsk, long addr, long data); |
| 123 | 123 | ||
| 124 | /** | ||
| 125 | * task_ptrace - return %PT_* flags that apply to a task | ||
| 126 | * @task: pointer to &task_struct in question | ||
| 127 | * | ||
| 128 | * Returns the %PT_* flags that apply to @task. | ||
| 129 | */ | ||
| 130 | static inline int task_ptrace(struct task_struct *task) | ||
| 131 | { | ||
| 132 | return task->ptrace; | ||
| 133 | } | ||
| 134 | |||
| 135 | /** | ||
| 136 | * ptrace_event - possibly stop for a ptrace event notification | ||
| 137 | * @mask: %PT_* bit to check in @current->ptrace | ||
| 138 | * @event: %PTRACE_EVENT_* value to report if @mask is set | ||
| 139 | * @message: value for %PTRACE_GETEVENTMSG to return | ||
| 140 | * | ||
| 141 | * This checks the @mask bit to see if ptrace wants stops for this event. | ||
| 142 | * If so we stop, reporting @event and @message to the ptrace parent. | ||
| 143 | * | ||
| 144 | * Returns nonzero if we did a ptrace notification, zero if not. | ||
| 145 | * | ||
| 146 | * Called without locks. | ||
| 147 | */ | ||
| 148 | static inline int ptrace_event(int mask, int event, unsigned long message) | ||
| 149 | { | ||
| 150 | if (mask && likely(!(current->ptrace & mask))) | ||
| 151 | return 0; | ||
| 152 | current->ptrace_message = message; | ||
| 153 | ptrace_notify((event << 8) | SIGTRAP); | ||
| 154 | return 1; | ||
| 155 | } | ||
| 156 | |||
| 157 | /** | ||
| 158 | * ptrace_init_task - initialize ptrace state for a new child | ||
| 159 | * @child: new child task | ||
| 160 | * @ptrace: true if child should be ptrace'd by parent's tracer | ||
| 161 | * | ||
| 162 | * This is called immediately after adding @child to its parent's children | ||
| 163 | * list. @ptrace is false in the normal case, and true to ptrace @child. | ||
| 164 | * | ||
| 165 | * Called with current's siglock and write_lock_irq(&tasklist_lock) held. | ||
| 166 | */ | ||
| 167 | static inline void ptrace_init_task(struct task_struct *child, bool ptrace) | ||
| 168 | { | ||
| 169 | INIT_LIST_HEAD(&child->ptrace_entry); | ||
| 170 | INIT_LIST_HEAD(&child->ptraced); | ||
| 171 | child->parent = child->real_parent; | ||
| 172 | child->ptrace = 0; | ||
| 173 | if (unlikely(ptrace)) { | ||
| 174 | child->ptrace = current->ptrace; | ||
| 175 | __ptrace_link(child, current->parent); | ||
| 176 | } | ||
| 177 | } | ||
| 178 | |||
| 179 | /** | ||
| 180 | * ptrace_release_task - final ptrace-related cleanup of a zombie being reaped | ||
| 181 | * @task: task in %EXIT_DEAD state | ||
| 182 | * | ||
| 183 | * Called with write_lock(&tasklist_lock) held. | ||
| 184 | */ | ||
| 185 | static inline void ptrace_release_task(struct task_struct *task) | ||
| 186 | { | ||
| 187 | BUG_ON(!list_empty(&task->ptraced)); | ||
| 188 | ptrace_unlink(task); | ||
| 189 | BUG_ON(!list_empty(&task->ptrace_entry)); | ||
| 190 | } | ||
| 191 | |||
| 124 | #ifndef force_successful_syscall_return | 192 | #ifndef force_successful_syscall_return |
| 125 | /* | 193 | /* |
| 126 | * System call handlers that, upon successful completion, need to return a | 194 | * System call handlers that, upon successful completion, need to return a |
| @@ -246,6 +314,10 @@ static inline void user_enable_block_step(struct task_struct *task) | |||
| 246 | #define arch_ptrace_stop(code, info) do { } while (0) | 314 | #define arch_ptrace_stop(code, info) do { } while (0) |
| 247 | #endif | 315 | #endif |
| 248 | 316 | ||
| 317 | extern int task_current_syscall(struct task_struct *target, long *callno, | ||
| 318 | unsigned long args[6], unsigned int maxargs, | ||
| 319 | unsigned long *sp, unsigned long *pc); | ||
| 320 | |||
| 249 | #endif | 321 | #endif |
| 250 | 322 | ||
| 251 | #endif | 323 | #endif |
