Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1166)

Unified Diff: sandbox/linux/seccomp-bpf/sandbox_bpf.cc

Issue 604123002: Linux sandbox: fill all parameters when detecting seccomp syscall. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/linux/seccomp-bpf/sandbox_bpf.cc
diff --git a/sandbox/linux/seccomp-bpf/sandbox_bpf.cc b/sandbox/linux/seccomp-bpf/sandbox_bpf.cc
index 399087c368ed58482901feaae73ab74709929d6f..886ee84c557d85c9bbe4d8c1a89846b17c70c586 100644
--- a/sandbox/linux/seccomp-bpf/sandbox_bpf.cc
+++ b/sandbox/linux/seccomp-bpf/sandbox_bpf.cc
@@ -492,20 +492,17 @@ SandboxBPF::SandboxStatus
SandboxBPF::SupportsSeccompThreadFilterSynchronization() {
// Applying NO_NEW_PRIVS, a BPF filter, and synchronizing the filter across
// the thread group are all handled atomically by this syscall.
- int rv = syscall(__NR_seccomp);
+ const int rv = syscall(
+ __NR_seccomp, SECCOMP_SET_MODE_FILTER, SECCOMP_FILTER_FLAG_TSYNC, NULL);
- // The system call should have failed with EINVAL.
- if (rv != -1) {
- NOTREACHED();
- return STATUS_UNKNOWN;
- }
-
- if (errno == EINVAL || errno == EFAULT)
+ if (rv == -1 && errno == EFAULT) {
return STATUS_AVAILABLE;
-
- // errno is probably ENOSYS, indicating the system call is not available.
- DCHECK_EQ(errno, ENOSYS);
- return STATUS_UNSUPPORTED;
+ } else {
+ // TODO(jln): turn these into DCHECK after 417888 is considered fixed.
+ CHECK_EQ(-1, rv);
+ CHECK(ENOSYS == errno || EINVAL == errno);
+ return STATUS_UNSUPPORTED;
+ }
}
void SandboxBPF::set_proc_fd(int proc_fd) { proc_fd_ = proc_fd; }
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698