kernel-module

insmod error: inserting './hello.ko': -1 Invalid module format"

冷暖自知 提交于 2019-12-18 13:09:33
问题 I have just made my first driver module, the hello world module following LDD3. However unfortunately encountered this error: insmod: error inserting './hello.ko': -1 Invalid module format. I am doing this on Ubuntu 11.04, and my environment: $ uname -r 2.6.38-8-generic I get the kernel source like this: sudo apt-cache search linux-source linux-source - Linux kernel source with Ubuntu patches linux-source-2.6.38 - Linux kernel source for version 2.6.38 with Ubuntu patches $sudo apt-get

How to filter and intercept Linux packets by using net_dev_add() API?

自古美人都是妖i 提交于 2019-12-18 11:44:37
问题 I'm writing ethernet network driver for linux. I want to receive packets, edit and resend them. I know how to edit the packet in packet_interceptor function, but how can I drop incoming packets in this function?? #include <linux/netdevice.h> #include <linux/skbuff.h> #include <linux/ip.h> #include <net/sock.h> struct packet_type my_proto; int packet_interceptor(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) { // I dont want certain packets go

error while loading new compiled Linux kernel image into the android emulator(1.5)

女生的网名这么多〃 提交于 2019-12-18 09:01:31
问题 I have successfully compiled Linux kernel for android: root@ubuntu:~/common# ARCH=arm CROSS_COMPILE=~/mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi- make CHK include/linux/version.h make[1]: `include/asm-arm/mach-types.h' is up to date. CHK include/linux/utsrelease.h . . . SYMLINK include/asm -> include/asm-arm CALL scripts/checksyscalls.sh <stdin>:1097:2: warning: #warning syscall fadvise64 not implemented <stdin>:1265:2: warning: #warning syscall migrate_pages not

How do I configure modprobe to find my module?

纵然是瞬间 提交于 2019-12-17 21:40:14
问题 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 /etc/modules. What is the proper configuration? 回答1: You can make a symbolic link of your module to the standard path, so depmod will see it and you'll be able

How to append data on a packet from kernel space?

a 夏天 提交于 2019-12-17 18:33:44
问题 I am trying to append some data on a packet from kernel space. I have an echo client and server. I type in the command line like: ./client "message" and the server just echoes it back. The server was run with ./server . Now, the client and server are on two different machines (may be VMs). I am writing a kernel module which runs on the client machine. Its work is to append "12345" after "message" while the packet goes out of the machine. I am presenting the code below. /* * This is ibss_obsf

How do I use ioctl() to manipulate my kernel module?

廉价感情. 提交于 2019-12-17 17:44:07
问题 So I'm trying to write a kernel module that uses the linux/timer.h file. I got it to work inside just the module, and now I am trying to get it to work from a user program. Here is my kernel module: //Necessary Includes For Device Drivers. #include <linux/init.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/fs.h> #include <linux/errno.h> #include <linux/proc_fs.h> #include <asm/uaccess.h> #include <linux/timer.h> #include <linux/ioctl.h> #define DEVICE_NAME "mytimer"

Calling times() in kernel space

╄→гoц情女王★ 提交于 2019-12-13 16:08:46
问题 I am developing a kernel module, and I need to get an approximate value of the CPU time consumed by some process (iterating the processes is not an issue). Specifically, I want the same behavior provided by the libc clock or the times syscall. I tried calling do_sys_times but seems it's not exported (undefined symbol when compiled). Is there a way to call times inside a kernel module? Are there any other alternatives? 回答1: If you want precisely measure times between some events in kernel

Invalid module format

扶醉桌前 提交于 2019-12-13 16:04:20
问题 $insmod helloworld module generates the error message "Invalid module format". $dmesg outputs: overflow in relocation type 10 val ffffffff88640070 'hello' likely not compiled with -mcmodel=kernel The Makefile is a mix of tradition format (using (CC)) and module build system format "make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules" . The system is 1.6.18-194.el5 x86_64. The same Makefile works fine when it is used in i386 machine. Any idea of what to look into? Thanks. #Makefile,

sys v shared memory from kernel module to user space process

蓝咒 提交于 2019-12-13 07:18:14
问题 i am new in linux kernel module developpement and i am searching for sharing a memory segment from kernel module to user space process to escape latency of copying data. i am using the sys v shared memory api, when i share memory between two process it's work fine, but i am not able to share memory between process and kernel module. bellow is my code of the kernel module and the user space app server side : module #include <linux/module.h> // init_module, cleanup_module // #include <linux

How to gracefully disable the interrupt line without a kernel crash?

给你一囗甜甜゛ 提交于 2019-12-13 05:02:41
问题 I have implemented a program that reads from the keyboad, and scans code and put it into the tasklet. The tasklet unblocks the read(). Thus, my QT-application can read the data and if it finds the scan code of l, it fires a callback to Qt-webkit. However, when I am doing rmmod of my character driver. The entire kernel crashes. What is the problem in my character driver. #include <linux/init.h> #include <linux/module.h> /** needed by all modules **/ #include <linux/kernel.h> /** This is for