Skip to content

Commit

Permalink
Do not recreate network and IPC namespaces for each judge
Browse files Browse the repository at this point in the history
Public [1] and private reports suggest doing so is causing scalability
issues with current Ubuntu LTS (22.04) kernel (5.15).

Note that the safety of this change depends on Identity::dynamic
(which implies `RemoveIPC=true`) or we'd leave some attack vectors.
  • Loading branch information
xry111 committed Dec 1, 2023
1 parent d78b93a commit b912335
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 59 deletions.
110 changes: 60 additions & 50 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ optional = true
hustoj = ["dep:sqlx"]

[dependencies.systemd-run]
version = "0.5.0"
version = "0.6.0"
features = [ "systemd_249", "unified_cgroup" ]
11 changes: 11 additions & 0 deletions etc/systemd/system/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This file need to be copied to
# opoj-empty-ns-0.service, opoj-empty-ns-1.service, ... for each
# possible runner_id and adjusted.

[Unit]
Description=Empty namespace holder (runner %I)

[Service]
ExecStart=/bin/sleep infinity
PrivateIPC=true
PrivateNetwork=true
1 change: 1 addition & 0 deletions etc/systemd/system/opoj-x.slice
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

[Unit]
Description=Slice for OJ (runner X)
[email protected]

[Slice]
# Normally we expect solutions judged with one CPU core.
Expand Down
10 changes: 10 additions & 0 deletions mocktest/code/aplusb/net.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from urllib.request import urlopen

urlopen("https://acm.xidian.edu.cn/")

try:
while True:
a, b = map(int, input().split())
print(a + b)
except EOFError:
pass
5 changes: 5 additions & 0 deletions mocktest/etc/judge3.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ src_name = "main.cc"
cmd_compile = ["/usr/bin/g++", "main.cc", "-o", "main", "-fmax-errors=256"]
cmd_run = ["/tmp/main"]

[language."python"]
src_name = "main.py"
cmd_compile = ["/usr/bin/python3", "-m", "py_compile", "main.py"]
cmd_run = ["/usr/bin/python3", "/tmp/main.py"]

# An example for HustOJ configuration.
#[hust]
#db_url = "mysql://user:passwd@localhost/jol?socket=/run/mysqld/mysqld.sock"
Expand Down
6 changes: 6 additions & 0 deletions mocktest/test19.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language = "python"
time_limit = 1
memory_limit = "256 MiB"
testcase_dir = "problem/aplusb"
src = "code/aplusb/net.py"
expect = "RunError"
Loading

1 comment on commit b912335

@xry111
Copy link
Contributor Author

@xry111 xry111 commented on b912335 Dec 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.