Message ID | 89612fe01d902007bf84a7dfb0df5f85d5c166e4.1664873933.git.research_trasio@irq.a4lg.com |
---|---|
State | Accepted, archived |
Headers |
Return-Path: <binutils-bounces+ouuuleilei=gmail.com@sourceware.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp28033wrs; Tue, 4 Oct 2022 01:59:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5RnRqHKjK1RV71/8RsGOx3piiTxAnPRzNnETdkvlfWfT/KKBctZvh3pq9uzkdokqPjd+1g X-Received: by 2002:a17:906:4fc3:b0:72e:eab4:d9d7 with SMTP id i3-20020a1709064fc300b0072eeab4d9d7mr18407803ejw.599.1664873997966; Tue, 04 Oct 2022 01:59:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664873997; cv=none; d=google.com; s=arc-20160816; b=xICSlRqisomx3xyCnftL96y0O4vaPA1CvvuODG/uzbcTYiYG88DDbaErhPf8kn5IUn 8z7YgN2KOAcvXaO5LvJNsecV1XEZ8drLlUyfZ8FOC8S0WiGJnsjdV1edAlfD7rgkC3Q0 nv3KbV4QSEtrYHEtPND5JuyyH3J4wjJ3ptkbnHWsZD+7WEBOy3Re8oJ/CoKXbnDmXSax zGiMU8vSaRUXorCs+gMSXq+7KuTmtVMdf7d4jztSMhfOQi+WAPAjGPgN9A8Zr0MEOh6e ebriqanM+v1c6firdASlV1v6crxjDRX03htnnvrQZaM3XZp62hePrpWuD9afttmEWKuQ 1VSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=10RJpob7TsEpqZgz/da2hq7jdcBrovdJT3P2jfK5qUs=; b=ubHr69SixIrxlGvBH91JskVtXjBphCZ21TnAws0PkvBgWDlfgdkTrHRYVVufeNhcH0 C3cPMBb7V1UnCX5yqQ5gMxuR3EF7To0etPHCaqGTYtYOqOy5sHB9sHObPgIdebjrzw0F t6pbBQavmKgmcusyTJYUskHb8SP/Wg7HSx+MHGe6ydjL0HBPwmeunfR558wyC23SK55c 9dErIFvMLp/y0yqYI6+yjZ/S2MgO5ptnO9sF+5/2KY43+U5nq8pccGGYLif8EvCbd/DB fRX9285HKA2fu8sC+GSK80xHwjS6eqPT4jCLsCOKwLC2ygJMjzM8B1m6Z9kZ36J5brEf N1Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=tpnCcDNT; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id h22-20020a056402281600b0044f3b9ef98bsi12293800ede.27.2022.10.04.01.59.57 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Oct 2022 01:59:57 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=tpnCcDNT; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BD1C23854158 for <ouuuleilei@gmail.com>; Tue, 4 Oct 2022 08:59:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BD1C23854158 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1664873991; bh=10RJpob7TsEpqZgz/da2hq7jdcBrovdJT3P2jfK5qUs=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=tpnCcDNT25cnLquDiycF0kjMoF3NBFVxMOYkTk1MLIPvcTI/2PW9grMPvt6J8oVsM 75yhndnKKGT2SwKLUZ1JFKycpBKURG7r839bAHQtjbFhnoiKiDpnUfx7IWvtsN5RQ2 yOLMARic5YuomXbCVX+kEabVyL7D4ZODpJsqMHy4= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-sender-0.a4lg.com (mail-sender.a4lg.com [153.120.152.154]) by sourceware.org (Postfix) with ESMTPS id 03A53385C335; Tue, 4 Oct 2022 08:59:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 03A53385C335 Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail-sender-0.a4lg.com (Postfix) with ESMTPSA id 4294A300089; Tue, 4 Oct 2022 08:59:42 +0000 (UTC) To: Tsukasa OI <research_trasio@irq.a4lg.com>, Nelson Chu <nelson@rivosinc.com>, Kito Cheng <kito.cheng@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Andrew Burgess <aburgess@redhat.com>, Jan Beulich <jbeulich@suse.com> Subject: [PATCH 2/2] gdb/riscv: Fix buffer overflow on riscv_insn::fetch_instruction Date: Tue, 4 Oct 2022 08:59:08 +0000 Message-Id: <89612fe01d902007bf84a7dfb0df5f85d5c166e4.1664873933.git.research_trasio@irq.a4lg.com> In-Reply-To: <cover.1664873933.git.research_trasio@irq.a4lg.com> References: <cover.1664873933.git.research_trasio@irq.a4lg.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, KAM_MANYTO, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list <binutils.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/binutils>, <mailto:binutils-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/binutils/> List-Post: <mailto:binutils@sourceware.org> List-Help: <mailto:binutils-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/binutils>, <mailto:binutils-request@sourceware.org?subject=subscribe> From: Tsukasa OI via Binutils <binutils@sourceware.org> Reply-To: Tsukasa OI <research_trasio@irq.a4lg.com> Cc: binutils@sourceware.org, gdb-patches@sourceware.org Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" <binutils-bounces+ouuuleilei=gmail.com@sourceware.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1745746917576060928?= X-GMAIL-MSGID: =?utf-8?q?1745746917576060928?= |
Series |
RISC-V: Fix buffer overflow after long instruction support
|
|
Checks
Context | Check | Description |
---|---|---|
snail/binutils-gdb-check | success | Github commit url |
Commit Message
Tsukasa OI
Oct. 4, 2022, 8:59 a.m. UTC
Because riscv_insn_length started to support instructions up to 176-bit, we need to increase packet buffer size to 176-bit in size. Note that this change will make the result of riscv_insn::fetch_instruction partial when the instruction is longer than 64-bits. To really support instructions longer than 64-bit, we need something more. --- gdb/riscv-tdep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Okt 04 2022, Tsukasa OI via Gdb-patches wrote: > diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c > index 47d8f9e601b..99307bd2de1 100644 > --- a/gdb/riscv-tdep.c > +++ b/gdb/riscv-tdep.c > @@ -1770,7 +1770,7 @@ riscv_insn::fetch_instruction (struct gdbarch *gdbarch, > CORE_ADDR addr, int *len) > { > enum bfd_endian byte_order = gdbarch_byte_order_for_code (gdbarch); > - gdb_byte buf[8]; > + gdb_byte buf[22]; Can the magic number be derived from something else so that is adapts automatically?
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index 47d8f9e601b..99307bd2de1 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -1770,7 +1770,7 @@ riscv_insn::fetch_instruction (struct gdbarch *gdbarch, CORE_ADDR addr, int *len) { enum bfd_endian byte_order = gdbarch_byte_order_for_code (gdbarch); - gdb_byte buf[8]; + gdb_byte buf[22]; int instlen, status; /* All insns are at least 16 bits. */