22 #include "llvm/ADT/ImmutableMap.h"
24 using namespace clang;
30 enum Kind { NO_CHROOT, ROOT_CHANGED, JAIL_ENTERED };
32 bool isRootChanged(
intptr_t k) {
return k == ROOT_CHANGED; }
42 class ChrootChecker :
public Checker<eval::Call, check::PreStmt<CallExpr> > {
45 mutable std::unique_ptr<BuiltinBug> BT_BreakJail;
48 ChrootChecker() : II_chroot(nullptr), II_chdir(nullptr) {}
50 static void *getTag() {
94 state = Mgr.
addGDM(state, ChrootChecker::getTag(), (
void*) ROOT_CHANGED);
103 const void *k = state->FindGDM(ChrootChecker::getTag());
113 if (
const StringRegion* StrRegion= dyn_cast<StringRegion>(R)) {
116 state = Mgr.
addGDM(state, ChrootChecker::getTag(),
117 (
void*) JAIL_ENTERED);
141 void *
const* k = C.
getState()->FindGDM(ChrootChecker::getTag());
147 this,
"Break out of jail",
"No call of chdir(\"/\") immediately "
150 *BT_BreakJail, BT_BreakJail->getDescription(), N));
ProgramStateRef addGDM(ProgramStateRef St, void *Key, void *Data)
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
MemRegion - The root abstract class for all memory regions.
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
ExplodedNode * addTransition(ProgramStateRef State=nullptr, const ProgramPointTag *Tag=nullptr)
Generates a new transition in the program state graph (ExplodedGraph).
One of these records is kept for each identifier that is lexed.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const FunctionDecl * getCalleeDecl(const CallExpr *CE) const
Get the declaration of the called function (path-sensitive).
i32 captured_struct **param SharedsTy A type which contains references the shared variables *param Shareds Context with the list of shared variables from the p *TaskFunction *param Data Additional data for task generation like final * state
__INTPTR_TYPE__ intptr_t
A signed integer type with the property that any valid pointer to void can be converted to this type...
Expr - This represents one expression.
const ProgramStateRef & getState() const
ExplodedNode * generateNonFatalErrorNode(ProgramStateRef State=nullptr, const ProgramPointTag *Tag=nullptr)
Generate a transition to a node that will be used to report an error.
void emitReport(std::unique_ptr< BugReport > R)
Emit the diagnostics report.
CHECKER * registerChecker()
Used to register checkers.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
SVal - This represents a symbolic expression, which can be either an L-value or an R-value...
ASTContext & getASTContext()
StringRef getString() const
const MemRegion * getAsRegion() const
StringLiteral - This represents a string literal expression, e.g.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
StringRegion - Region associated with a StringLiteral.
const LocationContext * getLocationContext() const