[HWASan][bugfix] Fix kernel check in ShadowMapping::init#142226
Merged
usama54321 merged 1 commit intomainfrom Jun 2, 2025
Merged
[HWASan][bugfix] Fix kernel check in ShadowMapping::init#142226usama54321 merged 1 commit intomainfrom
usama54321 merged 1 commit intomainfrom
Conversation
The function currently checks for the command line argument only to check if compiling for kernel. This is incorrect as the setting can also be passed programatically.
Member
|
@llvm/pr-subscribers-llvm-transforms Author: Usama Hameed (usama54321) ChangesThe function currently checks for the command line argument only to check if compiling for kernel. This is incorrect as the setting can also be passed programatically. Full diff: https://github.com/llvm/llvm-project/pull/142226.diff 1 Files Affected:
diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
index e81a725c62ead..77db686f8229c 100644
--- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -419,7 +419,8 @@ class HWAddressSanitizer {
}
public:
- void init(Triple &TargetTriple, bool InstrumentWithCalls);
+ void init(Triple &TargetTriple, bool InstrumentWithCalls,
+ bool CompileKernel);
Align getObjectAlignment() const { return Align(1ULL << Scale); }
bool isInGlobal() const { return Kind == OffsetKind::kGlobal; }
bool isInIfunc() const { return Kind == OffsetKind::kIfunc; }
@@ -642,7 +643,7 @@ void HWAddressSanitizer::initializeModule() {
PointerTagShift = IsX86_64 ? 57 : 56;
TagMaskByte = IsX86_64 ? 0x3F : 0xFF;
- Mapping.init(TargetTriple, InstrumentWithCalls);
+ Mapping.init(TargetTriple, InstrumentWithCalls, CompileKernel);
C = &(M.getContext());
IRBuilder<> IRB(*C);
@@ -1874,7 +1875,8 @@ void HWAddressSanitizer::instrumentPersonalityFunctions() {
}
void HWAddressSanitizer::ShadowMapping::init(Triple &TargetTriple,
- bool InstrumentWithCalls) {
+ bool InstrumentWithCalls,
+ bool CompileKernel) {
// Start with defaults.
Scale = kDefaultShadowScale;
Kind = OffsetKind::kTls;
@@ -1885,7 +1887,7 @@ void HWAddressSanitizer::ShadowMapping::init(Triple &TargetTriple,
// Fuchsia is always PIE, which means that the beginning of the address
// space is always available.
SetFixed(0);
- } else if (ClEnableKhwasan || InstrumentWithCalls) {
+ } else if (CompileKernel || InstrumentWithCalls) {
SetFixed(0);
WithFrameRecord = false;
}
|
Member
|
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Usama Hameed (usama54321) ChangesThe function currently checks for the command line argument only to check if compiling for kernel. This is incorrect as the setting can also be passed programatically. Full diff: https://github.com/llvm/llvm-project/pull/142226.diff 1 Files Affected:
diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
index e81a725c62ead..77db686f8229c 100644
--- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -419,7 +419,8 @@ class HWAddressSanitizer {
}
public:
- void init(Triple &TargetTriple, bool InstrumentWithCalls);
+ void init(Triple &TargetTriple, bool InstrumentWithCalls,
+ bool CompileKernel);
Align getObjectAlignment() const { return Align(1ULL << Scale); }
bool isInGlobal() const { return Kind == OffsetKind::kGlobal; }
bool isInIfunc() const { return Kind == OffsetKind::kIfunc; }
@@ -642,7 +643,7 @@ void HWAddressSanitizer::initializeModule() {
PointerTagShift = IsX86_64 ? 57 : 56;
TagMaskByte = IsX86_64 ? 0x3F : 0xFF;
- Mapping.init(TargetTriple, InstrumentWithCalls);
+ Mapping.init(TargetTriple, InstrumentWithCalls, CompileKernel);
C = &(M.getContext());
IRBuilder<> IRB(*C);
@@ -1874,7 +1875,8 @@ void HWAddressSanitizer::instrumentPersonalityFunctions() {
}
void HWAddressSanitizer::ShadowMapping::init(Triple &TargetTriple,
- bool InstrumentWithCalls) {
+ bool InstrumentWithCalls,
+ bool CompileKernel) {
// Start with defaults.
Scale = kDefaultShadowScale;
Kind = OffsetKind::kTls;
@@ -1885,7 +1887,7 @@ void HWAddressSanitizer::ShadowMapping::init(Triple &TargetTriple,
// Fuchsia is always PIE, which means that the beginning of the address
// space is always available.
SetFixed(0);
- } else if (ClEnableKhwasan || InstrumentWithCalls) {
+ } else if (CompileKernel || InstrumentWithCalls) {
SetFixed(0);
WithFrameRecord = false;
}
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The function currently checks for the command line argument only to check if compiling for kernel. This is incorrect as the setting can also be passed programatically.