Skip to content

Commit

Permalink
Merge pull request #2569 from zhaomaosu/asan-only-warn-host-ptr
Browse files Browse the repository at this point in the history
[DevASAN] Only report warning if passing host ptr to kernel
  • Loading branch information
kbenzie committed Jan 17, 2025
1 parent ffb83cc commit ef7829e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions source/loader/layers/sanitizer/asan/asan_interceptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,10 @@ ur_result_t AsanInterceptor::prepareLaunch(
ContextInfo->Handle, DeviceInfo->Handle, (uptr)Ptr)) {
ReportInvalidKernelArgument(Kernel, ArgIndex, (uptr)Ptr,
ValidateResult, PtrPair.second);
exitWithErrors();
if (ValidateResult.Type !=
ValidateUSMResult::MAYBE_HOST_POINTER) {
exitWithErrors();
}
}
}
}
Expand Down Expand Up @@ -864,13 +867,15 @@ AsanInterceptor::findAllocInfoByAddress(uptr Address) {
std::shared_lock<ur_shared_mutex> Guard(m_AllocationMapMutex);
auto It = m_AllocationMap.upper_bound(Address);
if (It == m_AllocationMap.begin()) {
return std::optional<AllocationIterator>{};
return std::nullopt;
}
--It;
// Make sure we got the right AllocInfo
assert(Address >= It->second->AllocBegin &&
Address < It->second->AllocBegin + It->second->AllocSize &&
"Wrong AllocInfo for the address");

// Maybe it's a host pointer
if (Address < It->second->AllocBegin ||
Address >= It->second->AllocBegin + It->second->AllocSize) {
return std::nullopt;
}
return It;
}

Expand Down

0 comments on commit ef7829e

Please sign in to comment.