kernel-module

Get all mount points in kernel module

老子叫甜甜 提交于 2021-02-08 07:23:30
问题 I'm trying to get all the mount points in a kernel module. Below is what I've come up with. It segfaults because of the strcat. Is this the correct way to get the mount points? Will this work? if so how do i fix the segfault? If not, how does one go about getting the mount points in a linux kernel module? I've tried cycle the whole namespace looking for mountpoint roots that match but its from 2003 and the kernel has changed so much so its basically useless. Also tried get filesystem mount

Get all mount points in kernel module

*爱你&永不变心* 提交于 2021-02-08 07:20:33
问题 I'm trying to get all the mount points in a kernel module. Below is what I've come up with. It segfaults because of the strcat. Is this the correct way to get the mount points? Will this work? if so how do i fix the segfault? If not, how does one go about getting the mount points in a linux kernel module? I've tried cycle the whole namespace looking for mountpoint roots that match but its from 2003 and the kernel has changed so much so its basically useless. Also tried get filesystem mount

Base address at which the linux kernel is loaded

若如初见. 提交于 2021-02-07 06:36:31
问题 I have a couple of doubts about how the kernel is loaded into memory. Upon inspecting /proc/kallsyms I'm able to find the address of various symbols in the kernel. $ cat /proc/kallsyms | head -n 10 00000000 t __vectors_start 80008240 T asm_do_IRQ 80008240 T _stext 80008240 T __exception_text_start 80008244 T do_undefinstr 80008408 T do_IPI 8000840c T do_DataAbort 800084a8 T do_PrefetchAbort 80008544 t gic_handle_irq 800085a0 T secondary_startup Is there any way I can find the base address at

Trying to find all the kernel modules needed for my machine using shell script

旧巷老猫 提交于 2021-02-04 10:27:10
问题 I'm developing kernel modules right now, and the build times are starting to get under my skin. As a side effect I'm taking way too many "coffee" breaks during builds. So I was looking for a way to build only the stuffs I need for my platform. Chapter 7 and 8 of "linux kernel in a nutshell" gave a good detail of how to do that by hand. Its a good read : http://www.kroah.com/lkn/ But Although I understand the stuffs, this is still a lot of tweaks to make that work. 2.6.32 and later kernels

Making Kernel Module and registering it as pci device driver and network device driver and accessing the module's buffer using ioctl. Possible?

本小妞迷上赌 提交于 2021-01-29 17:16:50
问题 I like to make a kernel module. And inside it I like to register it as pci and network device driver. And using ioctle from user space to access the module's buffer(in pci and network driver) and getting buffer. The buffer contains packets received in interrupt handler when packet arrives in my kernel module/device driver and the buffer is global in the module. Means it will not be inside interrupt handler for receiving packets. and in ioctl function implementation inside device driver just

LiME Kernel Module Cross Compilation Fails

杀马特。学长 韩版系。学妹 提交于 2021-01-29 11:11:22
问题 I'm trying to cross-compile the LiME Kernel Module for the android-goldfish-3.10-n-dev ( commit: 3a3b199582a68ba0688a099147738d6c99f3282d ) Linux Kernel version with the following Makefile: obj-m := lime.o lime-objs := tcp.o disk.o main.o KDIR_GOLD := /path/to/goldfish PWD := $(shell pwd) CCPATH :=/path/to/x86_64-linux-android-4.9/bin default: # cross-compile for Android emulator $(MAKE) ARCH=x86_64 CROSS_COMPILE=$(CCPATH)/x86_64-linux-android- -C $(KDIR_GOLD) M="$(PWD)" modules $(CCPATH)/x86

Edit and compile a kernel module

五迷三道 提交于 2021-01-29 07:17:18
问题 I'm trying to edit one module from kernel source and compile it for kernel: 5.4.0-40-generic #44-Ubuntu . This is how i did it: git clone git://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/focal git checkout -b temp Ubuntu-5.4.0-40.44 nano drivers/media/usb/siano/smsusb.c make oldconfig make prepare make modules_prepare make SUBDIRS=scripts/mod make SUBDIRS=drivers/media/usb/siano modules cd drivers/media/usb/siano/ insmod smsusb.ko I got this error: insmod: ERROR: could not

ARM64 - Linux Memory Write protection won't disable

喜你入骨 提交于 2021-01-28 09:51:53
问题 i'm trying to disable the Memory Write protection on an ARM64 system from within an LKM. (Startet in the DOM0 of the Xen hypervisor) I found the corresponding PTE to an virtual address by using the Linux Kernel Functions. pgd_t *pgd; pte_t *ptep, pte; pud_t *pud; pmd_t *pmd; pgd = pgd_offset(init_mm, (addr)); if (pgd_none(*pgd) || pgd_bad(*pgd)) goto out; printk(KERN_NOTICE "Valid pgd 0x%lx\n",pgd); pud = pud_offset(pgd, addr); if (pud_none(*pud) || pud_bad(*pud)) goto out; printk(KERN_NOTICE

How can a kernel module unload itself without generating errors in kernel log?

安稳与你 提交于 2021-01-28 04:58:54
问题 I've made a simple module which prints GDT and IDT on loading. After it's done its work, it's no longer needed and can be unloaded. But if it returns a negative number in order to stop loading, insmod will complain, and an error message will be logged in kernel log. How can a kernel module gracefully unload itself? 回答1: As far as I can tell, it is not possible with a stock kernel (you can modify the module loader core as I describe below but that's probably not a good thing to rely on). Okay,

C - Linux - Custom kernel module to iterate over a process' children blows up kernel log and the computer

不打扰是莪最后的温柔 提交于 2021-01-27 21:49:30
问题 I'm new to linux kernel modules and I am trying to implement some basic concepts before handling complex ones. I wrote a code which takes a module parameter (an int) and checks if there is a process with that pid. If there is, it takes its children as a list and iterates over it while printing the children's ids and descriptions. Here is the code: #include <linux/init.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/list.h> #include <linux/types.h> #include <linux/slab.h