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

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

Issue 565713004: Linux sandbox: Remove CodeGen::JoinInstructions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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 | « sandbox/linux/seccomp-bpf/codegen.h ('k') | sandbox/linux/seccomp-bpf/codegen_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/linux/seccomp-bpf/codegen.cc
diff --git a/sandbox/linux/seccomp-bpf/codegen.cc b/sandbox/linux/seccomp-bpf/codegen.cc
index aa47155fce7a7178c4ed1948ccf71dd0a5b98884..2273cafe7b3ec9e16b5198d3fdd2469c70a5418d 100644
--- a/sandbox/linux/seccomp-bpf/codegen.cc
+++ b/sandbox/linux/seccomp-bpf/codegen.cc
@@ -181,9 +181,7 @@ Instruction* CodeGen::MakeInstruction(uint16_t code,
if (BPF_CLASS(code) != BPF_JMP || BPF_OP(code) == BPF_JA) {
SANDBOX_DIE("Expected a BPF_JMP instruction");
}
- if (!jt && !jf) {
- // We allow callers to defer specifying exactly one of the branch
- // targets. It must then be set later by calling "JoinInstructions".
+ if (!jt || !jf) {
SANDBOX_DIE("Branches must jump to a valid instruction");
}
Instruction* insn = new Instruction(code, k, jt, jf);
@@ -191,35 +189,6 @@ Instruction* CodeGen::MakeInstruction(uint16_t code,
return insn;
}
-void CodeGen::JoinInstructions(Instruction* head, Instruction* tail) {
- // Merge two instructions, or set the branch target for an "always" jump.
- // This function should be called, if the caller didn't initially provide
- // a value for "next" when creating the instruction.
- if (BPF_CLASS(head->code) == BPF_JMP) {
- if (BPF_OP(head->code) == BPF_JA) {
- if (head->jt_ptr) {
- SANDBOX_DIE("Cannot append instructions in the middle of a sequence");
- }
- head->jt_ptr = tail;
- } else {
- if (!head->jt_ptr && head->jf_ptr) {
- head->jt_ptr = tail;
- } else if (!head->jf_ptr && head->jt_ptr) {
- head->jf_ptr = tail;
- } else {
- SANDBOX_DIE("Cannot append instructions after a jump");
- }
- }
- } else if (BPF_CLASS(head->code) == BPF_RET) {
- SANDBOX_DIE("Cannot append instructions after a return statement");
- } else if (head->next) {
- SANDBOX_DIE("Cannot append instructions in the middle of a sequence");
- } else {
- head->next = tail;
- }
- return;
-}
-
void CodeGen::Traverse(Instruction* instruction,
void (*fnc)(Instruction*, void*),
void* aux) {
« no previous file with comments | « sandbox/linux/seccomp-bpf/codegen.h ('k') | sandbox/linux/seccomp-bpf/codegen_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698