Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EVM-69 Fix panic issue in opReturnDataCopy #778

Merged
merged 6 commits into from
Oct 21, 2022

Conversation

Kourin1996
Copy link
Contributor

@Kourin1996 Kourin1996 commented Oct 6, 2022

Description

This PR fixes the issue that may cause panic in opReturnDataCopy. dataOffset is expected to be uint64 value but this function doesn't check the negativity before using. This PR adds such a check.

In addition, this PR change the order of checks in checkMemory function because it always passes when the size argument is zero, even thought offset is negative

Changes include

  • Bugfix (non-breaking change that solves an issue)
  • Hotfix (change that solves an urgent issue, and requires immediate attention)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)

Breaking changes

Please complete this section if any breaking changes have been made, otherwise delete it

Checklist

  • I have assigned this PR to myself
  • I have added at least 1 reviewer
  • I have added the relevant labels
  • I have updated the official documentation
  • I have added sufficient documentation in code

Testing

  • I have tested this code with the official test suite
  • I have tested this code manually

Manual tests

Please complete this section if you ran manual tests for this functionality, otherwise delete it

Documentation update

Please link the documentation update PR in this section if it's present, otherwise delete it

Additional comments

Please post additional comments in this section if you have them, otherwise delete it

@Kourin1996 Kourin1996 added the bug fix Functionality that fixes a bug label Oct 6, 2022
@Kourin1996 Kourin1996 self-assigned this Oct 6, 2022
@codecov
Copy link

codecov bot commented Oct 6, 2022

Codecov Report

Merging #778 (87d7d41) into develop (690b4b4) will decrease coverage by 0.01%.
The diff coverage is 40.00%.

@@             Coverage Diff             @@
##           develop     #778      +/-   ##
===========================================
- Coverage    52.70%   52.69%   -0.02%     
===========================================
  Files          130      132       +2     
  Lines        17146    17481     +335     
===========================================
+ Hits          9037     9211     +174     
- Misses        7461     7605     +144     
- Partials       648      665      +17     
Impacted Files Coverage Δ
state/runtime/evm/state.go 64.82% <33.33%> (+2.51%) ⬆️
state/runtime/evm/instructions.go 15.80% <38.88%> (+2.01%) ⬆️
jsonrpc/jsonrpc.go 25.53% <100.00%> (+7.29%) ⬆️
state/txn.go 19.76% <0.00%> (-0.10%) ⬇️
state/executor.go 3.86% <0.00%> (-0.08%) ⬇️
helper/predeployment/argparser.go 55.48% <0.00%> (ø)
helper/predeployment/predeployment.go 0.00% <0.00%> (ø)
jsonrpc/dispatcher.go 55.00% <0.00%> (+1.17%) ⬆️
... and 3 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@ferranbt
Copy link
Contributor

ferranbt commented Oct 7, 2022

Should this check be implemented in the other instructions that have a dataOffset?

Copy link
Contributor

@zivkovicmilos zivkovicmilos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great 💯

Thank you for fixing this up, and for adding coverage as well 🙏

@Kourin1996
Copy link
Contributor Author

Kourin1996 commented Oct 10, 2022

Should this check be implemented in the other instructions that have a dataOffset?

Are you asking whether we need to do such a check in other instructions?
Basically checkMemory checks the negativities but this instruction didn't check all of values.

I did quick check and other instructions check the negativities.

@Kourin1996
Copy link
Contributor Author

@zivkovicmilos Renamed and added comment 87d7d41

Copy link
Contributor

@0xAleksaOpacic 0xAleksaOpacic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you for fixing it and adding relevant tests :D

@Kourin1996 Kourin1996 merged commit ae69b37 into develop Oct 21, 2022
@Kourin1996 Kourin1996 deleted the fix/out-of-range-in-evm branch October 21, 2022 08:29
@github-actions github-actions bot locked and limited conversation to collaborators Oct 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug fix Functionality that fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants