I'd like to modify the security module (Specifically security/IMA) of the linux kernel.(This module has to be compiled into the kernel)

I have to use functions from a shared library (an .so file) in this module.

but I don't know how to compile it.

Is there a way to put the shared library file to the Linux kernel?

And if there is no way to do it ,can you tell me the reason?


You practically cannot do that (linking a shared library into the kernel or some kernel module). The kernel is conceptually a freestanding program (so does not know about low-level standard C functions like malloc or fprintf that your shared library is very likely to use). Kernel modules (*.ko files) are specially built and are loaded by some special kernel code.

Also, user-land code (including libraries) are based upon system calls (listed in syscalls(2)), which are not available in kernel code (since the kernel is providing the system calls to processes running in user mode thru specific machinery).

You might consider having a user-land helper program communicating with the kernel (i.e. your kernel module), e.g. using netlink(7). Perhaps look also into systemd.

You probably should read more about Operating Systems and read Advanced Linux Programming to understand the user-land aspects.

BTW, as a rule of thumb, you should limit the amount of kernel code added to the system (and prefer working in user-land).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.