|
Static Value-Flow Analysis
|
Detector for identifying buffer overflow issues. More...
#include <AEDetector.h>
Public Member Functions | |
| BufOverflowDetector () | |
| Constructor initializes the detector kind to BUF_OVERFLOW and sets up external API buffer overflow rules. | |
| ~BufOverflowDetector ()=default | |
| Destructor. | |
| void | updateGepObjOffsetFromBase (const ICFGNode *node, AddressValue gepAddrs, AddressValue objAddrs, IntervalValue offset) |
| Updates the offset of a GEP object from its base. | |
| void | detect (const ICFGNode *) override |
| Detect buffer overflow issues within a node. | |
| void | handleStubFunctions (const CallICFGNode *) override |
| Handles external API calls related to buffer overflow detection. | |
| void | addToGepObjOffsetFromBase (const GepObjVar *obj, const IntervalValue &offset) |
| Adds an offset to a GEP object. | |
| bool | hasGepObjOffsetFromBase (const GepObjVar *obj) const |
| Checks if a GEP object has an associated offset. | |
| IntervalValue | getGepObjOffsetFromBase (const GepObjVar *obj) const |
| Retrieves the offset of a GEP object from its base. | |
| IntervalValue | getAccessOffset (NodeID objId, const GepStmt *gep) |
| Retrieves the access offset for a given object and GEP statement. | |
| void | addBugToReporter (const AEException &e, const ICFGNode *node) |
| Adds a bug to the reporter based on an exception. | |
| void | reportBug () override |
| Reports all detected buffer overflow bugs. | |
| void | initExtAPIBufOverflowCheckRules () |
| Initializes external API buffer overflow check rules. | |
| void | detectExtAPI (const CallICFGNode *call) |
| Handles external API calls related to buffer overflow detection. | |
| bool | canSafelyAccessMemory (const ValVar *value, const IntervalValue &len, const ICFGNode *node) |
| Checks if memory can be safely accessed. | |
Public Member Functions inherited from SVF::AEDetector | |
| AEDetector () | |
| Constructor initializes the detector kind to UNKNOWN. | |
| virtual | ~AEDetector ()=default |
| Virtual destructor for safe polymorphic use. | |
| DetectorKind | getKind () const |
| Get the kind of the detector. | |
Static Public Member Functions | |
| static bool | classof (const AEDetector *detector) |
| Check if the detector is of the BUF_OVERFLOW kind. | |
Static Public Member Functions inherited from SVF::AEDetector | |
| static bool | classof (const AEDetector *detector) |
| Check if the detector is of the UNKNOWN kind. | |
Private Member Functions | |
| bool | detectStrcat (const CallICFGNode *call) |
| Detects buffer overflow in 'strcat' function calls. | |
| bool | detectStrcpy (const CallICFGNode *call) |
| Detects buffer overflow in 'strcpy' function calls. | |
Private Attributes | |
| Map< const GepObjVar *, IntervalValue > | gepObjOffsetFromBase |
| Maps GEP objects to their offsets from the base. | |
| Map< std::string, std::vector< std::pair< u32_t, u32_t > > > | extAPIBufOverflowCheckRules |
| Rules for checking buffer overflows in external APIs. | |
| Set< std::string > | bugLoc |
| Set of locations where bugs have been reported. | |
| SVFBugReport | recoder |
| Recorder for abstract execution bugs. | |
| Map< const ICFGNode *, std::string > | nodeToBugInfo |
| Maps ICFG nodes to bug information. | |
Friends | |
| class | AbstractInterpretation |
Additional Inherited Members | |
Public Types inherited from SVF::AEDetector | |
| enum | DetectorKind { BUF_OVERFLOW , NULL_DEREF , UNKNOWN } |
| Enumerates the types of detectors available. More... | |
Protected Attributes inherited from SVF::AEDetector | |
| DetectorKind | kind |
| The kind of the detector. | |
Detector for identifying buffer overflow issues.
Definition at line 139 of file AEDetector.h.
|
inline |
Constructor initializes the detector kind to BUF_OVERFLOW and sets up external API buffer overflow rules.
Definition at line 146 of file AEDetector.h.
|
default |
Destructor.
|
inline |
Adds a bug to the reporter based on an exception.
| e | The exception that was thrown. |
| node | Pointer to the ICFG node where the bug was detected. |
Definition at line 243 of file AEDetector.h.
|
inline |
Adds an offset to a GEP object.
| obj | Pointer to the GEP object. |
| offset | The interval value of the offset. |
Definition at line 198 of file AEDetector.h.
| bool BufOverflowDetector::canSafelyAccessMemory | ( | const ValVar * | value, |
| const IntervalValue & | len, | ||
| const ICFGNode * | node | ||
| ) |
Checks if memory can be safely accessed.
Checks if a memory access is safe given a specific buffer length.
| value | Pointer to the SVF var. |
| len | The interval value representing the length of the memory access. |
| node | The ICFG node providing context. |
This function ensures that a given memory access, starting at a specific value, does not exceed the allocated size of the buffer.
| as | Reference to the abstract state. |
| value | Pointer to the SVF var. |
| len | The interval value representing the length of the memory access. |
Definition at line 460 of file AEDetector.cpp.
|
inlinestatic |
Check if the detector is of the BUF_OVERFLOW kind.
| detector | Pointer to the detector. |
Definition at line 162 of file AEDetector.h.
Detect buffer overflow issues within a node.
Detects buffer overflow issues within a given ICFG node.
| as | Reference to the abstract state. |
| node | Pointer to the ICFG node. |
This function handles both non-call nodes, where it analyzes GEP (GetElementPtr) instructions for potential buffer overflows, and call nodes, where it checks for external API calls that may cause overflows.
| as | Reference to the abstract state. |
| node | Pointer to the ICFG node. |
Implements SVF::AEDetector.
Definition at line 45 of file AEDetector.cpp.
| void BufOverflowDetector::detectExtAPI | ( | const CallICFGNode * | call | ) |
Handles external API calls related to buffer overflow detection.
| as | Reference to the abstract state. |
| call | Pointer to the call ICFG node. |
This function checks the type of external memory API (e.g., memcpy, memset, strcpy, strcat) and applies the corresponding buffer overflow checks based on predefined rules.
| call | Pointer to the call ICFG node. |
Definition at line 212 of file AEDetector.cpp.
|
private |
Detects buffer overflow in 'strcat' function calls.
| call | Pointer to the call ICFG node. |
Definition at line 418 of file AEDetector.cpp.
|
private |
Detects buffer overflow in 'strcpy' function calls.
| call | Pointer to the call ICFG node. |
This function checks if the destination buffer can safely accommodate the source string being copied, accounting for the null terminator.
| as | Reference to the abstract state. |
| call | Pointer to the call ICFG node. |
Definition at line 409 of file AEDetector.cpp.
| IntervalValue BufOverflowDetector::getAccessOffset | ( | SVF::NodeID | objId, |
| const GepStmt * | gep | ||
| ) |
Retrieves the access offset for a given object and GEP statement.
| as | Reference to the abstract state. |
| objId | The ID of the object. |
| gep | Pointer to the GEP statement. |
This function calculates the access offset for a base object or a sub-object of an aggregate object (using GEP). If the object is a dummy object, it returns a top interval value.
| objId | The ID of the object. |
| gep | Pointer to the GEP statement. |
Definition at line 305 of file AEDetector.cpp.
|
inline |
Retrieves the offset of a GEP object from its base.
| obj | Pointer to the GEP object. |
Definition at line 218 of file AEDetector.h.
|
overridevirtual |
Handles external API calls related to buffer overflow detection.
Handles stub functions within the ICFG node.
| call | Pointer to the call ICFG node. |
This function is a placeholder for handling stub functions within the ICFG node.
| node | Pointer to the ICFG node. |
Implements SVF::AEDetector.
Definition at line 116 of file AEDetector.cpp.
Checks if a GEP object has an associated offset.
| obj | Pointer to the GEP object. |
Definition at line 208 of file AEDetector.h.
| void BufOverflowDetector::initExtAPIBufOverflowCheckRules | ( | ) |
Initializes external API buffer overflow check rules.
This function sets up rules for various memory-related functions like memcpy, memset, etc., defining which arguments should be checked for buffer overflows.
Definition at line 179 of file AEDetector.cpp.
|
inlineoverridevirtual |
Reports all detected buffer overflow bugs.
Implements SVF::AEDetector.
Definition at line 275 of file AEDetector.h.
| void BufOverflowDetector::updateGepObjOffsetFromBase | ( | const ICFGNode * | node, |
| SVF::AddressValue | gepAddrs, | ||
| SVF::AddressValue | objAddrs, | ||
| SVF::IntervalValue | offset | ||
| ) |
Updates the offset of a GEP object from its base.
| as | Reference to the abstract state. |
| gepAddrs | Address value for GEP. |
| objAddrs | Address value for the object. |
| offset | The interval value of the offset. |
This function calculates and stores the offset of a GEP object from its base object using the addresses and offsets provided.
| gepAddrs | The addresses of the GEP objects. |
| objAddrs | The addresses of the base objects. |
| offset | The interval value of the offset. |
Definition at line 336 of file AEDetector.cpp.
|
friend |
Definition at line 141 of file AEDetector.h.
|
private |
Set of locations where bugs have been reported.
Definition at line 328 of file AEDetector.h.
|
private |
Rules for checking buffer overflows in external APIs.
Definition at line 327 of file AEDetector.h.
|
private |
Maps GEP objects to their offsets from the base.
Definition at line 326 of file AEDetector.h.
Maps ICFG nodes to bug information.
Definition at line 330 of file AEDetector.h.
|
private |
Recorder for abstract execution bugs.
Definition at line 329 of file AEDetector.h.