kernel-module

How do I configure modprobe to find my module?

I'm trying to get a kernel module to load at boot. If I run insmod /path/to/module.ko, it works fine. But this has to be repeated every time I reboot. If I run modprobe /path/to/module.ko, it can't find the module. I know modprobe uses a configuration file, but I can't get it to load the module even after adding /path/to/module.ko to /...

File I/O in a Linux kernel module

I'm writing a Linux kernel module that needs to open and read files. What's the best way to accomplish that? ...

Linux Kernel Programming: "Unable to handle kernel NULL pointer dereference"

I'm writting a Linux module (Kernel Programming), and I`m getting: "Unable to handle kernel NULL pointer dereference" What does it mean? ...

Is there a way to figure out what is using a Linux kernel module?

If I load a kernel module and list the loaded modules with lsmod, I can get the "use count" of the module (number of other modules with a reference to the module). Is there a way to figure out what is using a module, though? The issue is that a module I am developing insists its use count is 1 and thus I cannot use rmmod to unload it, b...

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 if it was possible to actually add to the sys_call_table. I realize it's probably not pos...

Methods of communicating between kernel and user apps

New to Linux programming in general. I am trying to communicate with a kernel module via shared memory, but cannot call the functions used in user apps such as shmget(); I have installed kernel-headers and kernel-devel, and included , to the kernel module source, but the headers do not contain any functions. Is there a standard way of...

How to create proc under /proc/driver?

I want to create a proc file under /proc/driver directory. I would like to use a macro like proc_root_driver (or something else provided) rather than use "driver/MODULE_NAME" explicitly. I use create_proc_entry : ... struct proc_dir_entry *simpleproc_fops_entry; simpleproc_fops_entry = create_proc_entry(MODULE_NAME, 0400, NULL /* proc...

linux kernel module linker warnings: "*** Warning: <function> [<module>] undefined!" - any way to get rid of them?

While compiling Linux kernel modules that depend on each other, linker gives undefined symbol warnings like Building modules, stage 2. MODPOST *** Warning: "function_name1" [module_name] undefined! *** Warning: "function_name2" [module_name] undefined! *** Warning: "function_name3" [module_name] undefined! The unresolved symbols ar...

Any experience with SANOS operating system kernel?

I was browsing for an open source kernel when I ran across SANOS which feels like something worth keeping alive as open source. To bring it up to modern standards, the following enhancements need to occur: Support for Multiple CPUs/Cores Add IPv6 (currently only supports IPv4) Ability to run 8192 concurrent threads Ability to support ...

open() returns with "No such device" error, but there is such a device (linux)

I'm trying to use a somewhat old DAQ, and had to jump through a few hoops to get an old (circa 2004) device driver for it to compile (DTI-DT340 Linux-DAQ-PCI). I've gotten to the point where it compiles, I can load the the kernel module, it finds the card, and I can create the character devices using mknod. But I can't seem to open the...

Compile linux kernel (2.6) module including non kernel headers

Is it possible to compile a linux kernel(2.6) module that includes functionality defined by non-kernel includes? For example: kernelmodule.h #include <linux/init.h> #include <linux/module.h> #include <linux/kernel.h> // printk() // ... #include <openssl/sha.h> // ... Makefile obj-m := kernelmodule.o all: $(MAKE) -C /lib/mo...

How to intercept system calls on aix 5.3 or aix 6.1?

How to intercept system calls on aix 5.3 or aix 6.1? ...

Setting process affinity in kernel mode

How can the CPU affinity of a process be set in kernel module? In user mode there is a syscall sched_setaffinity, but I am looking for the kernel mode equivalent. In the Linux kernel code, there is also a function called sched_setaffinity. It's called from the sys_sched_setaffinity function which is called by system_call. From what i...

kernelHow to read/write files within kernel module?

I know all the discussions about why one should not read/write files from kernel, instead how to use /proc or netlink to do that. I want to read/write anyway. I have also read http://www.linuxjournal.com/article/8110 However, problem is 2.6.30 does not export sys_read(). Rather its wrapped in SYSCALL_DEFINE3. So if I use that in my mod...

Can I replace a Linux kernel function with a module?

Hi, 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 provided by a dynamically loaded kernel module. I think this would improve the pace at w...

Changing file permissions in kernel.

I am writing kernel module(C in Linux) and I want to change the permission of the other files in it. any solution? since I am in kernel I can't use chmod syscall and ... thanks for your help This is my Makefile: > obj-m += ca.o > > all: > make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules > > clean: > ...

Problem with chardev.c example from The Linux Kernel Module Programmers Guide

I compiled and ran the chardev.c example from the lkmpg and when writing to the device received an unexpected error: anon@anon:~/lkmpg$ sudo echo "hi" > /dev/chardev bash: /dev/chardev: Permission denied The module write function looks like this: /* * Called when a process writes to dev file: echo "hi" > /dev/chardev */ static s...

Linux Kernel Modules: When to use try_module_get / module_put

I was reading the LKMPG ( See Section 4.1.4. Unregistering A Device ) and it wasn't clear to me when to use the try_module_get / module_put functions. Some of the LKMPG examples use them, some don't. To add to the confusion, try_module_get appears 282 times in 193 files in the 2.6.24 source, yet in Linux Device Drivers ( LDD3 ) and Ess...

Kernel page request-related OOPS

Hello all; I'm working on modifying a Linux 2.6.22-5 kernel driver in order to add threading, and I'm running into a problem I can't seem to figure out. I have set up the module so that there is a single function which is called, which invokes one or more worker threads to do the actual work. The worker threads contain only existing f...

User space access from Kernel space - get_user_pages

Hello, I'd like pass a pointer from a user space memory into a function in my kernel module. I don't want to use copy_from_user. I've read that I should use get_user_pages function. For example one page. struct page **pages; pages = kmalloc(1 * sizeof(*pages), GFP_KERNEL); down_read(&current->mm->mmap_sem); get_user_pages(current,cur...