ioi / isolate

Sandbox for securely executing untrusted programs
Other
1.04k stars 154 forks source link

Fail-safe when memory.swap.max is not available #141

Closed fer22f closed 6 months ago

fer22f commented 7 months ago

This PR closes #137.

It seems like if the kernel is not compiled with CONFIG_MEMCG_SWAP, memory.swap.max and related are not available. Currently, isolate just crashes when this happens, since it tries to write to a file that may not exist. If the user does not use swap, writing to this file does not change behavior.

It should be noted, though, that the user could:

However, this will not happen in the majority of the cases; the manual recommends not setting up swap and having a kernel compiled without this feature is result of running in an environment with a custom kernel (which sometimes you have no control over).

So this PR just allows isolate to ignore the fact that the controller is not there. A more diligent solution would also include warning that the file does not exist.

AlexVasiluta commented 7 months ago

I would also like to add the fact that in the master branch, swap-related code does set the maybe flag using the question mark, so it was probably forgotten during the cg2 development effort:

https://github.com/ioi/isolate/blob/c24e80f50125052dcc56f81f5a6c9c633a76c2e3/cg.c#L241-L248