journal article·2023-11-28Open access

Thetis: A Booster for Building Safer Systems Using the Rust Programming Language

Renshuang Jiang, Pan Dong, Yan Ding, Ran Wei, Zhe Jiang

Applied Sciences· Volume 13· Issue 23

Abstract

Rust is a new system-level programming language that prioritizes performance, safety, and productivity. However, as evidenced in many previous works, unsafe code fragments broadly exist in Rust projects. The use of these unsafe fragments can fundamentally violate the safety of systems developed using the programming language. In response to this problem, we propose a novel methodology (Thetis) to enhance the safety capability of Rust. The core idea of Thetis is to reduce unsafe code, encapsulate unsafe code using safety rules, and make it easier to verify unsafe code through formal means. The proposed methodology involves three main components. In the context of Rust itself, Thetis combines replacement and encapsulation for Interior Unsafe segments, minimizing unsafe fragments and reducing unsafe operations and their range. For systems developed using Rust, new ACSL formal statutes are applied to reduce the unsafe potential of the encapsulated Interior Unsafe segments, enhancing the safety of the system. Regarding the development life cycle in Rust, Thetis introduces automatic defect detection and optimization based on feature extraction, improving engineering efficiency. We demonstrate the effectiveness of Thetis by using it to fix defects in BlogOS and ArceOS. The experimental results reveal that Thetis reduces the number of unsafe operations in these OSs by 40% and 45%, respectively. The use of Miri to detect and eliminate defects in ArceOS reduces the likelihood of undefined behavior by about 50%, which effectively demonstrates that the proposed method can improve the safety of the Rust system. In addition, performance test results from LMbench show that the performance loss caused by Thetis is only 1.076%, thereby maintaining the high-performance characteristics of the Rust system.
Source: crossref · Quality: baseline

Research context

OpenAlex topics: Software Testing and Debugging Techniques · Software Reliability and Analysis Research · Software Engineering Research

SciVX discovery tags are terminology-based. OpenAlex topics are source-provided classifications.

Affiliations

College of Computer Science and Technology, National University of Defense Technology, Changsha 410073, China

Department of Engineering, University of Cambridge, Cambridge CB2 1PZ, UK

Department of Computer Science and Technology, University of Cambridge, Cambridge CB3 0FD, UK

Funding

National Natural Science Foundation of China · Pre-Research Project

References (62)

