[FZH] [Misc] 如何限制系统调用

Hexchain Tong richard0053在gmail.com
星期五 一月 7 08:29:25 UTC 2011


Hi all,

最近在写一个类似于 OI 评测机的程序,由用户提交代码,处理后编译为目标程序执行。现在的想法是由一个程序 fork 出子进程,在子进程里
chroot 后执行目标程序,主程序卡时间等待子程序退出(主进程退出时会按 pid 杀掉 fork
出来的子进程)。但是目标程序的这样一段代码会让自身不被杀掉:

extern int kill(int, int);
extern int getppid(void);
extern int pause(void);

int main() {
    kill(getppid(), 9);
    pause();
    return 0;
}

在 USACO (http://ace.delos.com/usacogate) 上测试会出现 Bad syscall 的错误,请问这种对
syscall 的限制是怎么做到的?如果有更好的方法,请告诉我,谢谢!

-- 
Hexchain Tong
----------------------------------------------------
Profile: https://www.google.com/profiles/richard0053
Twitter: @Hexc4l
Facebook: hexchain在facebook.com
Mail: richard0053在gmail.com


关于邮件列表 Chinese 的更多信息