From 67939c061ed0b4827644417e36af605f621242c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Mei=C3=9Fner?= Date: Thu, 4 May 2023 21:03:09 +0200 Subject: [PATCH] Feature Gate Update - Requires the owner accounts of programs to be built-ins. (#31488) Requires the owner accounts of programs to be built-ins. (owned by the native_loader and have the executable flag set) --- runtime/src/accounts.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/runtime/src/accounts.rs b/runtime/src/accounts.rs index 8582d17ecc..1d6b889305 100644 --- a/runtime/src/accounts.rs +++ b/runtime/src/accounts.rs @@ -535,16 +535,23 @@ impl Accounts { builtins_start_index.saturating_add(owner_index) } else { let owner_index = accounts.len(); - if let Some((program_account, _)) = + if let Some((owner_account, _)) = self.accounts_db.load_with_fixed_root(ancestors, owner_id) { + if disable_builtin_loader_ownership_chains + && !native_loader::check_id(owner_account.owner()) + || !owner_account.executable() + { + error_counters.invalid_program_for_execution += 1; + return Err(TransactionError::InvalidProgramForExecution); + } Self::accumulate_and_check_loaded_account_data_size( &mut accumulated_accounts_data_size, - program_account.data().len(), + owner_account.data().len(), requested_loaded_accounts_data_size_limit, error_counters, )?; - accounts.push((*owner_id, program_account)); + accounts.push((*owner_id, owner_account)); } else { error_counters.account_not_found += 1; return Err(TransactionError::ProgramAccountNotFound);