Please keep in mind that your sandbox can only be secure if the code it runs is not multi-threaded. You will also need to be very careful to prevent sand code from warping.
See, for example, the following discussion of an article by Robert Watson:
Exploiting races in wrapper system calls
The document is linked to this article, but I also offer a link here:
Using Concurrency Vulnerabilities in System Call Fairings
The best approach still seems to be the same as Watson recommends: fully integrate the security framework into the kernel and take care of its use to avoid Concurrency issues. Linux and NetBSD and Mac OS X and other security-oriented systems already provide such structures, and therefore all that is needed when using these systems is to implement your policies within existing infrastructures. That is, do not even try to implement your security policies in system call shells or other system call interpolation mechanisms.
Greg A. Woods
source share