@@ -227,7 +227,7 @@ static cl::opt<bool> ClKeepGoing("msan-keep-going",
227
227
228
228
static cl::opt<bool > ClPoisonStack (" msan-poison-stack" ,
229
229
cl::desc (" poison uninitialized stack variables" ),
230
- cl::Hidden, cl::init(true ));
230
+ cl::Hidden, cl::init(false ));
231
231
232
232
static cl::opt<bool > ClPoisonStackWithCall (" msan-poison-stack-with-call" ,
233
233
cl::desc (" poison uninitialized stack variables with a call" ),
@@ -239,7 +239,7 @@ static cl::opt<int> ClPoisonStackPattern("msan-poison-stack-pattern",
239
239
240
240
static cl::opt<bool > ClPoisonUndef (" msan-poison-undef" ,
241
241
cl::desc (" poison undef temps" ),
242
- cl::Hidden, cl::init(true ));
242
+ cl::Hidden, cl::init(false ));
243
243
244
244
static cl::opt<bool > ClHandleICmp (" msan-handle-icmp" ,
245
245
cl::desc (" propagate shadow through ICmpEQ and ICmpNE" ),
@@ -279,7 +279,7 @@ static cl::opt<bool> ClHandleAsmConservative(
279
279
// be zeroed. As of 2012-08-28 this flag adds 20% slowdown.
280
280
static cl::opt<bool > ClCheckAccessAddress (" msan-check-access-address" ,
281
281
cl::desc (" report accesses through a pointer which has poisoned shadow" ),
282
- cl::Hidden, cl::init(true ));
282
+ cl::Hidden, cl::init(false ));
283
283
284
284
static cl::opt<bool > ClEagerChecks (
285
285
" msan-eager-checks" ,
@@ -650,10 +650,10 @@ template <class T> T getOptOrDefault(const cl::opt<T> &Opt, T Default) {
650
650
651
651
MemorySanitizerOptions::MemorySanitizerOptions (int TO, bool R, bool K,
652
652
bool EagerChecks)
653
- : Kernel(getOptOrDefault(ClEnableKmsan, K)),
654
- TrackOrigins(getOptOrDefault(ClTrackOrigins, Kernel ? 2 : TO) ),
655
- Recover(getOptOrDefault(ClKeepGoing, Kernel || R) ),
656
- EagerChecks(getOptOrDefault(ClEagerChecks, EagerChecks) ) {}
653
+ : Kernel(false ), // BFSAN: Overwrite defaults.
654
+ TrackOrigins(false ),
655
+ Recover(true ),
656
+ EagerChecks(false ) {}
657
657
658
658
PreservedAnalyses MemorySanitizerPass::run (Function &F,
659
659
FunctionAnalysisManager &FAM) {
@@ -1208,6 +1208,8 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
1208
1208
1209
1209
// / Helper function to insert a warning at IRB's current insert point.
1210
1210
void insertWarningFn (IRBuilder<> &IRB, Value *Origin) {
1211
+ return ; // BFSAN: Ignore taint checks.
1212
+
1211
1213
if (!Origin)
1212
1214
Origin = (Value *)IRB.getInt32 (0 );
1213
1215
assert (Origin->getType ()->isIntegerTy ());
@@ -1791,6 +1793,8 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
1791
1793
// / This location will be later instrumented with a check that will print a
1792
1794
// / UMR warning in runtime if the value is not fully defined.
1793
1795
void insertShadowCheck (Value *Val, Instruction *OrigIns) {
1796
+ return ; // BFSAN: Disable checks
1797
+
1794
1798
assert (Val);
1795
1799
Value *Shadow, *Origin;
1796
1800
if (ClCheckConstantShadow) {
@@ -2323,37 +2327,8 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
2323
2327
// / Sometimes the comparison result is known even if some of the bits of the
2324
2328
// / arguments are not.
2325
2329
void handleEqualityComparison (ICmpInst &I) {
2326
- IRBuilder<> IRB (&I);
2327
- Value *A = I.getOperand (0 );
2328
- Value *B = I.getOperand (1 );
2329
- Value *Sa = getShadow (A);
2330
- Value *Sb = getShadow (B);
2331
-
2332
- // Get rid of pointers and vectors of pointers.
2333
- // For ints (and vectors of ints), types of A and Sa match,
2334
- // and this is a no-op.
2335
- A = IRB.CreatePointerCast (A, Sa->getType ());
2336
- B = IRB.CreatePointerCast (B, Sb->getType ());
2337
-
2338
- // A == B <==> (C = A^B) == 0
2339
- // A != B <==> (C = A^B) != 0
2340
- // Sc = Sa | Sb
2341
- Value *C = IRB.CreateXor (A, B);
2342
- Value *Sc = IRB.CreateOr (Sa, Sb);
2343
- // Now dealing with i = (C == 0) comparison (or C != 0, does not matter now)
2344
- // Result is defined if one of the following is true
2345
- // * there is a defined 1 bit in C
2346
- // * C is fully defined
2347
- // Si = !(C & ~Sc) && Sc
2348
- Value *Zero = Constant::getNullValue (Sc->getType ());
2349
- Value *MinusOne = Constant::getAllOnesValue (Sc->getType ());
2350
- Value *Si =
2351
- IRB.CreateAnd (IRB.CreateICmpNE (Sc, Zero),
2352
- IRB.CreateICmpEQ (
2353
- IRB.CreateAnd (IRB.CreateXor (Sc, MinusOne), C), Zero));
2354
- Si->setName (" _msprop_icmp" );
2355
- setShadow (&I, Si);
2356
- setOriginForNaryOp (I);
2330
+ setShadow (&I, getCleanShadow (&I));
2331
+ setOrigin (&I, getCleanOrigin ());
2357
2332
}
2358
2333
2359
2334
// / Build the lowest possible value of V, taking into account V's
@@ -3970,7 +3945,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
3970
3945
Sa1 = IRB.CreateOr ({IRB.CreateXor (C, D), Sc, Sd});
3971
3946
}
3972
3947
Value *Sa = IRB.CreateSelect (Sb, Sa1, Sa0, " _msprop_select" );
3973
- setShadow (&I, Sa);
3948
+ setShadow (&I, Sa0); // BFSAN: Avoid checking condition taint.
3974
3949
if (MS.TrackOrigins ) {
3975
3950
// Origins are always i32, so any vector conditions must be flattened.
3976
3951
// FIXME: consider tracking vector origins for app vectors?
@@ -4008,7 +3983,8 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
4008
3983
}
4009
3984
4010
3985
void visitGetElementPtrInst (GetElementPtrInst &I) {
4011
- handleShadowOr (I);
3986
+ setShadow (&I, getCleanShadow (&I));
3987
+ setOrigin (&I, getCleanOrigin ());
4012
3988
}
4013
3989
4014
3990
void visitExtractValueInst (ExtractValueInst &I) {
0 commit comments