Skip to content

Commit

Permalink
Revert "Cherry pick from bytecode verifier" (#53)
Browse files Browse the repository at this point in the history
* Revert "[bytecode verifier] Meter type instantiations (#64)"

This reverts commit 803d4d1.

* Revert "[bytecode verifer] Adjust metering to decrease runtime of some tests. (#62)"

This reverts commit 459029f.

* Revert "[bytecode-verifier] Add metering logic and apply to absint based analysis (#58)"

This reverts commit 14d624d.

* Revert "copyloc-pop test (#54)"

This reverts commit 443c45a.

* Revert "[verifier] fix incorrect error code for per-module back edge limit check"

This reverts commit 1926f1a.

* Revert "[verifier] limit the number of back edges"

This reverts commit ef2f4d4.

* Revert "[language] add catch_unwind panic handling (move-language#750)"

This reverts commit b110827.
  • Loading branch information
nkysg authored Feb 28, 2023
1 parent 803d4d1 commit d5d95b6
Show file tree
Hide file tree
Showing 44 changed files with 192 additions and 2,101 deletions.
3 changes: 0 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions language/move-binary-format/src/control_flow_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ pub trait ControlFlowGraph {
/// Checks if the the edge from cur->next is a back edge
/// returns false if the edge is not in the cfg
fn is_back_edge(&self, cur: BlockId, next: BlockId) -> bool;

/// Return the number of back edges in the cfg
fn num_back_edges(&self) -> usize;
}

struct BasicBlock {
Expand Down Expand Up @@ -328,10 +325,4 @@ impl ControlFlowGraph for VMControlFlowGraph {
.get(&next)
.map_or(false, |back_edges| back_edges.contains(&cur))
}

fn num_back_edges(&self) -> usize {
self.loop_heads
.iter()
.fold(0, |acc, (_, edges)| acc + edges.len())
}
}
20 changes: 4 additions & 16 deletions language/move-binary-format/src/deserializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use crate::{check_bounds::BoundsChecker, errors::*, file_format::*, file_format_common::*};
use move_core_types::{
account_address::AccountAddress, identifier::Identifier, metadata::Metadata, state::VMState,
account_address::AccountAddress, identifier::Identifier, metadata::Metadata,
vm_status::StatusCode,
};
use std::{collections::HashSet, convert::TryInto, io::Read};
Expand Down Expand Up @@ -43,21 +43,9 @@ impl CompiledModule {
binary: &[u8],
max_binary_format_version: u32,
) -> BinaryLoaderResult<Self> {
let prev_state = move_core_types::state::set_state(VMState::DESERIALIZER);
let result = std::panic::catch_unwind(|| {
let module = deserialize_compiled_module(binary, max_binary_format_version)?;
BoundsChecker::verify_module(&module)?;

Ok(module)
})
.unwrap_or_else(|_| {
Err(PartialVMError::new(
StatusCode::VERIFIER_INVARIANT_VIOLATION,
))
});
move_core_types::state::set_state(prev_state);

result
let module = deserialize_compiled_module(binary, max_binary_format_version)?;
BoundsChecker::verify_module(&module)?;
Ok(module)
}

// exposed as a public function to enable testing the deserializer
Expand Down
8 changes: 0 additions & 8 deletions language/move-borrow-graph/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,6 @@ impl<Loc: Copy, Lbl: Clone + Ord> BorrowGraph<Loc, Lbl> {
Self(BTreeMap::new())
}

/// Returns the graph size, that is the number of nodes + number of edges
pub fn graph_size(&self) -> usize {
self.0
.values()
.map(|r| 1 + r.borrowed_by.0.values().map(|e| e.len()).sum::<usize>())
.sum()
}

/// checks if the given reference is mutable or not
pub fn is_mutable(&self, id: RefID) -> bool {
self.0.get(&id).unwrap().mutable
Expand Down
1 change: 0 additions & 1 deletion language/move-bytecode-verifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ edition = "2021"
[dependencies]
anyhow = "1.0.52"
petgraph = "0.5.1"
fail = "0.4.0"

move-borrow-graph = { path = "../move-borrow-graph" }
move-binary-format = { path = "../move-binary-format" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ edition = "2021"
[dev-dependencies]
petgraph = "0.5.1"
proptest = "1.0.0"
fail = { version = "0.4.0", features = ['failpoints']}
hex = "0.4.3"

move-bytecode-verifier = { path = "../" }
invalid-mutations = { path = "../invalid-mutations" }
move-core-types = { path = "../../move-core/types" }
move-binary-format = { path = "../../move-binary-format", features = ["fuzzing" ] }
move-binary-format = { path = "../../move-binary-format", features = ["fuzzing"] }

[features]
fuzzing = ["move-binary-format/fuzzing"]
address32 = ["move-core-types/address32"]

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fn test_max_number_of_bytecode() {
nops.push(Bytecode::Ret);
let module = dummy_procedure_module(nops);

let result = CodeUnitVerifier::verify_module(&VerifierConfig::unbounded(), &module);
let result = CodeUnitVerifier::verify_module(&Default::default(), &module);
assert!(result.is_ok());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ proptest! {
}

#[test]
#[cfg(not(feature = "address32"))]
fn valid_primitives() {
let mut module = empty_module();
module.constant_pool = vec![
Expand Down Expand Up @@ -58,7 +57,6 @@ fn valid_primitives() {
}

#[test]
#[cfg(not(feature = "address32"))]
fn invalid_primitives() {
malformed(SignatureToken::U8, vec![0, 0]);
malformed(SignatureToken::U16, vec![0, 0, 0, 0]);
Expand All @@ -74,7 +72,6 @@ fn invalid_primitives() {
}

#[test]
#[cfg(not(feature = "address32"))]
fn valid_vectors() {
let double_vec = |item: Vec<u8>| -> Vec<u8> {
let mut items = vec![2];
Expand Down Expand Up @@ -196,7 +193,6 @@ fn valid_vectors() {
}

#[test]
#[cfg(not(feature = "address32"))]
fn invalid_vectors() {
let double_vec = |item: Vec<u8>| -> Vec<u8> {
let mut items = vec![2];
Expand Down Expand Up @@ -248,7 +244,6 @@ fn tvec(s: SignatureToken) -> SignatureToken {
SignatureToken::Vector(Box::new(s))
}

#[allow(unused)]
fn malformed(type_: SignatureToken, data: Vec<u8>) {
error(type_, data, StatusCode::MALFORMED_CONSTANT_DATA)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use move_binary_format::{
errors::PartialVMResult,
file_format::{Bytecode, CompiledModule, FunctionDefinitionIndex, TableIndex},
};
use move_bytecode_verifier::{control_flow, meter::DummyMeter, VerifierConfig};
use move_bytecode_verifier::{control_flow, VerifierConfig};
use move_core_types::vm_status::StatusCode;

fn verify_module(verifier_config: &VerifierConfig, module: &CompiledModule) -> PartialVMResult<()> {
Expand All @@ -30,7 +30,6 @@ fn verify_module(verifier_config: &VerifierConfig, module: &CompiledModule) -> P
current_function,
function_definition,
code,
&mut DummyMeter,
)?;
}
Ok(())
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use move_binary_format::file_format::*;
use move_bytecode_verifier::{
limits::LimitsVerifier, verify_module_with_config_for_test, VerifierConfig,
};
use move_bytecode_verifier::{limits::LimitsVerifier, verify_module_with_config, VerifierConfig};
use move_core_types::{
account_address::AccountAddress, identifier::Identifier, vm_status::StatusCode,
};
Expand Down Expand Up @@ -245,8 +243,8 @@ fn big_vec_unpacks() {
module.serialize(&mut mvbytes).unwrap();
let module = CompiledModule::deserialize(&mvbytes).unwrap();

let res = verify_module_with_config_for_test(
"big_vec_unpacks",
// run with mainnet aptos config
let res = verify_module_with_config(
&VerifierConfig {
max_loop_depth: Some(5),
max_generic_instantiation_length: Some(32),
Expand Down
Loading

0 comments on commit d5d95b6

Please sign in to comment.