[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 28/31] gdbstub.c: fix GDB connection segfault caused
From: |
Michael Tokarev |
Subject: |
[Qemu-devel] [PULL 28/31] gdbstub.c: fix GDB connection segfault caused by empty machines |
Date: |
Tue, 24 Jan 2017 12:39:32 +0300 |
From: Ziyue Yang <address@hidden>
This patch is to fix the segmentation fault caused by attaching
GDB to a QEMU instance initialized with "-M none" option.
The bug can be reproduced by
> ./qemu-system-x86_64 -M none -nographic -S -s
and attach a GDB to it by
> gdb -ex 'target remote :1234
The segmentation fault was originally caused by trying to read
the information about CPU when communicating with GDB. However,
it's impossible for any control flow to exist on an empty machine,
nor can CPU's be hot plugged to an empty machine later by QOM
commands. So I think simply disabling GDB connections on empty
machines makes sense.
Signed-off-by: Ziyue Yang <address@hidden>
Reviewed-by: Thomas Huth <address@hidden>
Signed-off-by: Michael Tokarev <address@hidden>
---
gdbstub.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/gdbstub.c b/gdbstub.c
index de9b62b..27e0923 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -18,6 +18,7 @@
*/
#include "qemu/osdep.h"
#include "qapi/error.h"
+#include "qemu/error-report.h"
#include "qemu/cutils.h"
#include "cpu.h"
#ifdef CONFIG_USER_ONLY
@@ -1732,6 +1733,12 @@ int gdbserver_start(const char *device)
CharDriverState *mon_chr;
ChardevCommon common = { 0 };
+ if (!first_cpu) {
+ error_report("gdbstub: meaningless to attach gdb to a "
+ "machine without any CPU.");
+ return -1;
+ }
+
if (!device)
return -1;
if (strcmp(device, "none") != 0) {
--
2.1.4
- [Qemu-devel] [PULL 01/31] doc: don't mention -memory, it is -m, (continued)
- [Qemu-devel] [PULL 01/31] doc: don't mention -memory, it is -m, Michael Tokarev, 2017/01/24
- [Qemu-devel] [PULL 12/31] qemu-img: remove dead check, Michael Tokarev, 2017/01/24
- [Qemu-devel] [PULL 15/31] qga: fix erroneous argument to strerror, Michael Tokarev, 2017/01/24
- [Qemu-devel] [PULL 11/31] pcie: fix typo in comments, Michael Tokarev, 2017/01/24
- [Qemu-devel] [PULL 09/31] object.h: spelling fix, Michael Tokarev, 2017/01/24
- [Qemu-devel] [PULL 17/31] hw/i386/kvmvapic: Remove dead code in patch_hypercalls(), Michael Tokarev, 2017/01/24
- [Qemu-devel] [PULL 13/31] pci-assign: avoid pointless stat, Michael Tokarev, 2017/01/24
- [Qemu-devel] [PULL 06/31] hw: Fix typos found by codespell, Michael Tokarev, 2017/01/24
- [Qemu-devel] [PULL 02/31] hw/block/m25p80: Fix typo in local macro name, Michael Tokarev, 2017/01/24
- [Qemu-devel] [PULL 31/31] hw/isa/isa-bus: Set category of the "isabus-bridge" device, Michael Tokarev, 2017/01/24
- [Qemu-devel] [PULL 28/31] gdbstub.c: fix GDB connection segfault caused by empty machines,
Michael Tokarev <=
- [Qemu-devel] [PULL 16/31] doc/usb2: fix typo, Michael Tokarev, 2017/01/24
- [Qemu-devel] [PULL 25/31] hw/display/framebuffer.c: Avoid overflow for framebuffers > 4GB, Michael Tokarev, 2017/01/24
- [Qemu-devel] [PULL 22/31] util/mmap-alloc: check parameter before using, Michael Tokarev, 2017/01/24
- [Qemu-devel] [PULL 30/31] usb: Set category and description of the MTP device, Michael Tokarev, 2017/01/24
- [Qemu-devel] [PULL 19/31] disas/cris.c: Fix Coverity warning about unchecked NULL, Michael Tokarev, 2017/01/24
- [Qemu-devel] [PULL 03/31] README: Add linux to macOS build info, Michael Tokarev, 2017/01/24
- [Qemu-devel] [PULL 07/31] qemu-options: cleanup duplicated help message for kernel_irqchip, Michael Tokarev, 2017/01/24
- [Qemu-devel] [PULL 05/31] include: Fix typos found by codespell, Michael Tokarev, 2017/01/24
- [Qemu-devel] [PULL 29/31] gdbstub.c: update old error report statements, Michael Tokarev, 2017/01/24
- [Qemu-devel] [PULL 21/31] vfio: remove a duplicated word in comments, Michael Tokarev, 2017/01/24