//===- FuzzerTracePC.cpp - PC tracing--------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// Trace PCs.
// This module implements __sanitizer_cov_trace_pc_guard[_init],
// the callback required for -fsanitize-coverage=trace-pc-guard instrumentation.
//
//===----------------------------------------------------------------------===//
#include "FuzzerTracePC.h"
#include "FuzzerBuiltins.h"
#include "FuzzerBuiltinsMsvc.h"
#include "FuzzerCorpus.h"
#include "FuzzerDefs.h"
#include "FuzzerDictionary.h"
#include "FuzzerExtFunctions.h"
#include "FuzzerIO.h"
#include "FuzzerPlatform.h"
#include "FuzzerUtil.h"
#include "FuzzerValueBitMap.h"
#include <set>
// Used by -fsanitize-coverage=stack-depth to track stack depth
ATTRIBUTES_INTERFACE_TLS_INITIAL_EXEC uintptr_t __sancov_lowest_stack;
namespace fuzzer {
TracePC TPC;
size_t TracePC::GetTotalPCCoverage() {
return ObservedPCs.size();
}
void TracePC::HandleInline8bitCountersInit(uint8_t *Start, uint8_t *Stop) {
if (Start == Stop)
return;
if (NumModules &&
Modules[NumModules -
1].Start() == Start)
return;
assert(NumModules <
sizeof(Modules) /
sizeof(Modules[
0]));
auto &M = Modules[NumModules++];
uint8_t *AlignedStart = RoundUpByPage(Start);
uint8_t *AlignedStop = RoundDownByPage(Stop);
size_t NumFullPages = AlignedStop > AlignedStart ?
(AlignedStop - AlignedStart) / PageSize() :
0;
bool NeedFirst = Start < AlignedStart || !NumFullPages;
bool NeedLast = Stop > AlignedStop && AlignedStop >= AlignedStart;
M.NumRegions = NumFullPages + NeedFirst + NeedLast;;
assert(M.NumRegions >
0);
M.Regions =
new Module::Region[M.NumRegions];
assert(M.Regions);
size_t R =
0;
if (NeedFirst)
M.Regions[R++] = {Start, std::min(Stop, AlignedStart), true,
false};
for (uint8_t *P = AlignedStart; P < AlignedStop; P += PageSize())
M.Regions[R++] = {P, P + PageSize(), true, true};
if (NeedLast)
M.Regions[R++] = {AlignedStop, Stop, true,
false};
assert(R == M.NumRegions);
assert(M.Size() == (size_t)(Stop - Start));
assert(M.Stop() == Stop);
assert(M.Start() == Start);
NumInline8bitCounters += M.Size();
}
void TracePC::HandlePCsInit(
const uintptr_t *Start,
const uintptr_t *Stop) {
if (Start == Stop) {
return;
}
const PCTableEntry *B = reinterpret_cast<
const PCTableEntry *>(Start);
const PCTableEntry *E = reinterpret_cast<
const PCTableEntry *>(Stop);
if (NumPCTables && ModulePCTable[NumPCTables -
1].Start == B)
return;
assert(NumPCTables <
sizeof(ModulePCTable) /
sizeof(ModulePCTable[
0]));
ModulePCTable[NumPCTables++] = {B, E};
NumPCsInPCTables += E - B;
}
void TracePC::PrintModuleInfo() {
if (NumModules) {
Printf(
"INFO: Loaded %zd modules (%zd inline 8-bit counters): ",
NumModules, NumInline8bitCounters);
for (size_t i =
0; i < NumModules; i++)
Printf(
"%zd [%p, %p), ", Modules[i].Size(), Modules[i].Start(),
Modules[i].Stop());
Printf(
"\n");
}
if (NumPCTables) {
Printf(
"INFO: Loaded %zd PC tables (%zd PCs): ", NumPCTables,
NumPCsInPCTables);
for (size_t i =
0; i < NumPCTables; i++) {
Printf(
"%zd [%p,%p), ", ModulePCTable[i].Stop - ModulePCTable[i].Start,
ModulePCTable[i].Start, ModulePCTable[i].Stop);
}
Printf(
"\n");
if (NumInline8bitCounters && NumInline8bitCounters != NumPCsInPCTables) {
Printf(
"ERROR: The size of coverage PC tables does not match the\n"
"number of instrumented PCs. This might be a compiler bug,\n"
"please contact the libFuzzer developers.\n"
"Also check https://bugs.llvm.org/show_bug.cgi?id=34636\n"
"for possible workarounds (tl;dr: don't use the old GNU ld)\n");
_
Exit(
1);
}
}
if (size_t NumExtraCounters = ExtraCountersEnd() - ExtraCountersBegin())
Printf(
"INFO: %zd Extra Counters\n", NumExtraCounters);
size_t MaxFeatures = CollectFeatures([](uint32_t) {});
if (MaxFeatures > std::numeric_limits<uint32_t>::max())
Printf(
"WARNING: The coverage PC tables may produce up to %zu features.\n"
"This exceeds the maximum 32-bit value. Some features may be\n"
"ignored, and fuzzing may become less precise. If possible,\n"
"consider refactoring the fuzzer into several smaller fuzzers\n"
"linked against only a portion of the current target.\n",
MaxFeatures);
}
ATTRIBUTE_NO_SANITIZE_ALL
void TracePC::HandleCallerCallee(uintptr_t Caller, uintptr_t Callee) {
const uintptr_t kBits =
12;
const uintptr_t kMask = (
1 << kBits) -
1;
uintptr_t Idx = (Caller & kMask) | ((Callee & kMask) << kBits);
ValueProfileMap.AddValueModPrime(Idx);
}
/// \return the address of the previous instruction.
/// Note: the logic is copied from `sanitizer_common/sanitizer_stacktrace.h`
inline ALWAYS_INLINE uintptr_t GetPreviousInstructionPc(uintptr_t PC) {
#if defined(__arm__)
// T32 (Thumb) branch instructions might be 16 or 32 bit long,
// so we return (pc-2) in that case in order to be safe.
// For A32 mode we return (pc-4) because all instructions are 32 bit long.
return (PC -
3) & (~
1);
#elif defined(__sparc__) ||
defined(__mips__)
return PC -
8;
#elif defined(__riscv__)
return PC -
2;
#elif defined(__i386__) ||
defined(__x86_64__) ||
defined(_M_IX86) ||
defined(_M_X64)
return PC -
1;
#else
return PC -
4;
#endif
}
/// \return the address of the next instruction.
/// Note: the logic is copied from `sanitizer_common/sanitizer_stacktrace.cpp`
ALWAYS_INLINE uintptr_t TracePC::GetNextInstructionPc(uintptr_t PC) {
#if defined(__mips__)
return PC +
8;
#elif defined(__powerpc__) ||
defined(__sparc__) ||
defined(__arm__) || \
defined(__aarch64__) ||
defined(__loongarch__)
return PC +
4;
#else
return PC +
1;
#endif
}
void TracePC::UpdateObservedPCs() {
std::vector<uintptr_t> CoveredFuncs;
auto ObservePC = [&](
const PCTableEntry *TE) {
if (ObservedPCs.insert(TE).second && DoPrintNewPCs) {
PrintPC(
"\tNEW_PC: %p %F %L",
"\tNEW_PC: %p",
GetNextInstructionPc(TE->PC));
Printf(
"\n");
}
};
auto Observe = [&](
const PCTableEntry *TE) {
if (PcIsFuncEntry(TE))
if (++ObservedFuncs[TE->PC] ==
1 && NumPrintNewFuncs)
CoveredFuncs.push_back(TE->PC);
ObservePC(TE);
};
if (NumPCsInPCTables) {
if (NumInline8bitCounters == NumPCsInPCTables) {
for (size_t i =
0; i < NumModules; i++) {
auto &M = Modules[i];
assert(M.Size() ==
(size_t)(ModulePCTable[i].Stop - ModulePCTable[i].Start));
for (size_t r =
0; r < M.NumRegions; r++) {
auto &R = M.Regions[r];
if (!R.Enabled)
continue;
for (uint8_t *P = R.Start; P < R.Stop; P++)
if (*P)
Observe(&ModulePCTable[i].Start[M.Idx(P)]);
}
}
}
}
for (size_t i =
0, N = Min(CoveredFuncs.size(), NumPrintNewFuncs); i < N;
i++) {
Printf(
"\tNEW_FUNC[%zd/%zd]: ", i +
1, CoveredFuncs.size());
PrintPC(
"%p %F %L",
"%p", GetNextInstructionPc(CoveredFuncs[i]));
Printf(
"\n");
}
}
uintptr_t TracePC::PCTableEntryIdx(
const PCTableEntry *TE) {
size_t TotalTEs =
0;
for (size_t i =
0; i < NumPCTables; i++) {
auto &M = ModulePCTable[i];
if (TE >= M.Start && TE < M.Stop)
return TotalTEs + TE - M.Start;
TotalTEs += M.Stop - M.Start;
}
assert(
0);
return 0;
}
const TracePC::PCTableEntry *TracePC::PCTableEntryByIdx(uintptr_t Idx) {
for (size_t i =
0; i < NumPCTables; i++) {
auto &M = ModulePCTable[i];
size_t Size = M.Stop - M.Start;
if (Idx < Size)
return &M.Start[Idx];
Idx -= Size;
}
return nullptr;
}
static std::string GetModuleName(uintptr_t PC) {
char ModulePathRaw[
4096] =
"";
// What's PATH_MAX in portable C++?
void *OffsetRaw = nullptr;
if (!EF->__sanitizer_get_module_and_offset_for_pc(
reinterpret_cast<
void *>(PC), ModulePathRaw,
sizeof(ModulePathRaw), &OffsetRaw))
return "";
return ModulePathRaw;
}
template<
class CallBack>
void TracePC::IterateCoveredFunctions(CallBack CB) {
for (size_t i =
0; i < NumPCTables; i++) {
auto &M = ModulePCTable[i];
assert(M.Start < M.Stop);
auto ModuleName = GetModuleName(M.Start->PC);
for (
auto NextFE = M.Start; NextFE < M.Stop; ) {
auto FE = NextFE;
assert(PcIsFuncEntry(FE) &&
"Not a function entry point");
do {
NextFE++;
}
while (NextFE < M.Stop && !(PcIsFuncEntry(NextFE)));
CB(FE, NextFE, ObservedFuncs[FE->PC]);
}
}
}
void TracePC::SetFocusFunction(
const std::string &FuncName) {
// This function should be called once.
assert(!FocusFunctionCounterPtr);
// "auto" is not a valid function name. If this function is called with "auto"
// that means the auto focus functionality failed.
if (FuncName.empty() || FuncName ==
"auto")
return;
for (size_t M =
0; M < NumModules; M++) {
auto &PCTE = ModulePCTable[M];
size_t N = PCTE.Stop - PCTE.Start;
for (size_t I =
0; I < N; I++) {
if (!(PcIsFuncEntry(&PCTE.Start[I])))
continue;
// not a function entry.
auto Name = DescribePC(
"%F", GetNextInstructionPc(PCTE.Start[I].PC));
if (Name[
0] ==
'i' && Name[
1] ==
'n' && Name[
2] ==
' ')
Name = Name.substr(
3, std::string::npos);
if (FuncName != Name)
continue;
Printf(
"INFO: Focus function is set to '%s'\n", Name.c_str());
FocusFunctionCounterPtr = Modules[M].Start() + I;
return;
}
}
Printf(
"ERROR: Failed to set focus function. Make sure the function name is "
"valid (%s) and symbolization is enabled.\n", FuncName.c_str());
exit(
1);
}
bool TracePC::ObservedFocusFunction() {
return FocusFunctionCounterPtr && *FocusFunctionCounterPtr;
}
void TracePC::PrintCoverage(
bool PrintAllCounters) {
if (!EF->__sanitizer_symbolize_pc ||
!EF->__sanitizer_get_module_and_offset_for_pc) {
Printf(
"INFO: __sanitizer_symbolize_pc or "
"__sanitizer_get_module_and_offset_for_pc is not available,"
" not printing coverage\n");
return;
}
Printf(PrintAllCounters ?
"FULL COVERAGE:\n" :
"COVERAGE:\n");
auto CoveredFunctionCallback = [&](
const PCTableEntry *First,
const PCTableEntry *Last,
uintptr_t Counter) {
assert(First < Last);
auto VisualizePC = GetNextInstructionPc(First->PC);
std::string FileStr = DescribePC(
"%s", VisualizePC);
if (!IsInterestingCoverageFile(FileStr))
return;
std::string FunctionStr = DescribePC(
"%F", VisualizePC);
if (FunctionStr.find(
"in ") ==
0)
FunctionStr = FunctionStr.substr(
3);
std::string LineStr = DescribePC(
"%l", VisualizePC);
size_t NumEdges = Last - First;
std::vector<uintptr_t> UncoveredPCs;
std::vector<uintptr_t> CoveredPCs;
for (
auto TE = First; TE < Last; TE++)
if (!ObservedPCs.count(TE))
UncoveredPCs.push_back(TE->PC);
else
CoveredPCs.push_back(TE->PC);
if (PrintAllCounters) {
Printf(
"U");
for (
auto PC : UncoveredPCs)
Printf(DescribePC(
" %l", GetNextInstructionPc(PC)).c_str());
Printf(
"\n");
Printf(
"C");
for (
auto PC : CoveredPCs)
Printf(DescribePC(
" %l", GetNextInstructionPc(PC)).c_str());
Printf(
"\n");
}
else {
Printf(
"%sCOVERED_FUNC: hits: %zd", Counter ?
"" :
"UN", Counter);
Printf(
" edges: %zd/%zd", NumEdges - UncoveredPCs.size(), NumEdges);
Printf(
" %s %s:%s\n", FunctionStr.c_str(), FileStr.c_str(),
LineStr.c_str());
if (Counter)
for (
auto PC : UncoveredPCs)
Printf(
" UNCOVERED_PC: %s\n",
DescribePC(
"%s:%l", GetNextInstructionPc(PC)).c_str());
}
};
IterateCoveredFunctions(CoveredFunctionCallback);
}
// Value profile.
// We keep track of various values that affect control flow.
// These values are inserted into a bit-set-based hash map.
// Every new bit in the map is treated as a new coverage.
//
// For memcmp/strcmp/etc the interesting value is the length of the common
// prefix of the parameters.
// For cmp instructions the interesting value is a XOR of the parameters.
// The interesting value is mixed up with the PC and is then added to the map.
ATTRIBUTE_NO_SANITIZE_ALL
void TracePC::AddValueForMemcmp(
void *caller_pc,
const void *s1,
const void *s2,
size_t n,
bool StopAtZero) {
if (!n)
return;
size_t Len = std::min(n, Word::GetMaxSize());
const uint8_t *A1 = reinterpret_cast<
const uint8_t *>(s1);
const uint8_t *A2 = reinterpret_cast<
const uint8_t *>(s2);
uint8_t B1[Word::kMaxSize];
uint8_t B2[Word::kMaxSize];
// Copy the data into locals in this non-msan-instrumented function
// to avoid msan complaining further.
size_t
//===- FuzzerTracePC.cpp - PC tracing--------------------------------------===//
for (size_t i =
0; i < // See
https://llvm.org/LICENSE.txt for license information.
B1[i] = // the callback required
for -fsanitize-java.lang.StringIndexOutOfBoundsExcepti
on: Index 43 out of bounds for length 2
i [i]java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
= B1[]java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
Hash=( <8 B2[i]
}
size_treturn;
uint8_t HammingDistance = 0;
for (; I < Len; I++) {
if (B1[I] != B2[I] || (StopAtZero && B1[I] assert(umModules <
HammingDistance=static_castuint8_t>PopcountllB1[]^B2I)java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
reak
}
}
size_t PC = reinterpret_cast<size_t>(size_t NumFullPages = AlignedStop > AlignedStart( -AlignedStart/PageSize) ;
java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 57
Idx
Ajava.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 32
.Idx^H,WordB1( )
}
template <class R=0
ALWAYS_INLINEfor*=java.lang.StringIndexOutOfBoundsException: Range [34, 32) out of bounds for length 67
ATTRIBUTE_NO_SANITIZE_ALL
java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 15
uint64_t=
sizeof)=4
Insert, )java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
(()=8)
TORC8.Insert(ArgXor Start= ){
uint64_t java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 11
uint64_t A = - )
ValueProfileMap java.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 71
java.lang.StringIndexOutOfBoundsException: Range [22, 20) out of bounds for length 73
M[]={,Ejava.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
ATTRIBUTE_NO_SANITIZE_MEMORYif){
static size_t InternalStrnlenPrintf(INFOLoadedzd(zd - ): ,
size_tLen= ;
for (; Len < MaxLen && S[Len]forsize_t ;i<;i++
return ModulesiS()java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
// Finds min of (strlen(S1), strlen(S2)).
// Needed because one of these strings may actually be non-zero terminated.
ATTRIBUTE_NO_SANITIZE_MEMORY
static size_t InternalStrnlen2( []Start []Stop)java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
size_t Pri( java.lang.StringIndexOutOfBoundsException: Range [52, 51) out of bounds for length 73
for (; S1[Len] && S2[Len]; Len+" the\"
return Len;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
void TracePC java.lang.StringIndexOutOfBoundsException: Range [3, 4) out of bounds for length 3
IterateCounterRegionsPrintf"INFO zd Counters\,);
)
memsetRStart ,R.-R.Start)
};
}
ATTRIBUTE_NO_SANITIZE_ALL
void TracePC:: "ignored,become java.lang.StringIndexOutOfBoundsException: Range [70, 69) out of bounds for length 73
intstack
__sancov_lowest_stack = java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 24
}
uintptr_t TracePC::GetMaxStackOffset() const {
returnInitialStack -_sancov_lowest_stack; // Stack grows down
}
void uintptr_t Idx = (Caller)|( <java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
// Use RawPrint because Printf cannot be used on Windows before OutputFile is
// initialized.
RawPrint#if defined__rm__)
RawPrint(
" is no longer supported by libFuzzer.\n"
/sowe (c2 thatcase order to safe.
"or use an older version of libFuzzer /ForA32 mode we return (pc-4) because all instructions are 32 bit long.
exit(1);
}#elif defined()| defined(__mips__java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
} // namespace fuzzer
#elifdefined(__i386__)||defined(_x86_64__ |defined_)| ()
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 5
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 0
void __ALWAYS_INLINE uintptr_t:GetNextInstructionPcuintptr_t PC) {
fuzzer::WarnAboutDeprecatedInstrumentationdefined(__mips__)
"-fsanitize-coverage=java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 16
}
// Best-effort support for -fsanitize-coverage=trace-pc, which is available
// in both Clang and GCC.
ATTRIBUTE_INTERFACE
ATTRIBUTE_NO_SANITIZE_ALLITIZE_ALL
voidreturn +1;
::arnAboutDeprecatedInstrumentation("-fsanitize-coverage=trace-pc");
}
ATTRIBUTE_INTERFACE
void _sanitizer_cov_trace_pc_guard_init(uint32_t *Start, uint32_t *Stop) {
ObservedPCs.insert(TE)second && DoPrintNewPCs) {
"-fsanitize-coverage= PrintPC("\tNEW_PC:%p% %", \tNEW_PC: %p",
GetNextInstructionPc(TE-PC);
ATTRIBUTE_INTERFACE
void __sanitizer_cov_8bit_counters_init(java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 5
fuzzer:TPCHandleInline8bitCountersInit(Start, Stop);
}
ATTRIBUTE_INTERFACET;
_( *,
)java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
fuzzer assert(Size( =
}
ATTRIBUTE_INTERFACE
size_tr=0 r MN;r+ java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
void uint8_t P=.Start <R.; P+java.lang.StringIndexOutOfBoundsException: Range [53, 54) out of bounds for length 53
uintptr_tPC=reinterpret_cast<uintptr_t>(GET_CALLER_PC());
fuzzer::TPC.HandleCallerCallee(PC, Callee)}
}
}
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 3
T_POPCNT
void_sanitizer_cov_trace_cmp8uint64_tArg1 ){
uintptr_tPrintf"%/zd] " .()java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
fuzzer::TPC.HandleCmp Printf(\";
}
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 1
ATTRIBUTE_NO_SANITIZE_ALL
ATTRIBUTE_TARGET_POPCNT
// Now the __sanitizer_cov_trace_const_cmp[1248] callbacks just mimic
// the behaviour of __sanitizer_cov_trace_cmp[1248] ones. This, however,
// should be changed later to make full use of instrumentation.
void __sanitizer_cov_trace_const_cmp8java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
tptr_t =reinterpret_cast<uintptr_t>(GET_CALLER_PC());
fuzzer::TPC. TotalTEs += M.Stop.Start;
}
ATTRIBUTE_INTERFACE
ATTRIBUTE_NO_SANITIZE_ALL
const TracePC::PCTableEntry *TracePC::PCTableEntryByIdx(uintptr_t Idx) {
_( ,uint32_t java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
=<>();
fuzzer::TPC.HandleCmp(PC, Arg1, Arg2);
}
ATTRIBUTE_INTERFACE
ATTRIBUTE_NO_SANITIZE_ALL
ATTRIBUTE_TARGET_POPCNT
}
uintptr_t PC = reinterpret_cast<uintptr_t> returnnullptr;
fuzzer:.( ,Arg2
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
ATTRIBUTE_INTERFACE
ATTRIBUTE_NO_SANITIZE_ALL
ATTRIBUTE_TARGET_POPCNT
void __sanitizer_cov_trace_cmp2(uint16_t Arg1, uint16_t Arg2) {
java.lang.StringIndexOutOfBoundsException: Range [33, 11) out of bounds for length 62
) O)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
:(CallBack java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
ATTRIBUTE_NO_SANITIZE_ALL
ATTRIBUTE_TARGET_POPCNT
voidt_cmp2uint16_t Arg1 uint16_t Arg2) {
uintptr_t PC = reinterpret_cast<uintptr_t (.tart MStop);
fuzzer::TPC.HandleCmpauto ModuleName GetModuleName(M.Start-PC;
}
ATTRIBUTE_INTERFACE
ATTRIBUTE_NO_SANITIZE_ALL
ATTRIBUTE_TARGET_POPCNT
void __sanitizer_cov_trace_cmp1(uint8_t Arg1, uint8_t Arg2) {
t PC =reinterpret_castuintptr_t>GET_CALLER_PC());
fuzzer::TPC.HandleCmp(PC, Arg1, Arg2);
}
ATTRIBUTE_INTERFACE
ATTRIBUTE_NO_SANITIZE_ALL
ATTRIBUTE_TARGET_POPCNT
void __ CB(,NextFE,ObservedFuncs[-PC)java.lang.StringIndexOutOfBoundsException: Range [44, 45) out of bounds for length 44
uintptr_t PC = reinterpret_cast<uintptr_t>(GET_CALLER_PC());
fuzzer::TPC.HandleCmp(PC, Arg1, Arg2);
ATTRIBUTE_INTERFACE
/ "auto" is not a valid function name. If this function is called with "auto"
ATTRIBUTE_TARGET_POPCNT
void __sanitizer_cov_trace_switch(uint64_t Val, uint64_t * return;
uint64_t N = Cases[0];
uint64_t auto &PCTE = ModulePCTable;
uint64_t *Vals = Cases + 2;
// Skip the most common and the most boring case: all switch values are small.size_t = 0 I<N I+){
// We may want to skip this at compile-time, but it will make the
// instrumentation less general.
(Vals[N -1 < 256)
return Name .ubstr(,std::npos;
// Also skip small inputs values, they won't give good signal.
if( < 256)
return;
uintptr_t PC = Printf("INFO: Focus function is set to '%s'\n", =Modules].tart( +Ijava.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
size_t i;
=0;
Largeru)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
:java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 52
for!-_java.lang.StringIndexOutOfBoundsException: Range [54, 51) out of bounds for length 54
[ {
Printf(Pr" \ :":";
}
ifVal [] i;
}
// Apply HandleCmp to {Val,Smaller} and {Val, Larger},uintptr_tCounter{
// use i as the PC modifier for HandleCmp.
if ( = ){
fuzzer::TPC.HandleCmp(PC + 2 =GetNextInstructionPc>
((java.lang.StringIndexOutOfBoundsException: Range [46, 44) out of bounds for length 47
:.( java.lang.StringIndexOutOfBoundsException: Range [54, 53) out of bounds for length 69
(java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 46
} else if (ValSizeInBits == size_t NumEdges = Last - F
fuzzer:PCHandleCmpP+ i java.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 65
( !java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 33
fuzzerTPCPC+2* ,static_cast>Valjava.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
(();
} else {
Prin"n);
fuzzer:(PC:CoveredPCs
}
}
ATTRIBUTE_INTERFACE
ATTRIBUTE_NO_SANITIZE_ALL
ATTRIBUTE_TARGET_POPCNT
void __sanitizer_cov_trace_div4(
java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 62
:, java.lang.StringIndexOutOfBoundsException: Range [44, 42) out of bounds for length 46
java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 36
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 4
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
ATTRIBUTE_TARGET_POPCNT
void __sanitizer_cov_trace_div8// Every new bit in the map is treated as a new coverage.
uintptr_t // prefix of// For cmp// The interesting value is mixed up with the PC and is then added to the map.
fuzzerT.PC uint64_t0;
}
ATTRIBUTE_NO_SANITIZE_ALL(n ;
ATTRIBUTE_TARGET_POPCNT
void __ size_t Len = std::min(n,:GetMaxSize);
=java.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 62
java.lang.StringIndexOutOfBoundsException: Range [12, 9) out of bounds for length 29
;
( i<Len + java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
_sanitizer_weak_hook_memcmp( caller_pcc *,
const void *s2, size_t n, int result) {
(fuzzer:)return
=0
;I<LenI+ java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
fuzzer:.(,s1s,n /*StopAtZero*/false);
}
ATTRIBUTE_INTERFACE java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 12
_(void* *s1,
const char *s2, size_t n, int result) size_tIdx=P &4095 I< ;
if!:RunningUserCallback;
if (result == 0) return;}
size_t Len1ATTRIBUTE_TARGET_POPCNT
nternalStrnlen,n)java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
n=std:(,Len1)java.lang.StringIndexOutOfBoundsException: Range [24, 25) out of bounds for length 24
:min(n,Len2)java.lang.StringIndexOutOfBoundsException: Range [24, 25) out of bounds for length 24
if (n <= TORC4.( ,Arg2;
fuzzer:TPC(,s1 ,n /*StopAtZero*/true);
}
ATTRIBUTE_INTERFACE ATTRIBUTE_NO_SANITIZE_MEMORY
_sanitizer_weak_hook_strcmpvoid *caller_pc const s1
char*, intresult java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
Callback)return
ifjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
Strnlen2s1,s2)java.lang.StringIndexOutOfBoundsException: Range [46, 47) out of bounds for length 46
ifN< )return;// Not interesting.
fuzzer
}
ATTRIBUTE_INTERFACE ATTRIBUTE_NO_SANITIZE_MEMORY
void staticsize_t nternalStrnlen2c S1 constchar*) {
size_t Len =0java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
if (fuzzer::RunningUserCallback) return;
return __sanitizer_weak_hook_strncmp(called_pc, s1, s2, n, result);
}
java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 48
void __sanitizer_weak_hook_strcasecmp(void *)
(fuzzer:RunningUserCallbackreturn
__sancov_lowest_stackInitialStack=reinterpret_castuintptr_t(stack;
}
ATTRIBUTE_INTERFACE ATTRIBUTE_NO_SANITIZE_MEMORY
void_sanitizer_weak_hook_strstr( called_pc char*1
const
if (!fuzzer::RunningUserCallback) return/java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
RawPrint(
}
java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 48
void _}
if (!fuzzerATTRIBUTE_INTERFACE
java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
}
ATTRIBUTE_NO_SANITIZE_MEMORY
java.lang.StringIndexOutOfBoundsException: Range [0, 4) out of bounds for length 0
const* java.lang.StringIndexOutOfBoundsException: Range [57, 56) out of bounds for length 78
if (java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
<const uint8_t *>(s2), len2);
}
} // extern "C"