Skip to content

Commit

Permalink
Reject EBPF_OP_LDDW if src != 0 (#132)
Browse files Browse the repository at this point in the history
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
  • Loading branch information
Alan-Jowett committed Oct 12, 2022
1 parent 0afd630 commit 09a122b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/err-lddw-invalid-src.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- raw
0x5566778800001118
0x0000000000000000
-- error
Failed to load code: invalid source register for LDDW at PC 0
4 changes: 4 additions & 0 deletions vm/ubpf_vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,10 @@ validate(const struct ubpf_vm *vm, const struct ebpf_inst *insts, uint32_t num_i
break;

case EBPF_OP_LDDW:
if (inst.src != 0) {
*errmsg = ubpf_error("invalid source register for LDDW at PC %d", i);
return false;
}
if (i + 1 >= num_insts || insts[i+1].opcode != 0) {
*errmsg = ubpf_error("incomplete lddw at PC %d", i);
return false;
Expand Down

0 comments on commit 09a122b

Please sign in to comment.