Skip to content

Extend rbran's parser robustness fixes with file-backed bounds and configurable limits (ELF)#8356

Open
Weitao-Sun wants to merge 8 commits into
devfrom
test_fuzz-elf
Open

Extend rbran's parser robustness fixes with file-backed bounds and configurable limits (ELF)#8356
Weitao-Sun wants to merge 8 commits into
devfrom
test_fuzz-elf

Conversation

@Weitao-Sun

Copy link
Copy Markdown

Summary

Split out from #8303 per review feedback, containing the ELF portion only. (Mach-O is being merged in #8303; PE is a separate PR.)

Builds on rbran's parser robustness fixes with the following improvements:

  • ReadStringTable: rejects sections whose declared size exceeds the actual file length, and fixes an off-by-one in the offset check, preventing reads past the end of the buffer.
  • Init: fixes an integer underflow when localMipsSyms is zero.
  • ApplyTypesToParentStringTable: bounds section.size to a configurable setting (files.elf.maxStringTableTypeSizeMB, default 4 MB) rather than trusting the declared section size directly.
  • Adds IsRangeBackedByFile, which validates every byte in a range is file-backed (rather than only the first/last byte), and uses it to guard the MIPS GOT entry count against a PT_LOAD segment's declared file extent exceeding the actual file length (with overflow checking).
  • Changes the MIPS GOT budget setting from an entry-count cap to files.elf.maxMipsGotMB (default 4 MB, max 64 MB), mirroring fs/binfmt_elf.c's byte-size-based approach so the same limit applies equally regardless of 32/64-bit entry size.

rbran and others added 8 commits July 22, 2026 17:11
Replace magic-number loop guards in MIPS GOT processing with segment-derived
limits and configurable budgets. Fix integer underflow when localMipsSyms is
zero. Correct string table validation to compare against file length rather
than virtual address space. Add IsRangeBackedByFile helper that validates
every byte in the given range is file-backed, and guard against overflow
when a program header's declared file extent is used to bound the GOT
entry count.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Mirrors the Linux kernel pattern (fs/binfmt_elf.c) of bounding by total
byte size rather than entry count, so the same limit applies equally to
32-bit and 64-bit MIPS ELF files regardless of entry size.

The setting files.elf.maxMipsGotMB (default 4 MB) is divided by the
per-entry size at load time to derive the effective entry limit.

Ref: https://github.com/torvalds/linux/blob/master/fs/binfmt_elf.c

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants