Although Rust primarily intends to be a safe programming language that excludes undefined behaviour, it provides its users with the escape hatch of unsafe Rust, allowing them to circumvent some of its strong compile-time checks. This additional freedom has some advantages, including potentially more efficient code, which is one of the main reasons why unsafe code is used extensively throughout Rust's standard library. However, because unsafe code also re-opens the door to undefined behaviour, Amazon has convened a community to verify the safety of the standard library, and in particular the unsafe code contained therein. Given that this effort is done in public, is open-sourced, and has seen significant participation (from at least 50 different contributors), we have access to a wealth of information on how people are verifying the standard library, as well as what is currently possible and what still appears to be beyond the state of the art for verified software. In this paper, we discuss the lessons learned thus far from this verification effort, from both our work on it, as well as that of the broader community. In particular, we start by reviewing what has been accomplished thus far, as well as the main tools used (specifically, their advantages and their limitations). We then focus on some of the remaining fundamental obstacles to verifying the standard library, and propose potential solutions to overcome them. We hope that these observations can guide future verification of not only the standard library, but also unsafe Rust code in general.
翻译:尽管 Rust 主要旨在成为一种排除未定义行为的安全编程语言,但它为用户提供了不安全 Rust 这一“逃生舱口”,允许其绕过某些严格的编译时检查。这种额外的自由具有一些优势,包括可能实现更高效的代码,这也是不安全代码在 Rust 标准库中被广泛使用的主要原因之一。然而,由于不安全代码也重新开启了未定义行为的大门,亚马逊召集了一个社区来验证标准库的安全性,特别是其中包含的不安全代码。鉴于此项工作公开进行、开源,并已获得广泛参与(来自至少 50 位不同的贡献者),我们能够获取大量关于人们如何验证标准库的信息,以及当前可实现的技术边界和仍超出验证软件现有技术水平的部分。本文中,我们讨论了从这项验证工作(包括我们自身及更广泛社区的工作)中迄今获得的经验教训。具体而言,我们首先回顾目前已完成的成果,以及所使用的主要工具(特别是其优势和局限性)。随后,我们聚焦于验证标准库仍面临的一些根本性障碍,并提出潜在的解决方案以克服它们。我们希望这些观察不仅能指导标准库的未来验证工作,也能为一般性的不安全 Rust 代码验证提供方向。