Skip to content

Commit

Permalink
Validate jump target before updating vm->int_funcs
Browse files Browse the repository at this point in the history
Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
  • Loading branch information
Alan Jowett committed Apr 22, 2024
1 parent dfd2e9c commit de908a1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions vm/ubpf_vm.c
Expand Up @@ -245,6 +245,10 @@ ubpf_load(struct ubpf_vm* vm, const void* code, uint32_t code_len, char** errmsg
*/
if (source_inst[i].opcode == EBPF_OP_CALL && source_inst[i].src == 1) {
uint32_t target = i + source_inst[i].imm + 1;
if (target >= vm->num_insts) {
*errmsg = ubpf_error("invalid call target %u", target);
return -1;
}
vm->int_funcs[target] = true;
}
// Store instructions in the vm.
Expand Down

0 comments on commit de908a1

Please sign in to comment.