From 509bcd2e742e158ae14bface4aeefbb37130ec8f Mon Sep 17 00:00:00 2001 From: Jack May Date: Tue, 14 Dec 2021 07:51:23 -0800 Subject: [PATCH] Bump rbpf to v0.2.19 (#21880) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Bump rbpf to v0.2.19 Co-authored-by: Alexander Meißner --- Cargo.lock | 4 ++-- cli/Cargo.toml | 2 +- programs/bpf/Cargo.lock | 4 ++-- programs/bpf/Cargo.toml | 2 +- programs/bpf/benches/bpf_loader.rs | 2 +- programs/bpf/tests/programs.rs | 2 +- programs/bpf_loader/Cargo.toml | 2 +- programs/bpf_loader/src/lib.rs | 14 +++++++++----- rbpf-cli/Cargo.toml | 2 +- rbpf-cli/src/main.rs | 2 +- sdk/src/feature_set.rs | 5 +++++ 11 files changed, 25 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9e4013cc2..0fb0a3bd6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6187,9 +6187,9 @@ dependencies = [ [[package]] name = "solana_rbpf" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c7a237a92714db63de655e20af29a3b59c007881f2dfbdc2d3838ca3675f45f" +checksum = "4b4ea641d81290842c822f1348ce9f35ff3e11d09553e709c894af9765b7934c" dependencies = [ "byteorder", "combine", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index d05d4787a..36761c5e3 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -36,7 +36,7 @@ solana-config-program = { path = "../programs/config", version = "=1.10.0" } solana-faucet = { path = "../faucet", version = "=1.10.0" } solana-logger = { path = "../logger", version = "=1.10.0" } solana-program-runtime = { path = "../program-runtime", version = "=1.10.0" } -solana_rbpf = "=0.2.18" +solana_rbpf = "=0.2.19" solana-remote-wallet = { path = "../remote-wallet", version = "=1.10.0" } solana-sdk = { path = "../sdk", version = "=1.10.0" } solana-transaction-status = { path = "../transaction-status", version = "=1.10.0" } diff --git a/programs/bpf/Cargo.lock b/programs/bpf/Cargo.lock index 01476b1ff..51191c393 100644 --- a/programs/bpf/Cargo.lock +++ b/programs/bpf/Cargo.lock @@ -3626,9 +3626,9 @@ dependencies = [ [[package]] name = "solana_rbpf" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c7a237a92714db63de655e20af29a3b59c007881f2dfbdc2d3838ca3675f45f" +checksum = "4b4ea641d81290842c822f1348ce9f35ff3e11d09553e709c894af9765b7934c" dependencies = [ "byteorder 1.4.3", "combine", diff --git a/programs/bpf/Cargo.toml b/programs/bpf/Cargo.toml index dbd790854..41e87a5ab 100644 --- a/programs/bpf/Cargo.toml +++ b/programs/bpf/Cargo.toml @@ -33,7 +33,7 @@ solana-bpf-rust-realloc-invoke = { path = "rust/realloc_invoke", version = "=1.1 solana-cli-output = { path = "../../cli-output", version = "=1.10.0" } solana-logger = { path = "../../logger", version = "=1.10.0" } solana-measure = { path = "../../measure", version = "=1.10.0" } -solana_rbpf = "=0.2.18" +solana_rbpf = "=0.2.19" solana-runtime = { path = "../../runtime", version = "=1.10.0" } solana-program-runtime = { path = "../../program-runtime", version = "=1.10.0" } solana-sdk = { path = "../../sdk", version = "=1.10.0" } diff --git a/programs/bpf/benches/bpf_loader.rs b/programs/bpf/benches/bpf_loader.rs index 97b9a1f64..63513f6a7 100644 --- a/programs/bpf/benches/bpf_loader.rs +++ b/programs/bpf/benches/bpf_loader.rs @@ -110,7 +110,7 @@ fn bench_program_alu(bencher: &mut Bencher) { register_syscalls(invoke_context).unwrap(), ) .unwrap(); - executable.jit_compile().unwrap(); + Executable::::jit_compile(&mut executable).unwrap(); let compute_meter = invoke_context.get_compute_meter(); let mut instruction_meter = ThisInstructionMeter { compute_meter }; let mut vm = create_vm(&executable, &mut inner_iter, invoke_context, &[]).unwrap(); diff --git a/programs/bpf/tests/programs.rs b/programs/bpf/tests/programs.rs index 914f6487a..0c0021bd0 100644 --- a/programs/bpf/tests/programs.rs +++ b/programs/bpf/tests/programs.rs @@ -222,7 +222,7 @@ fn run_program(name: &str) -> u64 { register_syscalls(invoke_context).unwrap(), ) .unwrap(); - executable.jit_compile().unwrap(); + Executable::::jit_compile(&mut executable).unwrap(); let mut instruction_count = 0; let mut tracer = None; diff --git a/programs/bpf_loader/Cargo.toml b/programs/bpf_loader/Cargo.toml index efa655679..371f0b259 100644 --- a/programs/bpf_loader/Cargo.toml +++ b/programs/bpf_loader/Cargo.toml @@ -20,7 +20,7 @@ libsecp256k1 = "0.6.0" solana-measure = { path = "../../measure", version = "=1.10.0" } solana-program-runtime = { path = "../../program-runtime", version = "=1.10.0" } solana-sdk = { path = "../../sdk", version = "=1.10.0" } -solana_rbpf = "=0.2.18" +solana_rbpf = "=0.2.19" thiserror = "1.0" [dev-dependencies] diff --git a/programs/bpf_loader/src/lib.rs b/programs/bpf_loader/src/lib.rs index b468b6a27..f33ab43e2 100644 --- a/programs/bpf_loader/src/lib.rs +++ b/programs/bpf_loader/src/lib.rs @@ -38,7 +38,7 @@ use { clock::Clock, entrypoint::{HEAP_LENGTH, SUCCESS}, feature_set::{ - do_support_realloc, reduce_required_deploy_balance, + do_support_realloc, reduce_required_deploy_balance, reject_all_elf_rw, reject_deployment_of_unresolved_syscalls, reject_section_virtual_address_file_offset_mismatch, requestable_heap_size, start_verify_shift32_imm, stop_verify_mul64_imm_nonzero, @@ -52,7 +52,7 @@ use { rent::Rent, system_instruction::{self, MAX_PERMITTED_DATA_LENGTH}, }, - std::{cell::RefCell, fmt::Debug, rc::Rc, sync::Arc}, + std::{cell::RefCell, fmt::Debug, pin::Pin, rc::Rc, sync::Arc}, thiserror::Error, }; @@ -107,6 +107,9 @@ pub fn create_executor( verify_shift32_imm: invoke_context .feature_set .is_active(&start_verify_shift32_imm::id()), + reject_all_writable_sections: invoke_context + .feature_set + .is_active(&reject_all_elf_rw::id()), ..Config::default() }; let mut executable = { @@ -124,7 +127,8 @@ pub fn create_executor( 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() { + if let Err(err) = Executable::::jit_compile(&mut executable) + { ic_msg!(invoke_context, "Failed to compile program {:?}", err); return Err(InstructionError::ProgramFailedToCompile); } @@ -164,7 +168,7 @@ fn check_loader_id(id: &Pubkey) -> bool { /// Create the BPF virtual machine pub fn create_vm<'a, 'b>( - program: &'a Executable, + program: &'a Pin>>, parameter_bytes: &mut [u8], invoke_context: &'a mut InvokeContext<'b>, orig_data_lens: &'a [usize], @@ -955,7 +959,7 @@ impl InstructionMeter for ThisInstructionMeter { /// BPF Loader's Executor implementation pub struct BpfExecutor { - executable: Executable, + executable: Pin>>, } // Well, implement Debug for solana_rbpf::vm::Executable in solana-rbpf... diff --git a/rbpf-cli/Cargo.toml b/rbpf-cli/Cargo.toml index fbde54291..a1bee13e7 100644 --- a/rbpf-cli/Cargo.toml +++ b/rbpf-cli/Cargo.toml @@ -16,5 +16,5 @@ solana-bpf-loader-program = { path = "../programs/bpf_loader", version = "=1.10. solana-logger = { path = "../logger", version = "=1.10.0" } solana-program-runtime = { path = "../program-runtime", version = "=1.10.0" } solana-sdk = { path = "../sdk", version = "=1.10.0" } -solana_rbpf = "=0.2.18" +solana_rbpf = "=0.2.19" time = "0.3.5" diff --git a/rbpf-cli/src/main.rs b/rbpf-cli/src/main.rs index 6311e033d..ee40c6e5b 100644 --- a/rbpf-cli/src/main.rs +++ b/rbpf-cli/src/main.rs @@ -257,7 +257,7 @@ native machine code before execting it in the virtual machine.", let text_bytes = executable.get_text_bytes().1; check(text_bytes, &config).unwrap(); } - executable.jit_compile().unwrap(); + Executable::::jit_compile(&mut executable).unwrap(); let analysis = Analysis::from_executable(&executable); match matches.value_of("use") { diff --git a/sdk/src/feature_set.rs b/sdk/src/feature_set.rs index 24bf8c529..4c37b319f 100644 --- a/sdk/src/feature_set.rs +++ b/sdk/src/feature_set.rs @@ -279,6 +279,10 @@ pub mod allow_votes_to_directly_update_vote_state { solana_sdk::declare_id!("Ff8b1fBeB86q8cjq47ZhsQLgv5EkHu3G1C99zjUfAzrq"); } +pub mod reject_all_elf_rw { + solana_sdk::declare_id!("DeMpxgMq51j3rZfNK2hQKZyXknQvqevPSFPJFNTbXxsS"); +} + lazy_static! { /// Map of feature identifiers to user-visible description pub static ref FEATURE_NAMES: HashMap = [ @@ -343,6 +347,7 @@ lazy_static! { (reject_non_rent_exempt_vote_withdraws::id(), "fail vote withdraw instructions which leave the account non-rent-exempt"), (evict_invalid_stakes_cache_entries::id(), "evict invalid stakes cache entries on epoch boundaries"), (allow_votes_to_directly_update_vote_state::id(), "enable direct vote state update"), + (reject_all_elf_rw::id(), "reject all read-write data in program elfs"), /*************** ADD NEW FEATURES HERE ***************/ ] .iter()