Commit 95c3eb76dc07fd81289888ffc42948196b34b444

Authored by Oleg Nesterov
Committed by Linus Torvalds
1 parent 6588c1e3ff

ptrace: kill __ptrace_detach(), fix ->exit_state check

Move the code from __ptrace_detach() to its single caller and kill this
helper.

Also, fix the ->exit_state check, we shouldn't wake up EXIT_DEAD tasks.
Actually, I think task_is_stopped_or_traced() makes more sense, but this
needs another patch.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Cc: Jerome Marchand <jmarchan@redhat.com>
Cc: Roland McGrath <roland@redhat.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 9 additions and 13 deletions Side-by-side Diff

... ... @@ -235,16 +235,6 @@
235 235 return retval;
236 236 }
237 237  
238   -static inline void __ptrace_detach(struct task_struct *child, unsigned int data)
239   -{
240   - child->exit_code = data;
241   - /* .. re-parent .. */
242   - __ptrace_unlink(child);
243   - /* .. and wake it up. */
244   - if (child->exit_state != EXIT_ZOMBIE)
245   - wake_up_process(child);
246   -}
247   -
248 238 int ptrace_detach(struct task_struct *child, unsigned int data)
249 239 {
250 240 if (!valid_signal(data))
251 241  
... ... @@ -254,10 +244,16 @@
254 244 ptrace_disable(child);
255 245 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
256 246  
257   - write_lock_irq(&tasklist_lock);
258 247 /* protect against de_thread()->release_task() */
259   - if (child->ptrace)
260   - __ptrace_detach(child, data);
  248 + write_lock_irq(&tasklist_lock);
  249 + if (child->ptrace) {
  250 + child->exit_code = data;
  251 +
  252 + __ptrace_unlink(child);
  253 +
  254 + if (!child->exit_state)
  255 + wake_up_process(child);
  256 + }
261 257 write_unlock_irq(&tasklist_lock);
262 258  
263 259 return 0;