Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

v1.16: Fix - Adds missing "Executable account not owned by the BPF loader" error to remove_bpf_loader_incorrect_program_id (backport of #32695) #32700

Merged
merged 1 commit into from
Aug 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions programs/bpf_loader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,11 +494,13 @@ fn process_instruction_inner(
transaction_context.get_key_of_account_at_index(index_in_transaction)
});
let program_id = instruction_context.get_last_program_key(transaction_context)?;
if first_account_key == program_id
|| second_account_key
.map(|key| key == program_id)
.unwrap_or(false)
let program_account_index = if first_account_key == program_id {
first_instruction_account
} else if second_account_key
.map(|key| key == program_id)
.unwrap_or(false)
{
first_instruction_account.saturating_add(1)
} else {
let first_account = try_borrow_account(
transaction_context,
Expand All @@ -509,6 +511,19 @@ fn process_instruction_inner(
ic_logger_msg!(log_collector, "BPF loader is executable");
return Err(Box::new(InstructionError::IncorrectProgramId));
}
first_instruction_account
};
let program = try_borrow_account(
transaction_context,
instruction_context,
program_account_index,
)?;
if program.is_executable() && !check_loader_id(program.get_owner()) {
ic_logger_msg!(
log_collector,
"Executable account not owned by the BPF loader"
);
return Err(Box::new(InstructionError::IncorrectProgramId));
}
}

Expand Down