Memory Safety Check for Unmanaged Code via Static Analysis
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Unmanaged programming languages lack mechanisms to prevent memory safety violations, such as spatial, temporal, and privacy issues, which can lead to security flaws and compromise code or data in distributed systems, potentially affecting multiple interconnected parties.
Innovation Solution
A method and system for performing memory safety checks on programs coded in unmanaged languages, involving static analysis to generate annotations for safe and unsafe pointers, removing safe pointers, inserting sandbox function calls at unsafe pointers, and executing the program within a sandbox framework to dynamically validate memory access using metadata and enhanced pointers.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If memory safety checks are implemented in unmanaged programming languages, then security and reliability are improved, but execution performance and productivity deteriorate due to runtime overhead
Solution Approach 1:
The memory safety mechanism is segmented into two distinct phases: a compile-time static analysis phase that performs comprehensive pointer validation without runtime overhead, and a runtime phase that only executes safety checks for pointers identified as unsafe during static analysis. This segmentation allows the system to achieve both high reliability through thorough checking and good performance by limiting runtime overhead to only necessary cases.
Solution Approach 2:
The static analysis pass performs preliminary identification and classification of safe versus unsafe pointers before runtime execution. By conducting this analysis in advance during compilation, the system prepares all necessary safety information upfront, enabling the runtime system to skip redundant checks for safe pointers and only execute validation for previously identified unsafe pointers, thus minimizing runtime performance impact.
2Reliability
If comprehensive static analysis is performed to identify all unsafe pointers, then memory safety is improved, but device complexity and analysis time increase
Solution Approach 1:
The static analysis process extracts and separates pointers into two distinct categories: safe pointers that do not require runtime checking and unsafe pointers that do require checking. This extraction simplifies the overall system complexity by identifying and removing the need for runtime analysis of safe pointers, leaving only a manageable set of unsafe pointers that require runtime validation. The analysis complexity is thus contained and focused on specific problematic cases rather than all pointers universally.
Data Source
AI summary
A method for performing a memory safety check of a program coded in an unmanaged programming language includes receiving an intermediate representation (IR) of the program and performing a static analysis pass of the IR to generate annotations including a safe pointer and an unsafe pointer. The method further includes removing, during a static analysis pass of the IR, the safe pointer from the annotations, inserting, into the IR using the annotations, a sandbox function call at the unsafe pointer to generate a modified IR, compiling the modified IR to generate an executable version of the program, executing, inside a sandbox framework, the executable version of the program, generating, during runtime and upon reaching the sandbox function call, a metadata entry and an enhanced pointer for atomicity, and comparing, during runtime and upon reaching a use of the unsafe pointer, the metadata entry with the enhanced pointer.


