Feature gates for rbpf v0.2.16 (#21590)
- Adds feature reject_section_virtual_address_file_offset_mismatch. - Adds feature start_verify_shift32_imm. - Enables enable_symbol_and_section_labels only in the rbpf-cli.
This commit is contained in:
committed by
Trent Nelson
parent
f04e06e0c2
commit
6777ca244f
@ -1991,7 +1991,9 @@ fn read_and_verify_elf(program_location: &str) -> Result<Vec<u8>, Box<dyn std::e
|
|||||||
Some(verifier::check),
|
Some(verifier::check),
|
||||||
Config {
|
Config {
|
||||||
reject_unresolved_syscalls: true,
|
reject_unresolved_syscalls: true,
|
||||||
verify_mul64_imm_nonzero: true, // TODO: Remove me after feature gate
|
verify_mul64_imm_nonzero: false,
|
||||||
|
verify_shift32_imm: true,
|
||||||
|
reject_section_virtual_address_file_offset_mismatch: true,
|
||||||
..Config::default()
|
..Config::default()
|
||||||
},
|
},
|
||||||
register_syscalls(&mut invoke_context).unwrap(),
|
register_syscalls(&mut invoke_context).unwrap(),
|
||||||
|
@ -213,6 +213,10 @@ fn run_program(
|
|||||||
|
|
||||||
let config = Config {
|
let config = Config {
|
||||||
enable_instruction_tracing: true,
|
enable_instruction_tracing: true,
|
||||||
|
reject_unresolved_syscalls: true,
|
||||||
|
reject_section_virtual_address_file_offset_mismatch: true,
|
||||||
|
verify_mul64_imm_nonzero: false,
|
||||||
|
verify_shift32_imm: true,
|
||||||
..Config::default()
|
..Config::default()
|
||||||
};
|
};
|
||||||
let mut executable = Executable::<BpfError, ThisInstructionMeter>::from_elf(
|
let mut executable = Executable::<BpfError, ThisInstructionMeter>::from_elf(
|
||||||
|
@ -35,7 +35,8 @@ use {
|
|||||||
feature_set::{
|
feature_set::{
|
||||||
add_missing_program_error_mappings, close_upgradeable_program_accounts,
|
add_missing_program_error_mappings, close_upgradeable_program_accounts,
|
||||||
fix_write_privs, reduce_required_deploy_balance,
|
fix_write_privs, reduce_required_deploy_balance,
|
||||||
reject_deployment_of_unresolved_syscalls, requestable_heap_size,
|
reject_deployment_of_unresolved_syscalls,
|
||||||
|
reject_section_virtual_address_file_offset_mismatch, start_verify_shift32_imm,
|
||||||
stop_verify_mul64_imm_nonzero, upgradeable_close_instruction,
|
stop_verify_mul64_imm_nonzero, upgradeable_close_instruction,
|
||||||
},
|
},
|
||||||
ic_logger_msg, ic_msg,
|
ic_logger_msg, ic_msg,
|
||||||
@ -80,7 +81,7 @@ pub fn create_executor(
|
|||||||
program_data_offset: usize,
|
program_data_offset: usize,
|
||||||
invoke_context: &mut dyn InvokeContext,
|
invoke_context: &mut dyn InvokeContext,
|
||||||
use_jit: bool,
|
use_jit: bool,
|
||||||
reject_unresolved_syscalls: bool,
|
reject_deployment_of_broken_elfs: bool,
|
||||||
) -> Result<Arc<BpfExecutor>, InstructionError> {
|
) -> Result<Arc<BpfExecutor>, InstructionError> {
|
||||||
let syscall_registry = syscalls::register_syscalls(invoke_context).map_err(|e| {
|
let syscall_registry = syscalls::register_syscalls(invoke_context).map_err(|e| {
|
||||||
ic_msg!(invoke_context, "Failed to register syscalls: {}", e);
|
ic_msg!(invoke_context, "Failed to register syscalls: {}", e);
|
||||||
@ -91,10 +92,14 @@ pub fn create_executor(
|
|||||||
max_call_depth: bpf_compute_budget.max_call_depth,
|
max_call_depth: bpf_compute_budget.max_call_depth,
|
||||||
stack_frame_size: bpf_compute_budget.stack_frame_size,
|
stack_frame_size: bpf_compute_budget.stack_frame_size,
|
||||||
enable_instruction_tracing: log_enabled!(Trace),
|
enable_instruction_tracing: log_enabled!(Trace),
|
||||||
reject_unresolved_syscalls: reject_unresolved_syscalls
|
reject_unresolved_syscalls: reject_deployment_of_broken_elfs
|
||||||
&& invoke_context.is_feature_active(&reject_deployment_of_unresolved_syscalls::id()),
|
&& invoke_context.is_feature_active(&reject_deployment_of_unresolved_syscalls::id()),
|
||||||
|
reject_section_virtual_address_file_offset_mismatch: reject_deployment_of_broken_elfs
|
||||||
|
&& invoke_context
|
||||||
|
.is_feature_active(&reject_section_virtual_address_file_offset_mismatch::id()),
|
||||||
verify_mul64_imm_nonzero: !invoke_context
|
verify_mul64_imm_nonzero: !invoke_context
|
||||||
.is_feature_active(&stop_verify_mul64_imm_nonzero::id()), // TODO: Feature gate and then remove me
|
.is_feature_active(&stop_verify_mul64_imm_nonzero::id()),
|
||||||
|
verify_shift32_imm: invoke_context.is_feature_active(&start_verify_shift32_imm::id()),
|
||||||
..Config::default()
|
..Config::default()
|
||||||
};
|
};
|
||||||
let mut executable = {
|
let mut executable = {
|
||||||
|
@ -147,6 +147,7 @@ native machine code before execting it in the virtual machine.",
|
|||||||
|
|
||||||
let config = Config {
|
let config = Config {
|
||||||
enable_instruction_tracing: matches.is_present("trace") || matches.is_present("profile"),
|
enable_instruction_tracing: matches.is_present("trace") || matches.is_present("profile"),
|
||||||
|
enable_symbol_and_section_labels: true,
|
||||||
..Config::default()
|
..Config::default()
|
||||||
};
|
};
|
||||||
let mut accounts = Vec::new();
|
let mut accounts = Vec::new();
|
||||||
|
@ -169,6 +169,10 @@ pub mod stop_verify_mul64_imm_nonzero {
|
|||||||
solana_sdk::declare_id!("EHFwHg2vhwUb7ifm7BuY9RMbsyt1rS1rUii7yeDJtGnN");
|
solana_sdk::declare_id!("EHFwHg2vhwUb7ifm7BuY9RMbsyt1rS1rUii7yeDJtGnN");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub mod start_verify_shift32_imm {
|
||||||
|
solana_sdk::declare_id!("CqvdhqAYMc6Eq6tjW3H42Qg39TK2SCsL8ydMsC363PRp");
|
||||||
|
}
|
||||||
|
|
||||||
pub mod merge_nonce_error_into_system_error {
|
pub mod merge_nonce_error_into_system_error {
|
||||||
solana_sdk::declare_id!("21AWDosvp3pBamFW91KB35pNoaoZVTM7ess8nr2nt53B");
|
solana_sdk::declare_id!("21AWDosvp3pBamFW91KB35pNoaoZVTM7ess8nr2nt53B");
|
||||||
}
|
}
|
||||||
@ -265,6 +269,10 @@ pub mod reject_deployment_of_unresolved_syscalls {
|
|||||||
solana_sdk::declare_id!("DqniU3MfvdpU3yhmNF1RKeaM5TZQELZuyFGosASRVUoy");
|
solana_sdk::declare_id!("DqniU3MfvdpU3yhmNF1RKeaM5TZQELZuyFGosASRVUoy");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub mod reject_section_virtual_address_file_offset_mismatch {
|
||||||
|
solana_sdk::declare_id!("5N4NikcJLEiZNqwndhNyvZw15LvFXp1oF7AJQTNTZY5k");
|
||||||
|
}
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
/// Map of feature identifiers to user-visible description
|
/// Map of feature identifiers to user-visible description
|
||||||
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
|
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
|
||||||
@ -307,6 +315,7 @@ lazy_static! {
|
|||||||
(rent_for_sysvars::id(), "collect rent from accounts owned by sysvars"),
|
(rent_for_sysvars::id(), "collect rent from accounts owned by sysvars"),
|
||||||
(libsecp256k1_0_5_upgrade_enabled::id(), "upgrade libsecp256k1 to v0.5.0"),
|
(libsecp256k1_0_5_upgrade_enabled::id(), "upgrade libsecp256k1 to v0.5.0"),
|
||||||
(stop_verify_mul64_imm_nonzero::id(), "Sets rbpf vm config verify_mul64_imm_nonzero to false"),
|
(stop_verify_mul64_imm_nonzero::id(), "Sets rbpf vm config verify_mul64_imm_nonzero to false"),
|
||||||
|
(start_verify_shift32_imm::id(), "sets rbpf vm config verify_shift32_imm to true"),
|
||||||
(merge_nonce_error_into_system_error::id(), "merge NonceError into SystemError"),
|
(merge_nonce_error_into_system_error::id(), "merge NonceError into SystemError"),
|
||||||
(spl_token_v2_set_authority_fix::id(), "spl-token set_authority fix"),
|
(spl_token_v2_set_authority_fix::id(), "spl-token set_authority fix"),
|
||||||
(stake_merge_with_unmatched_credits_observed::id(), "allow merging active stakes with unmatched credits_observed #18985"),
|
(stake_merge_with_unmatched_credits_observed::id(), "allow merging active stakes with unmatched credits_observed #18985"),
|
||||||
@ -331,6 +340,7 @@ lazy_static! {
|
|||||||
(add_compute_budget_program::id(), "Add compute_budget_program"),
|
(add_compute_budget_program::id(), "Add compute_budget_program"),
|
||||||
(spl_token_v3_3_0_release::id(), "spl-token v3.3.0 release"),
|
(spl_token_v3_3_0_release::id(), "spl-token v3.3.0 release"),
|
||||||
(reject_deployment_of_unresolved_syscalls::id(), "Reject deployment of programs with unresolved syscall symbols"),
|
(reject_deployment_of_unresolved_syscalls::id(), "Reject deployment of programs with unresolved syscall symbols"),
|
||||||
|
(reject_section_virtual_address_file_offset_mismatch::id(), "enforce section virtual addresses and file offsets in ELF to be equal"),
|
||||||
/*************** ADD NEW FEATURES HERE ***************/
|
/*************** ADD NEW FEATURES HERE ***************/
|
||||||
]
|
]
|
||||||
.iter()
|
.iter()
|
||||||
|
Reference in New Issue
Block a user