runtimejs / runtime

[not maintained] Lightweight JavaScript library operating system for the cloud
http://runtimejs.org
Apache License 2.0
1.93k stars 128 forks source link

Execution of third-party binaries #9

Closed piranna closed 10 years ago

piranna commented 10 years ago

No, I'm not trolling :-)

In the technical details it says that it's the intention to have all the OS running on ring 0 in the same memory space and left to the Javascript VM to sandbox the applications, so there's no penalties by context switching and allow IPC by just sharing a pointer to an ArrayBuffer, but what happens if I need to run a binary application? If I had the sources I could try to compile it to Javascript so it gets sandboxed, but what happens if I don't have the sources? Running in ring 0 they could be able to write in memory address, so we wold be back to Windows 3.11... Worst than this, compiled modules have the same problem :-/

I was thinking that in a mid-term this binaries could be run on ring 3 in their own memory space and do normal IPC like in other OSes, so this way they could be sandboxed in a different way (Chrome inspired?).

groundwater commented 10 years ago

The v8 sandbox provides you with memory protection. It's exactly why javascript running in your browser does not have access the rest of the process memory.

If you really want to pre-compile C, you can check out emscripten an LLVM to javascript compiler. This is the whole asm argument though, and right now Chrome does not provide any asm-related accelerations.

piranna commented 10 years ago

The usage of emscripten is possible when you have the source code, but I'm talking about when you don't have it because it's closed source code or other thing. Another option is to require to have the source code so it can be compiled with emscripten and run inside a v8 sandbox, period :-)

Hum... LLVM compiled recursively using emscripten so it can compile C programs from inside Javascript, interesting... :-P