Skip to contentSkip to conversation

Code Generator

DISCUSSION mosta 4 participants 4 messages Sep 12, 2011 – Sep 16, 2011

lore
Share & tools
lore

mosta

author
#0 lore raw

Hey All,

does somebody know of projects that use code generators to generate kernel modules? I'm thinking about using a strongly typed language like haskell with a code generator to generate kernel C-Code. I want to achieve more secure kernel modules this way. Is this a silly idea? or had someone already done that.

hope for answers?

greetings mosta

#1 lore raw

Hi ...

Quoted 7 lines · mosta

Hey All,

does somebody know of projects that use code generators to generate kernel modules? I'm thinking about using a strongly typed language like haskell with a code generator to ?generate kernel C-Code. I want to achieve more secure kernel modules this way. Is this a silly idea? or had someone already done that.

I'm not sure, but are you referring to what SystemTap uses in its "scripting"? or more over, dtrace?

Signature · 7 lines
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com
#2 lore raw
In reply to mosta
Quoted 11 lines · mosta

Hey All,

does somebody know of projects that use code generators to generate kernel modules? I'm thinking about using a strongly typed language like haskell with a code generator to ?generate kernel C-Code. I want to achieve more secure kernel modules this way. Is this a silly idea? or had someone already done that.

hope for answers?

greetings mosta

I'm not aware of any code generators, but there are a few static code scanners that are routinely run against the kernel.

Coverity used to be one. I don't know if they still run it or not. Also, some people run other static code analysis tools looking for optimizations or bugs.

Hopefully someone else can help you out if that is related to your question.

Greg

#3 lore raw
In reply to mosta
Quoted 9 lines · mosta

Hey All,

does somebody know of projects that use code generators to generate kernel modules? I'm thinking about using a strongly typed language like haskell with a code generator to ?generate kernel C-Code. I want to achieve more secure kernel modules this way. Is this a silly idea? or had someone already done that.

hope for answers?

So you want to write a haskell program to write source code : foo.c for a kernel module, maybe write a makefile for an out-of-tree module, then make, install that module.

if you post a hello-world.ko generator, Id read the email ( haskell curiosity ) But I imagine youre looking towards more complex stuff.
what advantages are you anticipating ?
- correct-by-construction ?

similar but different is coccinelle.
it uses caml -> SmPL (the similar part) code
to parse C code, looks for sequences matched by semantic patches, and rewrites that code.

Its been used to find and repair numerous kernel programming errors, many with security ramifications. dozens of cocci scripts are in the kernel tree: ./scripts/coccinelle/*/*.cocci
to detect newly committed errors.

If security per se is your main motivation,
then you should probably use coccinelle.

If the haskell part is important too, maybe write an spatch generator. (Id read that too :)