Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute a program in kernel space in Linux

If I want to execute a user program (not a kernel module) in Linux kernel space, what options do I have?

I have looked at KML(kernel mode linux) but that is specific to IA-32 architecture. I want a solution which is cross platform and can work on embedded linux systems.

like image 611
binW Avatar asked Jul 20 '10 12:07

binW


4 Answers

User programs don't execute in kernel space - that's what makes them user programs.

If you want to execute code in kernel space you have two options: build it in to the kernel, or load it with a kernel module.

like image 180
caf Avatar answered Nov 13 '22 17:11

caf


call_usrmodehelper

like image 31
user414686 Avatar answered Nov 13 '22 16:11

user414686


You wrote in another question that you are a newcomer to kernel programming. Using KML is highly unconventional, and will be far more complicated that doing things in the standard way. That will make your learning that much more difficult. I would suggest that your best option is reevaluate why you want to run a user space app in kernel space and find way not to do it.

There may be a good reason to do such a thing, but it's not clear to me what that reason could be. One thing you should understand with kernel development is that just because something is possible, it's not necessarily something that should be done.

If you really want a cross platform solution, you'll have to write it yourself. The only architectures supported by KML are IA32 and AMD64.

like image 5
JayM Avatar answered Nov 13 '22 17:11

JayM


Kernel programming is pretty much by definition platform specific, since kernels for different platforms are all different.

like image 3
T.E.D. Avatar answered Nov 13 '22 16:11

T.E.D.