kernel-module

insmod fails with “Unknown symbol in module” for a symbol defined in another module

柔情痞子 提交于 2019-12-20 17:37:57
问题 I am working in Ubuntu. I am trying to make two kernel modules which uses each other functions. My problem is that I got modules properly compiled, but the symbol is not resolved for one of them. To make things simple, let's call these modules as m1 and m2 . m2 is exporting function void func_m2(void) . The m1 is calling this function. Both modules properly compile. After it all compiles, I need to load first the m2 module (because it has exported func_m2 function) and afterwards m1 module.

Yocto: Adding kernel module recipe to image, but it doesn't load on boot

时光总嘲笑我的痴心妄想 提交于 2019-12-20 14:45:28
问题 For testing purposes, I am using the example recipe provided by yocto to demonstrate how to build kernel modules. SUMMARY = "Example of how to build an external Linux kernel module" LICENSE = "GPLv2" LIC_FILES_CHKSUM = "file://COPYING;md5=12f884d2ae1ff87c09e5b7ccc2c4ca7e" inherit module PR = "r0" PV = "0.1" SRC_URI = "file://Makefile \ file://hello.c \ file://COPYING \ " S = "${WORKDIR}" # The inherit of module.bbclass will automatically name module packages with # "kernel-module-" prefix as

Using sk_buff to add an Ethernet frame header

三世轮回 提交于 2019-12-20 14:44:02
问题 I have a kernel module that captures outgoing Internet traffic(Netfilter hook: LOCAL_OUT) At this hook, there's still no Ethernet header. I built the Ethernet header and it's ready to use, but how can I attach it to the skb so that I can send the whole skb struct to dev_queue_xmit() ? Is there any guide on how to manipulate sk_buff data that you can provide me for further information? As a sample, I try to do what I want to do on all ECHO ICMP traffic; this is the code I have. But when

mapping memory reserved by mmap kernel boot param into user space

一个人想着一个人 提交于 2019-12-20 10:47:36
问题 As discussed in this question, i am reserving a memory chunk at the boot time using a kernel boot parameter memmap=8G$64G I have written a character driver kernel module which , during initialization does a ioremap of this reserved memory chunk. As explained here , in my driver mmap all i need to do is remap_pfn_range for this memory chunk pointer returned by the ioremap . I am running this on 3.0 linux kernel . My user space application opens this memory chunk as a device mounted by the

Cross Compiling Linux Arm Kernel with new driver module

痴心易碎 提交于 2019-12-20 04:52:00
问题 I am trying to include a driver for use on my arch linux arm machine. I tried using these steps to include the driver module, but my cross-compiled kernel with the added driver doesn't load. 1) Include the driver I want to add by making it have < M > beside it's name in make ARCH=arm menuconfig 2) run: make ARCH=arm CROSS_COMPILE=/home/z3/bin/arm- (the path for my cross-compiling toolchain) 3) run: make ARCH=arm CROSS_COMPILE=/home/z3/bin/arm- modules 4) run: make ARCH=arm CROSS_COMPILE=/home

Multiple kernel modules intercepting same system call and crash during unload

北慕城南 提交于 2019-12-20 02:58:27
问题 I'm working on system call interception (for open() system call) and I got one problem: I have two kernel modules ( mod1 and mod2 ) and both of them are trying to intercept open() syscall. I've loaded mod1 first and then mod2 . The mod1 intercepted open() by: original_open1 = sys_call_table[__NR_open]; sys_call_table[__NR_open] = mod1_open; Here original_open1 would be sys_open . After this, mod2 intercepted open() by: original_open2 = sys_call_table[__NR_open]; sys_call_table[__NR_open] =

GCC Return optimiztion

六月ゝ 毕业季﹏ 提交于 2019-12-19 09:54:17
问题 I'd like to know if GCC can optimize code like int foo(args) { if(is_true) { do_smth; n = call_func(args); do_smth; return n; } else { return call_func(args); } } so that if i'm in else branch call_func's call would be executed like there was no foo call? I'm writing kernel module, and for solving one particular issue I need it to look like this call_func was called directly. To be more specific call_func is some system call. Foo is my version of this system call. In is_true case I should do

Cross compiling a kernel module: invalid module format

怎甘沉沦 提交于 2019-12-19 09:06:15
问题 I'm trying to cross compile a helloworld kernel module with specifications: host: intel x86 32 bit, linux-3.0.0 target: ARM machine (Parrot AR.Drone), linux-2.6.27.47 I'm using the makefile: PWD := $(shell pwd) obj-m := test.o all: $(MAKE) -C /path/to/kernel M=$(PWD) CROSS_COMPILE=arm-none-linux-gnueabi- ARCH=arm modules Where arm-none-linux-gnueabi- is the prefix of the arm toolchain. As kernel, I tried using a clone from git://github.com/CyanogenMod/cm-kernel.git as kernel. This is a 2.6

Cross compiling a kernel module: invalid module format

送分小仙女□ 提交于 2019-12-19 09:05:09
问题 I'm trying to cross compile a helloworld kernel module with specifications: host: intel x86 32 bit, linux-3.0.0 target: ARM machine (Parrot AR.Drone), linux-2.6.27.47 I'm using the makefile: PWD := $(shell pwd) obj-m := test.o all: $(MAKE) -C /path/to/kernel M=$(PWD) CROSS_COMPILE=arm-none-linux-gnueabi- ARCH=arm modules Where arm-none-linux-gnueabi- is the prefix of the arm toolchain. As kernel, I tried using a clone from git://github.com/CyanogenMod/cm-kernel.git as kernel. This is a 2.6

Replace system call in linux kernel 3

守給你的承諾、 提交于 2019-12-18 13:38:07
问题 I am interested in replacing a system call with a custom that I will implement in linux kernel 3. I read that the sys call table is no longer exposed. Any ideas? any reference to this http://www.linuxtopia.org/online_books/linux_kernel/linux_kernel_module_programming_2.6/x978.html example but for kernel 3 will be appreciated :) Thank you! 回答1: I would recommend using kprobes for this kind of job, you can easily break on any kernel address (or symbol...) and alter the execution path, all of