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

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

Issue 568053005: Split AssembleFilter into comprehensible chunks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to jln feedback 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 | sandbox/linux/seccomp-bpf/sandbox_bpf.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/linux/seccomp-bpf/sandbox_bpf.h
diff --git a/sandbox/linux/seccomp-bpf/sandbox_bpf.h b/sandbox/linux/seccomp-bpf/sandbox_bpf.h
index a85c7ac84b7d36317292917a766cb6e2038df4a5..f638fb988fd1850dad3f9e05cf40e5fbb638c3cd 100644
--- a/sandbox/linux/seccomp-bpf/sandbox_bpf.h
+++ b/sandbox/linux/seccomp-bpf/sandbox_bpf.h
@@ -246,6 +246,37 @@ class SANDBOX_EXPORT SandboxBPF {
// been configured with SetSandboxPolicy().
void InstallFilter(bool must_sync_threads);
+ // Compile the configured policy into a complete instruction sequence.
+ // (See MaybeAddEscapeHatch for |has_unsafe_traps|.)
+ Instruction* CompilePolicy(CodeGen* gen, bool* has_unsafe_traps);
+
+ // Return an instruction sequence that checks the
+ // arch_seccomp_data's "arch" field is valid, and then passes
+ // control to |passed| if so.
+ Instruction* CheckArch(CodeGen* gen, Instruction* passed);
+
+ // If the |rest| instruction sequence contains any unsafe traps,
+ // then sets |*has_unsafe_traps| to true and returns an instruction
+ // sequence that allows all system calls from Syscall::Call(), and
+ // otherwise passes control to |rest|.
+ //
+ // If |rest| contains no unsafe traps, then |rest| is returned
+ // directly and |*has_unsafe_traps| is set to false.
+ Instruction* MaybeAddEscapeHatch(CodeGen* gen,
+ bool* has_unsafe_traps,
+ Instruction* rest);
+
+ // Return an instruction sequence that loads and checks the system
+ // call number, performs a binary search, and then dispatches to an
+ // appropriate instruction sequence compiled from the current
+ // policy.
+ Instruction* DispatchSyscall(CodeGen* gen);
+
+ // Return an instruction sequence that checks the system call number
+ // (expected to be loaded in register A) and if valid, passes
+ // control to |passed| (with register A still valid).
+ Instruction* CheckSyscallNumber(CodeGen* gen, Instruction* passed);
+
// Verify the correctness of a compiled program by comparing it against the
// current policy. This function should only ever be called by unit tests and
// by the sandbox internals. It should not be used by production code.
« no previous file with comments | « no previous file | sandbox/linux/seccomp-bpf/sandbox_bpf.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698