[PATCH] D127345: [COFF] Don't reject executables with data directories pointing outside of provided data
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 8 14:02:00 PDT 2022
mstorsjo created this revision.
mstorsjo added reviewers: rnk, alvinhochun, glandium.
Herald added a subscriber: hiraditya.
Herald added a project: All.
mstorsjo requested review of this revision.
Herald added a project: LLVM.
Before bb94611d6545c2c5271f5bb01de1aa4228a37250 <https://reviews.llvm.org/rGbb94611d6545c2c5271f5bb01de1aa4228a37250>, we didn't check
that the sections in the COFF executable actually contained enough
raw data, when looking up what section contains tables pointed to
by the data directories.
That commit added checking, to avoid setting a pointer that points
out of bounds - by rejecting such executables.
It turns out that some binaries (e.g.g a "helper.exe" provided by
NSIS) contains a base relocation table data directory that points
into the wrong section. It points inside the virtual address space
allocated for that section, but the section contains much less raw
data, and the table points outside of the provided raw data.
No longer reject such binaries (to let tools operate on them and
inspect them), but don't set the table pointers (so that when
printing e.g. base relocations, we don't print anything).
This should fix the regression pointed out in
https://reviews.llvm.org/D126898#3565834.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D127345
Files:
llvm/lib/Object/COFFObjectFile.cpp
llvm/test/Object/Inputs/COFF/data-dir-out-of-bounds.yaml
llvm/test/Object/coff-data-dir-out-of-bounds.test
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127345.435319.patch
Type: text/x-patch
Size: 5404 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220608/10deea7f/attachment.bin>
More information about the llvm-commits
mailing list