-
Notifications
You must be signed in to change notification settings - Fork 76
[SWDEV-563823][Compiler-rt][ASan] Simplify API Logic 'asan_hsa_amd_ipc_memory_create'. #475
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: amd-staging
Are you sure you want to change the base?
[SWDEV-563823][Compiler-rt][ASan] Simplify API Logic 'asan_hsa_amd_ipc_memory_create'. #475
Conversation
971d852 to
0c173eb
Compare
0c173eb to
c1765c0
Compare
|
Does the test application in the ticket print the same "base" "len" and "end" as the uninstrumented version (taking into account address randomization)? |
Yes. If we include the current fix with/without intercepting hsa_amd_pointer_info. Non-Instrumented O/PInstrumented O/P |
|
But the output in the ticket, when -fsanitize=address is not used is: hsa_amd_pointer_info: test_buff 0x7f3df2400000 base 0x7f3df2400000 len 1024 end 0x7f3df2400400 Here the buffer and the base are the same, and len is 1024. Shouldn't our intercepted version of hsa_amd_pointer_info return the same buffer and base, and a len of 1024 instead of 16384? |
Hi @b-sumner , Ok in my previous o/p, the problem was because of LD_LIBRARY_PATH set to asan instrumented libraries and I compiled non-instrumented o/p without flags If I avoid adding the I think instrumentation here is not kind of problem, we enable the asan interception of those hsa_amd* api calls in the asanified libraries only as our code is bounded by preprocessor macro |
|
Hi @b-sumner, Here are the results without Instrumented (ASan enabled via -fsanitize=address -shared-libsan with LD_LIBRARY_PATH set to path/to/lib/asan)Non-Instrumented (ASan disabled with LD_LIBRARY_PATH not set to /path/to/lib/asan) |
|
Thanks! My thinking is that in order to provide acceptable information to our interception of hsa_amd_ipc_memory_create, our interception of hsa_amd_pointer_info should return the same base, len, and end as observed when the application is not built with instrumentation (or running instrumented libraries). But I would like to hear @bing-ma's take on this. |
c1765c0 to
0bb451f
Compare
0bb451f to
9bc5e55
Compare
9bc5e55 to
339e178
Compare
69a471e to
ee235e3
Compare
ee235e3 to
8681926
Compare
afae2e3 to
619e575
Compare
53c9dda to
bed99f8
Compare
bed99f8 to
c9f7d0d
Compare
'asan_hsa_amd_ipc_memory_create'.
- Use reinterpret_cast<uptr> for pointer arithmetic.
- Add sanitizer interception logic for api 'hsa_amd_pointer_info'.
- Allow only valid values of ptr and len in non-ASan mode.
- ptr == Actual agentBaseAddress && len ==
original_len_used_in_alloc
- Allow only valid values of ptr and len in ASan mode.
- Here pinfo is retrieved from external hsa_amd_pointer_info(not
internal device allocator function AmdgpuMemFuncs::GetPointerInfo)
- ptr == pinfo.agentBaseAddress && len == pinfo.sizeInBytes
- ptr == original_ptr_returned_by_ASAN && len ==
original_len_used_in_alloc
Improve logic of asan_hsa_amd_ipc_memory_create based on observations.
suggestions. This commit again adds the interception of 'hsa_amd_pointer_info' call.
- Changes to 'asan_hsa_amd_pointer_info'
- Initialize status with default value
'HSA_STATUS_ERROR_NOT_INITIALIZE'.
This reverts commit 00898ca.
- Changes to 'asan_hsa_amd_pointer_info'
- Initialize status with default value
'HSA_STATUS_ERROR_NOT_INITIALIZE'.
- Assure by adding ternary condition to check if ptr_ is not nullptr
when calling GetASanChunkByAddr.
Fix Typo.
c9f7d0d to
eed8503
Compare
| : nullptr; | ||
| hsa_status_t status = HSA_STATUS_ERROR_NOT_INITIALIZED; | ||
| if (ptr_ && m) { | ||
| status = REAL(hsa_amd_pointer_info)(ptr, info, alloc, num_agents_accessible, |
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.
Should we use ptr_ here instead of ptr? It might be a bit clearer to do so.
original_len_used_in_alloc
internal device allocator function AmdgpuMemFuncs::GetPointerInfo)
original_len_used_in_alloc