-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Implement src:*=sanitize for UBSan #139772
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,32 @@ | ||||
// RUN: rm -rf %t | ||||
// RUN: split-file %s %t | ||||
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow -fsanitize-ignorelist=%t/src.ignorelist -emit-llvm %t/test1.c -o - | FileCheck %s -check-prefix=CHECK-ALLOWLIST | ||||
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow -fsanitize-ignorelist=%t/src.ignorelist -emit-llvm %t/test2.c -o - | FileCheck %s -check-prefix=CHECK-IGNORELIST | ||||
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow -fsanitize-ignorelist=%t/src.ignorelist.contradict -emit-llvm %t/test1.c -o - | FileCheck %s -check-prefix=CHECK-ALLOWLIST | ||||
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow -fsanitize-ignorelist=%t/src.ignorelist.contradict -emit-llvm %t/test2.c -o - | FileCheck %s -check-prefix=CHECK-IGNORELIST | ||||
|
||||
|
||||
// Verify ubsan only emits checks for files in the allowlist | ||||
|
||||
//--- src.ignorelist | ||||
src:* | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like we have a problem with:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I have some ideas how to fix this:
Problem: SanitizerSpecialCaseList tracks linenum, but if you check parsing code, it can represent multiple files! I suggest to start with updating SpecialCaseList to track (fileindex, linenum). But, SpecialCaseList::Sections for whatever reasons is StringMap, Let's first PR to make SpecialCaseList::Sections -> vector There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For this example, I think I was a little hesitated about the change during implementing the feature. For example, if we have a ignore list file
If a file On the other hand,
Shall we still instrument the type I think the both answers are yes. Let me know if it makes sense to you. I will create a new PR with using user branches in llvm/llvm-project to update There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Oh, I find the
|
||||
src:*/test1.c=sanitize | ||||
|
||||
//--- src.ignorelist.contradict | ||||
src:* | ||||
src:*/test1.c=sanitize | ||||
src:*/test1.c | ||||
|
||||
//--- test1.c | ||||
int add1(int a, int b) { | ||||
// CHECK-ALLOWLIST: llvm.sadd.with.overflow.i32 | ||||
return a+b; | ||||
} | ||||
|
||||
//--- test2.c | ||||
int add2(int a, int b) { | ||||
// CHECK-IGNORELIST-NOT: llvm.sadd.with.overflow.i32 | ||||
return a+b; | ||||
} | ||||
|
||||
|
Uh oh!
There was an error while loading. Please reload this page.