]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Add jit.security().
authorMike Pall <mike>
Tue, 23 Jun 2020 01:12:32 +0000 (03:12 +0200)
committerMike Pall <mike>
Tue, 23 Jun 2020 01:12:32 +0000 (03:12 +0200)
src/lib_jit.c
src/lj_arch.h

index 7348ef210544c3d091c4212840d7c391e26f2806..21e01d3ed267215d59b7843c94dc19960b940916 100644 (file)
@@ -113,6 +113,13 @@ LJLIB_CF(jit_status)
 #endif
 }
 
+LJLIB_CF(jit_security)
+{
+  int idx = lj_lib_checkopt(L, 1, -1, LJ_SECURITY_MODESTRING);
+  setintV(L->top++, ((LJ_SECURITY_MODE >> (2*idx)) & 3));
+  return 1;
+}
+
 LJLIB_CF(jit_attach)
 {
 #ifdef LUAJIT_DISABLE_VMEVENT
index f148b3f7ef462cbbf6a4ba7e12b39004157b4d4c..240d0d161d7c6edc0fa374b7f272fddb1aa9f80d 100644 (file)
@@ -665,4 +665,14 @@ extern void *LJ_WIN_LOADLIBA(const char *path);
 #define LUAJIT_SECURITY_MCODE  1
 #endif
 
+#define LJ_SECURITY_MODE \
+  ( 0u \
+  | ((LUAJIT_SECURITY_PRNG & 3) << 0) \
+  | ((LUAJIT_SECURITY_STRHASH & 3) << 2) \
+  | ((LUAJIT_SECURITY_STRID & 3) << 4) \
+  | ((LUAJIT_SECURITY_MCODE & 3) << 6) \
+  )
+#define LJ_SECURITY_MODESTRING \
+  "\004prng\007strhash\005strid\005mcode"
+
 #endif