kernel-module

How does “get_user_pages” work (For linux driver)

落爺英雄遲暮 提交于 2021-02-18 22:37:28
问题 Working on a Linux PCI driver, now I'm trying to write codes for DMA using scatter/gather. For now, I've learned that to access to DMA datas directly from User space, we need to pin user space pages to kernel space. And to do this, we have get_user_pages , its full definition is like: int get_user_pages(struct task_struct * tsk, struct mm_struct * mm, unsigned long start, int nr_pages, int write, int force, struct page ** pages, struct vm_area_struct ** vmas); My first question is about the

How to send and receive messages from function other than registered callback function in Netlink socket?

左心房为你撑大大i 提交于 2021-02-18 19:10:14
问题 In following kernel module, I hooked syscall sys_open, and now trying to send filename to process in userspace using Netlink socket, in response process will return a msg, and then according to msg, the kernel module will proceed further. source code: foo.c #include <linux/module.h> #include <linux/init.h> #include <linux/types.h> #include <asm/uaccess.h> #include <asm/cacheflush.h> #include <linux/syscalls.h> #include <linux/delay.h> // loops_per_jiffy //===============netlink===============

How to send and receive messages from function other than registered callback function in Netlink socket?

别等时光非礼了梦想. 提交于 2021-02-18 19:10:12
问题 In following kernel module, I hooked syscall sys_open, and now trying to send filename to process in userspace using Netlink socket, in response process will return a msg, and then according to msg, the kernel module will proceed further. source code: foo.c #include <linux/module.h> #include <linux/init.h> #include <linux/types.h> #include <asm/uaccess.h> #include <asm/cacheflush.h> #include <linux/syscalls.h> #include <linux/delay.h> // loops_per_jiffy //===============netlink===============

How to send and receive messages from function other than registered callback function in Netlink socket?

混江龙づ霸主 提交于 2021-02-18 19:07:13
问题 In following kernel module, I hooked syscall sys_open, and now trying to send filename to process in userspace using Netlink socket, in response process will return a msg, and then according to msg, the kernel module will proceed further. source code: foo.c #include <linux/module.h> #include <linux/init.h> #include <linux/types.h> #include <asm/uaccess.h> #include <asm/cacheflush.h> #include <linux/syscalls.h> #include <linux/delay.h> // loops_per_jiffy //===============netlink===============

Get userspace RBP register from kernel syscall

孤者浪人 提交于 2021-02-11 15:01:31
问题 I am writing a kernel system call and I want to read the base pointer register (RBP) of the user. Maybe I can do that using the pt_regs struct that is passed for parameter, isn't it? Example code: unsigned long int data; asmlinkage int my_read(int d) { get_rbp_of_userStack(&data);#or somthing like that } I know this data saved somewhere for the context switch, how can I get to it? this is my user code void rar() {//rbp here should be rsp when it call so it basically the return addres of the

Replace kernel builtin module with a loadable one

我与影子孤独终老i 提交于 2021-02-08 18:47:56
问题 I have developped a kernel module to manage a nf4 tag as a char device. I have developped this module outside of the kernel and tested it compiled as a loadable kernel module (i.e. .ko) during the development phase. Once the driver has been functional and stable enough I have inserted it into linux kernel source (v4.9.30) using patches so it's built as part of the kernel. Here I'm in the situation where the module is loaded probed at boot by kernel as it's builtin and it appears into the

Replace kernel builtin module with a loadable one

给你一囗甜甜゛ 提交于 2021-02-08 18:40:12
问题 I have developped a kernel module to manage a nf4 tag as a char device. I have developped this module outside of the kernel and tested it compiled as a loadable kernel module (i.e. .ko) during the development phase. Once the driver has been functional and stable enough I have inserted it into linux kernel source (v4.9.30) using patches so it's built as part of the kernel. Here I'm in the situation where the module is loaded probed at boot by kernel as it's builtin and it appears into the

Replace kernel builtin module with a loadable one

谁都会走 提交于 2021-02-08 18:38:20
问题 I have developped a kernel module to manage a nf4 tag as a char device. I have developped this module outside of the kernel and tested it compiled as a loadable kernel module (i.e. .ko) during the development phase. Once the driver has been functional and stable enough I have inserted it into linux kernel source (v4.9.30) using patches so it's built as part of the kernel. Here I'm in the situation where the module is loaded probed at boot by kernel as it's builtin and it appears into the

Replace kernel builtin module with a loadable one

左心房为你撑大大i 提交于 2021-02-08 18:35:45
问题 I have developped a kernel module to manage a nf4 tag as a char device. I have developped this module outside of the kernel and tested it compiled as a loadable kernel module (i.e. .ko) during the development phase. Once the driver has been functional and stable enough I have inserted it into linux kernel source (v4.9.30) using patches so it's built as part of the kernel. Here I'm in the situation where the module is loaded probed at boot by kernel as it's builtin and it appears into the

Replace kernel builtin module with a loadable one

余生长醉 提交于 2021-02-08 18:32:46
问题 I have developped a kernel module to manage a nf4 tag as a char device. I have developped this module outside of the kernel and tested it compiled as a loadable kernel module (i.e. .ko) during the development phase. Once the driver has been functional and stable enough I have inserted it into linux kernel source (v4.9.30) using patches so it's built as part of the kernel. Here I'm in the situation where the module is loaded probed at boot by kernel as it's builtin and it appears into the