Bump solana_rbpf to version 0.2.13 (#18068) (#21302)

* Moves syscall_registry into the rbpf Executable constructor.

* Adds the reject_unresolved_syscalls flag which is only set when deploying programs via the CLI.

(cherry picked from commit 8d5c04e257)

Co-authored-by: Alexander Meißner <AlexanderMeissner@gmx.net>
This commit is contained in:
mergify[bot]
2021-11-17 01:23:15 +00:00
committed by GitHub
parent 064cce41f7
commit baa4c6eaf2
13 changed files with 114 additions and 371 deletions

View File

@@ -1,7 +1,6 @@
#![allow(clippy::integer_arithmetic)]
pub mod alloc;
pub mod allocator_bump;
pub mod bpf_verifier;
pub mod deprecated;
pub mod serialization;
pub mod syscalls;
@@ -10,7 +9,6 @@ pub mod upgradeable_with_jit;
pub mod with_jit;
use crate::{
bpf_verifier::VerifierError,
serialization::{deserialize_parameters, serialize_parameters},
syscalls::SyscallError,
};
@@ -22,6 +20,7 @@ use solana_rbpf::{
error::{EbpfError, UserDefinedError},
memory_region::MemoryRegion,
static_analysis::Analysis,
verifier::{self, VerifierError},
vm::{Config, EbpfVm, Executable, InstructionMeter},
};
use solana_runtime::message_processor::MessageProcessor;
@@ -86,23 +85,27 @@ pub fn create_executor(
let config = Config {
max_call_depth: bpf_compute_budget.max_call_depth,
stack_frame_size: bpf_compute_budget.stack_frame_size,
enable_instruction_meter: true,
enable_instruction_tracing: log_enabled!(Trace),
..Config::default()
};
let mut executable = {
let keyed_accounts = invoke_context.get_keyed_accounts()?;
let program = keyed_account_at_index(keyed_accounts, program_account_index)?;
let account = program.try_account_ref()?;
let data = &account.data()[program_data_offset..];
<dyn Executable<BpfError, ThisInstructionMeter>>::from_elf(data, None, config)
<dyn Executable<BpfError, ThisInstructionMeter>>::from_elf(
data,
None,
config,
syscall_registry,
)
}
.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))?;
bpf_verifier::check(elf_bytes)
.map_err(|e| map_ebpf_error(invoke_context, EbpfError::UserError(e)))?;
executable.set_syscall_registry(syscall_registry);
verifier::check(elf_bytes)
.map_err(|e| map_ebpf_error(invoke_context, EbpfError::UserError(e.into())))?;
if use_jit {
if let Err(err) = executable.jit_compile() {
ic_msg!(invoke_context, "Failed to compile program {:?}", err);
@@ -1001,6 +1004,7 @@ impl Executor for BpfExecutor {
mod tests {
use super::*;
use rand::Rng;
use solana_rbpf::vm::SyscallRegistry;
use solana_runtime::{bank::Bank, bank_client::BankClient};
use solana_sdk::{
account::{
@@ -1054,9 +1058,10 @@ mod tests {
solana_rbpf::elf::register_bpf_function(&mut bpf_functions, 0, "entrypoint").unwrap();
let program = <dyn Executable<BpfError, TestInstructionMeter>>::from_text_bytes(
program,
bpf_functions,
None,
Config::default(),
SyscallRegistry::default(),
bpf_functions,
)
.unwrap();
let mut vm =
@@ -1067,12 +1072,12 @@ mod tests {
}
#[test]
#[should_panic(expected = "VerifierError(LDDWCannotBeLast)")]
#[should_panic(expected = "LDDWCannotBeLast")]
fn test_bpf_loader_check_load_dw() {
let prog = &[
0x18, 0x00, 0x00, 0x00, 0x88, 0x77, 0x66, 0x55, // first half of lddw
];
bpf_verifier::check(prog).unwrap();
verifier::check(prog).unwrap();
}
#[test]