News for hackers. Stuff that matters.
Re:TinyKVM: Fast sandbox that runs on top of Varnish by cryptonector on Friday March 14, 2025 @02:43AM (#43360170)
IIUC there's no need for system calls because there's no I/O. There's just program arguments and shared memory.
Re:TinyKVM: Fast sandbox that runs on top of Varnish by dividuum on Friday March 14, 2025 @03:36AM (#43360385)
You need a few syscalls: to grow your heap size (brk) or to exit your program (exit). I took a quick look at their code and here are the syscalls and arguments implemented: https://github.com/varnish/tinykvm/blob/master/src/functions...

It’s a bit more than running a program under seccomp strict mode, but conceptually similar, so running anything too complicated likely won't work. You certainly won’t be able to sandbox chromium for taking website snapshots for example.

Re:TinyKVM: Fast sandbox that runs on top of Varnish by fwsgonzo on Friday March 14, 2025 @06:57AM (#43361373)
There's many ways to go about it, but essentially yes, brk and mmap and a few others just to get into main() for some common run-times.

But you can do whatever you want. For example in libriscv I override the global allocator in my guest programs to use a host-managed heap. That way heap usage has native performance in interpreter mode, while also allowing me full control of the heap from the outside. I wrote about this here: https://medium.com/@fwsgonzo/using-c-as-a-scripting-language...

Re:TinyKVM: Fast sandbox that runs on top of Varnish by cryptonector on Friday March 14, 2025 @11:57AM (#43363886)
Well, yes, there's a few system calls like `brk()`/`sbrk()`/`getrandom()`, and what not. But you don't get to open any files or sockets or devices.
Re:TinyKVM: Fast sandbox that runs on top of Varnish by fwsgonzo on Friday March 14, 2025 @12:42PM (#43364384)
For the Varnish integration I added permission-based access to local files. Network stuff can be accessed through custom APIs. A simple fetch(url, options)-like system call. Just have a look at the VMOD repository. It's something I'd like to move into TinyKVM when I feel like it.
Re:TinyKVM: Fast sandbox that runs on top of Varnish by winternewt on Friday March 14, 2025 @07:22AM (#43361527)
What do you mean by I/O exactly? Because to me handling HTTP requests definitely requires I/O, no matter how you technically implement it. Does the program start anew with new arguments for each HTTP request, and if so how is that an improvement over I/O syscalls?
Re:TinyKVM: Fast sandbox that runs on top of Varnish by nine_k on Friday March 14, 2025 @10:28AM (#43362961)
Handling HTTP requests can be done entirely via stdin + stdout. But it won't be too useful if you could not even talk to a database.

The VM may (and should) be limited to a small subset of what's available on the host though.

Re:TinyKVM: Fast sandbox that runs on top of Varnish by winternewt on Sunday March 16, 2025 @03:15PM (#43381376)
But in order to read from stdin and write to stdout, you must make I/O syscalls.
Re:TinyKVM: Fast sandbox that runs on top of Varnish by cryptonector on Friday March 14, 2025 @11:59AM (#43363907)
I mean you don't get to open files, sockets, devices, etc. in the sandboxed program. You get to do just a few minimal things like I/O on stdin/stdout/stderr, use shared memory, maybe allocate memory.
Re:TinyKVM: Fast sandbox that runs on top of Varnish by winternewt on Sunday March 16, 2025 @03:17PM (#43381395)
So how do you do I/O on stdin/stdiout/stderr without syscalls?
Re:TinyKVM: Fast sandbox that runs on top of Varnish by cryptonector on Tuesday March 18, 2025 @04:08PM (#43404403)
There's a tiny kernel, and there are syscalls, because after all the executable is -though ELF- a statically linked executable with a statically linked libc, but that mini kernel only handles very few system calls, and does not provide the full generality of Linux. Yes I shouldn't have said "there's no syscalls", just no generic I/O.