mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Hacks to disable instructions that may lead to false positives across interpreter and evmone.
This commit is contained in:
parent
c3a5b45d6e
commit
058e871ce2
@ -63,10 +63,12 @@ DEFINE_PROTO_FUZZER(Program const& _input)
|
|||||||
bool filterStatefulInstructions = true;
|
bool filterStatefulInstructions = true;
|
||||||
bool filterUnboundedLoops = true;
|
bool filterUnboundedLoops = true;
|
||||||
bool filterMemoryWrites = true;
|
bool filterMemoryWrites = true;
|
||||||
|
bool filterLogs = true;
|
||||||
ProtoConverter converter(
|
ProtoConverter converter(
|
||||||
filterStatefulInstructions,
|
filterStatefulInstructions,
|
||||||
filterUnboundedLoops,
|
filterUnboundedLoops,
|
||||||
filterMemoryWrites
|
filterMemoryWrites,
|
||||||
|
filterLogs
|
||||||
);
|
);
|
||||||
string yulSubObject = converter.programToString(_input);
|
string yulSubObject = converter.programToString(_input);
|
||||||
// Fuzzer also fuzzes the EVM version field.
|
// Fuzzer also fuzzes the EVM version field.
|
||||||
@ -104,7 +106,7 @@ DEFINE_PROTO_FUZZER(Program const& _input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
solidity::frontend::OptimiserSettings settings = solidity::frontend::OptimiserSettings::none();
|
solidity::frontend::OptimiserSettings settings = solidity::frontend::OptimiserSettings::none();
|
||||||
AssemblyStack stackUnoptimized;
|
AssemblyStack stackUnoptimized(version, AssemblyStack::Language::StrictAssembly, settings);
|
||||||
solAssert(
|
solAssert(
|
||||||
stackUnoptimized.parseAndAnalyze("source", yulSubObject),
|
stackUnoptimized.parseAndAnalyze("source", yulSubObject),
|
||||||
"Parsing fuzzer generated input failed."
|
"Parsing fuzzer generated input failed."
|
||||||
|
|||||||
@ -652,7 +652,17 @@ void ProtoConverter::visit(NullaryOp const& _x)
|
|||||||
op == NullaryOp::ADDRESS ||
|
op == NullaryOp::ADDRESS ||
|
||||||
op == NullaryOp::TIMESTAMP ||
|
op == NullaryOp::TIMESTAMP ||
|
||||||
op == NullaryOp::NUMBER ||
|
op == NullaryOp::NUMBER ||
|
||||||
op == NullaryOp::DIFFICULTY
|
op == NullaryOp::DIFFICULTY ||
|
||||||
|
op == NullaryOp::ORIGIN ||
|
||||||
|
op == NullaryOp::CALLER ||
|
||||||
|
op == NullaryOp::CALLVALUE ||
|
||||||
|
op == NullaryOp::GASPRICE ||
|
||||||
|
op == NullaryOp::GASLIMIT ||
|
||||||
|
op == NullaryOp::COINBASE ||
|
||||||
|
op == NullaryOp::TIMESTAMP ||
|
||||||
|
op == NullaryOp::NUMBER ||
|
||||||
|
op == NullaryOp::CHAINID ||
|
||||||
|
op == NullaryOp::SELFBALANCE
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -1344,6 +1354,7 @@ void ProtoConverter::visit(Statement const& _x)
|
|||||||
m_output << "continue\n";
|
m_output << "continue\n";
|
||||||
break;
|
break;
|
||||||
case Statement::kLogFunc:
|
case Statement::kLogFunc:
|
||||||
|
if (!m_filterLogs)
|
||||||
visit(_x.log_func());
|
visit(_x.log_func());
|
||||||
break;
|
break;
|
||||||
case Statement::kCopyFunc:
|
case Statement::kCopyFunc:
|
||||||
|
|||||||
@ -42,7 +42,8 @@ public:
|
|||||||
ProtoConverter(
|
ProtoConverter(
|
||||||
bool _filterStatefulInstructions = false,
|
bool _filterStatefulInstructions = false,
|
||||||
bool _filterUnboundedLoops = false,
|
bool _filterUnboundedLoops = false,
|
||||||
bool _filterMemoryWrites = false
|
bool _filterMemoryWrites = false,
|
||||||
|
bool _filterLogs = false
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
m_funcVars = std::vector<std::vector<std::vector<std::string>>>{};
|
m_funcVars = std::vector<std::vector<std::vector<std::string>>>{};
|
||||||
@ -61,6 +62,7 @@ public:
|
|||||||
m_filterStatefulInstructions = _filterStatefulInstructions;
|
m_filterStatefulInstructions = _filterStatefulInstructions;
|
||||||
m_filterUnboundedLoops = _filterUnboundedLoops;
|
m_filterUnboundedLoops = _filterUnboundedLoops;
|
||||||
m_filterMemoryWrites = _filterMemoryWrites;
|
m_filterMemoryWrites = _filterMemoryWrites;
|
||||||
|
m_filterLogs = _filterLogs;
|
||||||
}
|
}
|
||||||
ProtoConverter(ProtoConverter const&) = delete;
|
ProtoConverter(ProtoConverter const&) = delete;
|
||||||
ProtoConverter(ProtoConverter&&) = delete;
|
ProtoConverter(ProtoConverter&&) = delete;
|
||||||
@ -386,5 +388,8 @@ private:
|
|||||||
/// Flag that, if set, stops the converter from generating memory
|
/// Flag that, if set, stops the converter from generating memory
|
||||||
/// writes i.e., mstore/mstore8.
|
/// writes i.e., mstore/mstore8.
|
||||||
bool m_filterMemoryWrites;
|
bool m_filterMemoryWrites;
|
||||||
|
/// Flag that, if set, stops the converter from generating log
|
||||||
|
/// records.
|
||||||
|
bool m_filterLogs;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,6 +41,7 @@ using solidity::util::keccak256;
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#if 0
|
||||||
/// Reads 32 bytes from @a _data at position @a _offset bytes while
|
/// Reads 32 bytes from @a _data at position @a _offset bytes while
|
||||||
/// interpreting @a _data to be padded with an infinite number of zero
|
/// interpreting @a _data to be padded with an infinite number of zero
|
||||||
/// bytes beyond its end.
|
/// bytes beyond its end.
|
||||||
@ -63,6 +64,7 @@ u256 readZeroExtended(bytes const& _data, u256 const& _offset)
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/// Copy @a _size bytes of @a _source at offset @a _sourceOffset to
|
/// Copy @a _size bytes of @a _source at offset @a _sourceOffset to
|
||||||
/// @a _target at offset @a _targetOffset. Behaves as if @a _source would
|
/// @a _target at offset @a _targetOffset. Behaves as if @a _source would
|
||||||
@ -196,9 +198,11 @@ u256 EVMInstructionInterpreter::eval(
|
|||||||
case Instruction::CALLVALUE:
|
case Instruction::CALLVALUE:
|
||||||
return m_state.callvalue;
|
return m_state.callvalue;
|
||||||
case Instruction::CALLDATALOAD:
|
case Instruction::CALLDATALOAD:
|
||||||
return readZeroExtended(m_state.calldata, arg[0]);
|
// return readZeroExtended(m_state.calldata, arg[0]);
|
||||||
|
return u256{};
|
||||||
case Instruction::CALLDATASIZE:
|
case Instruction::CALLDATASIZE:
|
||||||
return m_state.calldata.size();
|
//return m_state.calldata.size();
|
||||||
|
return 0;
|
||||||
case Instruction::CALLDATACOPY:
|
case Instruction::CALLDATACOPY:
|
||||||
if (accessMemory(arg[0], arg[2]))
|
if (accessMemory(arg[0], arg[2]))
|
||||||
copyZeroExtended(
|
copyZeroExtended(
|
||||||
@ -458,6 +462,10 @@ u256 EVMInstructionInterpreter::evalBuiltin(
|
|||||||
);
|
);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
else if (fun == "memoryguard")
|
||||||
|
{
|
||||||
|
return _evaluatedArguments.at(0);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
yulAssert(false, "Unknown builtin: " + fun);
|
yulAssert(false, "Unknown builtin: " + fun);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user