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
13
votes
2 answers
Compile error: Kernel module
I am a newbie at kernel programming & I wish to run this kernel module (posted below)... and i ran the makefile (posted below) for that, but I am getting the following errors: Can someone please help me understand how to overcome this:
The kernel…

Rookie
- 5,179
- 13
- 41
- 65
13
votes
2 answers
Hello world kernel module for android & unknown relocation: 27 when insmod
I am trying to create a simple kernel module.
I am trying to print messages to dmesg but i keep getting
insmod: init_module 'hello.ko' failed (Exec format error) in android
after :
dmesg:
unknown relocation: 27
#include
#include…

raising hope
- 404
- 5
- 13
12
votes
2 answers
Convert source IP address from struct iphdr* to string equivalent using Linux netfilter
I want to convert the source & destination IP addresses from a packet captured using netfilter to char *.
In my netfilter hook function, I have:
sock_buff = skb; // argument 2 of hook function
// ip_header is struct iphdr*
ip_header = (struct iphdr…

Jake
- 16,329
- 50
- 126
- 202
12
votes
2 answers
human readable timestamp in linux kernel
How can I write human readable timestamp in linux kernel? I think do_gettimeofday returns epoch but I don't want to try to convert it to readable time. I just want a format like Hour:Min:Sec:Msec.
Thanks

stedkka
- 345
- 2
- 4
- 14
12
votes
1 answer
Why is my module unable to handle kernel paging request?
This is my module to allocate one huge page by using dequeue_huge_page_vma() and alloc_buddy_huge_page(). To make them vma independent, I get available vm area from __get_vm_area_node(), and then get its virtual address. I want to allocate one 2MB…

CindyRabbit
- 359
- 2
- 17
12
votes
2 answers
How to write kernel space memory (physical address) to a file using O_DIRECT?
I want to write a physical memory to a file. The memory itself will not be touched again, thus I want to use O_DIRECT to gain the best write performance.
My first idea was to open /dev/mem and mmap the memory and write everything to a file, which is…

Friedrich
- 645
- 11
- 26
12
votes
2 answers
Profiling Linux Kernel Modules
I am interested in profiling a module for the Linux Kernel. I tried it this way:
Built the kernel with CONFIG_PROFILING=y
Booted the kernel with profile=2
Reset the profiler by echo 123 > /proc/profile
The module was successfully loaded by a…

Albus Dumbledore
- 12,368
- 23
- 64
- 105
12
votes
2 answers
How to find the version of a compiled kernel module?
I am in a situation where it would be very convenient to find the version of a loaded kernel module by querying the loaded module or .ko file.
Is there a standard way to do this without digging into the source code?

Jacob Marble
- 28,555
- 22
- 67
- 78
12
votes
3 answers
Linux kernel module crash debug: general protection fault: 0000 [#1] SMP
I have a kernel module for splitting incoming rtp packets and merging rtp outgoing packets. The program crashes once in 2/3 days. If would be very convenient for me if its possible to find the exact line where the module crashes.
I have given the…

Habibullah Araphat Konok
- 454
- 2
- 4
- 14
12
votes
4 answers
Not able to remove a loadable kernel module
I'm writing a loadable kernel module and trying to test it. After inserting it I was trying to remove it using rmmod xxx command, but I get an error saying module xxx is in use and the module gets stuck and I can't remove it. Any idea how to remove…

Varda Elentári
- 2,242
- 6
- 35
- 55
11
votes
1 answer
Periodic task in a Linux kernel module
Currently I am developing GPIO kernel module for friendlyarm Linux 2.6.32.2 (mini2440). I am from electronics background and new to Linux.
The kernel module loaded at start-up and the related device file is located in /dev as gpiofreq.
At first time…

JD1910
- 183
- 1
- 8
11
votes
1 answer
How to find physical and logical core number in a kernel module?
Are there kernel functions in Linux that would return the number of the physical core and
logical core (in case of Hyperthreading) on which a kernel module is running ?

vjain27
- 3,514
- 9
- 41
- 60
11
votes
1 answer
Warning: modules_install: missing 'System.map' file. Skipping depmod
I am trying to insert a kernel module using depmod and modprobe utilities in-order to resolve any dependencies. When I build the module it throws "Warning: modules_install: missing 'System.map' file. Skipping depmod."
And later when I try to…

user11875340
- 113
- 1
- 1
- 6
11
votes
3 answers
Is it possible to add a system call via a LKM?
I'd like to add a new system call via an LKM, but I'm not sure how to do this. That is, I know that if I want to add a completely new system call, I can look through the sys_call_table and find a sys_ni_syscall and just replace it, but I was curious…

FreeMemory
- 8,444
- 7
- 37
- 49
11
votes
2 answers
Bluetooth over uart using hciattach?
I am using QN9021 SoC working in controller mode (BLE Bluetooth core specification v4.0). It supports some standard HCI commands as well as some vendor specific commands. I am trying to attach it in my ubuntu laptop.
The command that i have used is…

abhiarora
- 9,743
- 5
- 32
- 57