Detecting Potentially Clobbered Variables due to the Use of Nonlocal Jumps Functions
https://doi.org/10.15514/ISPRAS-2023-35(6)-7
Abstract
The reason of undefined behavior is source code written in violation of the C language standard. Undefined behavior leads to vulnerabilities in software. One of the common sources of undefined behavior is an incorrect use of functions for nonlocal jumps (in particular setjmp and longjmp). This paper considers the means of detecting this type of undefined behavior which are implemented in the major modern compilers (GCC, Clang, MSVC). We conclude that these means either have significant disadvantages or are absent in some compilers. This paper presents the implementation of a new method of compiler warning of the considered undefined behavior. The described method is accurate enough for practical application on real projects. We consider the advantages of the proposed solution over similar existing ones.
About the Authors
Nikita Yurievich SHUGALEYRussian Federation
Senior laboratory technician of the Department of system programming of the Moscow Institute of Physics and Technology. Research interests: compiler technologies, software security, methods of static code analysis, program optimization.
Vladislav Anatolevich IVANISHIN
Russian Federation
Researcher at the Compiler Department of the Institute for System Programming of the RAS. Research interests include compiler technologies, operating systems, software security, methods of static code analysis, and program optimization.
Alexander Vladimirovich MONAKOV
Russian Federation
Researcher at the Compiler Department of the Institute for System Programming of the RAS. Research interests: compiler technologies, program optimization.
References
1. C11 Standard ISO/IEC 9899:2011 // Programming language – C. – 2011. – P. 561. – International standard.
2. Herity, Dominic. C++ in embedded systems: Myth and reality / Dominic Herity // Embedded Systems Programming. – 1998. – Vol. 11, no. 2. – Pp. 48–71.
3. ISO/IEC/IEEE 9945:2009 // Portable Operating System Interface (POSIX®) Base Specifications, Issue 7. – 2009. – P. 37. – International standard.
4. Xu, Xiao. Research on coroutine-based process interaction simulation mechanism in c++ / Xiao Xu, Ge Li // AsiaSim 2012: Asia Simulation Conference 2012, Shanghai, China, October 27-30, 2012. Proceedings, Part III / Springer. – 2012. – Pp. 178–187.
5. Baev, Roman Vyacheslavovich. Prevention of vulnerabilities arising from optimization of code with Undefined Behavior / Roman Vyacheslavovich Baev, Leonid Vladlenovich Skvortsov, Evgeny Alekseevich Kudryashov, Ruben Arturovich Buchatskiy, Roman Aleksandrovich Zhuykov // Proc. Inst. Syst. Program. RAS. – 2021. – Vol. 33, no. 4. – Pp. 195–210.
6. Novillo, Diego. GCC Internals-Internal Representations / Diego Novillo // GCC IR-2. – 2007.
7. The internals of the GNU compilers. – Аccessed: 2023-11-04. Available at:https://gcc.gnu.org/onlinedocs/gccint/.
8. Merrill, Jason. Generic and gimple: A new tree representation for entire functions / Jason Merrill // Proceedings of the 2003 GCC Summit. – 2003. – Pp. 171–180.
9. /10/11/12 Regression] clobbered by longjmp warning ignores the data flow // Bug 21161, GCC. – Аccessed: 2023-11-04. Available at: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=21161.
10. Aho, Alfred V. Compilers: principles, techniques, and tools / Alfred V Aho, Ravi Sethi, Jeffrey D Ullman // Addison-wesley Reading – 2007. – Vol. 2. - Pp. 399 - 410.
11. Jambor, Martin. The new intraprocedural scalar replacement of aggregates / Martin Jambor //GCC Developers’ Summit. – 2010. – Vol. 47.
12. Tarjan, Robert. Depth-first search and linear graph algorithms / Robert Tarjan // SIAM journal on computing. – 1972. – Vol. 1, no. 2. – Pp. 146–160.
13. Haghighat, Mohammad R. Symbolic analysis for parallelizing compilers / Mohammad R Haghighat. No. 1880. – Springer Science & Business Media, 1995.
Review
For citations:
SHUGALEY N.Yu., IVANISHIN V.A., MONAKOV A.V. Detecting Potentially Clobbered Variables due to the Use of Nonlocal Jumps Functions. Proceedings of the Institute for System Programming of the RAS (Proceedings of ISP RAS). 2023;35(6):121-134. (In Russ.) https://doi.org/10.15514/ISPRAS-2023-35(6)-7