pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc Make luajit PaX MPROTECT safe.



details:   https://anonhg.NetBSD.org/pkgsrc/rev/fbf512b67243
branches:  trunk
changeset: 441572:fbf512b67243
user:      nia <nia%pkgsrc.org@localhost>
date:      Fri Nov 06 12:15:53 2020 +0000

description:
Make luajit PaX MPROTECT safe.

diffstat:

 games/love010/Makefile                         |   4 +-
 games/love010/options.mk                       |   4 +--
 games/love09/Makefile                          |   4 +-
 games/love09/options.mk                        |   4 +--
 games/love11/Makefile                          |   4 +-
 games/love11/options.mk                        |   4 +--
 lang/LuaJIT2/Makefile                          |   6 +---
 lang/LuaJIT2/distinfo                          |   4 ++-
 lang/LuaJIT2/patches/patch-src_lj__ccallback.c |  21 ++++++++++++++++++++
 lang/LuaJIT2/patches/patch-src_lj__mcode.c     |  27 ++++++++++++++++++++++++++
 www/luakit/Makefile                            |   4 +-
 www/luakit/options.mk                          |   3 +-
 12 files changed, 65 insertions(+), 24 deletions(-)

diffs (221 lines):

diff -r 7e71e5ab5bec -r fbf512b67243 games/love010/Makefile
--- a/games/love010/Makefile    Fri Nov 06 11:16:38 2020 +0000
+++ b/games/love010/Makefile    Fri Nov 06 12:15:53 2020 +0000
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.7 2020/08/18 17:57:55 leot Exp $
+# $NetBSD: Makefile,v 1.8 2020/11/06 12:15:54 nia Exp $
 
 DISTNAME=      love-0.10.2-linux-src
 PKGNAME=       ${DISTNAME:S/-linux-src//:S/love/love010/}
-PKGREVISION=   3
+PKGREVISION=   4
 CATEGORIES=    games lua
 MASTER_SITES=  https://bitbucket.org/rude/love/downloads/
 
diff -r 7e71e5ab5bec -r fbf512b67243 games/love010/options.mk
--- a/games/love010/options.mk  Fri Nov 06 11:16:38 2020 +0000
+++ b/games/love010/options.mk  Fri Nov 06 12:15:53 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: options.mk,v 1.3 2020/06/28 09:29:16 nia Exp $
+# $NetBSD: options.mk,v 1.4 2020/11/06 12:15:54 nia Exp $
 
 PKG_OPTIONS_VAR=       PKG_OPTIONS.love
 
@@ -12,8 +12,6 @@
 .include "../../mk/bsd.options.mk"
 
 .if !empty(PKG_OPTIONS:Mluajit)
-# JIT needs WX mappings
-NOT_PAX_MPROTECT_SAFE+=                love0.10/bin/love
 .  include "../../lang/LuaJIT2/buildlink3.mk"
 .else
 CONFIGURE_ARGS+=               --with-lua=lua
diff -r 7e71e5ab5bec -r fbf512b67243 games/love09/Makefile
--- a/games/love09/Makefile     Fri Nov 06 11:16:38 2020 +0000
+++ b/games/love09/Makefile     Fri Nov 06 12:15:53 2020 +0000
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.7 2020/08/18 17:57:55 leot Exp $
+# $NetBSD: Makefile,v 1.8 2020/11/06 12:15:54 nia Exp $
 
 DISTNAME=      love-0.9.2-linux-src
 PKGNAME=       ${DISTNAME:S/-linux-src//:S/love/love09/}
-PKGREVISION=   3
+PKGREVISION=   4
 CATEGORIES=    games lua
 MASTER_SITES=  https://bitbucket.org/rude/love/downloads/
 
diff -r 7e71e5ab5bec -r fbf512b67243 games/love09/options.mk
--- a/games/love09/options.mk   Fri Nov 06 11:16:38 2020 +0000
+++ b/games/love09/options.mk   Fri Nov 06 12:15:53 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: options.mk,v 1.1 2020/07/01 16:39:58 nia Exp $
+# $NetBSD: options.mk,v 1.2 2020/11/06 12:15:54 nia Exp $
 
 PKG_OPTIONS_VAR=       PKG_OPTIONS.love
 
@@ -12,8 +12,6 @@
 .include "../../mk/bsd.options.mk"
 
 .if !empty(PKG_OPTIONS:Mluajit)
-# JIT needs WX mappings
-NOT_PAX_MPROTECT_SAFE+=                love0.9/bin/love
 CONFIGURE_ARGS+=               --with-lua=luajit
 .  include "../../lang/LuaJIT2/buildlink3.mk"
 .else
diff -r 7e71e5ab5bec -r fbf512b67243 games/love11/Makefile
--- a/games/love11/Makefile     Fri Nov 06 11:16:38 2020 +0000
+++ b/games/love11/Makefile     Fri Nov 06 12:15:53 2020 +0000
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.3 2020/08/18 17:57:55 leot Exp $
+# $NetBSD: Makefile,v 1.4 2020/11/06 12:15:54 nia Exp $
 
 DISTNAME=      love-11.3-linux-src
 PKGNAME=       ${DISTNAME:S/-linux-src//:S/love/love11/}
-PKGREVISION=   1
+PKGREVISION=   2
 CATEGORIES=    games lua
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=love2d/}
 GITHUB_PROJECT=        love
diff -r 7e71e5ab5bec -r fbf512b67243 games/love11/options.mk
--- a/games/love11/options.mk   Fri Nov 06 11:16:38 2020 +0000
+++ b/games/love11/options.mk   Fri Nov 06 12:15:53 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: options.mk,v 1.1 2020/06/29 13:04:14 nia Exp $
+# $NetBSD: options.mk,v 1.2 2020/11/06 12:15:54 nia Exp $
 
 PKG_OPTIONS_VAR=       PKG_OPTIONS.love
 PKG_SUPPORTED_OPTIONS= luajit
@@ -11,8 +11,6 @@
 .include "../../mk/bsd.options.mk"
 
 .if !empty(PKG_OPTIONS:Mluajit)
-# JIT needs WX mappings
-NOT_PAX_MPROTECT_SAFE+=                love11/bin/love
 .  include "../../lang/LuaJIT2/buildlink3.mk"
 .else
 CONFIGURE_ARGS+=               --with-lua=lua
diff -r 7e71e5ab5bec -r fbf512b67243 lang/LuaJIT2/Makefile
--- a/lang/LuaJIT2/Makefile     Fri Nov 06 11:16:38 2020 +0000
+++ b/lang/LuaJIT2/Makefile     Fri Nov 06 12:15:53 2020 +0000
@@ -1,9 +1,9 @@
-# $NetBSD: Makefile,v 1.15 2020/07/02 10:16:59 nia Exp $
+# $NetBSD: Makefile,v 1.16 2020/11/06 12:15:53 nia Exp $
 #
 
 DISTNAME=      LuaJIT-2.0.5
 PKGNAME=       ${DISTNAME:S/LuaJIT/LuaJIT2/}
-PKGREVISION=   1
+PKGREVISION=   2
 CATEGORIES=    lang lua
 MASTER_SITES=  http://luajit.org/download/
 
@@ -22,8 +22,6 @@
 ONLY_FOR_PLATFORM+=    *-*-powerpc
 ONLY_FOR_PLATFORM+=    *-*-x86_64
 
-NOT_PAX_MPROTECT_SAFE+=        bin/luajit
-
 # Address pkg/47587 lua not linked to pthread causes issues with modules
 PTHREAD_OPTS+=         native
 PTHREAD_AUTO_VARS=     yes
diff -r 7e71e5ab5bec -r fbf512b67243 lang/LuaJIT2/distinfo
--- a/lang/LuaJIT2/distinfo     Fri Nov 06 11:16:38 2020 +0000
+++ b/lang/LuaJIT2/distinfo     Fri Nov 06 12:15:53 2020 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.10 2018/06/02 20:01:21 he Exp $
+$NetBSD: distinfo,v 1.11 2020/11/06 12:15:53 nia Exp $
 
 SHA1 (LuaJIT-2.0.5.tar.gz) = 10427215da7d424fd9e48adbea087966053cdb6f
 RMD160 (LuaJIT-2.0.5.tar.gz) = 5176d34fa112c4586394398c3a5c9ce1ad4d4c72
@@ -7,3 +7,5 @@
 SHA1 (patch-Makefile) = edea30d017c9d2938d951bfdee88020906945aee
 SHA1 (patch-src_Makefile) = d7236260dc17f470d7d6e41a57a22dcd3a501c28
 SHA1 (patch-src_lj__arch.h) = 4c34706db4c678b368bb3e38b07505abde01e590
+SHA1 (patch-src_lj__ccallback.c) = 8032bc451a504ae9538fb0ae4cc1ee729ede3a70
+SHA1 (patch-src_lj__mcode.c) = c150e0b07ab441e983ace21e0e813fd4334290b5
diff -r 7e71e5ab5bec -r fbf512b67243 lang/LuaJIT2/patches/patch-src_lj__ccallback.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lang/LuaJIT2/patches/patch-src_lj__ccallback.c    Fri Nov 06 12:15:53 2020 +0000
@@ -0,0 +1,21 @@
+$NetBSD: patch-src_lj__ccallback.c,v 1.1 2020/11/06 12:15:53 nia Exp $
+
+Make this PaX-MPROTECT safe on NetBSD.
+
+--- src/lj_ccallback.c.orig    2017-05-01 18:11:00.000000000 +0000
++++ src/lj_ccallback.c
+@@ -228,8 +228,12 @@ static void callback_mcode_new(CTState *
+   if (!p)
+     lj_err_caller(cts->L, LJ_ERR_FFI_CBACKOV);
+ #elif LJ_TARGET_POSIX
+-  p = mmap(NULL, sz, (PROT_READ|PROT_WRITE), MAP_PRIVATE|MAP_ANONYMOUS,
+-         -1, 0);
++#ifdef PROT_MPROTECT
++  p = mmap(NULL, sz, (PROT_READ|PROT_WRITE) | PROT_MPROTECT(PROT_EXEC),
++#else
++  p = mmap(NULL, sz, (PROT_READ|PROT_WRITE),
++#endif
++           MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
+   if (p == MAP_FAILED)
+     lj_err_caller(cts->L, LJ_ERR_FFI_CBACKOV);
+ #else
diff -r 7e71e5ab5bec -r fbf512b67243 lang/LuaJIT2/patches/patch-src_lj__mcode.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lang/LuaJIT2/patches/patch-src_lj__mcode.c        Fri Nov 06 12:15:53 2020 +0000
@@ -0,0 +1,27 @@
+$NetBSD: patch-src_lj__mcode.c,v 1.1 2020/11/06 12:15:53 nia Exp $
+
+Make PaX-MPROTECT safe for NetBSD.
+
+--- src/lj_mcode.c.orig        2017-05-01 18:11:00.000000000 +0000
++++ src/lj_mcode.c
+@@ -99,7 +99,11 @@ static int mcode_setprot(void *p, size_t
+ 
+ static void *mcode_alloc_at(jit_State *J, uintptr_t hint, size_t sz, int prot)
+ {
++#ifdef PROT_MPROTECT
++  void *p = mmap((void *)hint, sz, prot | PROT_MPROTECT(MCPROT_RWX), MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
++#else
+   void *p = mmap((void *)hint, sz, prot, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
++#endif
+   if (p == MAP_FAILED) {
+     if (!hint) lj_trace_err(J, LJ_TRERR_MCODEAL);
+     p = NULL;
+@@ -255,7 +259,7 @@ static void *mcode_alloc(jit_State *J, s
+ /* All memory addresses are reachable by relative jumps. */
+ static void *mcode_alloc(jit_State *J, size_t sz)
+ {
+-#ifdef __OpenBSD__
++#if defined(__NetBSD__) || defined(__OpenBSD__)
+   /* Allow better executable memory allocation for OpenBSD W^X mode. */
+   void *p = mcode_alloc_at(J, 0, sz, MCPROT_RUN);
+   if (p && mcode_setprot(p, sz, MCPROT_GEN)) {
diff -r 7e71e5ab5bec -r fbf512b67243 www/luakit/Makefile
--- a/www/luakit/Makefile       Fri Nov 06 11:16:38 2020 +0000
+++ b/www/luakit/Makefile       Fri Nov 06 12:15:53 2020 +0000
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.6 2020/11/05 09:09:21 ryoon Exp $
+# $NetBSD: Makefile,v 1.7 2020/11/06 12:15:54 nia Exp $
 
 DISTNAME=      luakit-2.2.1
-PKGREVISION=   1
+PKGREVISION=   2
 CATEGORIES=    www lua
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=luakit/}
 
diff -r 7e71e5ab5bec -r fbf512b67243 www/luakit/options.mk
--- a/www/luakit/options.mk     Fri Nov 06 11:16:38 2020 +0000
+++ b/www/luakit/options.mk     Fri Nov 06 12:15:53 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: options.mk,v 1.1 2020/08/09 17:25:37 nia Exp $
+# $NetBSD: options.mk,v 1.2 2020/11/06 12:15:54 nia Exp $
 
 PKG_OPTIONS_VAR=               PKG_OPTIONS.luakit
 PKG_SUPPORTED_OPTIONS=         luajit
@@ -11,7 +11,6 @@
 
 .if !empty(PKG_OPTIONS:Mluajit)
 MAKE_FLAGS+=   USE_LUAJIT=1
-NOT_PAX_MPROTECT_SAFE+=        bin/luakit
 .  include "../../lang/LuaJIT2/buildlink3.mk"
 .else
 MAKE_FLAGS+=   USE_LUAJIT=0



Home | Main Index | Thread Index | Old Index