8000 sandbox: reject an empty seccomp_policy_file by matepad007 · Pull Request #420 · google/nsjail · GitHub
[go: up one dir, main page]

Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ test: $(BIN) $(TEST_BINS) test-cmdline test-newapi-recursive-readonly test-mnt-d
# --- Basic sanity tests ---
$(call run_test, ./nsjail -q -Mo --chroot / --user 99999 --group 99999 -- /bin/true, 0)
$(call run_test, ./nsjail -q -Mo --chroot / --user 99999 --group 99999 -- /bin/false, 1)
$(call run_test, ./nsjail -q -Mo --chroot / --user 99999 --group 99999 --seccomp_policy '' -- /bin/true, 255)
$(call run_test, ./nsjail -q -Mo --chroot / --user 99999 --group 99999 --use_cgroupv2 --cgroupv2_mount tests/cgroupv2 -- /bin/true, 0)
$(call run_test, ./nsjail -q -Mo --chroot / --user 99999 --group 99999 --use_cgroupv2 --cgroupv2_mount tests/cgroupv2 --cgroup_net_cls_classid 5 -- /bin/true, 255)
$(call run_test, strace -f -qq -e inject=setgroups:error=EPERM ./nsjail -q -Mo --disable_clone_newuser --chroot / --user 99999 --group 99999 -- /bin/true, 255)
Expand Down
4 changes: 4 additions & 0 deletions sandbox.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ bool preparePolicy(nsj_t* nsj) {
nsj->seccomp_unotify_fprog.len = 0;
nsj->seccomp_unotify_fprog.filter = NULL;

if (nsj->njc.has_seccomp_policy_file() && nsj->njc.seccomp_policy_file().empty()) {
LOG_E("seccomp_policy_file is set but empty");
return false;
}
if (nsj->njc.seccomp_policy_file().empty() && nsj->njc.seccomp_string().empty() &&
!nsj->njc.seccomp_unotify()) {
return true;
Expand Down
0