Repository navigation
rocr: Bounds-check ELF loader section and symbol indices - #357
Open
dayatsin-amd wants to merge 1 commit into
Open
dayatsin-amd wants to merge 1 commit into
dayatsin-amd wants to merge 1 commit into
Conversation
Backport ROCm/rocm-systems#9031 to release/rocm-rel-6.4.2.2. Reject attacker-controlled sh_link, sh_info, st_shndx, and r_info symbol indices that previously indexed past the ELF section and symbol vectors. JIRA ID : SWSPLAT-45972 Signed-off-by: David Yat Sin <David.YatSin@amd.com> Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Summary
Backport of ROCm/rocm-systems#9031 onto
release/rocm-rel-6.4.2.2.Hardens the ROCr ELF code-object loader against out-of-bounds heap reads driven by attacker-controlled section and symbol indices when parsing untrusted code objects (SWSPLAT-45972).
GElfImage::section()indexed the sections vector with unvalidatedsh_link,sh_info, andst_shndxfields, andGElfSymbolTable::symbol()indexed the symbols vector with the unvalidated relocationr_infosymbol index.section()/symbol()/getStringTable()reject out-of-range indices, and string/symbol-table lookups also reject an in-range section of the wrong type.GElfSymbol::section()rejects reserved indices (>= SHN_LORESERVE).pullData()fails the code object when the referenced string, symbol, or target section is invalid.sh_info == 0remains valid for dynamic relocation sections.executable.cppnull-checksGetSection()/section()/symbol()inLoadDefinitionSymbol, bothSymbolAddressoverloads,ApplyStaticRelocation, andApplyDynamicRelocation.The
elf::Symbol*SymbolAddressnull check is already present on develop and was missing on this branch, so it is included here.JIRA ID : SWSPLAT-45972
Test plan
HSA_STATUS_ERROR_INVALID_CODE_OBJECTinstead of SIGSEGV).libhsa-runtime64from this branch and reload a well-formed code object (with and without dynamic relocations).sh_link/sh_info/st_shndx/r_infoobjects and confirmHSA_STATUS_ERROR_INVALID_CODE_OBJECTinstead of a crash.Made with Cursor