Closed Bug 1586912 Opened 4 years ago Closed 4 years ago

Don’t ComputeRandomAllocationAddress on OpenBSD


(Core :: JavaScript Engine: JIT, defect, P2)

69 Branch



Tracking Status
firefox72 --- fixed


(Reporter: kurt, Assigned: kurt, NeedInfo)



(2 files)

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/76.0.3809.100 Chrome/76.0.3809.100 Safari/537.36

Steps to reproduce:

Build and use mozilla projects on OpenBSD/arm64.

Actual results:

Building x11/gnome/gjs failed in configure check of seamonkey.

Expected results:

ComputeRandomAllocationAddress() in js/src/jit/ProcessExecutableMemory.cpp makes broad assumptions about addressable memory. For 64 bit builds it assumes all cpus have 48-bit address space and uses 46-bits for its random calculation. For 32 bit builds it assumes [512MiB, 1.5GiB) is ideal.

On OpenBSD/arm64 the current addressable range is 38 bits. When mmap is provided an address hint greater than the addressable range it fails. Since OpenBSD already has random mmap when NULL is provided as the address hint, it makes sense to allow the kernel to select the random address. It removes incorrect assumptions about the addressable memory range and it allows the kernel to select a random address while attempting to reduce memory fragmentation.

Attached is a patch that makes ComputeRandomAllocationAddress() return nullptr on OpenBSD so that mmap gets NULL as hint address, enabling the kernel to select a random address.

Flags: needinfo?(nicolas.b.pierron)
Priority: -- → P2

Since submitting this bug report we have been able to release Firefox on OpenBSD/arm64 for our upcoming 6.6. release. This issue was the primary blocker for having firefox work on this architecture.

OpenBSD already has a random mmap()

Assignee: nobody → kurt
Ever confirmed: true

I tried conserving patch ownership with hg commit --author but it seems phabricator hides this information. bah.

Pushed by
Don't ComputeRandomAllocationAddress on OpenBSD r=nbp
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla72
You need to log in before you can comment on or make changes to this bug.