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

Rust's AccountInfo contains immutable members that might be changed by the runtime or other programs #14692

Open
jackcmay opened this issue Jan 20, 2021 · 0 comments
Milestone

Comments

@jackcmay
Copy link
Contributor

Problem

AccountInfo contains currently two members that may be changed by the runtime or other programs but are currently defined as immutable.

There are

  • The length of the account data because it is a slice. The program itself is not allowed to modify the length of the slice but the program may want to call the system program to CreateAccount or Realloc which changes the size of a program's data. Currently CreateAccount is supported up to a size of 10k only.
  • The account owner is an immutable slice. The program itself is not allowed to modify an account owner directly but may call the system program to Reassign which does.

The issue with the above two members is that when the program is compiled the Rust compiler thinks the data length and the owner are immutable and thus may make assumptions based on that. For example, the compiler might keep the data's length in a register across a call to CreateAccount which would lead the program to use a stale value after the call.

Proposed Solution

Rework the program's entrypoint parameter types to correctly describe data malleability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants