linux-kernel

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===============

Linux memory segmentation

ⅰ亾dé卋堺 提交于 2021-02-18 10:48:06
问题 Looking into the internals of Linux and memory management, I just stumbled upon the segmented paging model that Linux uses. Correct me if I am wrong, but Linux (protected mode) does use paging for mapping a linear virtual address space to the physical address space. This linear address space constituted of pages, is split into four segments for the process flat memory model, namely: The kernel code segment ( __KERNEL_CS ); The kernel data segment ( __KERNEL_DS ); The user code segment ( _

Android process memory map

若如初见. 提交于 2021-02-18 08:02:14
问题 I try to understand the memory regions in the com.android.browser process [memory map below], and have a few questions: For the address ranges without a pathname, what are mapped here? There're multiple [stack:xxxx] regions, are they thread local stacks? If not, what are they? They seem to get mapped in many different locations scattered in the memory space. If assuming the stack is at the top of the user space, then the user space memory is 2GB, the rest 2GB taken by the kernel space. Is it

Where is the heap?

六月ゝ 毕业季﹏ 提交于 2021-02-17 06:20:09
问题 I understand that in Linux the mm_struct describes the memory layout of a process. I also understand that the start_brk and brk mark the start and end of the heap section of a process respectively. Now, this is my problem: I have a process, for which I wrote the source code, that allocates 5.25 GB of heap memory using malloc . However, when I examine the process's mm_sruct using a kernel module I find the value of is equal to 135168. And this is different from what I expected: I expected brk

insmod: ERROR: could not insert module kernel.ko: Invalid parameters - Error related to naming scheme of kernel module

霸气de小男生 提交于 2021-02-17 03:56:07
问题 I'm using C to create a custom kernel module to hook into the netfilter operation on my Ubuntu box. However, I'm running into a problem revolving around the module_param argument. When inserting the module, I'm attempting to add a custom field, specifically this will drop ICMP traffic when specified. The code compiles fine using a standard make file but when using insmod to insert it, I get the error insmod: ERROR: could not insert module kernel.ko: Invalid parameters I'm using the command

How can I share a global variable between two Linux kernel modules?

*爱你&永不变心* 提交于 2021-02-16 09:04:13
问题 I am trying to get notification when USB is connected and disconnected. So I am trying to implement signals. I created a file "file1" in debugfs. Then I provided a simple write file operation. In user space there is a user space application, which will write its PID in the "file1" of debugfs. In kernel space I can get the PID passed using the write method mentioned above. But I want to use this PID in a different kernel module. So I tried using EXPORT_SYMBOL(); , but if I don't include the

How can I share a global variable between two Linux kernel modules?

元气小坏坏 提交于 2021-02-16 09:00:59
问题 I am trying to get notification when USB is connected and disconnected. So I am trying to implement signals. I created a file "file1" in debugfs. Then I provided a simple write file operation. In user space there is a user space application, which will write its PID in the "file1" of debugfs. In kernel space I can get the PID passed using the write method mentioned above. But I want to use this PID in a different kernel module. So I tried using EXPORT_SYMBOL(); , but if I don't include the

How can I share a global variable between two Linux kernel modules?

我与影子孤独终老i 提交于 2021-02-16 09:00:32
问题 I am trying to get notification when USB is connected and disconnected. So I am trying to implement signals. I created a file "file1" in debugfs. Then I provided a simple write file operation. In user space there is a user space application, which will write its PID in the "file1" of debugfs. In kernel space I can get the PID passed using the write method mentioned above. But I want to use this PID in a different kernel module. So I tried using EXPORT_SYMBOL(); , but if I don't include the