Given there is before and after code, perhaps the translation can be automated. If the whole code base were auto-translated, what bugs could be detected and fed back to the C implementation? I'm assuming there is going to be hesitance from the FreeBSD community from migrating their codebase from C to Checked C, but that doesn't mean this work needs to come to nought. On top of bounded memory accesses, it'd be interes…
Refactoring the FreeBSD Kernel with Checked C [pdf]
21–30 of 43 posts
Re: Refactoring the FreeBSD Kernel with Checked C [pdf]
#22Earlier quoted context omitted.
It mentions "symbolic execution" of code. Does that work fine with kernel code, being that the tool itself isn't in the right ring, etc?
Symbolic execution happens before deployment, and often can be incorporated into the compilation pipeline, much like a classic static analyzer. One of the most popular implementations (at least in the FOSS community) is KLEE: https://klee.github.io/
Re: Refactoring the FreeBSD Kernel with Checked C [pdf]
#23Earlier quoted context omitted.
Symbolic execution happens before deployment, and often can be incorporated into the compilation pipeline, much like a classic static analyzer. One of the most popular implementations (at least in the FOSS community) is KLEE: https://klee.github.io/
I think the question being asked includes, "would existing symbolic execution tools be able to tell that e.g. a page-table was mangled"
But the capacity for achieving that is a function of the engine and how it integrates with the language. Similar to formal verification it's strongly computationally bound in practice, so the best results (e.g. more comprehensive coverage) are achieved when you structure your code in a way that components (functions, groups of functions, etc) can be symbolically executed individually; and when you can drop annotations in the code to narrow down value ranges that the engine can't determine itself within a reasonable amount of time. So in principle a symbolic execution engine could determine whether a page-table could be mangled, but in practice it probably wouldn't be able to definitively tell you one way or another if you simply tossed the entire FreeBSD kernel source code at such an engine.
I'm not particularly knowledgable in this space. I'm abstaining from giving a proper description of what symbolic execution actually is because I'll probably just confuse things. But I have used KLEE and even found bugs using it. It's a steep learning curve so once you get to the point where you can make use of KLEE much of the theory will begin to make sense even if you can't describe it properly ;) And if you've ever used formal verification systems, especially ones with strong language integration, things will make sense much earlier.
I don't think there's a clean dividing line between symbolic execution and static analyzers. Some modern static analysis tests and optimizations in GCC and clang could be described as employing symbolic execution. A proper symbolic execution engine can just perform such tests more comprehensively, exploring much longer, deeper control flow paths with far greater state spaces.
Re: Refactoring the FreeBSD Kernel with Checked C [pdf]
#24I've looked at some source code written in Checked C. Doesn't it possibly take away some of the pleasure of writing C?
Re: Refactoring the FreeBSD Kernel with Checked C [pdf]
#25Re: Refactoring the FreeBSD Kernel with Checked C [pdf]
#26Earlier quoted context omitted.
> the only advantage that the paper offers is that Checked C seems to have a higher degree of backwards compatibility. In fairness, that's a big deal, especially when trying to port a large existing code base.
Yes, compatibility is at least 80% of the deal with C. The "C" in C stands for compatible.
Re: Refactoring the FreeBSD Kernel with Checked C [pdf]
#27When was this paper published? Why do so many academic papers seem to omit or bury the publication date? I see the bibliography cites some papers with 2020 dates, so this paper must be from 2020 or 2021.
Published in: 2020 IEEE Secure Development (SecDev)
Date of Conference: 28-30 Sept. 2020
Date Added to IEEE Xplore: 21 October 2020
Re: Refactoring the FreeBSD Kernel with Checked C [pdf]
#28Earlier quoted context omitted.
It mentions "symbolic execution" of code. Does that work fine with kernel code, being that the tool itself isn't in the right ring, etc?
Symbolic execution happens before deployment, and often can be incorporated into the compilation pipeline, much like a classic static analyzer. One of the most popular implementations (at least in the FOSS community) is KLEE: https://klee.github.io/
https://github.com/rurban/ctl/commit/cc65e82ba1fdafcf9c83697...
cbmc found some huge bugs the testsuites were not able to find.
KLEE has similar status as Z3. Hugely popular, but rarely used in practice. Educational toys, or used in side-projects only.
Re: Refactoring the FreeBSD Kernel with Checked C [pdf]
#29Checked C appears to be a relatively recent research project from Microsoft[0][1], so I'm not sure that FreeBSD would be terribly keen on refactoring around it. There have also been many "safer C" languages before, so the only advantage that the paper offers is that Checked C seems to have a higher degree of backwards compatibility. I suppose that would allow the implementation/refactoring to gradually occur over tim…
The only alternative to it, besides improved static analyzers, is the ongoing work from CPU and OS vendors to bring hardware tagged memory into mainstream computing.
Re: Refactoring the FreeBSD Kernel with Checked C [pdf]
#30When was this paper published? Why do so many academic papers seem to omit or bury the publication date? I see the bibliography cites some papers with 2020 dates, so this paper must be from 2020 or 2021.
That really irks me. It's apparently a holdover from the days when papers were published in magazine-type journals which had an issue date. Putting a date on the paper made it clear how far behind the publisher was. Papers should now have dates on them.