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

Memory syscalls cannot start in an account and end outside of it #3744

Merged
merged 3 commits into from
Dec 3, 2024

Conversation

seanyoung
Copy link

@seanyoung seanyoung commented Nov 22, 2024

The input area of the address space contains things like the instruction data and the accounts passed into the program, including the account data itself. From the perspective of the SBF program, all these are stored back-to-back in memory, but with direct mapping, the account data is actually stored in a separate memory region.

Previously, memcpy, memmove, memcmp, and memset can start and stop anywhere in memory; it is possible to start in account data, and give a length beyond the end of the account data; it would cross into a new region. Conversely, it possible to start before account data and up within the account data.

This change restricts these four syscalls so that memory regions are entirely inside account data or outside of it.

There is no reason why you require this and no mainnet program does this. This change was requested by Firedancer for direct mapping.

Copy link

mergify bot commented Nov 22, 2024

The Firedancer team maintains a line-for-line reimplementation of the
native programs, and until native programs are moved to BPF, those
implementations must exactly match their Agave counterparts.
If this PR represents a change to a native program implementation (not
tests), please include a reviewer from the Firedancer team. And please
keep refactors to a minimum.

@seanyoung seanyoung force-pushed the syscall-limits branch 3 times, most recently from 842df48 to 93e6375 Compare November 22, 2024 16:36
@seanyoung seanyoung marked this pull request as ready for review November 22, 2024 19:27
@seanyoung seanyoung requested a review from a team as a code owner December 2, 2024 20:55
Lichtso
Lichtso previously approved these changes Dec 2, 2024
@seanyoung seanyoung merged commit 36d1017 into anza-xyz:master Dec 3, 2024
52 checks passed
@seanyoung seanyoung deleted the syscall-limits branch December 3, 2024 12:55
@seanyoung seanyoung added the v2.1 Backport to v2.1 branch label Dec 3, 2024
Copy link

mergify bot commented Dec 3, 2024

Backports to the beta branch are to be avoided unless absolutely necessary for fixing bugs, security issues, and perf regressions. Changes intended for backport should be structured such that a minimum effective diff can be committed separately from any refactoring, plumbing, cleanup, etc that are not strictly necessary to achieve the goal. Any of the latter should go only into master and ride the normal stabilization schedule. Exceptions include CI/metrics changes, CLI improvements and documentation updates on a case by case basis.

mergify bot pushed a commit that referenced this pull request Dec 3, 2024
* Memory syscalls cannot start in an account and end outside of it

In the same way, a memory syscall cannot start outside of an account and
up within one.

(cherry picked from commit 36d1017)
seanyoung added a commit that referenced this pull request Dec 6, 2024
…t (backport of #3744) (#3885)

* Memory syscalls cannot start in an account and end outside of it (#3744)

* Memory syscalls cannot start in an account and end outside of it

In the same way, a memory syscall cannot start outside of an account and
up within one.

(cherry picked from commit 36d1017)

* Update Cargo.lock

---------

Co-authored-by: Sean Young <[email protected]>
KirillLykov pushed a commit that referenced this pull request Dec 9, 2024
…t (backport of #3744) (#3885)

* Memory syscalls cannot start in an account and end outside of it (#3744)

* Memory syscalls cannot start in an account and end outside of it

In the same way, a memory syscall cannot start outside of an account and
up within one.

(cherry picked from commit 36d1017)

* Update Cargo.lock

---------

Co-authored-by: Sean Young <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v2.1 Backport to v2.1 branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants