Skip to content

Commit

Permalink
Negative jump offsets are valid in eBPF
Browse files Browse the repository at this point in the history
Therefore, while all paths through the CFG should end with an exit
instruction, it is not necessarily the last instruction.

Signed-off-by: Paul Chaignon <[email protected]>
  • Loading branch information
pchaigno committed Jun 8, 2019
1 parent 7cb293e commit 9d10569
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 0 additions & 4 deletions tests/err-noexit.data

This file was deleted.

9 changes: 9 additions & 0 deletions tests/exit-not-last.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- asm
mov r1, 0
ja +2
mov r2, 0
exit
mov r0, 0
ja -4
-- result
0x0
5 changes: 0 additions & 5 deletions vm/ubpf_vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,11 +562,6 @@ validate(const struct ubpf_vm *vm, const struct ebpf_inst *insts, uint32_t num_i
return false;
}

if (num_insts == 0 || insts[num_insts-1].opcode != EBPF_OP_EXIT) {
*errmsg = ubpf_error("no exit at end of instructions");
return false;
}

int i;
for (i = 0; i < num_insts; i++) {
struct ebpf_inst inst = insts[i];
Expand Down

0 comments on commit 9d10569

Please sign in to comment.