From 2e68e1fc1897bfd83f7498b4df04d0bde256663d Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Tue, 23 Jun 2020 03:12:32 +0200 Subject: [PATCH] Add jit.security(). --- src/lib_jit.c | 7 +++++++ src/lj_arch.h | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/lib_jit.c b/src/lib_jit.c index 7348ef21..21e01d3e 100644 --- a/src/lib_jit.c +++ b/src/lib_jit.c @@ -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 diff --git a/src/lj_arch.h b/src/lj_arch.h index f148b3f7..240d0d16 100644 --- a/src/lj_arch.h +++ b/src/lj_arch.h @@ -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