two problems when run in a baremetal or a devcontainer
Hello, I'm using ubuntu 24.04, on both server and the docker devcontainer. The problem occurs in both the baremetal server and the docker container.
Sandlock partially works. Below are my findings for a 7.0.0-28-generic kernel:
The command used to start an interactive shell here in this experiment is:
sandlock run -i -r /usr -r /lib -r /lib64 -r /bin -r /etc -w /tmp -- /bin/sh
- while it is working,
sandlock listfrom an alternative terminal saysNo running sandboxes.. In the shell, it is possible to dols /tmpand it prints correctly, andls .gives permission errors, expectedly as the current location wasn't shared.
When running python:
from sandlock import Sandbox, confine
sandbox = Sandbox(
fs_writable=["/tmp/sandbox"],
fs_readable=["/usr", "/lib", "/etc"],
max_memory="256M",
max_processes=10,
clean_env=True,
)
# Run a command (with optional timeout in seconds)
result = sandbox.run(["python3", "-c", "print('hello')"], timeout=30)
- stops at the instant result line is sent to python repl, saying
[1]+ Stopped python.
The 2nd failure step must be doing an effect like sending a ctrl+z to the python process and freezing it. When I say fg, python process continues:
$ fg
python
>>> result
Result(success=False, exit_code=-1, error='sandlock_create failed', reason=None, signal=-1)
>>> sandbox
Sandbox(fs_writable=['/tmp/sandbox'], fs_readable=['/usr', '/lib', '/etc'], fs_denied=[], extra_deny_syscalls=[], extra_allow_syscalls=[], net_allow=[], net_deny=[], no_coredump=False, net_allow_bind=[], net_deny_bind=[], http_allow=[], http_deny=[], http_ports=[], http_ca=None, http_key=None, http_inject_ca=[], http_ca_out=None, max_memory='256M', max_processes=10, max_open_files=None, max_cpu=None, cpu_cores=None, num_cpus=None, port_remap=False, random_seed=None, time_start=None, no_randomize_memory=False, no_huge_pages=False, deterministic_dirs=False, gpu_devices=None, chroot=None, fs_mount={}, clean_env=True, env={}, uid=None, gid=None, notif_policy=None, workdir=None, cwd=None, fs_storage=None, max_disk=None, on_exit=<BranchAction.COMMIT: 'commit'>, on_error=<BranchAction.ABORT: 'abort'>, allow_degraded=[], disable=[])
I hope this debug log helps
@congwang-mk let me know if you need more debug info(but you need to refer me to a document that shows how to get that extra debug logs for sandlock. Thanks
Thanks for the report, @nnWhisperer
The first issue is somehow expected, because when I introduced sandlock list for network port remapping initially, I didn't go beyond networking. It is a bug anyway, as it should go beyond just port mapping. See also https://github.com/multikernel/sandlock/issues/68 and PR #153
The second issue is a bug related to tcsetpgrp, I will fix it now.
@nnWhisperer I verified on the latest main branch, both are fixed now.