arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2412.06251cs.SE
收藏

无畏的Unsafe:基于细化Safety Properties的更用户友好的Unsafe Rust编程文档

Fearless Unsafe. A More User-friendly Document for Unsafe Rust Programming Base on Refined Safety Properties

Mohan Cui, Penglei Mao, Shuran Sun, Yangfan Zhou, Hui Xu

AI总结:

本文针对Rust标准库unsafe API文档描述不统一的问题,定义了22项Safety Properties并标记438个API,重组文档并设计rust-analyzer插件辅助开发者,同时通过419个CVE和crates.io生态数据验证了其实际意义。

摘要:

Rust是一种流行的系统级编程语言,因实现运行时效率和内存安全的特性而备受关注。随着越来越多的真实项目采用Rust,理解如何协助程序员正确编写unsafe代码带来了重大挑战。根据我们的观察,当前标准库包含许多unsafe API,但它们的描述并不统一、完整和直观,特别是在描述安全要求方面。因此,我们主张建立一个系统化的安全要求类别,以修订这些文档。在本文中,我们扩展并细化了在ICSE 2024上的研究。我们定义了一个Safety Properties类别(共22项),这些类别是从标准库中unsafe API的文档中学习得出的。然后,我们标记了所有公开的unsafe API(共438个)并分析了它们的相关性。基于这些安全属性,我们重新组织了标准库中所有unsafe文档,并设计了一个集成到rust-analyzer的咨询插件,作为辅助Rust开发者编写unsafe代码的补充工具。为了验证实际意义,我们将截至2024-01-31的所有Rust CVE(共419个)的根本原因归类到安全属性中,并进一步统计了crates.io生态系统中unsafe API的真实使用情况。

英文摘要:

Rust, a popular systems-level programming language, has garnered widespread attention due to its features of achieving run-time efficiency and memory safety. With an increasing number of real-world projects adopting Rust, understanding how to assist programmers in correctly writing unsafe code poses a significant challenge. Based on our observations, the current standard library has many unsafe APIs, but their descriptions are not uniform, complete, and intuitive, especially in describing safety requirements. Therefore, we advocate establishing a systematic category of safety requirements for revising those documents. In this paper, we extended and refined our study in ICSE 2024. We defined a category of Safety Properties (22 items in total) that learned from the documents of unsafe APIs in the standard library. Then, we labeled all public unsafe APIs (438 in total) and analyzed their correlations. Based on the safety properties, we reorganized all the unsafe documents in the standard library and designed a consultation plugin into rust-analyzer as a complementary tool to assist Rust developers in writing unsafe code. To validate the practical significance, we categorized the root causes of all Rust CVEs up to 2024-01-31 (419 in total) into safety properties and further counted the real-world usage of unsafe APIs in the crates.io ecosystem.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