Skip to content

[HWASan][bugfix] Fix kernel check in ShadowMapping::init #142226

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

Merged
merged 1 commit into from
Jun 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
Loading