-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
runtime: vote program hardening, support 'tower sync'
- types: fd_treap and fd_deque alloc helper to accept custom max - sysvar: define max element count for 'slot hashes', 'recent block hashes', and 'stake history' - types: change collection 'max' to 'min', update deserializer to always allocate enough capacity for collections - types: remove 'SMALL_DEQUE' error - program: support vote program 'tower sync' instructions - runtime: fix typo in FD_SYSVAR_STAKE_HISTORY_CAP A note on hardening: Previously, Firedancer used Agave's size limits for various dynamically sized bincode data structures, such as the lockouts deque of the vote instruction and vote state. A malicious user could provide a oversize structure in instruction data though. Similarly, a fuzzer could provide a corrupted vote state, though this is assumed to not be possible on a real network. We did not handle this case correctly and would instead fail to deserialize the input (potentially leading to a different execution result). The real item count limit of dynamically sized structures in native programs is derived from size limitations: instruction data size is ~1.2kB max, account size is 10MiB max. This patch updates fd_types to consider the previous 'max' item count limits as minimums instead. If any larger structure is provided, the deserializer will allocate as much as needed. (Provably bounded as the deserializer always advances when it makes an allocation, and verifies that the serialization is valid before allocating) This handles all cases correctly. If the user provides 0 vote lockouts, we allocate 31 (the minimum), which is enough space to correctly execute native program business logic, which might append more entries to the structure. If the user provides 100 vote lockouts, we allocate 100, as that exceeds the minimum. However, we do still need to ensure that the native program never attempts to add more items to a collection in the oversize case. This is out of scope for this PR.
- Loading branch information
1 parent
b45978b
commit 8b176e0
Showing
15 changed files
with
471 additions
and
316 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.