views:

106

answers:

2

I'll looking for advice/resources to write a program that can intercept system calls from a programm to supervise it's filesystem, network, etc access.

The aim of this is to write an online judge, so that untrusted code can be run safely on a server.

This is on linux, and I would prefer to write C++ or a scripting langauge (ruby, python, etc), and a library would be great!

Thanks.

+3  A: 

This looks like a good place to start. http://www.linuxjournal.com/article/6100

Ganesh
This seems to be an interesting guide, however I'm more interested in a library that would do all the heavy-lifting behind the scenes. And prefreably let me write in a scripting language.
thomasfedb
+1  A: 

You can't safely use ptrace() to sandbox a hostile application.

The application can always use multiple threads with deliberate race conditions to alter syscall arguments passed via pointers (eg. a filename) after you've inspected them but before the kernel looks at them.

caf
Couldn't this be addressed by preventing the child from forking, this happens to be something we want to restrict anyway.
thomasfedb
While its good to know of caveats, its always best to give positive advice i feel.
thomasfedb
@thomasfedb: Sure, if you stop both `fork()` and `clone()` that should get you most of the way there (of course, it means people can't submit multithreaded code to your online judge). You will also want to stop access to shared memory segments too. You might still be better off at alternative approaches to the problem - eg. using SELinux for sandboxing.
caf
@caf thanks. I want to restrict users to one thread anyway, put people on an even footing. And the problems wont benifit from multithreading anyway.
thomasfedb