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.
Questions tagged [kernel-module]
2228 questions
11
votes
1 answer
Testing a kernel module
I'm interested in mocking functions and global variables in order to unit test a kernel module.
Initially tried with https://github.com/ThrowTheSwitch/CMock but ran into issues. Any articles links on how to do this would also be great. (for kernel…

andrei
- 8,252
- 14
- 51
- 66
11
votes
1 answer
Trigger Kernel Interrupt Handler: How?
I am trying to understand Asynchronous Interrupt handling in kernel, ofcourse through the legendary Understanding the Linux Kernel.
In this process how and who will trigger Kernel Interrupt Handler?
I would like some one to help me correcting this…

Keen Learner
- 195
- 2
- 15
11
votes
1 answer
Why processes are deprived of CPU for TOO long while busy looping in Linux kernel?
At first glance, my question might look bit trivial. Please bear with me and read completely.
I have identified a busy loop in my Linux kernel module. Due to this, other processes (e.g. sshd) are not getting CPU time for long spans of time (like 20…

APKar
- 323
- 2
- 8
11
votes
3 answers
Writing x86_64 linux kernel module in assembler
I try write simple kernel module (v3.6) in nasm, but insmod say me:
$ sudo insmod ./hello.ko
insmod: ERROR: could not insert module ./hello.ko: Invalid module format
$ echo $?
1
I compile my code with:
$ nasm -f elf64 -o hello.m hello.asm
$ ld -m…

Alexander Lavrukov
- 187
- 2
- 12
11
votes
2 answers
Programmatically check whether a linux kernel module exists or not at runtime
I am writing a C daemon, which depends on the existence of two kernel modules in order to do its job. The program does not directly use these (or any other) modules. It only needs them to exist.
Therefore, I would like to programmatically check…
user237076
11
votes
2 answers
Kernel Module Init and Exit functions being called in wrong order
I'm making a very simple hello world kernel module and getting some crazy behavior. This worked until I upgraded to kernel 3.3.8 and now it... Well, it's calling the init function on exit, and the exit function on initialize. I've made sure my…

Ben
- 2,867
- 2
- 22
- 32
10
votes
4 answers
intercepting file system system calls
I am writing an application for which I need to intercept some filesystem system calls eg. unlink. I would like to save some file say abc. If user deletes the file then I need to copy it to some other place. So I need unlink to call my code before…

gaurav
- 872
- 2
- 10
- 25
10
votes
3 answers
Is there a size limit for kernel module in linux?
I have a problem loading a kernel module, there is a large data structure, around the size of 2Gb of memory - whether I preallocate the table (so that it shows in .bss when I do size -A module.ko or try to vmalloc() it at load time, the module…

Kimvais
- 38,306
- 16
- 108
- 142
10
votes
2 answers
how to determine if a Linux kernel module is leaking memory
For testing the behavior of the kernel when it leaks memory, I am writing a kernel module that continuously allocates memory e.g. the code looks like
int bytesLeaked = 128000;
char *var = kmalloc(bytesLeaked, GFP_KERNEL);
if (var !=…

kakinada
- 129
- 1
- 2
- 5
10
votes
1 answer
Device Specific Data Structure with Platform Driver and Character Device Interface
I'm struggling with understanding the linkup between a platform device driver with a character device interface and storing data in a device specific data structure.
I created a struct keeping track of data related to my device, and then add it to…

gavenant
- 453
- 7
- 26
10
votes
1 answer
i2cdetect doesn't find anything on goodix chip
I have a goodix chip for the touchscreen on my tablet PC and even though I compiled the latest kernel module for it, things are not working.
I am using exactly this kernel version with the patched driver:
https://github.com/NimbleX/kernel
For…

Bogdan
- 622
- 6
- 21
10
votes
3 answers
Configure Parameters of LED Trigger from Kernel Space
I'm working on an embedded project. Our board is using Linux kernel v3.16.7. I'm working on supporting a couple of peripheral LEDs that monitor activity. I've successfully modified the boot procedure to load the drivers and create sysfs entries in…

Woodrow Barlow
- 8,477
- 3
- 48
- 86
10
votes
5 answers
What options do we have for communication between a user program and a Linux Kernel Module?
I am a new comer to Linux Kernel Module programming. From the material that I have read so far, I have found that there are 3 ways for a user program to request services or to communicate with a Linux Kernel Module
a device file in /dev
a file in…

binW
- 13,220
- 11
- 56
- 69
10
votes
7 answers
How do I strip local symbols from linux kernel module without breaking it?
If I do --strip-debug or --strip-unneeded, I have the .ko that lists all function names with nm, if I do just strip foo.ko I have a kernel module that refuses to load.
Does anyone know a quick shortcut how to remove all symbols that are not needed…

Kimvais
- 38,306
- 16
- 108
- 142
10
votes
3 answers
Linux Kernel Module - Creating proc file - proc_root undeclared error
I copy and paste code from this URL for creating and reading/writing a proc file using a kernel module and get the error that proc_root is undeclared. This same example is on a few sites so I assume it works. Any ideas why I'd get this error? Does…

Zach
- 343
- 1
- 3
- 9