kernel-module

how to use CryptoAPI in the linux kernel 2.6

会有一股神秘感。 提交于 2019-11-27 01:45:53
问题 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 only. 回答1: There are a couple of places in the kernel which use the crypto module: the eCryptfs file system (linux/fs/ecryptfs/) and the 802.11 wireless stack

Cross compiling a kernel module

孤者浪人 提交于 2019-11-27 00:22:06
问题 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 := Hello.o KDIR := /home/ravi/workspace/hawk/linux-omapl1 PWD := $(shell pwd) default: $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules clean: $(MAKE) -C $(KDIR) SUBDIRS=$

How to load Linux kernel modules from C code?

别来无恙 提交于 2019-11-26 20:39:12
问题 I have an application that has both two external kernel modules and a userspace daemon. I want to load the modules from the daemon code, written in C, at startup, and unload them on clean exit. Can I load them in a cleaner way than doing system("modprobe module"); and unload them using the corresponding rmmod ? 回答1: Minimal runnable example Tested on a QEMU + Buildroot VM and Ubuntu 16.04 host with this simple parameter printer module . We use the init_module / finit_module and remove_module

How to debug Linux kernel modules with QEMU?

泄露秘密 提交于 2019-11-26 16:57:30
问题 I am working on academic project that modifies some Kernel Networking code as well as include a new Kernel module . I am using QEMU to load modified kernel and test. However, i find that a complete OS is required in some .img to debug. Is it possible without it ? Or, which is the distro that can be used with Kernel 2.6 for system. The distro need not have any features, except ability to run programs, including networking support. 回答1: The easiest way in my opinion is to use buildroot http:/

How can I get a filename from a file descriptor inside a kernel module?

送分小仙女□ 提交于 2019-11-26 14:28:16
问题 I need to get the name of a file from a given file descriptor, inside a small linux kernel module that I wrote. I tried the solution given at Getting Filename from file descriptor in C, but for some reason, it prints out garbage values (on using readlink on /proc/self/fd/NNN as mentioned in the solution). How can I do it? 回答1: Don't call SYS_readlink - use the same method that procfs does when one of those links is read. Start with the code in proc_pid_readlink() and proc_fd_link() in fs/proc

File I/O in a Linux kernel module

浪子不回头ぞ 提交于 2019-11-26 13:44:27
问题 I'm writing a Linux kernel module that needs to open and read files. What's the best way to accomplish that? 回答1: Can I ask why are you trying to open a file? I like to follow Linux development (out of curiosity, I'm not a kernel developer, I do Java), and I've seen discussion of this question before. I was able to find a LKML message about this, basically mentioning it's usually a bad idea. I'm almost positive that LWN covered it in the last year, but I'm having trouble finding the article.

Read/write files within a Linux kernel module

南楼画角 提交于 2019-11-25 23:20:56
问题 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, the problem is that 2.6.30 does not export sys_read() . Rather it\'s wrapped in SYSCALL_DEFINE3 . So if I use it in my module, I get the following warnings: WARNING: \"sys_read\" [xxx.ko] undefined! WARNING: \"sys_open\" [xxx.ko] undefined! Obviously