Skip to content

Commit c48e087

Browse files
committed
Revert "[ASan] Do not misrepresent high value address dereferences as null dereferences"
As it was breaking bots running sanitizer lint check This reverts r374265 (git b577efe) llvm-svn: 374308
1 parent 186f1c5 commit c48e087

File tree

7 files changed

+6
-90
lines changed

7 files changed

+6
-90
lines changed

compiler-rt/lib/asan/asan_errors.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ struct ErrorDeadlySignal : ErrorBase {
4848
scariness.Scare(10, "stack-overflow");
4949
} else if (!signal.is_memory_access) {
5050
scariness.Scare(10, "signal");
51-
} else if (signal.is_true_faulting_addr &&
52-
signal.addr < GetPageSizeCached()) {
51+
} else if (signal.addr < GetPageSizeCached()) {
5352
scariness.Scare(10, "null-deref");
5453
} else if (signal.addr == signal.pc) {
5554
scariness.Scare(60, "wild-jump");

compiler-rt/lib/sanitizer_common/sanitizer_common.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -881,11 +881,6 @@ struct SignalContext {
881881
bool is_memory_access;
882882
enum WriteFlag { UNKNOWN, READ, WRITE } write_flag;
883883

884-
// In some cases the kernel cannot provide the true faulting address; `addr`
885-
// will be zero then. This field allows to distinguish between these cases
886-
// and dereferences of null.
887-
bool is_true_faulting_addr;
888-
889884
// VS2013 doesn't implement unrestricted unions, so we need a trivial default
890885
// constructor
891886
SignalContext() = default;
@@ -898,8 +893,7 @@ struct SignalContext {
898893
context(context),
899894
addr(GetAddress()),
900895
is_memory_access(IsMemoryAccess()),
901-
write_flag(GetWriteFlag()),
902-
is_true_faulting_addr(IsTrueFaultingAddress()) {
896+
write_flag(GetWriteFlag()) {
903897
InitPcSpBp();
904898
}
905899

@@ -920,7 +914,6 @@ struct SignalContext {
920914
uptr GetAddress() const;
921915
WriteFlag GetWriteFlag() const;
922916
bool IsMemoryAccess() const;
923-
bool IsTrueFaultingAddress() const;
924917
};
925918

926919
void InitializePlatformEarly();

compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,12 +1849,6 @@ SignalContext::WriteFlag SignalContext::GetWriteFlag() const {
18491849
#endif
18501850
}
18511851

1852-
bool SignalContext::IsTrueFaultingAddress() const {
1853-
auto si = static_cast<const siginfo_t *>(siginfo);
1854-
// SIGSEGV signals without a true fault address have si_code set to 128.
1855-
return si->si_signo == SIGSEGV && si->si_code != 128;
1856-
}
1857-
18581852
void SignalContext::DumpAllRegisters(void *context) {
18591853
// FIXME: Implement this.
18601854
}

compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -754,12 +754,6 @@ SignalContext::WriteFlag SignalContext::GetWriteFlag() const {
754754
#endif
755755
}
756756

757-
bool SignalContext::IsTrueFaultingAddress() const {
758-
auto si = static_cast<const siginfo_t *>(siginfo);
759-
// "Real" SIGSEGV codes (e.g., SEGV_MAPERR, SEGV_MAPERR) are non-zero.
760-
return si->si_signo == SIGSEGV && si->si_code != 0;
761-
}
762-
763757
static void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp) {
764758
ucontext_t *ucontext = (ucontext_t*)context;
765759
# if defined(__aarch64__)

compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_report.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,9 @@ static void ReportDeadlySignalImpl(const SignalContext &sig, u32 tid,
191191
SanitizerCommonDecorator d;
192192
Printf("%s", d.Warning());
193193
const char *description = sig.Describe();
194-
if (sig.is_memory_access && !sig.is_true_faulting_addr)
195-
Report("ERROR: %s: %s on unknown address (pc %p bp %p sp %p T%d)\n",
196-
SanitizerToolName, description, (void *)sig.pc, (void *)sig.bp,
197-
(void *)sig.sp, tid);
198-
else
199-
Report("ERROR: %s: %s on unknown address %p (pc %p bp %p sp %p T%d)\n",
200-
SanitizerToolName, description, (void *)sig.addr, (void *)sig.pc,
201-
(void *)sig.bp, (void *)sig.sp, tid);
194+
Report("ERROR: %s: %s on unknown address %p (pc %p bp %p sp %p T%d)\n",
195+
SanitizerToolName, description, (void *)sig.addr, (void *)sig.pc,
196+
(void *)sig.bp, (void *)sig.sp, tid);
202197
Printf("%s", d.Default());
203198
if (sig.pc < GetPageSizeCached())
204199
Report("Hint: pc points to the zero page.\n");
@@ -208,11 +203,7 @@ static void ReportDeadlySignalImpl(const SignalContext &sig, u32 tid,
208203
? "WRITE"
209204
: (sig.write_flag == SignalContext::READ ? "READ" : "UNKNOWN");
210205
Report("The signal is caused by a %s memory access.\n", access_type);
211-
if (!sig.is_true_faulting_addr)
212-
Report("Hint: this fault was caused by a dereference of a high value "
213-
"address (see registers below). Dissassemble the provided pc "
214-
"to learn which register value was used.\n");
215-
else if (sig.addr < GetPageSizeCached())
206+
if (sig.addr < GetPageSizeCached())
216207
Report("Hint: address points to the zero page.\n");
217208
}
218209
MaybeReportNonExecRegion(sig.pc);

compiler-rt/lib/sanitizer_common/sanitizer_win.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -945,11 +945,6 @@ bool SignalContext::IsMemoryAccess() const {
945945
return GetWriteFlag() != SignalContext::UNKNOWN;
946946
}
947947

948-
bool SignalContext::IsTrueFaultingAddress() const {
949-
// TODO: Provide real implementation for this. See Linux and Mac variants.
950-
return IsMemoryAccess();
951-
}
952-
953948
SignalContext::WriteFlag SignalContext::GetWriteFlag() const {
954949
EXCEPTION_RECORD *exception_record = (EXCEPTION_RECORD *)siginfo;
955950
// The contents of this array are documented at

compiler-rt/test/asan/TestCases/Posix/high-address-dereference.c

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)