Live data from Hacker News

Refactoring the FreeBSD Kernel with Checked C [pdf]

cs.rochester.edu

21–30 of 43 posts

Re: Refactoring the FreeBSD Kernel with Checked C [pdf]

#21
post #20

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…

Slightly tangential, I am under the impression that the CHERI project has actually identified security bugs and reported them back to FreeBSD.

https://www.cl.cam.ac.uk/research/security/ctsrd/cheri/

Re: Refactoring the FreeBSD Kernel with Checked C [pdf]

#22
post #18
post #17

Earlier 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/

I think the question being asked includes, "would existing symbolic execution tools be able to tell that e.g. a page-table was mangled"

Re: Refactoring the FreeBSD Kernel with Checked C [pdf]

#23
post #22
post #18

Earlier 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"

Symbolic execution would tell you whether a page-table could be mangled, and if so which range of input of values would lead to that state. (Though you may need to annotate your code to define what a bad state looks like if it's not something as simple as a NULL pointer dereference.)

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]

#26

Earlier 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.

And me thinking that C follows B in the US English alphabet.

Re: Refactoring the FreeBSD Kernel with Checked C [pdf]

#27

When 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.

https://ieeexplore.ieee.org/document/9229980

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]

#28
post #18
post #17

Earlier 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/

KLEE is only popular with the HN crowd, but not certainly not in the industry. There cbmc/satabs is leading. Esp. automotive. Also much older, and much easier to use. I recently even added formal verification to my CTL library variant, the STL for C.

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]

#29

Checked 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…

Regardless how much security minded people would like to replace C, the POSIX world isn't going away in generations to come, so this kind of solutions is welcomed.

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]

#30

When 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.

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.

Post reply on HN