kernel-module

Removing padding from structure in kernel module

I am compiling a kernel module, containing a structure of size 34, using the standard command. make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules The sizeof(some_structure) is coming as 36 instead of 34 i.e. the compiler is padding the structure. How do I remove this padding? Running make V=1 shows the gcc compiler options pas...

inode_operations , warning: initialization from incompatible pointer type

Hi everyone, I'm trying to compile a simple Kernel program that read and write from a proc file. I'm trying to set permission to that file by overriding the permission fp in inode_operations struct (.permission) static int module_permission(struct inode *inode, int op, struct nameidata *foo) { . . . } static struct inode_opera...

file_operations Question, how do i know if a process that opened a file for writing has decided to close it ?

Hi Kernel Gurus, I'm currently writing a simple "multicaster" module. Only one process can open a proc filesystem file for writing, and the rest can open it for reading. To do so i use the inode_operation .permission callback, I check the operation and when i detect someone open a file for writing I set a flag ON. i need a way to det...

task_current redundant field

Hi, I'm writing a kernel module that reads from a /proc file. When someone writes into the /proc file the reader will read it, but if it reads again while there is no "new" write, it should be blocked. In order to remember if we already read, i need to keep a map of the latest buffer that process read. To avoid that, I was told that th...

Saving information in the IO System

Hi Kernel Gurus, I need to write a kernel module that simulate a "multicaster" Using the /proc file system. Basically it need to support the following scenarios: 1) allow one write access to the /proc file and many read accesses to the /proc file. 2) The module should have a buffer of the contents last successful write. Each write sh...

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 for module loading so that people cannot reverse engineer the API:s as easily? PS: For a...

How can I uniquely identify users trying to open() a kernel module?

I'm working on a kernel module and I'm trying to uniquely identify each one of the users trying to open() the module (can be either processes or threads). What is the best way to identify them? Is there an ID I can get from a system call? I wish to get all users in a list that specifies whether they're trying to open the module for rea...

kernel get stack when signalled

hi there i write readers and writers where the kernel have to syncronize between them and block writer who already read a massage when i am in the queue waiting I get signal so I do the fallowing while (i_Allready_Read(myf) == ALLREADY_READ || isExistWriter == false ) //while (!(i_Allready_Read(aliveProc,current->pid))) { int i,...

Linux Real Mode Interface in a linux kernel module

Hi I have a BIOS function I need to call from time to time on an embedded system, and using LRMI I was able to call it successfully from a user space program. Now I want to do the same from a loadable kernel module. Is there any way to do this? Some other library maybe? ...

what is the likely cause of CMOS_WRITE failing to work?

I've been puzzled by a RTC problem for several days: i couldn't write to the RTC register. Following is the code snippet and the value I read from the reg(last line) is always different from what i just wrote to the reg. Anyone can help me understand this ? val = CMOS_READ(RTC_FREQ_SELECT); printk(KERN_INFO "reading val=%d from...

How to install a system call in a kernel module

I want to install a new system call in a place of an unused one and wait for instructions from userspace. i dont know how to do it. ...

How to get use count from Linux kernel module?

I have a problem with use count of kernel module being developed.I'd like to print it for debugging purpose. How can I obtain it from the module code? Kernel version in question - Linux 2.6.32 ...

How to use find_module?

How to use linux kernel's find_module() function? The documentation says "must hold module_mutex". Does that mean that I should acquire a lock in my module code before searching for a pointer to another? When this mutex is locked by non-module kernel code? Context I'm debugging a set of kernel modules working together. Module A cal...

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 /proc file system ioctl() call Question: What other options do we have for communicatio...

Can I add a systemcall from a module?

Can I add a systemcall from a module? ...

Cross compiling a kernel module

I'm trying to cross compile a helloworld kernel (2.6.x) module for ARM architecture on my intel x86 host. The codesourcery tool chain for ARM is located at: /home/ravi/workspace/hawk/arm-2009q3 The kernel source is located at :/home/ravi/workspace/hawk/linux-omapl1 My Makefile: ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi obj-m := H...

How to hook syscall table at runtime on PPC Linux ?

Hello All - Subject: PPC Assembly Language - Linux Loadble Kernel Module Detail: How access local TOC area (r2) when called from kernel in syscall table hook? I have written a loadable kernel module for Linux that uses syscall table hooking to intercept system calls and log information about them before passing the call on to the orig...

Kernel Module Make file problem

Hi, This is the first time I am trying to build kernal module. Following is make file. On running make command. I get the error /bin/sh: Syntax error: "(" unexpected make: * [all] Error 2 obj-m =mod.o obj-m +=depmod.o obj-m +=mod1.o obj-m +=mod2.o obj-m +=mod3.o KDIR=/lib/modules/$(shell uname -r)/build all: $(MAKE) -C $...

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 know, I would like to know how to do SHA1 / MD5 and Blowfish / AES within the kernel space o...

usbserial.ko for linux kernel 2.6.29.6

I need usbserial.ko for my linux 2.6.29.6. Anyone knows where to download it and how to integrate it into my current kernel? Thanks. ...