From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-sender-0.a4lg.com (mail-sender-0.a4lg.com [IPv6:2401:2500:203:30b:4000:6bfe:4757:0]) by sourceware.org (Postfix) with ESMTPS id 7EE793858299 for ; Tue, 4 Oct 2022 09:28:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7EE793858299 Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail-sender-0.a4lg.com (Postfix) with ESMTPSA id E0921300089; Tue, 4 Oct 2022 09:28:46 +0000 (UTC) Message-ID: Date: Tue, 4 Oct 2022 18:28:45 +0900 Mime-Version: 1.0 Subject: Re: [PATCH 2/2] gdb/riscv: Fix buffer overflow on riscv_insn::fetch_instruction Content-Language: en-US To: Andreas Schwab , gdb-patches@sourceware.org References: <89612fe01d902007bf84a7dfb0df5f85d5c166e4.1664873933.git.research_trasio@irq.a4lg.com> <29872020-9f00-b639-717e-a31a3e614210@irq.a4lg.com> From: Tsukasa OI In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, 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: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Oct 2022 09:28:50 -0000 On 2022/10/04 18:25, Andreas Schwab wrote: > On Okt 04 2022, Tsukasa OI wrote: > >> That's technically possible but it will make something like... >> 8 + 2 + 2 * ((1 << 3) - 1 - 1) > > That's still a magic number that doesn't adapt. Exactly. I could not find any constants to depend to. If we define "currently" magic number (22) as RISCV_MAX_INSN_LEN, at least we can share that constant between Binutils and GDB. > >> Defining RISCV_MAX_INSN_LEN might be a slightly better solution (still, >> content of RISCV_MAX_INSN_LEN will be a magic number). > > If that number is then used as the base for the other dependencies, it's > a win. >