Questions tagged [kernel-module]

A kernel module is a run-time loadable object file that is loaded into operating system kernel to add functionality to a running kernel. Examples include device drivers and other kernel items.

2228 questions
16
votes
2 answers

Linux kernel - add system call dynamically through module

Is there any way to add a system call dynamic, such as through a module? I have found places where I can override an existing system call with a module by just changing the sys_call_table[] array to get my overridden function instead of the native…
Zach
  • 343
  • 1
  • 3
  • 9
16
votes
1 answer

Hijacking the realtime clock in linux

I want to write a LKM (Linux Kernel Module) that hijacks the realtime clock (interrupt 8). So I want the interrupt to be set to my function and at some point send it back to the old function. I have tried to use the request_irq function without any…
Ramzi Khahil
  • 4,932
  • 4
  • 35
  • 69
15
votes
3 answers

Unknown symbol in while loading a kernel module

I need help understanding why I get an error when I insert a module. I have tried this with no success. $ sudo modprobe lpfc_scst FATAL: Error inserting lpfc_scst (/lib/modules/2.6.32-33-generic/extra/lpfc_scst.ko): Unknown symbol in module, or…
user663896
15
votes
1 answer

Insert linux kernel module statically

When building the Linux kernel from sources one could decide if a certain functionality is statically built into the kernel or packed into a module for dynamic insertion by .config. If on the other hand I have sources for any 3rd party module, like…
dronus
  • 10,774
  • 8
  • 54
  • 80
15
votes
3 answers

How can I obtain battery level inside a Linux kernel module?

I am trying to get the battery level inside a Linux kernel module (the module is inserted via modprobe). I would ideally like to use a kernel API call to get the battery information. I have searched on the web for solutions, and I have also explored…
razvanlupusoru
  • 261
  • 2
  • 9
15
votes
2 answers

Getting list of network devices inside the Linux kernel

I've been looking through net/core/dev.c and other files to try to find out how to get the list of network devices that are currently configured and it's proving to be a little difficult to find. The end goal is to be able to get network device…
15
votes
3 answers

How do I use ioctl() to manipulate my kernel module?

So I'm trying to write a kernel module that uses the linux/timer.h file. I got it to work inside just the module, and now I am trying to get it to work from a user program. Here is my kernel module: //Necessary Includes For Device Drivers. #include…
hwrd
  • 2,134
  • 6
  • 29
  • 36
15
votes
1 answer

Get current time in seconds in kernel module

What is the standard way to get the current time in seconds (since the epoch) in a kernel module? I have seen techniques involving getting xtime which are very long-winded and involve while-loops and locks. There must be a better way. [This is not a…
HXCaine
  • 4,228
  • 3
  • 31
  • 36
14
votes
1 answer

Marking loadable kernel module as in-tree

This question is about linux kernel 4.10. Loading an out-of-tree LKM causes kernel to print a warning: module: loading out-of-tree module taints kernel. This raises from this check in module.c: if (!get_modinfo(info, "intree")) { Reading get_modinfo…
Mr M.
  • 715
  • 1
  • 8
  • 24
14
votes
1 answer

Does the Linux kernel have its own SSE/AVX context?

Does the Linux kernel have its own SSE/AVX context? I mean, from the point of view of a kernel module, can I use SSE/AVX instructions without worrying about user-space applications which may use it too? Or do I need to use some locks or do some…
Ilya Matveychikov
  • 3,936
  • 2
  • 27
  • 42
14
votes
4 answers

Can I replace a Linux kernel function with a module?

Im getting into kernel work for a bit of my summer research. We are looking to make modifications to the TCP, in specific RTT calculations. What I would like to do is replace the resolution of one of the functions in tcp_input.c to a function…
Willi Ballenthin
  • 6,444
  • 6
  • 38
  • 52
13
votes
2 answers

Accessing a serial port from a linux kernel module

Hello Linux Kernel Driver Gurus! I'm writing a v4l2 driver for a camera that uses a serial interface for configuration. I'd like the driver to configure the camera, as it keeps the client code consistent across camera models. The question is:…
13
votes
2 answers

How to reload modified kernel modules

How can I instruct the system to reload all kernel modules that have changed? (I am developing a driver with several modules. I want a quick and error-free method to reload all the modules that change.)
apoorv020
  • 5,420
  • 11
  • 40
  • 63
13
votes
7 answers

how to use CryptoAPI in the linux kernel 2.6

I have been looking for some time but have not found anywhere near sufficient documentation / examples on how to use the CryptoAPI that comes with linux in the creation of syscalls / in kernel land. If anyone knows of a good source please let me…
Conor
  • 151
  • 1
  • 1
  • 5
13
votes
4 answers

insmod error: inserting './hello.ko': -1 Invalid module format"

I have just made my first driver module, the hello world module following LDD3. However unfortunately encountered this error: insmod: error inserting './hello.ko': -1 Invalid module format. I am doing this on Ubuntu 11.04, and my environment: $…