problem about kernel-module-Collection of common programming errors


  • Pavan Manjunath
    linux-kernel cross-compiling kernel-module sparc relocation
    First off: I am not an expert, so please excuse any mistakes I make trying to explain myself.I am trying to cross-compile an external Linux module for a SPARC machine using Sparc-Linux-GCC-4.4.2. The version of the Linux kernel is 2.6.36.4-00037-g059aa91-dirty. It has been patched with some files from the LEON processor. The build flow is provided to me and it uses LinuxBuild, Buildroot, and Busybox. I am trying to make a 32 bit OS.Everything seems to work but after I compile the module and try

  • Mathieu Devos
    android network-programming linux-kernel kernel-module kernel-programming
    I have quite a specific piece of code here and so far the internet has been of little help. I’m trying to write a piece of code that (for starters) should just be able to read out an 802.11 (wireless) packet and print information from the MAC header. I tried composing my code out of different tutorials, pieces of kernel information, … The program that I’m trying to write is a loadable kernel module for android (although linux kernel is very similar). While I can currently receive sk_buff packe

  • alexandernst
    c linux module linux-kernel kernel-module
    I have this POC in C that saves a few structs in a custom section and then iterates over those structs, showing their content.#include <stdio.h>char a, b, c;struct counter_info {int counter;char *name; } __attribute__((packed));#define __PUT_STUFF_IN_SECTION(_name) \ do{ \static struct counter_info __counter_info_##_name \__attribute((__section__(“counters”))) \__attribute((__used__)) = {

  • Vilhelm Gray
    c linux linux-kernel linux-device-driver kernel-module
    I’m using the kernel_fpu_begin and kernel_fpu_end functions in asm/i387.h to protect the FPU register states for some simple floating point arithmetic inside of a Linux kernel module.I’m curious about the behavior of calling the kernel_fpu_begin function twice before the kernel_fpu_end function, and vice versa. For example:#include <asm/i387.h>double foo(unsigned num){kernel_fpu_begin();double x = 3.14;x += num;kernel_fpu_end();return x; }…kernel_fpu_begin();double y = 1.23; unsigned z =

  • Sylvain Huard
    makefile kernel-module
    I’m adding an external driver module to an android Gingerbread kernel (works similar to Linux). I’ve done it before and it worked but I have a problem this time. I follow the recipe found in O’Reilly “Linux Device Drivers 3rd edition” which is:in the local Makefile, you add those statements: obj-m := GobiNet.o GobiNet-objs := GobiUSBNet.o QMIDevice.o QMI.o In human language it means build me a GobiNet.ko from GobiUSBNet.c + QMIDevice.c + QMI.c. This is for the case where the makefile is call

  • Mike Mu
    linux linux-kernel kernel kernel-module affinity
    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 it seems, this is the function that I want to use. The fact that it has the same name as the system call makes me a bit uneasy, though.But as we all know, the best

  • MirkoBanchi
    linux gcc kernel-module
    I have two kernel modules (say modA and modB). modA exports a symbol with EXPORT_SYMBOL(symA) and modB uses it. I have the header modA.h for modA:… extern void symA(int param); …and in modB.c:#include “modA.h” … static int __init modB_init(void) {symA(10); } …If i insmod modB all works fine, my modB is correctly linked in the kernel and the function symA is correctly called. However when i build modB the compiler raises a warning: symA is undefined. An LKM is an ELF relocatable so why th

  • prap19
    filesystems makefile kernel-programming static-linking kernel-module
    i have created a kernel module that uses kernel level functions such as vfs_read, write etc. This module has a makefile that builds this module to get the .ko file. I want to analyze the objdump output of this .ko file. However I observed that kernel functions such as vfs_read and write are not resolved in the .ko file. They are just called and my guess is that they are resolved at run time. Is it possible to make some changes in the makefile and statically link all these functions in the sing

  • Eugene
    linux-kernel kernel-module
    I wrote a module which uses EXPORT_SYMBOL(func) to export the function func.When modifying the kernel code, I declared extern void func(); at the top, and called func().But when compiling kernel, I get undefined reference to ‘func’ error.I guess the compiler can’t find where func() is, but I don’t know how to fix it.Can someone help me out? Thanks a lot!

  • Dew Kumar
    linux-kernel linux-device-driver kernel-programming kernel-module
    I have written a sample hello.ko kernel module:#include <linux/module.h> /* Needed by all modules */ #include <linux/kernel.h> /* Needed for KERN_INFO */int init_module(void) {printk(KERN_INFO “Hello world.\n”);return 0; }void cleanup_module(void) {printk(KERN_INFO “Goodbye world 1.\n”); }Here, I have used “printk” method which is a Kernel API exposed by Linux. I can see the Linux exported symbols in “/proc/kallsyms”. I am curious to know how do gcc/ld links the called Kern

  • Mat
    file-io linux-kernel 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 Driving Me Nuts – Things You Never Should Do in the Kernel.However, problem is 2.6.30 does not export sys_read(). Rather its wrapped in SYSCALL_DEFINE3. So if I use that in my module, I get following warnings:WARNING: “sys_read” [xxx.ko] undefined! WARNING: “sys_open” [xxx.ko] undefined!Obviously insmod cannot load the mo

  • Wojciech Reszelewski
    c kernel-programming kernel-module
    I’ ve got such a functionstatic ssize_t read_mydevice(struct file *filp, char* buf, size_t count, loff_t* ppos) {char *text = “Device is empty\n”;int len = strlen(text);if (*ppos != 0)return 0;if(count>bytesindev) count=bytesindev;if(bytesindev==0) {if (copy_to_user(buf, text, len))return -EINVAL;} else {while(count>0) {if (copy_to_user(buf++, msg_Ptr, (unsigned long) 1)) {return -EINVAL;} else {strcpy(msg_Ptr, (msg_Ptr+1));bytesindev-=1;*(msg_Ptr+bytesindev) = ‘\0’;}count-=1;printk(KERN_I

  • Gary
    c++ linux kernel-module compiler-errors
    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 are resolved as soon as module is inserted into kernel using insmod or modprobe. Is there any way to get rid of the linker warning, though?I have read through 3 Google SER

  • 8088
    ubuntu virtualbox ubuntu-11.04 linux-kernel kernel-module
    I just installed Ubuntu 11.04 with the linux-image-2.6.38-11-virtual kernel as a virtual machine in VirtualBox (4.1.2). When I booted the machine after installation, I got this error message:FATAL: Error inserting ahci (/lib/modules/2.6.38-11-virtual/kernel/drivers/ata/ahci. ko): Unknown symbol in module, or unknown parameter (see dmesg)I found this bug report. In prior Ubuntu releases, the virtual linux kernel did not include the ahci module, which I suspect is causing my problem. Could someon

  • cristi _b
    arm kernel-module raspberry-pi cross-compile
    Im trying to crosscompile a (example)linuxmodule for the raspberryPi(arm), with crosstool-ng 1.15.3.I got the following output:markus@markus-R55S:~/Desktop/speakerarm$ make ARCH=arm CROSS_COMPILE=arm-unknown-linux-gnueabi- make -C /lib/modules/3.2.0-35-generic-pae/build SUBDIRS=/home/markus/Desktop/speakerarm modules make[1]: Entering directory `/usr/src/linux-headers-3.2.0-35-generic-pae’CC [M] /home/markus/Desktop/speakerarm/speaker.o In file included from /usr/src/linux-headers-3.2.0-35-gen

  • afriza
    c linux vim clang kernel-module
    I tried to get gcc to dump the include paths and my .clang_complete file now looks like:-std=gnu89 -nostdinc -I/usr/src/linux-headers-3.0.0-16-generic/arch/x86/include -I/lib/modules/3.0.0-16-generic/build/arch/x86/include/generated -I/lib/modules/3.0.0-16-generic/build/include -I/lib/modules/3.0.0-16-generic/build/ubuntu/include -I/usr/lib/gcc/i686-linux-gnu/4.6.1/include -D__KERNEL__ -DMODULEBut libclang still complains tons of errors & warnings when editing a simple hello world kernel mod

  • Aiden Bell
    c linux file-permissions kernel-module
    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 helpThis is my Makefile:> obj-m += ca.o > > all: > make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules > > clean: > make -C /lib/modules/$(shell uname -r)/build M=$(PWD) cleanAnd this is my Code:> #include <linux/string.h> > #include <linux/m

  • mark mcmurray
    linux-kernel debian kernel-module
    I downloaded a kernel module source for the batman advanced MANET and then called make in the directory of the source and let it do its thing. Once make was finished the file batman-adv.ko was available in the folder located in /home/batman-adv-2013.2.0. When I call modprobe batman-adv in the directory I get the error:FATAL: Module batman_adv not found.and when I call insmod batman-adv.ko:insmod: error inserting ‘/home/batman-adv-2013.2.0/batman-adv.ko’: -1 Unknown symbol in moduleThe operating

  • user1471175
    memory-management linux-kernel kernel-module
    I am getting following error when i try to insert a module insmod: error inserting ‘memory.ko’: -1 Unknown symbol in moduleFollowing happens when i make the modulemake -C /lib/modules/2.6.32-279.19.1.el6.x86_64/build SUBDIRS=/work modules make[1]: Entering directory `/usr/src/kernels/2.6.32-279.19.1.el6.x86_64’Building modules, stage 2.MODPOST 1 modules WARNING: “arch_vma_name” [/work/memory.ko] undefined! make[1]: Leaving directory `/usr/src/kernels/2.6.32-279.19.1.el6.x86_64’You can see the re

  • ctuffli
    linux linux-kernel linux-device-driver kernel-programming kernel-module
    I am porting a Linux module (PageMgrMod) to a more recent kernel, but now the functions are not visible to other modules. For example, loading a module that uses PageMgrMod gives the errorno symbol version for init_pgmgrUnknown symbol init_pgmgrBut reading /proc/kallsyms shows the symbol existsffffffff81883c0d T x86_init_pgd_noopffffffffa012a5c0 r __ksymtab_init_pgmgr [PageMgrMod]ffffffffa012a669 r __kstrtab_init_pgmgr [PageMgrMod]ffffffffa012a600 r __kcrctab_init_pgmgr [PageMgrMod]ffffffffa012a

  • Abruzzo Forte e Gentile
    debugging linux-kernel kernel-module
    I am doing first steps into Linux kernel development. I have some code producing a .ko kernel module that I install with insmod. I would like a way to debug what happens when I install the module but I am facing some difficulties.I need to debug the call to init_module. Is this function called when I run insmode ? I try to use insmod “/my/url/fil.ko” -m to debug what happens but each time I got error -1 Unknown symbol in module while in /cat/log/message I can see the error unknown parameter -m

  • Dalchand
    ubuntu-10.04 kernel-module ioctl
    I want to communicate with my kernel module using ioctl. I have written two c program one for kernel module and other for user mode. I am getting this error while compiling kernel module:error: unknown field ‘ioctl’ specified in initializerat this line :struct file_operations Fops = {.read = device_read,.write = device_write,.ioctl = device_ioctl, ——> at this point error is occuring..open = device_open,.release = device_release, };any idea why this is happening. thanks

  • vidzi
    c linux-kernel kernel kernel-module kernel-programming
    I am trying to implement a kernel module, which can access the task_struct of a user process, whose Process ID is already known to me. I am using find_get_pid and pid_task to get the task_struct of the process:#include <linux/kernel.h> #include <linux/module.h> #include <linux/sched.h> #include <linux/pid.h> #include <linux/pid_namespace.h>int init_module( void ) { //Declaring the variablesint p_id = 6980; //6980 is the process ID of my user processstruct pid *pi

  • yiqi
    linux kernel-module
    I am writing a kernel module to manipute GPIOs. In initialization, the moduel needs to change the muplex of GPIOs. [tld.c]#include <mach-omap2/mux.h>. . .int open_gpio(void){int result;result = gpio_request_array(leds_gpios, ARRAY_SIZE(leds_gpios));if(result != 0) {printk(“tld: cannot request gpio ports\n”);}result = gpio_direction_output(LED_LE_PIN, 0);omap_mux_set_gpio(OMAP_MUX_MODE7, LED_LE_PIN);if(result != 0) {printk(“tld: cannot change GPIO muplex.\n”);gpio_free_array(leds_gpios, ARR

  • Martin M.
    android android-ndk malloc kernel-module
    I have developed a Loadable Kernel Module (LKM) for android.I use kzalloc:device = kzalloc(ndevices * sizeof (*device), GFP_KERNEL);and it worked for a while, but after an update of my android (since 4.1 it’s no more working), I got following error on insmod:insmod module.ko insmod: init_module ‘module.ko’ failed (No such file or directory)DMESG says: Unknown symbol malloc_sizes (err 0)This has something to do with inux/slab.h, that’s what I know. I googled for days over days and I’m very frustr

  • casperOne
    android module linux-kernel kernel kernel-module
    I am trying to create a simple kernel module. I am trying to print messages to dmesg but i keep gettinginsmod: init_module ‘hello.ko’ failed (Exec format error) in androidafter : dmesg: unknown relocation: 27#include <linux/module.h> #include <linux/kdb.h> int init_module(void) {printk(KERN_ALERT “Hello world!\n”);return 1; }void cleanup_module(void) {printk(KERN_INFO “Goodbye world 1.\n”); } MODULE_AUTHOR(“Robert P. J. Day”); MODULE_LICENSE(“Dual BSD/GPL”); MODULE_VERSION(“2:1.0”) ;

  • gforcada
    linux linux-kernel kernel-module
    Help to understand why error inserting module happens? The listing provided below. 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 unknown parameter (see dmesg)$ dmesg | tail [ 1201.262842] lpfc_scst: Unknown symbol scst_register_target [ 1201.262949] lpfc_scst: Unknown symbol lpfc_tm_term [ 1201.263161] lpfc_scst: no symbol version for scst_register_session [ 1201.2631

  • uki
    linux-kernel kernel-module
    I created the following error-prone kernel module for educational purposes.#include <linux/module.h> #include <linux/kernel.h> #include <linux/init.h> #include <linux/proc_fs.h> #include <linux/string.h> #include <asm/uaccess.h>void *(my_funptr)(void);int bug1_write(struct file *file,const char *buf,unsigned long len) {my_funptr();return len; }int init_module(void) {static struct proc_dir_entry *proc;proc = create_proc_entry(“bug1”, 0666, 0);proc->write_pro

Originally posted 2013-11-27 12:15:39.