Skip to content

Commit 67e3c21

Browse files
committed
executors: fixup executors for landlock
Under landlock, since /proc is not accessible in a subprocess, SCALA calls `mincore`. We allow this in order for it to pass. Also, since `execve` is checked under landlock, we need to add `/bin` to the list of readable directories.
1 parent a266eb1 commit 67e3c21

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

dmoj/executors/RUST.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import fcntl
22
import os
3+
from typing import List
34

4-
from dmoj.cptbox.filesystem_policies import ExactFile, RecursiveDir
5+
from dmoj.cptbox.filesystem_policies import ExactFile, FilesystemAccessRule, RecursiveDir
56
from dmoj.executors.compiled_executor import CompiledExecutor
67

78
CARGO_TOML = b"""\
@@ -86,6 +87,12 @@ def get_shared_target(self):
8687
# We intentionally don't clean this directory up at any point, since we can re-use it.
8788
return self.shared_target
8889

90+
def get_fs(self) -> List[FilesystemAccessRule]:
91+
assert self._executable is not None
92+
# Under landlock we need this for execve to work.
93+
# We use `self._executable` because it is copied when caching executors, but other properties are not.
94+
return super().get_fs() + [ExactFile(self._executable)]
95+
8996
def cleanup(self) -> None:
9097
super().cleanup()
9198
if self.shared_target is not None:

dmoj/executors/SCALA.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class Executor(JavaExecutor):
2020
ExactFile('/bin/bash'),
2121
RecursiveDir('/etc/alternatives'),
2222
]
23+
compiler_syscalls = ['mincore']
2324
vm = 'scala_vm'
2425

2526
test_program = """\

dmoj/executors/base_executor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
ExactFile('/dev/urandom'),
3434
ExactFile('/dev/random'),
3535
*USR_DIR,
36+
RecursiveDir('/bin'), # required under landlock when /bin is not a symlink, since we check execve.
3637
RecursiveDir('/lib'),
3738
RecursiveDir('/lib32'),
3839
RecursiveDir('/lib64'),

0 commit comments

Comments
 (0)