This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Handle broken size field of compressed sections header.
AbandonedPublic

Authored by grimar on Oct 12 2016, 8:53 AM.

Details

Summary

Patch fixes issue when 32bit host may have overflow after assigning ch_size to size_t.
Also adds uncompressed section size limit to help in diagnostic of broken inputs.

Diff Detail

Event Timeline

grimar updated this revision to Diff 74389.Oct 12 2016, 8:53 AM
grimar retitled this revision from to [ELF] - Handle broken size field of compressed sections header..
grimar updated this object.
grimar added reviewers: ruiu, rafael, davide.
grimar added subscribers: llvm-commits, grimar, evgeny777.
davide edited edge metadata.Oct 12 2016, 9:05 AM

Independently from this patch. Are we really trying to fully support 32-bit hosts? We mmap() the whole set of input which I think very likely causes shortage of VA on 32-bit platforms.

Independently from this patch. Are we really trying to fully support 32-bit hosts? We mmap() the whole set of input which I think very likely causes shortage of VA on 32-bit platforms.

Do you think we should check if 32 bits host is used to link 64 bit app and just error out before trying to link ?

ruiu edited edge metadata.Oct 12 2016, 10:39 AM

Our current policy is essentially to trust file contents but reject silly apparent errors. We are not trying to recover from all possible crashes (and this patch doesn't save the linker from crashing neither -- but instead it makes the linker to kill itself after printing out an error message.) Naturally, there are a lot of places left we can add error checking, but in most places we don't as a policy. When you add a check like this, I think you want to show that why this is special among other possible errors. Otherwise, we'd have tons of error checks in our code base and still the linker crashes for broken inputs.

As to 32-bit hosts, I think we want to support it, because, why not? You cannot create >4GB binary on 32 bit, but as long as it is smaller than a few gigs, LLD should work fine.

In D25518#568396, @ruiu wrote:

When you add a check like this, I think you want to show that why this is special among other possible errors. Otherwise, we'd have tons of error checks in our code base and still the linker crashes for broken inputs.

This error check at least special for 32 bit hosts. As if overflow happens here, user will get probably get error "error uncompressing section" instead of real reason "uncompressed section size is too large". Isn't that useful ?

grimar abandoned this revision.Dec 2 2016, 11:47 PM

Depricated.