[PATCH 0/2] RISC-V: Fix buffer overflow after long instruction support

Tsukasa OI research_trasio@irq.a4lg.com
Tue Oct 4 08:59:06 GMT 2022


Hello,

After commit bb996692bd9 "RISC-V/gas: allow generating up to 176-bit
instructions with .insn", I started to see some crashes while running
"make check-gas".

The cause was simple.  Some functions depended on the fact that maximum
length returned by riscv_insn_length is 8.  But since the commit above
increased that upper limit from 64-bits (8 bytes) to 176-bits (22 bytes),
we need to increase two buffer sizes to avoid crashes.

But note that this change doesn't really support over 64-bit instructions.
It can be said on riscv_insn::fetch_instruction because it now may return
only a part of instruction.
Instead of merging this, reverting that commit (for now) might be an option.

PATCH 1: Binutils
PATCH 2: GDB

Thanks,
Tsukasa




Tsukasa OI (2):
  RISC-V: Fix buffer overflow on print_insn_riscv
  gdb/riscv: Fix buffer overflow on riscv_insn::fetch_instruction

 gdb/riscv-tdep.c    | 2 +-
 opcodes/riscv-dis.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)


base-commit: 034235cebd790d4f9a1728043a175d7d7d9338b1
-- 
2.34.1



More information about the Binutils mailing list