SwiftSweeper: Defeating Use-After-Free Bugs Using Memory Sweeper Without Stop-the-World
Junho Ahn, Kanghyuk Lee, Chanyoung Park, Hyungon Moon, Youngjin Kwon
IEEE Symposium on Security and Privacy 2025 · Day 1 · Memory Safety
Overview
The talk "SwiftSweeper: Defeating Use-After-Free Bugs Using Memory Sweeper Without Stop-the-World," presented by Junho Ahn and co-authored by Kanghyuk Lee, Chanyoung Park, Hyungon Moon, and Youngjin Kwon at IEEE S&P, addresses one of the most persistent and critical vulnerability classes in modern software: Use-After-Free (UAF) bugs. These vulnerabilities arise when a program attempts to access memory that has been deallocated, opening a window for attackers to manipulate memory and potentially achieve control flow hijacking or arbitrary code execution. The urgency of this problem is underscored by statistics such as Google's report that over half of the high-severity bugs discovered in Google Chrome in 2022 were UAF-related.

Key moments
- 0:00 Introduction to Use-After-Free and Memory Sweeper
- 2:00 The 'Pointer Reallocation Problem' in sweepers
- 2:55 Limitations of traditional Stop-the-World approach
- 3:20 SwiftSweeper's core design: On-Demand Marking
- 4:00 On-Demand Marking workflow and Userport FD challenges
- 4:50 EBPF-based 'Express Memory Path' for page faults
- 5:55 Evaluation results: Performance and memory overhead
- 7:00 Summary: SwiftSweeper's key advantages
SwiftSweeper: Defeating Use-After-Free Bugs Using Memory Sweeper Without Stop-the-World
Speakers: Junho Ahn, Kanghyuk Lee, Chanyoung Park, Hyungon Moon, Youngjin Kwon
Conference: IEEE S&P
YouTube: https://www.youtube.com/watch?v=C-dYjb69xd0
Overview
The talk "SwiftSweeper: Defeating Use-After-Free Bugs Using Memory Sweeper Without Stop-the-World," presented by Junho Ahn and co-authored by Kanghyuk Lee, Chanyoung Park, Hyungon Moon, and Youngjin Kwon at IEEE S&P, addresses one of the most persistent and critical vulnerability classes in modern software: Use-After-Free (UAF) bugs. These vulnerabilities arise when a program attempts to access memory that has been deallocated, opening a window for attackers to manipulate memory and potentially achieve control flow hijacking or arbitrary code execution. The urgency of this problem is underscored by statistics such as Google's report that over half of the high-severity bugs discovered in Google Chrome in 2022 were UAF-related.
Traditional approaches to mitigate UAFs, particularly memory sweepers (akin to garbage collectors), often introduce significant performance penalties, most notably through "stop-the-world" pauses where all application threads are halted during memory reclamation. This limitation makes them unsuitable for performance-critical applications like databases or high-throughput web servers. SwiftSweeper proposes a novel solution that eliminates these disruptive pauses by introducing on-demand marking and an efficient eBPF-based custom page fault handler called Express Memory Path.
This article delves into SwiftSweeper's innovative architecture, explaining how it achieves robust UAF prevention without compromising application performance or scalability. It highlights the technical challenges faced by existing memory safety mechanisms and details SwiftSweeper's approach to overcome them, offering a compelling case for its adoption in environments demanding both high security and high performance in unsafe memory languages.
Background
▶ Watch: Introduction to Use-After-Free and Memory Sweeper (0:00)
To understand SwiftSweeper's contribution, it's essential to grasp the nature of Use-After-Free (UAF) vulnerabilities and the existing landscape of memory safety mechanisms. A UAF bug occurs in several stages: first, an object is allocated in memory; second, the object is freed, and its memory is returned to the allocator; third, a dangling pointer, still holding the address of the freed memory, is used to access that memory. While this might seem benign in a simple scenario, a malicious attacker can exploit this window. After the memory is freed, it might be reallocated for a different purpose or object. If the attacker can control the contents of this reallocated memory, the subsequent "use-after-free" access via the dangling pointer can lead to various malicious actions, including control flow hijacking, where the attacker redirects program execution, or arbitrary code execution. The prevalence and severity of UAFs, as evidenced by their dominance in critical Chrome vulnerabilities, underscore the urgent need for effective mitigation strategies.
One prominent approach to prevent UAFs is the memory sweeper, which operates conceptually similar to a garbage collector. When an object is "freed" by the application, a memory sweeper doesn't immediately return the memory to the system for reuse. Instead, it temporarily stores the object in a designated "zone." When a new memory allocation request comes in, the sweeper assigns a new pointer to a fresh memory location, ensuring that any existing dangling pointers still pointing to the old, "freed" memory will not inadvertently access newly allocated data. This mechanism prevents the core UAF problem by breaking the link between old pointers and new memory uses.
A key component of memory sweepers is the marking phase, often part of a mark-and-sweep algorithm. During marking, the sweeper scans the program's pointer space to identify all objects that are still "referenced" or reachable from active pointers. If an object has at least one valid reference, it is "marked." Conversely, objects that are not marked are considered unreachable and can be safely reclaimed and reused. For example, if Object 1 is referenced by Pointer P, Object 1 is marked. If Object 3 has no references, it remains unmarked and is eventually reclaimed.
However, traditional mark-and-sweep memory sweepers suffer from a critical flaw known as the pointer re-allocation problem. If the application threads continue to run while the memory sweeper is performing its marking phase, pointers can change or be re-assigned. This concurrency issue can lead to incorrect marking. For instance, Object 2 might be marked as referenced by Pointer R, but if Pointer R is subsequently reassigned or Object 2 is freed and its memory reallocated before the marking phase completes, the sweeper might erroneously consider Object 2 as still in use. This can lead to the sweeper reclaiming memory that is still genuinely in use, or, more commonly, failing to reclaim memory that is no longer needed, leading to memory leaks or, in the worst case, a UAF if a dangling pointer is used after the memory is mistakenly reclaimed.
To mitigate the pointer re-allocation problem and guarantee atomic, safe reclamations, traditional memory sweepers employ a stop-the-world (STW) mechanism. This involves pausing all application threads before initiating the marking phase. Once marking is complete, all threads are resumed. While STW ensures correctness by preventing any changes to the pointer graph during the critical marking operation, it introduces severe limitations. The most significant is the application latency caused by these pauses, which can be detrimental to performance-critical systems such as real-time databases, high-frequency trading platforms, or interactive web services. Existing research has attempted to mitigate STW by increasing overall marking time or skipping dirty pages, but these approaches often introduce their own overheads, such as increased dispatch durations or the computational cost of traversing compressed memory management stacks.
SwiftSweeper's core motivation is to address these fundamental limitations. It aims to redesign memory sweeping for performance-critical applications in unsafe memory languages by eliminating STW pauses through on-demand marking and overcoming the performance challenges of such a design using an efficient eBPF-based custom page fault handler, which they term Express Memory Path.
Key Findings
▶ Watch: Limitations of traditional Stop-the-World approach (2:55)
SwiftSweeper's research delivers several key findings that collectively represent a significant advancement in the field of memory safety, particularly for systems written in unsafe memory languages where Use-After-Free (UAF) vulnerabilities are prevalent. The primary contributions and findings can be summarized as follows:
- Elimination of Stop-the-World (STW) Pauses: SwiftSweeper successfully eliminates the disruptive STW pauses inherent in traditional memory sweepers. This is achieved through the implementation of on-demand marking, a novel approach where memory pages are marked only when an application thread attempts to access them. This fundamental design change ensures that application threads can continue execution without interruption, making SwiftSweeper suitable for high-throughput and low-latency environments.
- Efficient On-Demand Marking with Express Memory Path: The potential performance overhead of on-demand marking, which could otherwise be high due to frequent page fault handling, is effectively mitigated by the Express Memory Path. This innovation involves implementing the core page fault handling logic directly within the kernel space using eBPF (Extended Berkeley Packet Filter). By leveraging eBPF, SwiftSweeper bypasses the inefficiencies and latency associated with user-level page fault handling mechanisms like
userfaultfd, ensuring minimal overhead and efficient operation.
- Superior Performance and Scalability: Through extensive evaluations against benchmarks like SPEC CPU 2006 and the Apache web server, SwiftSweeper (referred to as "CC" in the presentation) demonstrates significantly improved performance and scalability compared to other memory safety solutions.
- In SPEC CPU 2006, SwiftSweeper exhibits the lowest performance overhead among the compared systems.
- For the Apache web server, SwiftSweeper maintains similar throughput scalability to a traditional Garbage Collector (GC), even as the number of concurrent connections increases. This contrasts sharply with other marking-based sweepers that show dramatic performance decrements due to thread interference.
- Low Memory Overhead: SwiftSweeper achieves its performance gains without incurring excessive memory overhead. Evaluations show that SwiftSweeper maintains similar memory overhead to a traditional Garbage Collector (GC). This is a crucial advantage over other advanced sweepers like MySweeper and Hushback, which demonstrated two to three times higher memory overhead due to their strategies of delaying garbage collection for performance or scalability.
In essence, SwiftSweeper's key finding is the successful demonstration of a memory safety solution that simultaneously delivers high performance, low memory overhead, and excellent scalability—a combination previously elusive in the domain of UAF prevention for unsafe memory languages. It provides a practical and robust mechanism to enhance security in critical applications without the prohibitive costs of traditional methods.
Technical Deep Dive
▶ Watch: On-Demand Marking workflow and Userport FD challenges (4:00)
SwiftSweeper's technical ingenuity lies in its two-pronged approach to overcoming the limitations of traditional memory sweepers: On-Demand Marking and the Express Memory Path utilizing eBPF.
On-Demand Marking Workflow
The fundamental idea behind on-demand marking is to defer the marking process until a memory page is actually accessed by the application. This eliminates the need for a global "stop-the-world" pause. The workflow proceeds as follows:
- Initial State: When SwiftSweeper is initialized, the entire memory space is conceptually placed into "unmarked regions." This means that all memory pages are initially considered "unmarked" and potentially subject to reclamation.
- Accessing Unmarked Memory: If an application thread attempts to access an object residing on a page within an "unmarked region," this access triggers a page fault. This fault is a signal that the memory region needs attention before it can be safely used.
- Custom Page Fault Handling: The operating system intercepts this page fault and delegates it to SwiftSweeper's custom page fault handler. This handler is the core of the on-demand marking mechanism.
- Page Marking: Inside the custom handler, SwiftSweeper performs the marking operation. Crucially, it marks the entire page that contains the accessed pointer. This is a coarse-grained but efficient approach, as marking a full page is faster than granular object-by-object marking. Once marked, the page is considered safe for access.
- Moving to Marked Regions: After the page is marked, it is conceptually moved from the "unmarked regions" to the "marked regions."
- Subsequent Accesses: Any subsequent accesses to objects within this now-marked page will not trigger further page faults. This ensures "only one invocation per page," meaning the overhead of marking is incurred only once per page, when it's first accessed after a potential reclamation cycle.
This on-demand approach ensures that all pointers within a page are marked as valid before they are used, effectively preventing Use-After-Free scenarios without requiring application-wide pauses. The marking process happens dynamically, driven by application memory access patterns.
Overcoming User-Level Page Fault Interception Limitations
Implementing on-demand marking efficiently requires intercepting page faults at a low level. A common mechanism for user-level page fault control in Linux is userfaultfd (UFD). userfaultfd allows a user-space process to register for and handle page faults from another process or even its own. While userfaultfd offers fine-grained control, the SwiftSweeper team identified two significant limitations that would hinder the performance of their on-demand marking:
- Rout Issues (Single-Threaded Bottleneck):
userfaultfdis fundamentally single-threaded. When multiple application threads concurrently trigger page faults, they all queue up, waiting for the singleuserfaultfdhandler thread to process them. This creates a severe bottleneck, leading to significant delays and reducing overall application throughput. In a highly parallel application, this queuing would negate the benefits of eliminating stop-the-world pauses. - Low Performance Issues (Context Switching and Copying Overhead): Handling page faults via
userfaultfdinvolves frequent context switching between the kernel and the user-spaceuserfaultfdhandler. Each page fault requires the kernel to wake up the user-space handler, which then processes the fault and communicates back to the kernel. Furthermore, there's memory copying overhead associated with passing arguments and data between kernel and user space for each fault. These overheads, when multiplied by the potentially numerous page faults in an on-demand marking system, would severely degrade performance.
SwiftSweeper's Solution: Express Memory Path with eBPF
To address these critical limitations, SwiftSweeper introduces the Express Memory Path, a novel approach that moves the core page fault handling logic directly into the kernel space using Extended Berkeley Packet Filter (eBPF).
eBPF is a powerful, sandboxed virtual machine within the Linux kernel that allows developers to run custom programs safely and efficiently inside the kernel without modifying kernel source code or loading kernel modules. It is widely used for network packet filtering, tracing, and security enforcement. SwiftSweeper leverages eBPF to:
- Handle Page Faults Directly in the Kernel: By injecting the on-demand marking logic as an eBPF program into the kernel, SwiftSweeper can process page faults directly at the kernel level. This eliminates the need for context switches to user space that plague
userfaultfd. When a page fault occurs, the eBPF program is triggered, marks the page, and allows the application thread to resume almost immediately. - Avoid User-App Delays: The direct kernel-level execution of the marking logic means that SwiftSweeper avoids "additional delay introduced by the user app" and the associated memory copying overhead. The eBPF program operates in a highly privileged and efficient environment, ensuring minimal latency for each page fault.
The use of eBPF for the Express Memory Path is a critical innovation. It provides the necessary performance and concurrency to make on-demand marking practical and efficient. While the talk briefly mentions "safety mechanism, automation technique and API design," the core technical contribution is the strategic deployment of eBPF to achieve high-performance, kernel-level page fault handling for memory safety. This architecture allows SwiftSweeper to achieve its goal of defeating UAF bugs without the performance penalties traditionally associated with memory sweepers.
Demo / Proof of Concept
▶ Watch: EBPF-based 'Express Memory Path' for page faults (4:50)
The talk presented a comprehensive evaluation section, serving as the proof of concept for SwiftSweeper's claims of high performance, low memory overhead, and good scalability. The evaluation compared SwiftSweeper (referred to as "CC" in the results) against several existing memory safety solutions: FFMO, Marker, MySweeper, Hushback, and a baseline Garbage Collector (GC), which likely represents a traditional mark-and-sweep approach with its inherent characteristics.
The evaluation focused on three key metrics: performance overhead, memory overhead, and scalability, using two distinct benchmarks:
- SPEC CPU 2006 Benchmarks:
- Performance Overhead: SwiftSweeper demonstrated the lowest performance overhead among the compared solutions in SPEC CPU 2006. This indicates its efficiency in general-purpose computational workloads, where the overhead introduced by memory safety mechanisms can significantly impact execution time.
- Memory Overhead (FFMO Comparison): The presenter noted that FFMO, another comparison point, suffered from the "largest memory overhead" because it utilizes a "one-time allocator" mechanism. This highlights a trade-off where some solutions might gain performance by simplifying memory management but at the cost of significantly increased memory consumption. SwiftSweeper, in contrast, aimed for a balanced approach.
- Apache Web Server Evaluation:
- Throughput and Scalability: The evaluation on the Apache web server focused on throughput as the number of concurrent connections increased. This scenario is crucial for assessing how well a memory safety solution scales under heavy load in a real-world, performance-critical application.
- The "Marker" solution exhibited "dramatic performance decrementations" as concurrent connections increased. This was attributed to the interference between its marking threads and the application threads, a common problem for traditional sweepers that lack efficient concurrency handling.
- SwiftSweeper, however, demonstrated "similar scalability with GC" (Garbage Collector). This is a significant finding, as it indicates that SwiftSweeper can maintain high throughput and effectively handle increasing loads without the performance degradation seen in other marking-based approaches, all while preventing UAFs.
- Memory Overhead: In terms of memory consumption with the Apache web server, SwiftSweeper showed "similar memory overhead with GC." This is a notable achievement when compared to MySweeper and Hushback, which showed "about two to three times much more memory overhead" than SwiftSweeper. MySweeper and Hushback often delay garbage collection to improve performance or scalability, but this strategy inevitably leads to higher memory footprints. SwiftSweeper's ability to achieve high performance and scalability with memory overhead comparable to a traditional garbage collector underscores its efficiency.
In summary, the evaluation results conclusively demonstrated that SwiftSweeper (CC) stands out by simultaneously achieving high performance, less memory overhead, and good scalability across diverse workloads. This comprehensive proof of concept validates its design principles and positions it as a robust solution for UAF prevention in demanding application environments.
Defensive Implications
▶ Watch: Summary: SwiftSweeper's key advantages (7:00)
SwiftSweeper presents significant defensive implications for developers, security architects, and system administrators operating in environments where Use-After-Free (UAF) vulnerabilities are a constant threat, particularly in unsafe memory languages like C and C++.
- Robust UAF Mitigation without Performance Penalties: The most direct implication is the availability of a robust mechanism to mitigate UAF bugs without incurring the severe performance penalties associated with traditional stop-the-world (STW) garbage collection or memory sweeping. For critical infrastructure, databases, high-performance computing, or web servers where STW pauses are unacceptable, SwiftSweeper offers a viable path to enhance memory safety without sacrificing application responsiveness or throughput. This directly translates to a reduced attack surface for a prevalent and high-severity vulnerability class.
- Enhanced Security Posture for Performance-Critical Applications: Organizations can deploy performance-critical applications with a significantly improved security posture. By integrating or adopting systems that incorporate SwiftSweeper's principles, they can prevent a large category of memory corruption exploits that attackers frequently leverage for control flow hijacking, privilege escalation, or arbitrary code execution. This is particularly relevant for applications handling sensitive data or operating in hostile network environments.
- Leveraging eBPF for Kernel-Level Security: SwiftSweeper's reliance on eBPF (Extended Berkeley Packet Filter) for its Express Memory Path highlights the growing potential of eBPF in security. Defenders should recognize eBPF as a powerful tool for implementing highly efficient, kernel-level security mechanisms without the risks of traditional kernel modules. This could inspire further research and development into eBPF-based solutions for other classes of vulnerabilities or for dynamic security policy enforcement.
- Informing Future Memory Allocator and Runtime Designs: For developers working on operating system kernels, custom memory allocators, or language runtimes, SwiftSweeper provides a blueprint for building more secure foundations. The principles of on-demand marking and efficient kernel-level page fault handling can guide the design of next-generation memory management systems that are secure by default, rather than relying on reactive patching.
- Reduced Operational Overhead and Incident Response: By proactively preventing UAFs, organizations can reduce the operational overhead associated with identifying, patching, and responding to security incidents stemming from these vulnerabilities. Less time spent on reactive security measures means more resources can be allocated to proactive security development and innovation.
In essence, SwiftSweeper offers a compelling, practical solution to a long-standing security challenge. Its adoption would allow defenders to strengthen their defenses against a critical attack vector, particularly in performance-sensitive contexts, by providing memory safety that is both effective and non-intrusive.
Key Takeaways
- Use-After-Free (UAF) vulnerabilities are a critical and pervasive threat, accounting for a significant portion of high-severity bugs in modern software (e.g., over 50% in Google Chrome in 2022).
- Traditional memory sweepers prevent UAFs but often rely on stop-the-world (STW) pauses, which severely impact the performance and scalability of critical applications like databases and web servers.
- SwiftSweeper introduces on-demand marking to eliminate STW pauses, marking memory pages only when they are accessed, thus allowing application threads to run continuously.
- The Express Memory Path, implemented using eBPF (Extended Berkeley Packet Filter), efficiently handles page faults directly within the kernel. This bypasses the performance bottlenecks and context switching overhead of user-level solutions like
userfaultfd. - Evaluations on SPEC CPU 2006 and Apache web server demonstrate SwiftSweeper's superior performance (lowest overhead), low memory consumption (similar to GC), and excellent scalability compared to existing memory safety mechanisms.
- SwiftSweeper provides a robust, high-performance, and scalable solution for defeating UAF bugs, offering a practical path to enhance memory safety in performance-critical applications written in unsafe memory languages.
About the Speaker(s)
The talk "SwiftSweeper: Defeating Use-After-Free Bugs Using Memory Sweeper Without Stop-the-World" was presented by Junho Ahn. He is listed as a co-author alongside Kanghyuk Lee, Chanyoung Park, Hyungon Moon, and Youngjin Kwon. While the transcript does not provide specific titles or affiliations for the speakers, their collective work on such a technically deep and impactful topic presented at a prestigious conference like IEEE S&P suggests their expertise in systems security, memory management, and low-level programming. Junho Ahn led the presentation, detailing the core concepts and evaluation results of their SwiftSweeper project.