This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Fix read after xfree in linux-nat.c:linux_nat_detach
- From: Pedro Alves <palves at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 11 Apr 2017 13:29:21 -0000
- Subject: [binutils-gdb] Fix read after xfree in linux-nat.c:linux_nat_detach
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a6acac06113f4b04fa0333ee2a3ab3025b43ee7c
commit a6acac06113f4b04fa0333ee2a3ab3025b43ee7c
Author: Philipp Rudo <prudo@linux.vnet.ibm.com>
Date: Tue Apr 11 14:28:51 2017 +0100
Fix read after xfree in linux-nat.c:linux_nat_detach
At the end of linux_nat_detach the main_lwp is deleted (delete_lwp).
This is problematic as during detach (detach_one_lwp and
linux_fork_detach) main_lwp already gets freed. Thus calling
delete_lwp causes a read after free. Fix it by removing the
unnecessary delete_lwp.
gdb/ChangeLog:
2017-04-11 Philipp Rudo <prudo@linux.vnet.ibm.com>
* linux-nat.c (linux_nat_detach): Remove delete_lwp call.
Diff:
---
gdb/ChangeLog | 4 ++++
gdb/linux-nat.c | 1 -
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index dc3393a..60e03e7 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2017-04-11 Philipp Rudo <prudo@linux.vnet.ibm.com>
+
+ * linux-nat.c (linux_nat_detach): Remove delete_lwp call.
+
2017-04-11 Alan Hayward <alan.hayward@arm.com>
* arm-tdep.c (arm_store_return_value): Use FP_REGISTER_SIZE
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index b06e400..8dececf 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -1549,7 +1549,6 @@ linux_nat_detach (struct target_ops *ops, const char *args, int from_tty)
inf_ptrace_detach_success (ops);
}
- delete_lwp (main_lwp->ptid);
}
/* Resume execution of the inferior process. If STEP is nonzero,