Howto compile my own module into the kernel

Hi there,

I'm currently writing a program/module which makes use of the Linux Security Modules (LSM), which provide hooks for some security .
The bad thing about it is: The function to set the hook to the LSM is not exported. That means, I can't just write a loadable kernel module, but have to compile my code directly into the kernel.
Unfortunately I have only experience with writing loadable kernel modules so far, now I would like to know what do I have to do to compile my code into the kernel?
Googleing only told me how to load a module, so hopefully you can help me :slight_smile:

In the good old days, even relatively minor configuration made UNIX compile a new kernel! Look for instructions online for testing new kernels. You build an alternate kernel and ask the system to reboot onto it, but the original is not overwritten. It is not so different than app compiles, but of course a) do not mess up and b) you have to put your objects in the link path ahead of the originals.

What distribution and version are you on? Which specific function is not exported?

LSM has a pretty complete abstraction layer to allow different security modules to be safely loaded and unloaded without messing with the kernel directly. Look at struct security_operations in /include/linux/security.h to see the huge number of function pointers available to you.

I'm using Ubuntu10.10 and currently I'm compiling a 2.6.35 kernel.

As I've been told in the mailing list a make command will only rebuild the files which have changed, so not the whole kernel completely. Unfortunately in Ubuntu you have to build your kernel using make�-kpgk and I don't know yet if this also builds just parts of it.

@fpmurphy: Yeah, that is the struct I need, I know. But to "install" my LSM I need to call register_security (see security/security.c) - that is the function not exported.