• Linus Torvalds's avatar
    ptrace_attach: fix possible deadlock schenario with irqs · f358166a
    Linus Torvalds authored
    Eric Biederman points out that we can't take the task_lock while holding
    tasklist_lock for writing, because another CPU that holds the task lock
    might take an interrupt that then tries to take tasklist_lock for writing.
    
    Which would be a nasty deadlock, with one CPU spinning forever in an
    interrupt handler (although admittedly you need to really work at
    triggering it ;)
    
    Since the ptrace_attach() code is special and very unusual, just make it
    be extra careful, and use trylock+repeat to avoid the possible deadlock.
    
    Cc: Oleg Nesterov <oleg@tv-sign.ru>
    Cc: Eric W. Biederman <ebiederm@xmission.com>
    Cc: Roland McGrath <roland@redhat.com>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    f358166a
ptrace.c 11.5 KB