Skip to content

Commit

Permalink
Adds check_call_target() to verifier.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed May 20, 2024
1 parent 0270240 commit 937c238
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,16 @@ fn check_jmp_offset(
Ok(())
}

fn check_call_target(
key: u32,
function_registry: &FunctionRegistry<usize>,
) -> Result<(), VerifierError> {
function_registry
.lookup_by_key(key)
.map(|_| ())
.ok_or(VerifierError::InvalidFunction(key as usize))
}

fn check_registers(
insn: &ebpf::Insn,
store: bool,
Expand Down Expand Up @@ -371,7 +381,7 @@ impl Verifier for RequisiteVerifier {
ebpf::JSLT_REG => { check_jmp_offset(prog, insn_ptr, &function_range)?; },
ebpf::JSLE_IMM => { check_jmp_offset(prog, insn_ptr, &function_range)?; },
ebpf::JSLE_REG => { check_jmp_offset(prog, insn_ptr, &function_range)?; },
ebpf::CALL_IMM if sbpf_version.static_syscalls() && insn.src != 0 => { check_jmp_offset(prog, insn_ptr, &program_range)?; },
ebpf::CALL_IMM if sbpf_version.static_syscalls() && insn.src != 0 => { check_call_target(insn.imm as u32, function_registry)?; },
ebpf::CALL_IMM => {},
ebpf::CALL_REG => { check_callx_register(&insn, insn_ptr, config, sbpf_version)?; },
ebpf::EXIT => {},
Expand Down

0 comments on commit 937c238

Please sign in to comment.