L1VM - security
Security in the L1VM
Here I want to show how L1VM handles security. This begins at the core: the memories for code and data are separated. Like in a Harvard CPU architecture. So a program never can change the own code in memory.
In the default config setting “memory bounds” is active. It checks if the variable addresses which are used are in legal range. So an out of bounds array variable access is a runtime error. And indicates that you did something wrong in your program! The string module has build in checks for string overflows. So it is also safe to use.
The file module only has access to the
~/l1vm directory in your
/home directory. It can never escape this directory.
The stack is checked by default. If you for example put a
byte variable on top of the stack and try to take an
int64 from it, then
you will get a stack error message.
You even can switch on math overflow checks if a number is in legal range. But this is not set as a default check. And there is a check if there is a division by zero.
Security in the Brackets language
You can set the legal value ranges of a variable via the
(x x_min x_max range)
Here the minimum and maximum value of variable
x are set. If the range gets illegal then the program exits with an error.
Math expressions can’t mix integer and double floating point numbers. You have to convert the variables to the needed type.
And if you assign an int64 to an int32 for example, then you need to do a
cast. Otherwise it results in a compiler error.
As you can see it is possible to write safety features even in C and C++. But you have to fix everything by yourself.