diff --git a/Cargo.lock b/Cargo.lock index 88eb92b07d01f8..952fa80aa1b10c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5830,9 +5830,9 @@ dependencies = [ [[package]] name = "solana_rbpf" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc1dced9892c2b0273318ef4d8486112ea7c7a7b8eb563a20e7858ad921b4719" +checksum = "e27486ed1c74044866b529076b6aa9ca6fab9ec494d1835439ec84efc5575953" dependencies = [ "byteorder", "combine", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 631ce8c521e4ea..124bf07a632751 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -39,7 +39,7 @@ solana-config-program = { path = "../programs/config", version = "=1.8.0" } solana-faucet = { path = "../faucet", version = "=1.8.0" } solana-logger = { path = "../logger", version = "=1.8.0" } solana-net-utils = { path = "../net-utils", version = "=1.8.0" } -solana_rbpf = "=0.2.13" +solana_rbpf = "=0.2.14" solana-remote-wallet = { path = "../remote-wallet", version = "=1.8.0" } solana-sdk = { path = "../sdk", version = "=1.8.0" } solana-transaction-status = { path = "../transaction-status", version = "=1.8.0" } diff --git a/cli/src/program.rs b/cli/src/program.rs index 8e5f1b77bcaf9c..07d33d558d7e03 100644 --- a/cli/src/program.rs +++ b/cli/src/program.rs @@ -1791,9 +1791,10 @@ fn read_and_verify_elf(program_location: &str) -> Result, Box>::from_elf( &program_data, - Some(|x| verifier::check(x)), + Some(verifier::check), Config { reject_unresolved_syscalls: true, + verify_mul64_imm_nonzero: true, // TODO: Remove me after feature gate ..Config::default() }, register_syscalls(&mut invoke_context).unwrap(), diff --git a/programs/bpf/Cargo.lock b/programs/bpf/Cargo.lock index ea8b23fb485c4b..18224175ae6807 100644 --- a/programs/bpf/Cargo.lock +++ b/programs/bpf/Cargo.lock @@ -3532,9 +3532,9 @@ dependencies = [ [[package]] name = "solana_rbpf" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc1dced9892c2b0273318ef4d8486112ea7c7a7b8eb563a20e7858ad921b4719" +checksum = "e27486ed1c74044866b529076b6aa9ca6fab9ec494d1835439ec84efc5575953" dependencies = [ "byteorder 1.4.3", "combine", diff --git a/programs/bpf/Cargo.toml b/programs/bpf/Cargo.toml index 74881704c799ad..0f2e1cbbd3e31f 100644 --- a/programs/bpf/Cargo.toml +++ b/programs/bpf/Cargo.toml @@ -30,7 +30,7 @@ solana-bpf-loader-program = { path = "../bpf_loader", version = "=1.8.0" } solana-cli-output = { path = "../../cli-output", version = "=1.8.0" } solana-logger = { path = "../../logger", version = "=1.8.0" } solana-measure = { path = "../../measure", version = "=1.8.0" } -solana_rbpf = "=0.2.13" +solana_rbpf = "=0.2.14" solana-runtime = { path = "../../runtime", version = "=1.8.0" } solana-sdk = { path = "../../sdk", version = "=1.8.0" } solana-transaction-status = { path = "../../transaction-status", version = "=1.8.0" } diff --git a/programs/bpf/tests/programs.rs b/programs/bpf/tests/programs.rs index e652b1d66a3f8b..19b7ddb0a12ed1 100644 --- a/programs/bpf/tests/programs.rs +++ b/programs/bpf/tests/programs.rs @@ -1258,11 +1258,8 @@ fn test_program_bpf_call_depth() { let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction); assert!(result.is_ok()); - let instruction = Instruction::new_with_bincode( - program_id, - &ComputeBudget::default().max_call_depth, - vec![], - ); + let instruction = + Instruction::new_with_bincode(program_id, &ComputeBudget::default().max_call_depth, vec![]); let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction); assert!(result.is_err()); } diff --git a/programs/bpf_loader/Cargo.toml b/programs/bpf_loader/Cargo.toml index 1f35b74a03aad1..a113e94fe15856 100644 --- a/programs/bpf_loader/Cargo.toml +++ b/programs/bpf_loader/Cargo.toml @@ -24,7 +24,7 @@ sha3 = "0.9.1" solana-measure = { path = "../../measure", version = "=1.8.0" } solana-runtime = { path = "../../runtime", version = "=1.8.0" } solana-sdk = { path = "../../sdk", version = "=1.8.0" } -solana_rbpf = "=0.2.13" +solana_rbpf = "=0.2.14" thiserror = "1.0" [dev-dependencies] diff --git a/programs/bpf_loader/src/lib.rs b/programs/bpf_loader/src/lib.rs index b2b9a4d364de28..9186d97a6886fc 100644 --- a/programs/bpf_loader/src/lib.rs +++ b/programs/bpf_loader/src/lib.rs @@ -16,9 +16,8 @@ use log::{log_enabled, trace, Level::Trace}; use solana_measure::measure::Measure; use solana_rbpf::{ aligned_memory::AlignedMemory, - ebpf::{HOST_ALIGN, MM_HEAP_START}, + ebpf::HOST_ALIGN, error::{EbpfError, UserDefinedError}, - memory_region::MemoryRegion, static_analysis::Analysis, verifier::{self, VerifierError}, vm::{Config, EbpfVm, Executable, InstructionMeter}, @@ -83,6 +82,7 @@ pub fn create_executor( max_call_depth: compute_budget.max_call_depth, stack_frame_size: compute_budget.stack_frame_size, enable_instruction_tracing: log_enabled!(Trace), + verify_mul64_imm_nonzero: true, // TODO: Feature gate and then remove me ..Config::default() }; let mut executable = { @@ -98,10 +98,8 @@ pub fn create_executor( ) } .map_err(|e| map_ebpf_error(invoke_context, e))?; - let (_, elf_bytes) = executable - .get_text_bytes() - .map_err(|e| map_ebpf_error(invoke_context, e))?; - verifier::check(elf_bytes) + let text_bytes = executable.get_text_bytes().1; + verifier::check(text_bytes, &config) .map_err(|e| map_ebpf_error(invoke_context, EbpfError::UserError(e.into())))?; if use_jit { if let Err(err) = executable.jit_compile() { @@ -150,10 +148,9 @@ pub fn create_vm<'a>( invoke_context: &'a mut dyn InvokeContext, ) -> Result, EbpfError> { let compute_budget = invoke_context.get_compute_budget(); - let heap = + let mut heap = AlignedMemory::new_with_size(compute_budget.heap_size.unwrap_or(HEAP_LENGTH), HOST_ALIGN); - let heap_region = MemoryRegion::new_from_slice(heap.as_slice(), MM_HEAP_START, 0, true); - let mut vm = EbpfVm::new(program, parameter_bytes, &[heap_region])?; + let mut vm = EbpfVm::new(program, heap.as_slice_mut(), parameter_bytes)?; syscalls::bind_syscall_context_objects(loader_id, &mut vm, invoke_context, heap)?; Ok(vm) } @@ -915,7 +912,8 @@ mod tests { ) .unwrap(); let mut vm = - EbpfVm::::new(program.as_ref(), input, &[]).unwrap(); + EbpfVm::::new(program.as_ref(), &mut [], input) + .unwrap(); let mut instruction_meter = TestInstructionMeter { remaining: 10 }; vm.execute_program_interpreted(&mut instruction_meter) .unwrap(); @@ -927,7 +925,7 @@ mod tests { let prog = &[ 0x18, 0x00, 0x00, 0x00, 0x88, 0x77, 0x66, 0x55, // first half of lddw ]; - verifier::check(prog).unwrap(); + verifier::check(prog, &Config::default()).unwrap(); } #[test] diff --git a/rbpf-cli/Cargo.toml b/rbpf-cli/Cargo.toml index 2ff5384da4b842..9e5f43bc708fbb 100644 --- a/rbpf-cli/Cargo.toml +++ b/rbpf-cli/Cargo.toml @@ -15,5 +15,5 @@ serde_json = "1.0.64" solana-bpf-loader-program = { path = "../programs/bpf_loader", version = "=1.8.0" } solana-logger = { path = "../logger", version = "=1.8.0" } solana-sdk = { path = "../sdk", version = "=1.8.0" } -solana_rbpf = "=0.2.13" +solana_rbpf = "=0.2.14" time = "0.2.25" diff --git a/rbpf-cli/src/main.rs b/rbpf-cli/src/main.rs index 3f64587c91fe19..b8f4ed4e1f64c7 100644 --- a/rbpf-cli/src/main.rs +++ b/rbpf-cli/src/main.rs @@ -206,8 +206,8 @@ native machine code before execting it in the virtual machine.", .unwrap(); if matches.is_present("verify") { - let (_, elf_bytes) = executable.get_text_bytes().unwrap(); - check(elf_bytes).unwrap(); + let text_bytes = executable.get_text_bytes().1; + check(text_bytes, &config).unwrap(); } executable.jit_compile().unwrap(); let analysis = Analysis::from_executable(executable.as_ref());