12.09.2016 Views

ESCAPING THE LUA 5.2 SANDBOX WITH UNTRUSTED BYTECODE

2cp3MRc

2cp3MRc

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Digression: Lua tagged values (TValues)<br />

Each value in Lua is 12 bytes *<br />

local a = "hello, world"<br />

local b = 1337<br />

*<br />

Typically, as we'll see soon<br />

First field: union between several<br />

different datatypes (8 bytes/64 bits,<br />

because numbers in Lua are doubles)<br />

Heap<br />

TString<br />

"hello, world"<br />

Second field: type tag to identify how<br />

to read the union (4 bytes/32 bits)<br />

Each function's local variable stack is<br />

just an array of TValues, which grows<br />

up<br />

Lua stack<br />

(TString *)0xdeadbeef<br />

(double)1337<br />

0x04<br />

0x03<br />

Value<br />

Tag

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!