LLM Assistance for Memory Safety
J. Nausheen Mohammed, Akash Lal, Aseem Rastogi, Rahul Sharma, Subhajit Roy
摘要
Memory safety violations in low-level code, written in languages like C, continues to remain one of the major sources of software vulnerabilities. One method of removing such violations by construction is to port C code to a safe C dialect. Such dialects rely on programmer-supplied annotations to guarantee safety with minimal runtime overhead. This porting, however, is a manual process that imposes significant burden on the programmer and, hence, there has been limited adoption of this technique. The task of porting not only requires inferring annotations, but may also need refactoring/rewriting of the code to make it amenable to such annotations. In this paper, we use Large Language Models (LLMs) towards addressing both these concerns. We show how to harness LLM capabilities to do complex code reasoning as well as rewriting of large codebases. We also present a novel framework for whole-program transformations that leverages lightweight static analysis to break the transformation into smaller steps that can be carried out effectively by an LLM. We implement our ideas in a tool called MSA that targets the CheckedC dialect. We evaluate MSA on several microbenchmarks, as well as real-world code ranging up to 20K lines of code. We showcase superior performance compared to a vanilla LLM baseline, as well as demonstrate improvement over a stateof-the-art symbolic (non-LLM) technique. • We present MSA, the first LLM-based assistant for porting C to Checked-C. MSA performs transformations that are out-of-reach of existing (symbolic-only) assistants. • We present a novel recipe for breaking a whole program transformation into smaller tasks that can fit into LLM prompts. • We evaluate MSA on real world C-programs, ranging up to 20K lines of code, showing that it can successfully infer 86% of the required annotations correctly. We plan to open-source the implementation of MSA, along with all the prompt templates that it uses. 1 The rest of this paper is organized as follows. Section II provides a background on Checked C, followed by examples that illustrate the challenges of the porting process from C code. Section III provides background on the state-of-the-art symbolic tool for Checked C inference. Our technical contributions follow next. We provide our generic recipe for whole program transformations using LLMs (Section IV) and then we show how MSA instantiates this recipe to overcomes the challenges in the porting process (Section V). We evaluate MSA (Section VI), discuss threats to validity (Section VII), and survey related work (Section VIII).
问问这篇 Paper
智能体会读完全文。
Lune 把这篇 Paper 索引到了最后一个公式,引用它的顶会 Paper 也一样。你提问,回答直接引用原文。
引用它的顶会 Paper4
- Verification Modulo Tested Library ContractsAbhishek Uppar, Omar Muhammad, Sumanth Prabhu S, Deepak D'Souza 等PLDI 2026 · 被引用 1 次
- Cpp2Rust: Automatic Translation of C++ to Safe RustLucian Popescu, Francisco Gouveia, Henrique Preto, João Silveira 等PLDI 2026 · 被引用 1 次
- Adding Spatial Memory Safety to EDK II through Checked C (Experience Paper)Sourag Cherupattamoolayil, Arunkumar Bhattar, Connor Glosner, Aravind MachiryISSTA 2025
- LLM-Based Repair of Static Nullability ErrorsNima Karimipour, Pascal Joos, Michael Pradel, Martin Kellogg 等ISSTA 2026
它引用的顶会 Paper9
- RepoBench: Benchmarking Repository-Level Code Auto-Completion SystemsTianyang Liu, Canwen Xu, Julian J. McAuleyICLR 2024 · 被引用 338 次
- Automated Program Repair in the Era of Large Pre-trained Language ModelsChunqiu Steven Xia, Yuxiang Wei, Lingming ZhangICSE 2023 · 被引用 321 次
- CodeGen: An Open Large Language Model for Code with Multi-Turn Program SynthesisErik Nijkamp, Bo Pang, Hiroaki Hayashi, Lifu Tu 等ICLR 2023 · 被引用 234 次
- Synchromesh: Reliable Code Generation from Pre-trained Language ModelsGabriel Poesia, Alex Polozov, Vu Le, Ashish Tiwari 等ICLR 2022 · 被引用 200 次
- Retrieval-Based Prompt Selection for Code-Related Few-Shot LearningNoor Nashid, Mifta Sintaha, Ali MesbahICSE 2023 · 被引用 156 次
相关 Paper
- SmartC2Rust: Iterative, Feedback-Driven C-to-Rust Translation via Large Language Models for Safety and EquivalenceMomoko Shiraishi, Yinzhi Cao, Takahiro ShinagawaICSE 2026 · 被引用 4 次
- RustAssure: Differential Symbolic Testing for LLM-Transpiled C-to-Rust CodeYubo Bai, Tapti PalitASE 2025 · 被引用 8 次
- NESA: Relational Neuro-Symbolic Static Program AnalysisChengpeng Wang, Yifei Gao, Wuqi Zhang, Xuwei Liu 等FSE 2026 · 被引用 1 次
- C to checked C by 3cAravind Machiry, John H. Kastner, Matt McCutchen, Aaron Eline 等OOPSLA 2022 · 被引用 20 次
- RustAssistant: Using LLMs to Fix Compilation Errors in Rust CodePantazis Deligiannis, Akash Lal, Nikita Mehrotra, Rishi Poddar 等ICSE 2025 · 被引用 6 次
