forked from LuaJIT/LuaJIT
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Always exit after machine code page protection change fails.
Reported by Sergey Kaplun. (cherry picked from commit c50232e)
- Loading branch information
1 parent
f0d6df4
commit cfe4f1f
Showing
6 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
test/tarantool-tests/lj-802-panic-at-mcode-protfail.test.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
local tap = require('tap') | ||
local test = tap.test('lj-flush-on-trace'):skipcond({ | ||
['Test requires JIT enabled'] = not jit.status(), | ||
['Disabled on *BSD due to #4819'] = jit.os == 'BSD', | ||
['mprotect overriding can break Tarantool'] = _TARANTOOL, | ||
}) | ||
|
||
test:plan(3) | ||
|
||
-- <makecmd> runs %testname%/script.lua by <LUAJIT_TEST_BINARY> | ||
-- with the given environment, launch options and CLI arguments. | ||
local script = require('utils').exec.makecmd(arg, { | ||
env = { LD_PRELOAD = 'mymprotect.so' }, | ||
redirect = '2>&1', | ||
}) | ||
|
||
local poison = 'runtime code generation succeed' | ||
local output = script(poison) | ||
test:like(output, 'runtime code generation failed, restricted kernel%?', | ||
'Panic occurred as a result of <mprotect> failure') | ||
test:unlike(output, 'Segmentation fault', | ||
'LuaJIT exited as a result of the panic (error check)') | ||
test:unlike(output, poison, | ||
'LuaJIT exited as a result of the panic (poison check)') | ||
|
||
test:done(true) |
1 change: 1 addition & 0 deletions
1
test/tarantool-tests/lj-802-panic-at-mcode-protfail/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
BuildTestCLib(mymprotect mymprotect.c) |
6 changes: 6 additions & 0 deletions
6
test/tarantool-tests/lj-802-panic-at-mcode-protfail/mymprotect.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <sys/mman.h> | ||
|
||
int mprotect(void *addr, size_t len, int prot) | ||
{ | ||
return -1; | ||
} |
11 changes: 11 additions & 0 deletions
11
test/tarantool-tests/lj-802-panic-at-mcode-protfail/script.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
jit.opt.start('hotloop=1') | ||
|
||
-- XXX: | ||
local a = 0 | ||
for i = 1, 3 do | ||
a = a + i | ||
end | ||
|
||
-- XXX: Just a simple contract in case if panic at <mprotect> | ||
-- failure didn't occur. | ||
io.write(arg[1]) |