From 5debf6437bdb9f5ea5fd828a4264e1ee0bb8abea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Mei=C3=9Fner?= Date: Wed, 26 Jul 2023 12:38:00 +0200 Subject: [PATCH] Feature - `lduw` (load upper word immediate) (#486) * Adds SBPFVersion::disable_lddw. * Adds LD_UW_IMM. * Adjusts the existing tests. * Adds test_lduw. --- src/assembler.rs | 13 +- src/disassembler.rs | 1 + src/ebpf.rs | 2 + src/elf.rs | 5 + src/interpreter.rs | 3 + src/jit.rs | 19 +- src/static_analysis.rs | 2 +- src/verifier.rs | 8 +- tests/elfs/reloc_64_64.so | Bin 5248 -> 5248 bytes tests/elfs/reloc_64_relative.so | Bin 5424 -> 5424 bytes tests/elfs/reloc_64_relative_data.so | Bin 5784 -> 5784 bytes tests/elfs/rodata_section.so | Bin 5424 -> 5424 bytes tests/elfs/struct_func_pointer.so | Bin 5112 -> 5112 bytes tests/elfs/syscall_static.so | Bin 5368 -> 5368 bytes tests/execution.rs | 353 +++++++++++++++------------ tests/verifier.rs | 2 +- 16 files changed, 234 insertions(+), 174 deletions(-) diff --git a/src/assembler.rs b/src/assembler.rs index 89ef50e8..9f3212cc 100644 --- a/src/assembler.rs +++ b/src/assembler.rs @@ -9,7 +9,7 @@ use self::InstructionType::{ AluBinary, AluUnary, CallImm, CallReg, Endian, JumpConditional, JumpUnconditional, LoadAbs, - LoadImm, LoadInd, LoadReg, NoOperand, StoreImm, StoreReg, Syscall, + LoadDwImm, LoadInd, LoadReg, LoadUwImm, NoOperand, StoreImm, StoreReg, Syscall, }; use crate::{ asm_parser::{ @@ -28,7 +28,8 @@ use std::{collections::HashMap, sync::Arc}; enum InstructionType { AluBinary, AluUnary, - LoadImm, + LoadUwImm, + LoadDwImm, LoadAbs, LoadInd, LoadReg, @@ -93,7 +94,8 @@ fn make_instruction_map() -> HashMap { entry("syscall", Syscall, ebpf::CALL_IMM); entry("call", CallImm, ebpf::CALL_IMM); entry("callx", CallReg, ebpf::CALL_REG); - entry("lddw", LoadImm, ebpf::LD_DW_IMM); + entry("lduw", LoadUwImm, ebpf::LD_UW_IMM); + entry("lddw", LoadDwImm, ebpf::LD_DW_IMM); // AluUnary. entry("neg", AluUnary, ebpf::NEG64); @@ -332,7 +334,8 @@ pub fn assemble( insn(opc, 0, 1, 0, target_pc as i64) } (Endian(size), [Register(dst)]) => insn(opc, *dst, 0, 0, size), - (LoadImm, [Register(dst), Integer(imm)]) => { + (LoadUwImm, [Register(dst), Integer(imm)]) => insn(opc, *dst, 0, 0, *imm), + (LoadDwImm, [Register(dst), Integer(imm)]) => { insn(opc, *dst, 0, 0, (*imm << 32) >> 32) } _ => Err(format!("Unexpected operands: {operands:?}")), @@ -340,7 +343,7 @@ pub fn assemble( insn.ptr = insn_ptr; instructions.push(insn); insn_ptr += 1; - if let LoadImm = inst_type { + if let LoadDwImm = inst_type { if let Integer(imm) = operands[1] { instructions.push(Insn { ptr: insn_ptr, diff --git a/src/disassembler.rs b/src/disassembler.rs index eb4f4ce9..7a19b43c 100644 --- a/src/disassembler.rs +++ b/src/disassembler.rs @@ -140,6 +140,7 @@ pub fn disassemble_instruction( ebpf::LD_IND_W => { name = "ldindw"; desc = ldind_str(name, insn); }, ebpf::LD_IND_DW => { name = "ldinddw"; desc = ldind_str(name, insn); }, + ebpf::LD_UW_IMM => { name = "lduw"; desc = format!("{} r{:}, {:#x}", name, insn.dst, insn.imm); }, ebpf::LD_DW_IMM => { name = "lddw"; desc = format!("{} r{:}, {:#x}", name, insn.dst, insn.imm); }, // BPF_LDX class diff --git a/src/ebpf.rs b/src/ebpf.rs index 52e2fe3b..7c118c74 100644 --- a/src/ebpf.rs +++ b/src/ebpf.rs @@ -204,6 +204,8 @@ pub const LD_IND_W: u8 = BPF_LD | BPF_IND | BPF_W; /// BPF opcode: `ldinddw src, dst, imm`. pub const LD_IND_DW: u8 = BPF_LD | BPF_IND | BPF_DW; +/// BPF opcode: `lduw dst, imm` /// `dst |= imm << 32`. +pub const LD_UW_IMM: u8 = BPF_LD | BPF_IMM | BPF_W; /// BPF opcode: `lddw dst, imm` /// `dst = imm`. pub const LD_DW_IMM: u8 = BPF_LD | BPF_IMM | BPF_DW; /// BPF opcode: `ldxb dst, [src + off]` /// `dst = (src + off) as u8`. diff --git a/src/elf.rs b/src/elf.rs index 9546ac83..c3c6d936 100644 --- a/src/elf.rs +++ b/src/elf.rs @@ -220,6 +220,11 @@ pub enum SBPFVersion { } impl SBPFVersion { + /// Disable the only two slots long instruction: LD_DW_IMM + pub fn disable_lddw(&self) -> bool { + self != &SBPFVersion::V1 + } + /// Enable native signed division pub fn enable_sdiv(&self) -> bool { self != &SBPFVersion::V1 diff --git a/src/interpreter.rs b/src/interpreter.rs index 86028928..62c87f9e 100644 --- a/src/interpreter.rs +++ b/src/interpreter.rs @@ -197,6 +197,9 @@ impl<'a, 'b, V: Verifier, C: ContextObject> Interpreter<'a, 'b, V, C> { self.vm.stack_pointer = self.vm.stack_pointer.overflowing_add(insn.imm as u64).0; } + ebpf::LD_UW_IMM if self.executable.get_sbpf_version().disable_lddw() => { + self.reg[dst] |= (insn.imm as u64).wrapping_shl(32); + } ebpf::LD_DW_IMM => { ebpf::augment_lddw_unchecked(self.program, &mut insn); instruction_width = 2; diff --git a/src/jit.rs b/src/jit.rs index 1383a2c6..6201364d 100644 --- a/src/jit.rs +++ b/src/jit.rs @@ -329,12 +329,16 @@ impl<'a, V: Verifier, C: ContextObject> JitCompiler<'a, V, C> { // Scan through program to find actual number of instructions let mut pc = 0; - while (pc + 1) * ebpf::INSN_SIZE <= program.len() { - let insn = ebpf::get_insn_unchecked(program, pc); - pc += match insn.opc { - ebpf::LD_DW_IMM => 2, - _ => 1, - }; + if executable.get_sbpf_version().disable_lddw() { + pc = program.len() / ebpf::INSN_SIZE; + } else { + while (pc + 1) * ebpf::INSN_SIZE <= program.len() { + let insn = ebpf::get_insn_unchecked(program, pc); + pc += match insn.opc { + ebpf::LD_DW_IMM => 2, + _ => 1, + }; + } } let mut code_length_estimate = MAX_EMPTY_PROGRAM_MACHINE_CODE_LENGTH + MAX_MACHINE_CODE_LENGTH_PER_INSTRUCTION * pc; @@ -397,6 +401,9 @@ impl<'a, V: Verifier, C: ContextObject> JitCompiler<'a, V, C> { self.emit_ins(X86Instruction::alu(OperandSize::S64, 0x81, 0, RBP, insn.imm, Some(stack_ptr_access))); } + ebpf::LD_UW_IMM => { + self.emit_sanitized_alu(OperandSize::S64, 0x09, 1, dst, (insn.imm as u64).wrapping_shl(32) as i64); + } ebpf::LD_DW_IMM => { self.emit_validate_and_profile_instruction_count(true, Some(self.pc + 2)); self.pc += 1; diff --git a/src/static_analysis.rs b/src/static_analysis.rs index 3c9670b3..3dbbc3df 100644 --- a/src/static_analysis.rs +++ b/src/static_analysis.rs @@ -975,7 +975,7 @@ impl<'a> Analysis<'a> { bind(&mut state, insn, false, DataResource::Register(insn.src)); bind(&mut state, insn, true, DataResource::Register(0)); } - ebpf::LD_DW_IMM => { + ebpf::LD_UW_IMM | ebpf::LD_DW_IMM => { bind(&mut state, insn, true, DataResource::Register(insn.dst)); } ebpf::LD_B_REG | ebpf::LD_H_REG | ebpf::LD_W_REG | ebpf::LD_DW_REG => { diff --git a/src/verifier.rs b/src/verifier.rs index 251b2fdd..67aca944 100644 --- a/src/verifier.rs +++ b/src/verifier.rs @@ -235,11 +235,6 @@ impl Verifier for RequisiteVerifier { if sbpf_version.static_syscalls() && function_iter.peek() == Some(&insn_ptr) { function_range.start = function_iter.next().unwrap_or(0); function_range.end = *function_iter.peek().unwrap_or(&program_range.end); - if insn.opc == 0 { - return Err(VerifierError::InvalidFunction( - function_range.start, - )); - } let insn = ebpf::get_insn(prog, function_range.end.saturating_sub(1)); match insn.opc { ebpf::JA | ebpf::CALL_IMM | ebpf::CALL_REG | ebpf::EXIT => {}, @@ -250,7 +245,8 @@ impl Verifier for RequisiteVerifier { } match insn.opc { - ebpf::LD_DW_IMM => { + ebpf::LD_UW_IMM if sbpf_version.disable_lddw() => {}, + ebpf::LD_DW_IMM if !sbpf_version.disable_lddw() => { check_load_dw(prog, insn_ptr)?; insn_ptr += 1; }, diff --git a/tests/elfs/reloc_64_64.so b/tests/elfs/reloc_64_64.so index 44c42ee5632f21ff9f88f5a61cdb684e20be9713..201eb6785114fbeb0ab3af1a5b3033de1d14c3bb 100755 GIT binary patch delta 13 UcmZqBY|vaFz_?{Iqd+|i03N3U{{R30 delta 13 UcmZqBY|vaFz$meqQJ|g$02==TV*mgE diff --git a/tests/elfs/reloc_64_relative.so b/tests/elfs/reloc_64_relative.so index 795f38c7bf54be27588fb7fd198094d632da9c98..940f00978d904e528e8e33a9a637a65b45e2fffb 100755 GIT binary patch delta 13 Ucmdm>wLxov0OOX;i~{wLxov0HefaMge_R03P-Ob^rhX diff --git a/tests/elfs/reloc_64_relative_data.so b/tests/elfs/reloc_64_relative_data.so index 01e7a98a1bcd06b5a67831ddff83de3ec9eb9237..05c0f29f2d8d9b9e96f2dc0f02d489886c813ad5 100755 GIT binary patch delta 22 ZcmbQCJ41JY0M`~q1_)r>%q7sr1^_&l1Y7_B delta 22 YcmbQCJ41JY0G9+K0~BoL66j+C05fd^zW@LL diff --git a/tests/elfs/rodata_section.so b/tests/elfs/rodata_section.so index 037afdf674b46d0a82a2c4ea594fa37bee0eff4f..bf406b44bf75e9dc5bfd374919193b577b696763 100755 GIT binary patch delta 22 ccmdm>wLxov0M`~q1_lKNAYk0gC7{L%06?AuJpcdz delta 22 bcmdm>wLxov0G9+K1A_ts2yEsOP-6uEH*^D_ diff --git a/tests/elfs/struct_func_pointer.so b/tests/elfs/struct_func_pointer.so index ded65ef03b6efe93c6a4e5f8ad7e6ddb362271aa..ed089f1e7a638e6211077a6569c576394e0363ce 100755 GIT binary patch delta 13 UcmeyN{zH9%0OOX;i~`@80V=8mVgLXD delta 13 UcmeyN{zH9%0HefaMuG3l04D+j#sB~S diff --git a/tests/elfs/syscall_static.so b/tests/elfs/syscall_static.so index 8a0ccadc2dd23666ebf4c528092c2fa2f85e4493..76b6959b5296e2a7b5b9de5d0dfcece56ba3c3d3 100755 GIT binary patch delta 22 ccmeyN`9pJo0M`~q1_lELAYk0gCGd^~08WJkq5uE@ delta 22 bcmeyN`9pJo0G9+K1A_qr2yEsOc*g<&MOy_0 diff --git a/tests/execution.rs b/tests/execution.rs index 58b2192a..59c0efbe 100644 --- a/tests/execution.rs +++ b/tests/execution.rs @@ -463,12 +463,13 @@ fn test_arsh32_high_shift() { test_interpreter_and_jit_asm!( " mov r0, 8 - lddw r1, 0x100000001 + mov32 r1, 0x00000001 + lduw r1, 0x00000001 arsh32 r0, r1 exit", [], (), - TestContextObject::new(4), + TestContextObject::new(5), ProgramResult::Ok(0x4), ); } @@ -784,12 +785,13 @@ fn test_div32_high_divisor() { test_interpreter_and_jit_asm!( " mov r0, 12 - lddw r1, 0x100000004 + mov32 r1, 0x00000004 + lduw r1, 0x00000001 div32 r0, r1 exit", [], (), - TestContextObject::new(4), + TestContextObject::new(5), ProgramResult::Ok(0x3), ); } @@ -798,12 +800,13 @@ fn test_div32_high_divisor() { fn test_div32_imm() { test_interpreter_and_jit_asm!( " - lddw r0, 0x10000000c + mov32 r0, 0x0000000c + lduw r0, 0x00000001 div32 r0, 4 exit", [], (), - TestContextObject::new(3), + TestContextObject::new(4), ProgramResult::Ok(0x3), ); } @@ -812,13 +815,14 @@ fn test_div32_imm() { fn test_div32_reg() { test_interpreter_and_jit_asm!( " - lddw r0, 0x10000000c + mov32 r0, 0x0000000c + lduw r0, 0x00000001 mov r1, 4 div32 r0, r1 exit", [], (), - TestContextObject::new(4), + TestContextObject::new(5), ProgramResult::Ok(0x3), ); } @@ -827,12 +831,13 @@ fn test_div32_reg() { fn test_sdiv32_imm() { test_interpreter_and_jit_asm!( " - lddw r0, 0x180000000 + mov32 r0, -0x80000000 + lduw r0, 0x00000001 sdiv32 r0, 4 exit", [], (), - TestContextObject::new(3), + TestContextObject::new(4), ProgramResult::Ok(0xFFFFFFFFE0000000), ); } @@ -841,12 +846,13 @@ fn test_sdiv32_imm() { fn test_sdiv32_neg_imm() { test_interpreter_and_jit_asm!( " - lddw r0, 0x10000000c + mov32 r0, 0x0000000c + lduw r0, 0x00000001 sdiv32 r0, -1 exit", [], (), - TestContextObject::new(3), + TestContextObject::new(4), ProgramResult::Ok((-0xc_i64) as u64), ); } @@ -855,13 +861,14 @@ fn test_sdiv32_neg_imm() { fn test_sdiv32_reg() { test_interpreter_and_jit_asm!( " - lddw r0, 0x180000000 + mov32 r0, -0x80000000 + lduw r0, 0x00000001 mov r1, 4 sdiv32 r0, r1 exit", [], (), - TestContextObject::new(4), + TestContextObject::new(5), ProgramResult::Ok(0xFFFFFFFFE0000000), ); } @@ -870,13 +877,14 @@ fn test_sdiv32_reg() { fn test_sdiv32_neg_reg() { test_interpreter_and_jit_asm!( " - lddw r0, 0x10000000c + mov32 r0, 0x0000000c + lduw r0, 0x00000001 mov r1, -1 sdiv32 r0, r1 exit", [], (), - TestContextObject::new(4), + TestContextObject::new(5), ProgramResult::Ok((-0xc_i64) as u64), ); } @@ -1085,12 +1093,13 @@ fn test_mod32() { fn test_mod32_imm() { test_interpreter_and_jit_asm!( " - lddw r0, 0x100000003 + mov32 r0, 0x00000003 + lduw r0, 0x00000001 mod32 r0, 3 exit", [], (), - TestContextObject::new(3), + TestContextObject::new(4), ProgramResult::Ok(0x0), ); } @@ -1145,8 +1154,169 @@ fn test_err_mod_by_zero_reg() { ); } +// LD_DW_IMM + +#[test] +fn test_lddw() { + let config = Config { + enable_sbpf_v2: false, + ..Config::default() + }; + test_interpreter_and_jit_asm!( + " + lddw r0, 0x1122334455667788 + exit", + config, + [], + (), + TestContextObject::new(2), + ProgramResult::Ok(0x1122334455667788), + ); + test_interpreter_and_jit_asm!( + " + lddw r0, 0x0000000080000000 + exit", + config, + [], + (), + TestContextObject::new(2), + ProgramResult::Ok(0x80000000), + ); +} + +#[test] +fn test_err_static_jmp_lddw() { + let config = Config { + enable_sbpf_v2: false, + ..Config::default() + }; + test_interpreter_and_jit_asm!( + " + mov r0, 0 + mov r1, 0 + mov r2, 0 + lddw r0, 0x1 + ja +2 + lddw r1, 0x1 + lddw r2, 0x1 + add r1, r2 + add r0, r1 + exit + ", + config, + [], + (), + TestContextObject::new(9), + ProgramResult::Ok(0x2), + ); +} + +#[test] +fn test_err_dynamic_jmp_lddw() { + let config = Config { + enable_sbpf_v2: false, + ..Config::default() + }; + test_interpreter_and_jit_asm!( + " + mov64 r8, 0x1 + lsh64 r8, 0x20 + or64 r8, 0x28 + callx r8 + lddw r0, 0x1122334455667788 + exit", + config, + [], + (), + TestContextObject::new(4), + ProgramResult::Err(Box::new(EbpfError::ExceededMaxInstructions(33))), + ); + test_interpreter_and_jit_asm!( + " + mov64 r8, 0x1 + lsh64 r8, 0x20 + or64 r8, 0x28 + callx r8 + lddw r0, 0x1122334455667788 + exit", + config, + [], + (), + TestContextObject::new(5), + ProgramResult::Err(Box::new(EbpfError::UnsupportedInstruction(34))), + ); + test_interpreter_and_jit_asm!( + " + mov64 r1, 0x1 + lsh64 r1, 0x20 + or64 r1, 0x38 + callx r1 + mov r0, r0 + mov r0, r0 + lddw r0, 0x1122334455667788 + exit + ", + config, + [], + (), + TestContextObject::new(5), + ProgramResult::Err(Box::new(EbpfError::UnsupportedInstruction(36))), + ); + test_interpreter_and_jit_asm!( + " + lddw r1, 0x100000038 + callx r1 + mov r0, r0 + mov r0, r0 + exit + lddw r0, 0x1122334455667788 + exit + ", + config, + [], + (), + TestContextObject::new(3), + ProgramResult::Err(Box::new(EbpfError::UnsupportedInstruction(36))), + ); +} + +#[test] +fn test_err_instruction_count_lddw_capped() { + let config = Config { + enable_sbpf_v2: false, + ..Config::default() + }; + test_interpreter_and_jit_asm!( + " + mov r0, 0 + lddw r1, 0x1 + mov r2, 0 + exit + ", + config, + [], + (), + TestContextObject::new(2), + ProgramResult::Err(Box::new(EbpfError::ExceededMaxInstructions(32))), + ); +} + // BPF_LD : Loads +#[test] +fn test_lduw() { + test_interpreter_and_jit_asm!( + " + lduw r0, 0x10203040 + lduw r0, 0x01020304 + exit", + [], + (), + TestContextObject::new(3), + ProgramResult::Ok(0x1122334400000000), + ); +} + #[test] fn test_ldxb() { test_interpreter_and_jit_asm!( @@ -1455,28 +1625,6 @@ fn test_ldxw_all() { ); } -#[test] -fn test_lddw() { - test_interpreter_and_jit_asm!( - " - lddw r0, 0x1122334455667788 - exit", - [], - (), - TestContextObject::new(2), - ProgramResult::Ok(0x1122334455667788), - ); - test_interpreter_and_jit_asm!( - " - lddw r0, 0x0000000080000000 - exit", - [], - (), - TestContextObject::new(2), - ProgramResult::Ok(0x80000000), - ); -} - #[test] fn test_stb() { test_interpreter_and_jit_asm!( @@ -2557,7 +2705,8 @@ fn test_stack_call_depth_tracking() { fn test_err_mem_access_out_of_bound() { let mem = [0; 512]; let mut prog = [0; 32]; - prog[0] = ebpf::LD_DW_IMM; + prog[0] = ebpf::MOV32_IMM; + prog[8] = ebpf::LD_UW_IMM; prog[16] = ebpf::ST_B_IMM; prog[24] = ebpf::EXIT; let loader = Arc::new(BuiltinProgram::new_mock()); @@ -2575,7 +2724,7 @@ fn test_err_mem_access_out_of_bound() { test_interpreter_and_jit!( executable, mem, - TestContextObject::new(2), + TestContextObject::new(3), ProgramResult::Err(Box::new(EbpfError::AccessViolation( 31, AccessType::Store, @@ -2718,96 +2867,6 @@ fn test_err_callx_oob_high() { ); } -#[test] -fn test_err_static_jmp_lddw() { - test_interpreter_and_jit_asm!( - " - mov r0, 0 - mov r1, 0 - mov r2, 0 - lddw r0, 0x1 - ja +2 - lddw r1, 0x1 - lddw r2, 0x1 - add r1, r2 - add r0, r1 - exit - ", - [], - (), - TestContextObject::new(9), - ProgramResult::Ok(0x2), - ); -} - -#[test] -fn test_err_dynamic_jmp_lddw() { - let config = Config { - enable_sbpf_v2: false, - ..Config::default() - }; - test_interpreter_and_jit_asm!( - " - mov64 r8, 0x1 - lsh64 r8, 0x20 - or64 r8, 0x28 - callx r8 - lddw r0, 0x1122334455667788 - exit", - config, - [], - (), - TestContextObject::new(4), - ProgramResult::Err(Box::new(EbpfError::ExceededMaxInstructions(33))), - ); - test_interpreter_and_jit_asm!( - " - mov64 r8, 0x1 - lsh64 r8, 0x20 - or64 r8, 0x28 - callx r8 - lddw r0, 0x1122334455667788 - exit", - [], - (), - TestContextObject::new(5), - ProgramResult::Err(Box::new(EbpfError::UnsupportedInstruction(34))), - ); - test_interpreter_and_jit_asm!( - " - mov64 r1, 0x1 - lsh64 r1, 0x20 - or64 r1, 0x38 - callx r1 - mov r0, r0 - mov r0, r0 - lddw r0, 0x1122334455667788 - exit - ", - config, - [], - (), - TestContextObject::new(5), - ProgramResult::Err(Box::new(EbpfError::UnsupportedInstruction(36))), - ); - test_interpreter_and_jit_asm!( - " - lddw r1, 0x100000038 - callx r1 - mov r0, r0 - mov r0, r0 - exit - lddw r0, 0x1122334455667788 - exit - ", - config, - [], - (), - TestContextObject::new(3), - ProgramResult::Err(Box::new(EbpfError::UnsupportedInstruction(36))), - ); -} - #[test] fn test_bpf_to_bpf_depth() { test_interpreter_and_jit_asm!( @@ -3161,22 +3220,6 @@ fn test_err_instruction_count_syscall_capped() { ); } -#[test] -fn test_err_instruction_count_lddw_capped() { - test_interpreter_and_jit_asm!( - " - mov r0, 0 - lddw r1, 0x1 - mov r2, 0 - exit - ", - [], - (), - TestContextObject::new(2), - ProgramResult::Err(Box::new(EbpfError::ExceededMaxInstructions(32))), - ); -} - #[test] fn test_non_terminate_early() { test_interpreter_and_jit_asm!( @@ -3377,7 +3420,7 @@ fn test_syscall_static() { ( "log" => syscalls::bpf_syscall_string, ), - TestContextObject::new(5), + TestContextObject::new(6), ProgramResult::Ok(0), ); } @@ -3406,7 +3449,7 @@ fn test_err_unresolved_syscall_static() { "tests/elfs/syscall_static.so", [], (), - TestContextObject::new(3), + TestContextObject::new(4), ProgramResult::Err(Box::new(EbpfError::UnsupportedInstruction(32))), ); } @@ -3434,7 +3477,7 @@ fn test_reloc_64_64() { "tests/elfs/reloc_64_64.so", [], (), - TestContextObject::new(2), + TestContextObject::new(3), ProgramResult::Ok(ebpf::MM_PROGRAM_START), ); } @@ -3464,7 +3507,7 @@ fn test_reloc_64_relative() { "tests/elfs/reloc_64_relative.so", [], (), - TestContextObject::new(2), + TestContextObject::new(3), ProgramResult::Ok(ebpf::MM_PROGRAM_START + 0x18), ); } @@ -3500,7 +3543,7 @@ fn test_reloc_64_relative_data() { "tests/elfs/reloc_64_relative_data.so", [], (), - TestContextObject::new(3), + TestContextObject::new(4), ProgramResult::Ok(ebpf::MM_PROGRAM_START + 0x20), ); } @@ -3540,7 +3583,7 @@ fn test_load_elf_rodata() { config, [], (), - TestContextObject::new(3), + TestContextObject::new(4), ProgramResult::Ok(42), ); } @@ -3778,7 +3821,7 @@ fn test_struct_func_pointer() { "tests/elfs/struct_func_pointer.so", [], (), - TestContextObject::new(2), + TestContextObject::new(3), ProgramResult::Ok(0x102030405060708), ); } diff --git a/tests/verifier.rs b/tests/verifier.rs index 5c906325..e3be968b 100644 --- a/tests/verifier.rs +++ b/tests/verifier.rs @@ -133,7 +133,7 @@ fn test_verifier_err_incomplete_lddw() { let executable = Executable::::from_text_bytes( prog, Arc::new(BuiltinProgram::new_mock()), - SBPFVersion::V2, + SBPFVersion::V1, FunctionRegistry::default(), ) .unwrap();