Repository navigation
Fix SuperscalarHash buffer overflows in the RISC-V vector JIT - #371
Open
thomasbuilds wants to merge 1 commit into
Open
thomasbuilds wants to merge 1 commit into
thomasbuilds wants to merge 1 commit into
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The RISC-V vector JIT compiles the SuperscalarHash programs into fixed areas of its template (512
IMUL_RCPliterals in total and 8 KiB of code per Cache access) without checking that they fit. Larger values ofRANDOMX_SUPERSCALAR_LATENCYorRANDOMX_CACHE_ACCESSES, which configuration.md permits, can need more (with 16 Cache accesses, about 0.8% of keys; with a latency of 500, every key), and the JIT then writes past them. On CPUs with VLEN ≥ 256 this crashes or hangs Dataset initialization and larger overflows also corrupt the JIT's other code or memory past its buffer, even at VLEN 128, where this code is generated but not run.This checks the space while generating and, if a key's programs don't fit, uses the scalar Dataset init code for that key. Keys in the default configuration fit with a wide margin so they keep using the vector code which is unchanged.
initCacheCompilenow updatescache->datasetInitsince the choice can change with the key.