Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cptbox/isolate: print target of denied *kill and prlimit syscalls #1176

Merged
merged 1 commit into from
Jun 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions dmoj/cptbox/isolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,13 +390,15 @@ def _access_check(self, debugger: Debugger, file: str, fs_jail: FilesystemPolicy

def handle_kill(self, debugger: Debugger) -> None:
# Allow tgkill to execute as long as the target thread group is the debugged process
# libstdc++ seems to use this to signal itself, see <https://github.com/DMOJ/judge/issues/183>
if debugger.uarg0 != debugger.pid:
raise DeniedSyscall(ACCESS_EPERM, 'Cannot kill other processes')
# libstdc++ seems to use this to signal itself, see <https://github.com/DMOJ/judge/issues/18A3>
target = debugger.uarg0
if target != debugger.pid:
raise DeniedSyscall(ACCESS_EPERM, f'Cannot kill other processes (target={target}, self={debugger.pid})')

def handle_prlimit(self, debugger: Debugger) -> None:
if debugger.uarg0 not in (0, debugger.pid):
raise DeniedSyscall(ACCESS_EPERM, 'Cannot prlimit other processes')
target = debugger.uarg0
if target not in (0, debugger.pid):
raise DeniedSyscall(ACCESS_EPERM, f'Cannot prlimit other processes (target={target}, self={debugger.pid})')

def handle_prctl(self, debugger: Debugger) -> None:
PR_GET_DUMPABLE = 3
Expand Down
Loading