From nobody Tue Nov 5 05:09:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1553512806661417.19235889830065; Mon, 25 Mar 2019 04:20:06 -0700 (PDT) Received: from localhost ([127.0.0.1]:40747 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h8Ne0-0002AF-CT for importer@patchew.org; Mon, 25 Mar 2019 07:19:56 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59390) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h8NPz-0007fl-DV for qemu-devel@nongnu.org; Mon, 25 Mar 2019 07:05:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h8NPx-0000Zr-EH for qemu-devel@nongnu.org; Mon, 25 Mar 2019 07:05:27 -0400 Received: from greensocs.com ([193.104.36.180]:38713) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h8NPv-0000Yt-AV for qemu-devel@nongnu.org; Mon, 25 Mar 2019 07:05:23 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id DEC337D78AA; Mon, 25 Mar 2019 12:05:21 +0100 (CET) Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id g-67o7Tw_o2q; Mon, 25 Mar 2019 12:05:20 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 9092F7D788E; Mon, 25 Mar 2019 12:05:20 +0100 (CET) Received: from michell-laptop.bar.greensocs.com (antfield.tima.u-ga.fr [147.171.129.253]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 16D617D7887; Mon, 25 Mar 2019 12:05:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1553511921; bh=jMsdF1/7njOw+ibE9Ehl3HJ5ykuTl7a7rchbEnW+tTg=; h=From:To:Cc:Subject:Date; b=LmxE2pxu+LOtYZ0ujNOUvYTRhU4ngW+kgGU0lsJ6/HqDemBVQxdGhvS0/eK0Ct3mX unEBRvrubRBiKNIt12sXwESChh5fzO6vfwtJennAI0zP5P0lbpPNo30uHYt3iijewI G0AqtJHv/NivX0psDokDWmNyw4qfRsDH6vvHKEfk= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=Sp7Tz1RB; dkim=pass (1024-bit key) header.d=greensocs.com header.b=Sp7Tz1RB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1553511920; bh=jMsdF1/7njOw+ibE9Ehl3HJ5ykuTl7a7rchbEnW+tTg=; h=From:To:Cc:Subject:Date; b=Sp7Tz1RBtkikzp0qF1gh3KIuTkJb5BOi4ZnAEWDEG5GFE+e1qyuJxdrKdAvCgZ3Sz KCEz/PCkSualImyi6fZrYPLNvSt1pcfb9c3qISTrCxC4CTH4VkW2ygFEQ0q8NVKRKy Ep4ctujVkLOWgHIjwBcT6niYbF5KwU/NKO8CPSd0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1553511920; bh=jMsdF1/7njOw+ibE9Ehl3HJ5ykuTl7a7rchbEnW+tTg=; h=From:To:Cc:Subject:Date; b=Sp7Tz1RBtkikzp0qF1gh3KIuTkJb5BOi4ZnAEWDEG5GFE+e1qyuJxdrKdAvCgZ3Sz KCEz/PCkSualImyi6fZrYPLNvSt1pcfb9c3qISTrCxC4CTH4VkW2ygFEQ0q8NVKRKy Ep4ctujVkLOWgHIjwBcT6niYbF5KwU/NKO8CPSd0= From: Luc Michel To: qemu-devel@nongnu.org Date: Mon, 25 Mar 2019 12:04:52 +0100 Message-Id: <20190325110452.6756-1-luc.michel@greensocs.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH for-4.0] gdbstub: fix vCont packet handling when no thread is specified X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Lucien Murray-Pitts , Luc Michel , Jan Kiszka Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) Content-Type: text/plain; charset="utf-8" The vCont packet accepts a series of actions, each being applied on a given thread ID. Giving no thread ID for an action is valid and means "all threads". This commit fixes vCont packets being incorrectly rejected when no thread ID was given for an action. In multiprocess mode, the GDB Remote Protocol specification is unclear on what "all threads" means. We choose to apply the action on all threads of all attached processes. This commit is based on the initial fix by Lucien Murray-Pitts. Fixes: e40e5204af8388 Reported-by: Lucien Murray-Pitts Reported-by: Jan Kiszka Signed-off-by: Luc Michel Reviewed-by: Richard Henderson --- gdbstub.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index bc774ae992..d54abd17cc 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1150,10 +1150,11 @@ static int gdb_handle_vcont(GDBState *s, const char= *p) char *newstates; unsigned long tmp; uint32_t pid, tid; GDBProcess *process; CPUState *cpu; + GDBThreadIdKind kind; #ifdef CONFIG_USER_ONLY int max_cpus =3D 1; /* global variable max_cpus exists only in system = mode */ =20 CPU_FOREACH(cpu) { max_cpus =3D max_cpus <=3D cpu->cpu_index ? cpu->cpu_index + 1 : m= ax_cpus; @@ -1192,16 +1193,25 @@ static int gdb_handle_vcont(GDBState *s, const char= *p) /* unknown/invalid/unsupported command */ res =3D -ENOTSUP; goto out; } =20 - if (*p++ !=3D ':') { + if (*p =3D=3D '\0' || *p =3D=3D ';') { + /* + * No thread specifier, action is on "all threads". The + * specification is unclear regarding the process to act on. We + * choose all processes. + */ + kind =3D GDB_ALL_PROCESSES; + } else if (*p++ =3D=3D ':') { + kind =3D read_thread_id(p, &p, &pid, &tid); + } else { res =3D -ENOTSUP; goto out; } =20 - switch (read_thread_id(p, &p, &pid, &tid)) { + switch (kind) { case GDB_READ_THREAD_ERR: res =3D -EINVAL; goto out; =20 case GDB_ALL_PROCESSES: --=20 2.21.0