ptrace: fix ptrace vs tasklist_lock race

This is an update to the patch so it looks the way it has been presented to the
list:

- Use also ->saved_state in task_state_match_and_set().
- Wait in wait_task_inactive() until the desired task state is in
  ->__state so that the task won't wake up a as part of lock
  resolving. Pointed out by Oleg Nesterov.

Link: https://lore.kernel.org/r/YkW55u6u2fo5QmV7@linutronix.de
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
2 files changed