Fix use-after-free in gdbserver
authorTom Tromey <tom@tromey.com>
Mon, 30 Jul 2018 01:21:01 +0000 (19:21 -0600)
committerTom Tromey <tom@tromey.com>
Thu, 29 Nov 2018 17:47:42 +0000 (10:47 -0700)
commitd105de22fc385da878e8db44c9503a7f30419322
tree0c14538cb98df9bb05c66cef9ca25286feab9bf7
parente368bf56d38afecd1ac0e19c9e9cb54e2bb4fad2
Fix use-after-free in gdbserver

-fsanitize=address pointed out a use-after-free in gdbserver.  In
particular, handle_detach could reference "process" after it was
deleted by detach_inferior.  Avoiding this also necessitated changing
target_ops::join to take a pid rather than a process_info*.

Tested by the buildbot using a few of the gdbserver builders.

gdb/gdbserver/ChangeLog
2018-11-29  Tom Tromey  <tom@tromey.com>

* win32-low.c (win32_join): Take pid, not process.
* target.h (struct target_ops) <join>: Change argument type.
(join_inferior): Change argument name.
* spu-low.c (spu_join): Take pid, not process.
* server.c (handle_detach): Preserve pid before destroying
process.
* lynx-low.c (lynx_join): Take pid, not process.
* linux-low.c (linux_join): Take pid, not process.
gdb/gdbserver/ChangeLog
gdb/gdbserver/linux-low.c
gdb/gdbserver/lynx-low.c
gdb/gdbserver/server.c
gdb/gdbserver/spu-low.c
gdb/gdbserver/target.h
gdb/gdbserver/win32-low.c