ioi / isolate

Sandbox for securely executing untrusted programs
Other
1.05k stars 157 forks source link

I tried to build a dynamic library and call it with C #, but there was an error #103

Closed Zeng1998 closed 2 years ago

Zeng1998 commented 3 years ago

I build a .so file following this

gcc -std=gnu99 -Wall -Wextra -Wno-parentheses -Wno-unused-result -Wno-missing-field-initializers -Wstrict-prototypes -Wmissing-prototypes -D_GNU_SOURCE  -c -fPIC cg.c config.c isolate.c rules.c util.c -lcap && gcc -shared *.o -lcap -o libisolate.so

Then I call the main function in C# code

class Program {
        [DllImport("/home/zxc/CLionProjects/isolate/libisolate.so",
            EntryPoint = "main")]
        public static extern void Main(int argc, string[] argv);
        static void Main(string[] args) {
            Main(22, new[] {"main","-b","1","--processes=1000","-M","metadata.txt","-i","/dev/null","-t","5","-x","0","-w","10","-k","1000000","-f","1000000", "--run", "--","/usr/bin/gcc","--version", null});
        }
    }

Following the expected output, it output the error

Sandbox keeper received fatal signal 6
UGH: Lost track of the process (No child processes)

and the content of metadata.txt is

status:XX
message:Sandbox keeper received fatal signal 6
killed:1

I pass the same arguments to the execution file isolate, it's ok and with no error.

Zeng1998 commented 3 years ago

with execution file, p = wait4(proxy_pid, &stat, 0, &rus); return a valid pid, but with dynamic library calling, it return -1. I want to figure out why

gollux commented 2 years ago

Isolate is definitely not suited for being used as a shared library.