Abstract
The frequent tweaking of heuristics in the Linux kernel task scheduler suggests a need for formal verification, to ensure that important properties are maintained. Nevertheless, writing and verifying specifications for Linux kernel code have been considered to be impractical, leading other operating system verification efforts to propose co-design of new code and associated specifications instead. Furthermore, the Linux kernel evolves frequently, making any verification effort quickly out of date. Still, verification tools for C code are becoming more and more robust. In this paper, we explore whether it is now possible to apply formal verification directly to Linux kernel code, and to maintain the resulting specifications as the Linux kernel evolves. Our experiment focuses on the function should_we_balance, which is the gatekeeper to the Linux kernel scheduler’s load balancer, and on the verification tool Frama-C.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
- 2.
The load balancer is implemented in kernel/sched/fair.c. load_balance() was renamed sched_balance_rq() in Linux 6.10.
- 3.
for_each_cpu_and is a macro of the Linux kernel. It expands to a for loop header.
- 4.
https://zenodo.org/records/13132904 (10.5281/zenodo.13132903).
- 5.
- 6.
This predicate is actually defined as a macro, to expose the constituent properties to the SMT solvers used by Frama-C without relying on the solver to unfold predicates.
- 7.
References
Barbosa, H., et al.: cvc5: a versatile and industrial-strength SMT solver. In: Fisman, D., Rosu, G. (eds.) TACAS 2022. LNCS, vol. 13243, pp. 415–442. Springer, Cham (2022). https://doi.org/10.1007/978-3-030-99524-9_24
Barrett, C., et al.: CVC4. In: Gopalakrishnan, G., Qadeer, S. (eds.) CAV 2011. LNCS, vol. 6806, pp. 171–177. Springer, Heidelberg (2011). https://doi.org/10.1007/978-3-642-22110-1_14
Baudin, P., Filliâtre, J.-C., Marché, C., Monate, B., Moy, Y., Prevosto, V.: ACSL: ANSI/ISO C Specification Language
Bernier, T., Ziani, Y., Kosmatov, N., Loulergue, F.: Combining deductive verification with shape analysis. In: Beyer, D., Cavalcanti, A. (eds.) FASE 2024. LNCS, vol. 14573, pp. 280–289. Springer, Cham (2024). https://doi.org/10.1007/978-3-031-57259-3_14
Bertot, Y., Castéran, P.: Interactive Theorem Proving and Program Development: Coq’Art: The Calculus of Inductive Constructions. Texts in Theoretical Computer Science. An EATCS Series (TTCS), Springer, Cham (2004). https://doi.org/10.1007/978-3-662-07964-5
Bessey, A., et al.: A few billion lines of code later: using static analysis to find bugs in the real world. Commun. ACM 53(2), 66–75 (2010)
Bobot, F., Filliâtre, J.-C., Marché, C., Paskevich, A.: Why3: shepherd your herd of provers. In: Boogie 2011: First International Workshop on Intermediate Verification Languages, Wrocław, Poland, pp. 53–64 (2011). https://hal.inria.fr/hal-00790310
de Oliveira, D.B., Cucinotta, T., de Oliveira, R.S.: Efficient formal verification for the Linux kernel. In: Ölveczky, P.C., Salaün, G. (eds.) SEFM 2019. LNCS, vol. 11724, pp. 315–332. Springer, Cham (2019). https://doi.org/10.1007/978-3-030-30446-1_17
Brown, N.: Smatch: pluggable static analysis for C. Linux Weekly News (2016)
Conchon, S., Coquereau, A., Iguernlala, M., Mebsout, A.: Alt-Ergo 2.2. In: SMT Workshop: International Workshop on Satisfiability Modulo Theories, Oxford, UK (2018)
Corbet, J.: The managed resource API. Linux Weekly News (2007)
Corbet, J.: Committing to Rust for kernel code. Linux Weekly News (2023)
Corbet, J.: Scope-based resource management for the kernel. Linux Weekly News (2023)
Correnson, L., Blanchard, A., Djoudi, A., Kosmatov, N.: Automate where automation fails: proof strategies for Frama-C/WP. In: Finkbeiner, B., Kovács, L. (eds.) TACAS 2024. LNCS, vol. 14570, pp. 331–339. Springer, Cham (2024). https://doi.org/10.1007/978-3-031-57246-10.1007/978-3-031-57246-3_18
Cousot, P., Cousot, R.: Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints. In: POPL, pp. 238–252 (1977)
Cuoq, P., Kirchner, F., Kosmatov, N., Prevosto, V., Signoles, J., Yakobowski, B.: Frama-C. In: Eleftherakis, G., Hinchey, M., Holcombe, M. (eds.) SEFM 2012. LNCS, vol. 7504, pp. 233–247. Springer, Heidelberg (2012). https://doi.org/10.1007/978-3-642-33826-7_16
Efremov, D., Mandrykin, M., Khoroshilov, A.: Deductive verification of unmodified Linux kernel library functions. In: Margaria, T., Steffen, B. (eds.) ISoLA 2018. LNCS, vol. 11245, pp. 216–234. Springer, Cham (2018). https://doi.org/10.1007/978-3-030-03421-4_15
Felsing, D., Grebing, S., Klebanov, V., Rümmer, P., Ulbrich, M.: Automating regression verification. In: Automated Software Engineering (ASE), pp. 349–360 (2014)
Giet, J., Ridoux, F., Rival, X.: A product of shape and sequence abstractions. In: Hermenegildo, M.V., Morales, J.F. (eds.) SAS 2023. LNCS, vol. 14284, pp. 310–342. Springer, Cham (2023). https://doi.org/10.1007/978-3-031-44245-2_15
Godlin, B., Strichman, O.: Regression verification. In: Design Automation Conference (DAC), pp. 466–471 (2009)
Greenaway, D., Lim, J., Andronick, J., Klein, G.: Don’t sweat the small stuff: formal verification of C code without the pain. In: PLDI, pp. 429–439 (2014)
Gu, R., et al.: CertiKOS: an extensible architecture for building certified concurrent OS kernels. In: OSDI, pp. 653–669 (2016)
Jacobs, B., Smans, J., Philippaerts, P., Vogels, F., Penninckx, W., Piessens, F.: VeriFast: a powerful, sound, predictable, fast verifier for C and Java. In: Bobaru, M., Havelund, K., Holzmann, G.J., Joshi, R. (eds.) NFM 2011. LNCS, vol. 6617, pp. 41–55. Springer, Heidelberg (2011). https://doi.org/10.1007/978-3-642-20398-5_4
Kim, S., Xu, M., Kashyap, S., Yoon, J., Xu, W., Kim, T.: Finding semantic bugs in file systems with an extensible fuzzing framework. In: SOSP, pp. 207–220 (2019)
Klein, G., et al.: seL4: formal verification of an OS kernel. In: SOSP, pp. 207–220 (2009)
Lahiri, S.K., Hawblitzel, C., Kawaguchi, M., Rebêlo, H.: SYMDIFF: a language-agnostic semantic diff tool for imperative programs. In: Madhusudan, P., Seshia, S.A. (eds.) CAV 2012. LNCS, vol. 7358, pp. 712–717. Springer, Heidelberg (2012). https://doi.org/10.1007/978-3-642-31424-7_54
Lawall, J., Muller, G.: Coccinelle: 10 years of automated evolution in the Linux kernel. In: USENIX Annual Technical Conference, pp. 601–614 (2018)
Lepers, B., et al.: Provable multicore schedulers with Ipanema: application to work conservation. In: EuroSys, pp. 3:1–3:16 (2020)
Levin, R., Cohen, E.S., Corwin, W.M., Pollack, F.J., Wulf, W.A.: Policy/mechanism separation in HYDRA. In: SOSP, pp. 132–140 (1975)
Lu, S., Li, Z., Qin, F., Tan, L., Zhou, P., Zhou, Y.: Bugbench: benchmarks for evaluating bug detection tools. In: Workshop on the Evaluation of Software Defect Detection Tools (BUGS), vol. 5 (2005)
Memarian, K., et al.: Into the depths of C: elaborating the de facto standards. In: PLDI, pp. 1–15 (2016)
de Moura, L., Bjørner, N.: Z3: an efficient SMT solver. In: Ramakrishnan, C.R., Rehof, J. (eds.) TACAS 2008. LNCS, vol. 4963, pp. 337–340. Springer, Heidelberg (2008). https://doi.org/10.1007/978-3-540-78800-3_24
Miller, M.L., Goldstein, I.P.: SPADE: a grammar based editor for planning and debugging programs. MIT AI Memo, no. 386 (1976)
Palix, N., Thomas, G., Saha, S., Calvès, C., Muller, G., Lawall, J.: Faults in Linux 2.6. ACM Trans. Comput. Syst. 32(2):4:1–4:40 (2014)
Paturel, M., Subasinghe, I., Heiser, G.: First steps in verifying the seL4 core platform. In: Asia-Pacific Workshop on Systems (APSys), pp. 9–15 (2023)
Pulte, C., Makwana, D.C., Sewell, T., Memarian, K., Sewell, P., Krishnaswami, N.: CN: verifying systems C code with separation-logic refinement types. Proc. ACM Program. Lang. 7(POPL), 1–32 (2023)
Sotin, P., Rival, X.: Hierarchical shape abstraction of dynamic structures in static blocks. In: Jhala, R., Igarashi, A. (eds.) APLAS 2012. LNCS, vol. 7705, pp. 131–147. Springer, Heidelberg (2012). https://doi.org/10.1007/978-3-642-35182-2_10
Acknowledgements
We would like to thank the Frama-C team for their quick and thorough feedback throughout this work. We would like to thank Olivier Danvy and Xavier Rival for their feedback on preliminary drafts of this paper. This work was supported in part by the ANR grants VeriAMOS and EMASS.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2025 The Author(s), under exclusive license to Springer Nature Switzerland AG
About this paper
Cite this paper
Lawall, J., Nishimura, K., Lozi, JP. (2025). Should We Balance? Towards Formal Verification of the Linux Kernel Scheduler. In: Giacobazzi, R., Gorla, A. (eds) Static Analysis. SAS 2024. Lecture Notes in Computer Science, vol 14995. Springer, Cham. https://doi.org/10.1007/978-3-031-74776-2_8
Download citation
DOI: https://doi.org/10.1007/978-3-031-74776-2_8
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-031-74775-5
Online ISBN: 978-3-031-74776-2
eBook Packages: Computer ScienceComputer Science (R0)