How to Trigger a Function in Kernel Module Interrupt

How to send a signal / interrupt from kernel built in module to a loadable kernel module?

Also for an efficient solution, you can make use of function pointers from kernel source code.

But the problem here is you have to modify Linux source code. Be very careful when you do such modifications.

  1. Implement a NULL function pointer from you Linux source code - Call to this function pointer from the kernel routine (check for NULL and do)
  2. Export the symbol
  3. Provide a local function address to this symbol from your loadable module.

That's it...!!! You will get a function call from the kernel routine. Also make sure that when you exit the module, put the symbol back to NULL, otherwise kernel will crash.

Executing a user-space function from the kernel space

You are out of luck with invoking user-space functions from the kernel since the kernel doesn't and isn't supposed to know about individual user-space application functions and logic, not to mention that each user-space application has its own memory layout, that no other process nor the kernel is allowed to invade in that way (shared objects are the exception here, but still you can't tap into that from the kernel space). What about the security model, you aren't supposed to run user-space code (which is automatically considered unsafe code in the kernel context) in the kernel context in the first place since that will break the security model of a kernel right there in that instant. Now considering all of the above mentioned, plus many other motives you might want to reconsider your approach and focus on Kernel <-> User-space IPC and Interfaces, the file system or the user-mode helper API(read bellow).

You can invoke user space apps from the kernel though, that using the usermode-helper API. The following IBM DeveloperWorks article should get you started on using the usermode-helper Linux kernel API:

Kernel APIs, Part 1: Invoking user-space applications from the kernel



Related Topics



Leave a reply



Submit