Show source-provided references
1. Gens, D., Schmitt, S., Davi, L., and Sadeghi, A.-R. (2018, January 18–21). K-Miner: Uncovering Memory Corruption in Linux. Proceedings of the 25th Annual Network and Distributed System Security Symposium, NDSS 2018, San Diego, CA, USA.10.14722/ndss.2018.23326 ↗
2. Research Situation and Prospects of Operating System Virtualization
3. (2019, May 30). Concurrency in Operating System. Available online: https://www.geeksforgeeks.org/concurrency-in-operating-system/.
4. (2023, November 13). Memory Management. Available online: https://www.tutorialspoint.com/operating_system/os_memory_management.htm.
5. Nagarakatte, S.G. (2012). Practical Low-Overhead Enforcement of Memory Safety for C Programs, University of Pennsylvania.
6. Stack Overflow (2020, January 01). Stack Overflow Developer Survey 2020. Available online: https://insights.stackoverflow.com/survey/2020#most-loved-dreaded-and-wanted.
7. Stack Overflow (2021, January 01). Stack Overflow Developer Survey 2021. Available online: https://insights.stackoverflow.com/survey/2021#most-loved-dreaded-and-wanted.
8. (2019, May 03). Rust Ownership. Available online: https://doc.rust-lang.org/book/ch04-01-what-is-ownership.html.
9. (2019, May 03). Rust Lifetime. Available online: https://doc.rust-lang.org/book/ch10-03-lifetime-syntax.html.
10. Redox (2015, January 01). The Redox Operating System [CP/OL]. Available online: https://www.redox-os.org.
11. Servo (2016, January 01). The Servo Browser Engine [CP/OL]. Available online: https://servo.org.
12. Matsakis, N.D., and Klock, F.S. (2014, January 18–21). The rust language. Proceedings of the 2014 ACM SIGAda Annual Conference on High Integrity Language Technology, Portland, NY, USA.10.1145/2663171.2663188 ↗
13. Rustsec (2021, July 07). Rustsec Advisory Database. Available online: https://github.com/RustSec/advisory-db.
14. (2023, February 09). The Rust Programming Language. Available online: https://rustwiki.org/zh-CN/book/ch19-01-unsafe-rust.html.
15. Zhu, S., Zhang, Z., Qin, B., Xiong, A., and Song, L. (2022, January 21–29). Learning and Programming Challenges of Rust: A Mixed-Methods Study. Proceedings of the ICSE’22: 44th International Conference on Software Engineering, Pittsburgh, PA, USA.10.1145/3510003.3510164 ↗
16. (2019, May 03). Rust-Book. Available online: https://www.rust-lang.org/.
17. (2007, May 06). Formal_Verification. Available online: https://en.wikipedia.org/wiki/Formal_verification.
18. Formal Verification of Hybrid System
19. A parametric analysis of the state-explosion problem in model checking10.1016/j.jcss.2005.11.003 ↗
20. Wang, J., Zhan, N.-J., Feng, X.-Y., and Liu, Z.-M. (1998). Overview of Formal Methods, Carnegie Mellon University.
21. MEBS: Uncovering Memory Life-Cycle Bugs in Operating System Kernels10.1007/s11390-021-1593-4 ↗
22. (2006, January 10). Undefined Behavior. Available online: https://en.wikipedia.org/wiki/Undefined_behavior.
23. (2023, November 08). C++ Undefined Behaviors. Available online: https://en.cppreference.com/w/cpp/language/ub.
24. (2019, January 01). A Guide to Undefined Behavior in C and C++. Available online: https://blog.regehr.org/archives/213.
25. Qin, B., Chen, Y., Yu, Z., Song, L., and Zhang, Y. (2020, January 15–20). Understanding Memory and Thread Safety Practices and Issues in Real-World Rust Programs. Proceedings of the 41st ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI’20), London, UK.10.1145/3385412.3386036 ↗
26. Qin, B. (2021). An Empirical Study on the Safety of Real-World Rust Programs, Beijing University of Posts and Telecommunications.
27. Rustbelt: Securing the foundations of the rust programming language10.1145/3158154 ↗
28. The Prusti Project: Formal Verification for Rust10.1007/978-3-031-06773-0_5 ↗
29. Leveraging Rust Types for Modular Specification and Verification10.1145/3360573 ↗
30. Fuzzing: State of the art10.1109/TR.2018.2834476 ↗
31. Jiang, J., Xu, H., and Zhou, Y. (2021, January 15–19). RULF: Rust Library Fuzzing via API Dependency Graph Traversal. Proceedings of the ASE’21: 36th IEEE/ACM International Conference on Automated Software Engineering, Melbourne, Australia.10.1109/ASE51524.2021.9678813 ↗
32. Luo, J., Liu, M., Luo, Y., Chen, Z., and Zhang, Y. (2021, January 25–28). A Runtime Monitoring Based Fuzzing Framework for Temporal Properties. Proceedings of the 32nd IEEE International Symposium on Software Reliability Engineering Workshops, ISSREW, Wuhan, China.10.1109/ISSREW53611.2021.00089 ↗
33. Symbolic execution for software testing: Three decades later10.1145/2408776.2408795 ↗
34. (2019, January 17). Rustybox. Available online: https://github.com/samuela/rustybox.
35. Chen, Z., Chen, Z., Shuai, Z., Zhang, Y., and Pan, W. (2020, January 21–25). Synthesizing smart solving strategy for symbolic execution. Proceedings of the 35th IEEE/ACM International Conference on Automated Software Engineering, Virtual.10.1145/3324884.3418904 ↗
36. Bae, Y., Kim, Y., Askar, A., Lim, J., and Kim, T. (2021, January 26–29). Rudra: Finding Memory Safety Bugs in Rust at the Ecosystem Scale. Proceedings of the SOSP’21: ACM SIGOPS 28th Symposium on Operating Systems Principles, Koblenz, Germany.10.1145/3477132.3483570 ↗
37. Li, Z., Wang, J., Sun, M., and Lui, J.C.S. (2021, January 15–19). MirChecker: Detecting Bugs in Rust Programs via Static Analysis. Proceedings of the CCS’21: 2021 ACM SIGSAC Conference on Computer and Communications Security, Virtual.10.1145/3460120.3484541 ↗
38. SafeDrop: Detecting memory deallocation bugs of rust programs via static data-flow analysis10.1145/3542948 ↗
39. (2019, May 03). The Rust Standard Library. Available online: https://doc.rust-lang.org/std/sync/struct.Mutex.html.
40. (2009, June 05). seL4. Available online: https://sel4.systems/.
41. (2019, May 22). Miri. Available online: https://github.com/rust-lang/miri.
42. Classes of recursively enumerable sets and their decision problems10.1090/S0002-9947-1953-0053041-6 ↗
43. Static analysis for security10.1109/MSP.2004.111 ↗
44. (2019, June 15). Interior Mutability. Available online: http://rcore-os.cn/rCore-Tutorial-Book-v3/chapter2/3batch-system.html#term-interior-mutability.
45. System deadlocks10.1145/356586.356588 ↗
46. (2012, January 12). RAII. Available online: https://zh.m.wikipedia.org/zh-hans/RAII.
47. Frama-C: A software analysis perspective10.1007/s00165-014-0326-7 ↗
48. (2020, October 19). ACSL and Frama-C Validation Tools. Available online: https://zhuanlan.zhihu.com/p/266701781.
49. Classification and Analysis of Ubuntu Bug Reports Based on Topic Model
50. Survey of Software Vulnerability Mining Methods Based on Machine Learning
51. Cohen, I., Huang, Y., Chen, J., Benesty, J., Benesty, J., Chen, J., and Cohen, I. (2009). Pearson correlation coefficient. Noise Reduct. Speech Process., 1–4.10.1007/978-3-642-00296-0_5 ↗
52. Myers, L., and Sirois, M.J. (2004). Spearman correlation coefficients, differences between. Encycl. Stat. Sci., 12.10.1002/0471667196.ess5050 ↗
53. Kendall rank correlation and Mann-Kendall trend test
54. (2022, May 10). KataOS. Available online: https://opensource.googleblog.com/2022/10/announcing-kataos-and-sparrow.html.
55. Alexander, B.K. (2020). Theseus: Rethinking Operating Systems Structure and State Management, Rice University.
56. (2018, June 07). Blog_os. Available online: https://github.com/phil-opp/blog_os.
57. (2019, May 03). Memory Allocation APIs. Available online: https://doc.rust-lang.org/src/std/alloc.rs.html#1-416.
58. (2022, June 01). ArceOS. Available online: https://github.com/rcore-os/arceos.
59. Controlling the sensitivity of support vector machines
60. Biffle, C.L. (2021, January 21). On Hubris and Humility: Developing an OS for Robustness in Rust. Proceedings of the Open Source Firmware Conerence 2021, Virtual.
61. McVoy, L.W., and Staelin, C. (1996, January 22–26). lmbench: Portable Tools for Performance Analysis. Proceedings of the USENIX Annual Technical Conference, San Diego, CA, USA.
62. (2019, June 15). rCore. Available online: https://github.com/rcore-os/rCore-Tutorial-v3.