Re: [FIX] mozilla ComputeRandomAllocationAddress

2019-10-01 Thread Landry Breuil
On Tue, Oct 01, 2019 at 09:34:25AM -0400, k...@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).

As soon as you have a UI, pretty sure javascript runs. Maybe not the
JIT, no idea.

> okay?

Please file a bug upstream, so that it's at least discussed with them,
as i'm not the one who would be able to justify such a change there so
that it's properly upstreamed later on. Sorry, no time those days.

> Did I miss any copies of mozilla java script in other ports?

there's www/seamonkey & www/tor-browser/browser but they're both marked
BROKEN.

Landry



Re: [FIX] mozilla ComputeRandomAllocationAddress

2019-10-01 Thread Todd C . Miller
On Tue, 01 Oct 2019 07:47:44 -0600, "Theo de Raadt" wrote:

> 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.

The funny thing is they got the idea from the Windows code in V8.
I don't know if chrome tries to do anything like this on non-Windows
platforms.

 - todd



Re: [FIX] mozilla ComputeRandomAllocationAddress

2019-10-01 Thread Theo de Raadt
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.


k...@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 -  1.296
> +++ mail/mozilla-thunderbird/Makefile 30 Sep 2019 18:21:54 -
> @@ -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 -
> +++ 
> mail/mozilla-thunderbird/patches/patch-js_src_jit_ProcessExecutableMemory_cpp 
> 30 Sep 2019 18:21:54 -
> @@ -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);
> ++#endif
> + }
> + 
> + static void* ReserveProcessExecutableMemory(size_t bytes) {
> Index: 
> mail/mozilla-thunderbird/patches/patch-mozilla_js_src_jit_ProcessExecutableMemory_h
> ===
> RCS file: 
> /cvs/ports/mail/mozilla-thunderbird/patches/patch-mozilla_js_src_jit_ProcessExecutableMemory_h,v
> retrieving revision 1.5
> diff -u -p -u -r1.5 patch-mozilla_js_src_jit_ProcessExecutableMemory_h
> --- 
> mail/mozilla-thunderbird/patches/patch-mozilla_js_src_jit_ProcessExecutableMemory_h
>13 Sep 2019 15:05:17 -  1.5
> +++ 
> mail/mozilla-thunderbird/patches/patch-mozilla_js_src_jit_ProcessExecutableMemory_h
>30 Sep 2019 18:21:54 -
> @@ -11,4 +11,4 @@ Index: js/src/jit/ProcessExecutableMemor
>  +#if JS_BITS_PER_WORD == 32 || defined (__OpenBSD__)
>   static const size_t MaxCodeBytesPerProcess = 140 * 1024 * 1024;
>   #else
> - static const size_t MaxCodeBytesPerProcess = 1 * 1024 * 1024 * 1024;
> + // This is the largest number which satisfies various alignment static
> Index: 
> mail/mozilla-thunderbird/patches/patch-mozilla_security_manager_pki_resources_content_exceptionDialog_js
> ===
> RCS file: 
> /cvs/ports/mail/mozilla-thunderbird/patches/patch-mozilla_security_manager_pki_resources_content_exceptionDialog_js,v
> retrieving revision 1.9
> diff -u -p -u -r1.9 
> patch-mozilla_security_manager_pki_resources_content_exceptionDialog_js
> --- 
> mail/mozilla-thunderbird/patches/patch-mozilla_security_manager_pki_resources_content_exceptionDialog_js
>   13 Sep 2019 15:05:17 -  1.9
> +++ 
> mail/mozilla-thunderbird/patches/patch-mozilla_security_manager_pki_resources_content_exceptionDialog_js
>   30 Sep 2019 18:21:54 -
> @@ -3,7 +3,7 @@ $OpenBSD: patch-mozilla_security_manager
>  Index: security/manager/pki/resources/content/exceptionDialog.js
>  --- 

[FIX] mozilla ComputeRandomAllocationAddress

2019-10-01 Thread kurt
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 -  1.296
+++ mail/mozilla-thunderbird/Makefile   30 Sep 2019 18:21:54 -
@@ -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 -
+++ 
mail/mozilla-thunderbird/patches/patch-js_src_jit_ProcessExecutableMemory_cpp   
30 Sep 2019 18:21:54 -
@@ -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);
++#endif
+ }
+ 
+ static void* ReserveProcessExecutableMemory(size_t bytes) {
Index: 
mail/mozilla-thunderbird/patches/patch-mozilla_js_src_jit_ProcessExecutableMemory_h
===
RCS file: 
/cvs/ports/mail/mozilla-thunderbird/patches/patch-mozilla_js_src_jit_ProcessExecutableMemory_h,v
retrieving revision 1.5
diff -u -p -u -r1.5 patch-mozilla_js_src_jit_ProcessExecutableMemory_h
--- 
mail/mozilla-thunderbird/patches/patch-mozilla_js_src_jit_ProcessExecutableMemory_h
 13 Sep 2019 15:05:17 -  1.5
+++ 
mail/mozilla-thunderbird/patches/patch-mozilla_js_src_jit_ProcessExecutableMemory_h
 30 Sep 2019 18:21:54 -
@@ -11,4 +11,4 @@ Index: js/src/jit/ProcessExecutableMemor
 +#if JS_BITS_PER_WORD == 32 || defined (__OpenBSD__)
  static const size_t MaxCodeBytesPerProcess = 140 * 1024 * 1024;
  #else
- static const size_t MaxCodeBytesPerProcess = 1 * 1024 * 1024 * 1024;
+ // This is the largest number which satisfies various alignment static
Index: 
mail/mozilla-thunderbird/patches/patch-mozilla_security_manager_pki_resources_content_exceptionDialog_js
===
RCS file: 
/cvs/ports/mail/mozilla-thunderbird/patches/patch-mozilla_security_manager_pki_resources_content_exceptionDialog_js,v
retrieving revision 1.9
diff -u -p -u -r1.9 
patch-mozilla_security_manager_pki_resources_content_exceptionDialog_js
--- 
mail/mozilla-thunderbird/patches/patch-mozilla_security_manager_pki_resources_content_exceptionDialog_js
13 Sep 2019 15:05:17 -  1.9
+++ 
mail/mozilla-thunderbird/patches/patch-mozilla_security_manager_pki_resources_content_exceptionDialog_js
30 Sep 2019 18:21:54 -
@@ -3,7 +3,7 @@ $OpenBSD: patch-mozilla_security_manager
 Index: security/manager/pki/resources/content/exceptionDialog.js
 --- security/manager/pki/resources/content/exceptionDialog.js.orig
 +++ security/manager/pki/resources/content/exceptionDialog.js
-@@ -241,6 +241,7 @@ function updateCertStatus() {
+@@ -248,6 +248,7 @@ function updateCertStatus() {
  
// In these cases, we do want to enable the "Add Exception" button
gDialog.getButton("extra1").disabled = false;
Index: 
mail/mozilla-thunderbird/patches/patch-mozilla_storage_mozStorageConnection_cpp
===
RCS file: 
/cvs/ports/mail/mozilla-thunderbird/patches/patch-mozilla_storage_mozStorageConnection_cpp,v
retrieving revision 1.5
diff -u -p -u -r1.5 patch-mozilla_storage_mozStorageConnection_cpp
--- 
mail/mozilla-thunderbird/patches/patch-mozilla_storage_mozStorageConnection_cpp 
13 Sep 2019 15:05:17 -  1.5
+++