binutils Newspaper
NOVEMBER 30, 2026
binutils — Under Review — Sentiment 8 / 10

xtensa_insnbuf_from_chars buffer overflow checking

Patch adds buffer overflow checking to xtensa_insnbuf_from_chars in binutils, gas, and gdb to handle malformed relocations.

This patch addresses a buffer overflow vulnerability in binutils’ xtensa_insnbuf_from_chars function, which can be triggered by malformed R_XTENSA_ASM_SIMPLIFY relocations. The fix modifies xtensa_insnbuf_from_chars to return buffer size validity, updates gas and gdb to pass actual buffer lengths, and adds status checks. This prevents potential overflows when processing zero-sized buffers, which fuzzers might generate.

In the Thread 4 participants
  1. Alan Modra <amodra@gmail.com> proposer

    Proposes a fix for a buffer overflow in xtensa_insnbuf_from_chars by adding size checks and updating its usage in gas and gdb.

    “R_XTENSA_ASM_SIMPLIFY has size zero, thus it can appear right at the end of a section without failing bfd_reloc_offset_in_range. Of course the reloc should never appear at the end of a section let alone in debug sections, but fuzzers do horrible things.”
  2. Max Filippov <jcmvbkbc@gmail.com> reviewer

    Acknowledges the issue with R_XTENSA_ASM_SIMPLIFY and the proposed solution, discussing the use of a wrapper function for gas.

    “On Tue, Nov 3, 2026 at 2:46 AM Alan Modra <amodra@gmail.com> wrote: > R_XTENSA_ASM_SIMPLIFY has size zero, thus it can appear right at the > end of a section without failing bfd_reloc_offset_in_range. Of course > the reloc should never appear at the end of a section let alone in > debug sections, but fuzzers do horrible things.”
  3. Alan Modra <amodra@gmail.com> proposer

    Clarifies the implementation details of the `xtensa_insnbuf_from_frag` wrapper and its relation to gas frags.

    “+/* Wrapper for xtensa_insnbuf_from_chars to convert frag bytes + to xtensa_insnbuf. */ +static bool +xtensa_insnbuf_from_frag (xtensa_isa isa, xtensa_insnbuf insnbuf, + const fragS *frag, size_t off) +{ + const unsigned char *buf = (const unsigned char *) frag->fr_literal + off; + size_t len = frag-”
  4. Max Filippov <jcmvbkbc@gmail.com> reviewer

    Responds to Alan's clarification, indicating that the changes look reasonable.

    “On Tue, Nov 3, 2026 at 3:04 PM Alan Modra <amodra@gmail.com> wrote: On Tue, Nov 03, 2026 at 05:22:26AM -0800, Max Filippov wrote: > On Tue, Nov 3, 2026 at 2:46 AM Alan Modra <amodra@gmail.com> wrote: > > +/* Wrapper for xtensa_insnbuf_from_chars to convert frag bytes > > + to xtensa_insnbuf. */ > > + > > +static bool > > +xtensa_insnbuf_from_frag (xtensa_isa isa, xtensa_insnbuf insnbuf, > > +…”

Technical Tradeoffs

  • Adds checks and wrappers, potentially increasing code complexity and slightly impacting performance in non-error cases.

In Details

A buffer overflow vulnerability in the Xtensa ELF backend's xtensa_insnbuf_from_chars function is being addressed. The issue arises from R_XTENSA_ASM_SIMPLIFY relocations with zero size, which can bypass range checks and lead to reading beyond allocated buffers when num_chars is zero. The patch updates the function and its callers in gas and gdb to correctly handle buffer sizes and check return values, preventing overflows.

For Context
xtensa_insnbuf_from_chars
A function within binutils used for Xtensa processors to convert character data into an instruction buffer, potentially susceptible to buffer overflows.
R_XTENSA_ASM_SIMPLIFY
A relocation type specific to the Xtensa architecture, used in assembly processing.
relocation
A symbol or pointer in an object file that needs to be resolved by the linker before the program can be executed. Relocations contain information about how to modify addresses or other data.
gas
The GNU Assembler, a component of the GNU toolchain that translates assembly language code into machine code.
bfd
The Binary File Descriptor library, a GNU library used by binutils components to provide a common interface to various object file formats.
fuzzer
A tool that automatically generates malformed or random data as input to a program to discover bugs, such as buffer overflows.
Filed Under: binutilsXtensasecuritybuffer overflowrelocation