-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[asan][x86] Skip memintrinsics that write to special address spaces on x86-64 #129291
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
Open
cheezeburglar
wants to merge
1
commit into
llvm:main
Choose a base branch
from
cheezeburglar:asan_bug
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
88 changes: 88 additions & 0 deletions
88
llvm/test/Instrumentation/AddressSanitizer/X86/bug_124238.ll
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| ; RUN: opt -passes=asan %s -S | FileCheck %s | ||
|
|
||
| ;; Punt AddressSanitizer::instrumentMemIntrinsics out for MemIntrinsics | ||
| ;; that need to write to unsupported address spaces on X86 | ||
| ;; PR124238: https://www.github.com/llvm/llvm-project/issues/124238 | ||
|
|
||
| target triple = "x86_64-unknown-linux-gnu" | ||
|
|
||
| $.str.658906a285b7a0f82dabd9915e07848c = comdat any | ||
| @.str = internal constant { [2 x i8], [30 x i8] } { [2 x i8] c"x\00", [30 x i8] zeroinitializer }, comdat($.str.658906a285b7a0f82dabd9915e07848c), align 32 | ||
| @0 = private alias { [2 x i8], [30 x i8] }, ptr @.str | ||
|
|
||
| define void @test_memcpy(i64 noundef %addr) sanitize_address #0 { | ||
| entry: | ||
| %addr.addr = alloca i64, align 8 | ||
| store i64 %addr, ptr %addr.addr, align 8 | ||
| %0 = load i64, ptr %addr.addr, align 8 | ||
| %1 = inttoptr i64 %0 to ptr addrspace(257) | ||
| call void @llvm.memcpy.p257.p0.i64(ptr addrspace(257) align 1 %1, ptr align 1 @.str, i64 1, i1 false) | ||
| ; CHECK: llvm.memcpy | ||
| %2 = load i64, ptr %addr.addr, align 8 | ||
| %3 = inttoptr i64 %2 to ptr addrspace(256) | ||
| call void @llvm.memcpy.p256.p0.i64(ptr addrspace(256) align 1 %3, ptr align 1 @.str, i64 1, i1 false) | ||
| ; CHECK: llvm.memcpy | ||
| %4 = load i64, ptr %addr.addr, align 8 | ||
| %5 = inttoptr i64 %4 to ptr addrspace(258) | ||
| call void @llvm.memcpy.p258.p0.i64(ptr addrspace(258) align 1 %5, ptr align 1 @.str, i64 1, i1 false) | ||
| ; CHECK: __asan_memcpy | ||
| %6 = load i64, ptr %addr.addr, align 8 | ||
| %7 = inttoptr i64 %6 to ptr addrspace(0) | ||
| call void @llvm.memcpy.p0.p0.i64(ptr addrspace(0) align 1 %7, ptr align 1 @.str, i64 1, i1 false) | ||
| ; CHECK: __asan_memcpy | ||
| ret void | ||
| } | ||
|
|
||
| define void @test_memset(i64 noundef %addr) sanitize_address #0 { | ||
| entry: | ||
| %addr.addr = alloca i64, align 8 | ||
| store i64 %addr, ptr %addr.addr, align 8 | ||
| %0 = load i64, ptr %addr.addr, align 8 | ||
| %1 = inttoptr i64 %0 to ptr addrspace(257) | ||
| call void @llvm.memset.p257.i64(ptr addrspace(257) align 1 %1, i8 0, i64 1, i1 false) | ||
| ; CHECK: llvm.memset | ||
| %2 = load i64, ptr %addr.addr, align 8 | ||
| %3 = inttoptr i64 %2 to ptr addrspace(256) | ||
| call void @llvm.memset.p256.i64(ptr addrspace(256) align 1 %3, i8 0, i64 1, i1 false) | ||
| ; CHECK: llvm.memset | ||
| %4 = load i64, ptr %addr.addr, align 8 | ||
| %5 = inttoptr i64 %4 to ptr addrspace(258) | ||
| call void @llvm.memset.p258.i64(ptr addrspace(258) align 1 %5, i8 0, i64 1, i1 false) | ||
| ; CHECK: __asan_memset | ||
| %6 = load i64, ptr %addr.addr, align 8 | ||
| %7 = inttoptr i64 %6 to ptr addrspace(0) | ||
| call void @llvm.memset.p0.i64(ptr addrspace(0) align 1 %7, i8 0, i64 1, i1 false) | ||
| ; CHECK: __asan_memset | ||
| ret void | ||
| } | ||
|
|
||
| define void @test_memmove(i64 noundef %addr) sanitize_address #0 { | ||
| entry: | ||
| %addr.addr = alloca i64, align 8 | ||
| store i64 %addr, ptr %addr.addr, align 8 | ||
| %0 = load i64, ptr %addr.addr, align 8 | ||
| %1 = inttoptr i64 %0 to ptr addrspace(257) | ||
| %2 = load i64, ptr %addr.addr, align 8 | ||
| %3 = inttoptr i64 %2 to ptr | ||
| call void @llvm.memmove.p257.p0.i64(ptr addrspace(257) align 1 %1, ptr align 1 %3, i64 1, i1 false) | ||
| ; CHECK: llvm.memmove | ||
| %4 = load i64, ptr %addr.addr, align 8 | ||
| %5 = inttoptr i64 %4 to ptr addrspace(256) | ||
| %6 = load i64, ptr %addr.addr, align 8 | ||
| %7 = inttoptr i64 %6 to ptr | ||
| call void @llvm.memmove.p256.p0.i64(ptr addrspace(256) align 1 %5, ptr align 1 %7, i64 1, i1 false) | ||
| ; CHECK: llvm.memmove | ||
| %8 = load i64, ptr %addr.addr, align 8 | ||
| %9 = inttoptr i64 %8 to ptr addrspace(258) | ||
| %10 = load i64, ptr %addr.addr, align 8 | ||
| %11 = inttoptr i64 %10 to ptr | ||
| call void @llvm.memmove.p258.p0.i64(ptr addrspace(258) align 1 %9, ptr align 1 %11, i64 1, i1 false) | ||
| ; CHECK: __asan_memmove | ||
| %12 = load i64, ptr %addr.addr, align 8 | ||
| %13 = inttoptr i64 %12 to ptr addrspace(0) | ||
| %14 = load i64, ptr %addr.addr, align 8 | ||
| %15 = inttoptr i64 %14 to ptr | ||
| call void @llvm.memmove.p0.p0.i64(ptr addrspace(0) align 1 %13, ptr align 1 %15, i64 1, i1 false) | ||
| ; CHECK: __asan_memmove | ||
| ret void | ||
| } | ||
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.
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.
Can you add tests for addrspace(0) and addrspace(257) (which should probably be kept instrumented)?
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.
My bad, should be
addrspace(258)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.
Done, in latest commit