diff options
Diffstat (limited to '')
-rw-r--r-- | src/lj_mcode.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/lj_mcode.c b/src/lj_mcode.c index 9ce1deec..fc67eaee 100644 --- a/src/lj_mcode.c +++ b/src/lj_mcode.c | |||
@@ -314,21 +314,21 @@ void lj_mcode_abort(jit_State *J) | |||
314 | /* Set/reset protection to allow patching of MCode areas. */ | 314 | /* Set/reset protection to allow patching of MCode areas. */ |
315 | MCode *lj_mcode_patch(jit_State *J, MCode *ptr, int finish) | 315 | MCode *lj_mcode_patch(jit_State *J, MCode *ptr, int finish) |
316 | { | 316 | { |
317 | #if LUAJIT_SECURITY_MCODE == 0 | ||
318 | UNUSED(J); UNUSED(ptr); UNUSED(finish); | ||
319 | return NULL; | ||
320 | #else | ||
321 | if (finish) { | 317 | if (finish) { |
318 | #if LUAJIT_SECURITY_MCODE | ||
322 | if (J->mcarea == ptr) | 319 | if (J->mcarea == ptr) |
323 | mcode_protect(J, MCPROT_RUN); | 320 | mcode_protect(J, MCPROT_RUN); |
324 | else if (LJ_UNLIKELY(mcode_setprot(ptr, ((MCLink *)ptr)->size, MCPROT_RUN))) | 321 | else if (LJ_UNLIKELY(mcode_setprot(ptr, ((MCLink *)ptr)->size, MCPROT_RUN))) |
325 | mcode_protfail(J); | 322 | mcode_protfail(J); |
323 | #endif | ||
326 | return NULL; | 324 | return NULL; |
327 | } else { | 325 | } else { |
328 | MCode *mc = J->mcarea; | 326 | MCode *mc = J->mcarea; |
329 | /* Try current area first to use the protection cache. */ | 327 | /* Try current area first to use the protection cache. */ |
330 | if (ptr >= mc && ptr < (MCode *)((char *)mc + J->szmcarea)) { | 328 | if (ptr >= mc && ptr < (MCode *)((char *)mc + J->szmcarea)) { |
329 | #if LUAJIT_SECURITY_MCODE | ||
331 | mcode_protect(J, MCPROT_GEN); | 330 | mcode_protect(J, MCPROT_GEN); |
331 | #endif | ||
332 | return mc; | 332 | return mc; |
333 | } | 333 | } |
334 | /* Otherwise search through the list of MCode areas. */ | 334 | /* Otherwise search through the list of MCode areas. */ |
@@ -336,13 +336,14 @@ MCode *lj_mcode_patch(jit_State *J, MCode *ptr, int finish) | |||
336 | mc = ((MCLink *)mc)->next; | 336 | mc = ((MCLink *)mc)->next; |
337 | lj_assertJ(mc != NULL, "broken MCode area chain"); | 337 | lj_assertJ(mc != NULL, "broken MCode area chain"); |
338 | if (ptr >= mc && ptr < (MCode *)((char *)mc + ((MCLink *)mc)->size)) { | 338 | if (ptr >= mc && ptr < (MCode *)((char *)mc + ((MCLink *)mc)->size)) { |
339 | #if LUAJIT_SECURITY_MCODE | ||
339 | if (LJ_UNLIKELY(mcode_setprot(mc, ((MCLink *)mc)->size, MCPROT_GEN))) | 340 | if (LJ_UNLIKELY(mcode_setprot(mc, ((MCLink *)mc)->size, MCPROT_GEN))) |
340 | mcode_protfail(J); | 341 | mcode_protfail(J); |
342 | #endif | ||
341 | return mc; | 343 | return mc; |
342 | } | 344 | } |
343 | } | 345 | } |
344 | } | 346 | } |
345 | #endif | ||
346 | } | 347 | } |
347 | 348 | ||
348 | /* Limit of MCode reservation reached. */ | 349 | /* Limit of MCode reservation reached. */ |