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

HandleSysMmap allocations with hints #13448

Open
BlocksOnAChain opened this issue Dec 17, 2024 · 0 comments
Open

HandleSysMmap allocations with hints #13448

BlocksOnAChain opened this issue Dec 17, 2024 · 0 comments
Labels
MT cannon - audit findings grouping for audit findings MT cannon - Mainnet relevant issues needed to complete the work for our Mainnet release

Comments

@BlocksOnAChain
Copy link

Description
The sys_mmap system call allows the use of address hints to allocate memory at or near a requested address. Currently, op-cannon processes hinted sys_mmap calls indiscriminately in exec.HandleSysMmap, always informing the caller that it has memory at the requested address without performing any validation or tracking. This behavior poses a risk of guest memory allocations overlapping with op-cannon's internal memory spaces.

In certain scenarios, hints are commonly used. For instance, dependencies of the op-program handle some allocations by directly using runtime.mallocgc, which for large allocations will use hints.

Note
In testing the emulated program's heap is presently located at 0xc000000000, providing substantial overhead relative to cannon's arch64.HeapStart. However, blindly allowing allocations at any address and with any size is a security risk.

Recommendation
Implement bounds checking for sys_mmap calls leveraging hints to prevent memory overlaps.

--
OP labs team solution for this finding:

@Inphi - We won't be implementing bounds checking in the VM. As this issue does not affect the op-program (and Go programs in general). And Cannon is not intended to support any other types of programs.

  • We will document mmap hinting in the spec per auditors suggestion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MT cannon - audit findings grouping for audit findings MT cannon - Mainnet relevant issues needed to complete the work for our Mainnet release
Projects
Development

No branches or pull requests

1 participant