File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -668,6 +668,21 @@ pub fn verify_with_options(
668668 // A malicious prover could set counts to 0, removing entire constraint sets.
669669 vm_proof. table_counts . validate ( ) ?;
670670
671+ // Bound num_private_input_pages before allocating PageConfigs.
672+ // MAX_PRIVATE_INPUT_SIZE fits in ~26 pages of DEFAULT_PAGE_SIZE.
673+ {
674+ use executor:: vm:: memory:: MAX_PRIVATE_INPUT_SIZE ;
675+ use crate :: tables:: page:: DEFAULT_PAGE_SIZE ;
676+ let max_pages =
677+ ( MAX_PRIVATE_INPUT_SIZE as usize + 4 + DEFAULT_PAGE_SIZE - 1 ) / DEFAULT_PAGE_SIZE + 1 ;
678+ if vm_proof. num_private_input_pages > max_pages {
679+ return Err ( Error :: InvalidTableCounts ( format ! (
680+ "num_private_input_pages ({}) exceeds max ({max_pages})" ,
681+ vm_proof. num_private_input_pages,
682+ ) ) ) ;
683+ }
684+ }
685+
671686 let program = Elf :: load ( elf_bytes) . map_err ( |e| Error :: ElfLoad ( format ! ( "{e}" ) ) ) ?;
672687 let page_configs = Traces :: page_configs_from_elf_and_runtime (
673688 & program,
You can’t perform that action at this time.
0 commit comments