gecko-dev/mozglue
Toshihito Kikuchi e61c0c2555 Bug 1671314 - Expand the region to be scanned for a trampoline. r=mhowell
The latest launcher process ping showed one of the reasons why we failed to
detour `NtMapViewOfSection` is that `MMPolicyBase::FindRegion` failed to find
a free region.  Inspecting the function carefully, there were three problems.

Firstly, `FindRegion` did not fully scan the given range.  To randomize
the address of a free region we use, we start scanning from a random address
within the given range.  The problem is we scan only addresses bigger than
that random address, without scanning smaller addresses.  Probably this is
the reason why `FindRegion` fails.

Secondly, `FindRegion` may return an address not aligned with the allocation
granularity because `VirtualQueryEx` returns such an address.  If that happens,
the subsequent mapping API fails with the alignment error.

Lastly, when we randomize an address to start scanning from, we divide a random
number by `maxOffset`, but with that, we never start scanning from the last
region.  It does not affect the product's behavior, but to have fair randomization,
a divisor should be `maxOffset + 1`.

This patch fixes all of these three problems along with a new test program.

Differential Revision: https://phabricator.services.mozilla.com/D94110
2020-10-20 22:51:00 +00:00
..
android Bug 689178 - Remove crash-reporter hooks to externally provide library mappings. r=gsvelto 2020-06-25 08:43:23 +00:00
baseprofiler Bug 1671536 - Remove BaseProfilerMarkerPayload.h and dependents - r=gregtatum 2020-10-16 22:10:36 +00:00
build Bug 1671692 - Organize and properly label things in the TSan supression list. r=decoder 2020-10-20 16:45:00 +00:00
dllservices Bug 1468250 - Block all versions of database.dll to stop the crash. r=aklotz 2020-10-09 20:39:58 +00:00
linker Bug 1519636 - Reformat recent changes to the Google coding style r=andi 2020-07-14 09:34:19 +00:00
misc Bug 1671314 - Expand the region to be scanned for a trampoline. r=mhowell 2020-10-20 22:51:00 +00:00
static Bug 1617369 - Reformat mozglue/ using rustfmt r=glandium 2020-03-04 06:12:38 +00:00
tests Bug 1671314 - Expand the region to be scanned for a trampoline. r=mhowell 2020-10-20 22:51:00 +00:00
moz.build Bug 1598196 - Support disabling the linker on Android in the code. r=froydnj 2019-11-21 14:57:24 +00:00