Paul McKenney's blog article inspired me to try apply his approach to kernel's memory allocation flags (gfp_flags) and how their combinations affect the decisions and actions taken during page allocation. Recent upstream development around these flags leads me to believe that the complexity is too high for me to reason about them and change the code without unintended changes in semantics. So it might be worth to let the computer do the hard work.

If it works out, the approach should allow to verify that changing the code doesn't result in corner cases where some flag combinations don't work as intended. Then we can attempt to e.g. reduce the number of flags and perform other cleanups without fear of breaking everything.

Of course with model checking, the not-so-surprising outcome would be that even the computer cannot handle such code complexity. Then we will at least know that even for humans it's not worth trying...

Looking for hackers with the skills:

modelchecking codeverification

This project is part of:

Hack Week 12

Activity

  • over 9 years ago: pluskalm liked this project.
  • over 9 years ago: vitezslav_cizek liked this project.
  • over 9 years ago: vbabka added keyword "modelchecking" to this project.
  • over 9 years ago: vbabka added keyword "modelchecking" to this project.
  • over 9 years ago: vbabka added keyword "codeverification" to this project.
  • over 9 years ago: vbabka started this project.
  • over 9 years ago: vbabka originated this project.

  • Comments

    Be the first to comment!

    Similar Projects

    Model checking the BPF verifier by shunghsiyu

    Project Description

    BPF verifier plays a crucial role in securing the system (though less so now that unprivileged BPF is disabled by default in both upstream and SLES), and bugs in the verifier has lead to privilege escalation vulnerabilities in the past (e.g. CVE-2021-3490).

    One way to check whether the verifer has bugs to use model checking (a formal verification technique), in other words, build a abstract model of how the verifier operates, and then see if certain condition can occur (e.g. incorrect calculation during value tracking of registers) by giving both the model and condition to a solver.

    For the solver I will be using the Z3 SMT solver to do the checking since it provide a Python binding that's relatively easy to use.

    Goal for this Hackweek

    Learn how to use the Z3 Python binding (i.e. Z3Py) to build a model of (part of) the BPF verifier, probably the part that's related to value tracking using tristate numbers (aka tnum), and then check that the algorithm work as intended.

    Resources