Tuesday, October 01, 2019

Re: [FIX] mozilla ComputeRandomAllocationAddress

Seems legit.

The strange thing about how they are emulating ASR direct from inside
the program is there's no attempt at reducing fragmentation. Without
such attempts, process teardown is very expensive as the kernel's
address space tracking datastructures have become very complicated.

That's why it is better to have the kernel do ASR. It can provide random
addresses, which are still organized to keep the address space tracking
a bit more dense.

Still, I'm astounded. I haven't seen any other program trying to do this,
and I doubt even mozilla has sufficient braintrust to review the impact
of this decision on all the platforms they run. Just weird.


kurt@intricatesoftware.com wrote:

> Similar to devel/spidermonkey60 change. Allow OpenBSD's mmap to
> handle ASLR by using NULL as hint to mmap.
>
> Built and lightly tested on amd64 (although not exactly sure
> how to ensure java script is executed in thunderbird).
>
> okay?
>
> Did I miss any copies of mozilla java script in other ports?
>
> Index: mail/mozilla-thunderbird/Makefile
> ===================================================================
> RCS file: /cvs/ports/mail/mozilla-thunderbird/Makefile,v
> retrieving revision 1.296
> diff -u -p -u -r1.296 Makefile
> --- mail/mozilla-thunderbird/Makefile 22 Sep 2019 17:19:07 -0000 1.296
> +++ mail/mozilla-thunderbird/Makefile 30 Sep 2019 18:21:54 -0000
> @@ -10,6 +10,7 @@ MOZILLA_VERSION = 68.1.0
> MOZILLA_BRANCH = release
> MOZILLA_PROJECT = thunderbird
> MOZILLA_CODENAME = comm/mail
> +REVISION = 0
> EXTRACT_SUFX = .tar.xz
>
> MULTI_PACKAGES = -main -lightning
> Index: mail/mozilla-thunderbird/patches/patch-js_src_jit_ProcessExecutableMemory_cpp
> ===================================================================
> RCS file: mail/mozilla-thunderbird/patches/patch-js_src_jit_ProcessExecutableMemory_cpp
> diff -N mail/mozilla-thunderbird/patches/patch-js_src_jit_ProcessExecutableMemory_cpp
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ mail/mozilla-thunderbird/patches/patch-js_src_jit_ProcessExecutableMemory_cpp 30 Sep 2019 18:21:54 -0000
> @@ -0,0 +1,26 @@
> +$OpenBSD$
> +
> +Index: js/src/jit/ProcessExecutableMemory.cpp
> +--- js/src/jit/ProcessExecutableMemory.cpp.orig
> ++++ js/src/jit/ProcessExecutableMemory.cpp
> +@@ -318,6 +318,12 @@ static void DecommitPages(void* addr, size_t bytes) {
> + }
> + #else // !XP_WIN
> + static void* ComputeRandomAllocationAddress() {
> ++#ifdef __OpenBSD__
> ++ // OpenBSD already has random mmap and the idea that all x64 cpus
> ++ // have 48-bit address space is not correct. Returning nullptr
> ++ // allows OpenBSD do to the right thing.
> ++ return nullptr;
> ++#else
> + uint64_t rand = js::GenerateRandomSeed();
> +
> + # ifdef HAVE_64BIT_BUILD
> +@@ -337,6 +343,7 @@ static void* ComputeRandomAllocationAddress() {
> + // Ensure page alignment.
> + uintptr_t mask = ~uintptr_t(gc::SystemPageSize() - 1);
> + return (void*)uintptr_t(rand & mask);
> ++

No comments:

Post a Comment