Index: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp +++ lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp @@ -438,6 +438,10 @@ dyn_cast(Arg->getType().getCanonicalType().getTypePtr()); SVal Val = State->getSVal(*AddrLoc, ArgTy ? ArgTy->getPointeeType(): QualType()); + + if (auto LCV = Val.getAs()) + return C.getSymbolManager().getRegionValueSymbol(LCV->getRegion()); + return Val.getAsSymbol(); } Index: lib/StaticAnalyzer/Core/ProgramState.cpp =================================================================== --- lib/StaticAnalyzer/Core/ProgramState.cpp +++ lib/StaticAnalyzer/Core/ProgramState.cpp @@ -690,6 +690,15 @@ if (!Reg) return false; + if (const TypedValueRegion *TVR = dyn_cast(Reg)) { + SymbolRef Sym = getSymbolManager().getRegionValueSymbol(TVR); + + // We don't call isTainted(Sym, K) here because it could lead to infinite recursion. + const TaintTagType *Tag = get(Sym); + if (Tag && *Tag == K) + return true; + } + // Element region (array element) is tainted if either the base or the offset // are tainted. if (const ElementRegion *ER = dyn_cast(Reg)) @@ -720,7 +729,8 @@ // If this is a SymbolDerived with a tainted parent, it's also tainted. if (const SymbolDerived *SD = dyn_cast(*SI)) - Tainted = Tainted || isTainted(SD->getParentSymbol(), Kind); + Tainted = Tainted || isTainted(SD->getParentSymbol(), Kind) + || isTainted(SD->getOriginRegion(), Kind); // If memory region is tainted, data is also tainted. if (const SymbolRegionValue *SRV = dyn_cast(*SI)) Index: test/Analysis/taint-generic.c =================================================================== --- test/Analysis/taint-generic.c +++ test/Analysis/taint-generic.c @@ -169,6 +169,11 @@ sock = socket(AF_LOCAL, SOCK_STREAM, 0); read(sock, buffer, 100); execl(buffer, "filename", 0); // no-warning + + sock = socket(AF_INET, SOCK_STREAM, 0); + // References to both buffer and &buffer as an argument should taint the argument + read(sock, &buffer, 100); + execl(buffer, "filename", 0); // expected-warning {{Untrusted data is passed to a system call}} } int testDivByZero() {