-
Notifications
You must be signed in to change notification settings - Fork 124
Amd/sdashmiz/nullstring #2990
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
base: develop
Are you sure you want to change the base?
Amd/sdashmiz/nullstring #2990
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adjusts HIP no-GPU tests and improves robustness around user object reference handling and fat binary loading, with an additional guard intended to avoid buffer over-reads when inspecting code object magic headers.
Changes:
- Fix
NoGpuTst_hipExtStreamGetCUMaskto pass a properly sized CU mask array tohipExtStreamGetCUMaskinstead of a singleuint32_t. - Reorder validation in
hipUserObjectReleaseso that user object validity is checked before accessing its reference count, avoiding potential dereference of invalid objects. - Add a minimum-size check before interpreting
image_inFatBinaryInfo::ExtractFatBinaryUsingCOMGR, though the current implementation incorrectly usesstrlenon a binary buffer.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| projects/hip-tests/catch/multiproc/hipNoGpuTsts.cc | Updates the no-GPU test for hipExtStreamGetCUMask to allocate a CU mask array of 16 uint32_t entries and pass it correctly to the API. |
| projects/clr/hipamd/src/hip_graph.cpp | Adjusts the condition in hipUserObjectRelease to validate the user object before comparing referenceCount() against count, reducing the risk of accessing invalid objects. |
| projects/clr/hipamd/src/hip_fatbin.cpp | Introduces a guard on image_ size before magic string checks in ExtractFatBinaryUsingCOMGR, but currently relies on strlen over a binary buffer, which can itself cause out-of-bounds reads and needs to be reworked to use a real size value. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| size_t image_len = strlen(reinterpret_cast<const char*>(image_)); | ||
| if (image_len < kMinMagicSize) { |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
image_ represents an arbitrary binary blob (mapped file or in-memory image), so calling strlen(reinterpret_cast<const char*>(image_)) is undefined behavior: the buffer is not guaranteed to be NUL-terminated and may contain embedded NUL bytes, which can cause out-of-bounds reads or incorrect lengths. To safely enforce the minimum size for the magic string comparisons, use a known size for the mapped region (e.g., ufd_->fsize_ when image_mapped_ is true, or an explicit size tracked alongside image_ for in-memory images) instead of strlen on binary data, and compare that size against kMinMagicSize before calling memcmp-based helpers.
| size_t image_len = strlen(reinterpret_cast<const char*>(image_)); | |
| if (image_len < kMinMagicSize) { | |
| size_t image_len = 0; | |
| if (image_mapped_ && ufd_ != nullptr) { | |
| image_len = ufd_->fsize_; | |
| } | |
| if (image_len != 0 && image_len < kMinMagicSize) { |
4e7d168 to
d59820e
Compare
Signed-off-by: shadi <[email protected]>
d59820e to
44323ab
Compare
Motivation
Technical Details
JIRA ID
Test Plan
Test Result
Submission Checklist