Skip to content

Commit

Permalink
Mark r0 as initialized by call
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 May 7, 2024
1 parent 4a436d2 commit 621d21f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions vm/ubpf_vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,16 @@ ubpf_validate_shadow_register(const struct ubpf_vm* vm, uint16_t* shadow_registe
*shadow_registers |= 1 << inst.dst;
}

if (inst.opcode == EBPF_OP_CALL) {
// Mark the return address register as initialized.
*shadow_registers |= 1 << 0;
}

if (inst.opcode == EBPF_OP_EXIT && !(*shadow_registers & (1 << 0))) {
vm->error_printf(stderr, "Error: Return address register r0 is not initialized.\n");
return false;
}

return true;
}

Expand Down

0 comments on commit 621d21f

Please sign in to comment.