linux-kernel

Linux kernel headers' organization

孤人 提交于 2021-02-07 13:46:58
问题 While I was doing some reading on system calls, I did a search for syscalls.h to find the header file in LXR. The search results puzzled me. There is a dozen of syscalls.h files coming from directories under arch/_arch_name_/include/asm . These are ok, they are architecture specific definitions or something else needed. The question is why do we have two different syscalls.h headers under both include/linux and include/asm-generic ? Also, I want to find out that what include/linux headers are

Incorrect memory access: why is my kernel *not* crashing

喜欢而已 提交于 2021-02-07 10:24:40
问题 I wanted to show to somebody an exemple of incorrect memory access (kernelspace trying to access userspace memory leading to a bug). Thus, I took an old tutorial as a POC, the important part is : static ssize_t dev_write(struct file *filep, const char *buffer, size_t len, loff_t *offset){ sprintf(message, "%s(%zu letters)", buffer, len); // appending received string with its length // [...] } This causes a crash in one of my environment tests, which is the expected behavior (I access the

Incorrect memory access: why is my kernel *not* crashing

孤街浪徒 提交于 2021-02-07 10:22:27
问题 I wanted to show to somebody an exemple of incorrect memory access (kernelspace trying to access userspace memory leading to a bug). Thus, I took an old tutorial as a POC, the important part is : static ssize_t dev_write(struct file *filep, const char *buffer, size_t len, loff_t *offset){ sprintf(message, "%s(%zu letters)", buffer, len); // appending received string with its length // [...] } This causes a crash in one of my environment tests, which is the expected behavior (I access the

How to make Linux ignore a keyboard while keeping it available for my program to read?

本小妞迷上赌 提交于 2021-02-07 09:44:54
问题 I am building some kind of kiosk system and I bought this USB DIY keyboard for it: https://www.amazon.com/gp/product/B07QPXQQ7L This allows me to have a lot of buttons and they behave like keyboard keys. I'm writing a program (Perl) that will take the input from that keyboard and do things based on that. The problem is that I need to have the rest of the system (both X and the TTYs) ignore that keyboard so that it won't type random things in the terminal or in the window manager. In other

How to make Linux ignore a keyboard while keeping it available for my program to read?

牧云@^-^@ 提交于 2021-02-07 09:44:06
问题 I am building some kind of kiosk system and I bought this USB DIY keyboard for it: https://www.amazon.com/gp/product/B07QPXQQ7L This allows me to have a lot of buttons and they behave like keyboard keys. I'm writing a program (Perl) that will take the input from that keyboard and do things based on that. The problem is that I need to have the rest of the system (both X and the TTYs) ignore that keyboard so that it won't type random things in the terminal or in the window manager. In other

How to acess the physical address from linux kernel space?

旧时模样 提交于 2021-02-07 08:21:33
问题 I am working on rasberry pi board. Is it possible to directly access the GPIO physical address from linux kernel space using inb(), outb()... ?. If yes how ?. GPIO register address link Page 90 http://www.raspberrypi.org/wp-content/uploads/2012/02/BCM2835-ARM-Peripherals.pdf Thank you 回答1: Yes. Get a virtual address mapping setup to the registers in question using ioremap Use readl/writel to manipulate the physical memory. Beware that ARM processors will fault on unaligned accesses. Linux

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

why sibling list is used to get the task_struct while fetching the children of a process

﹥>﹥吖頭↗ 提交于 2021-02-07 03:20:50
问题 Kernel task_struct looks like below.I am more interested in two members namely children and sibling , so i have removed other elements from this kernel structure . struct task_struct{ // some data elements . struct list_head children; /* list of my children */ struct list_head sibling; /* linkage in my parent's children list */ //some data members }; "children" is a doubly circular linked list of task_struct of the children of process .If I want to access the children from current process , I

why sibling list is used to get the task_struct while fetching the children of a process

99封情书 提交于 2021-02-07 03:18:33
问题 Kernel task_struct looks like below.I am more interested in two members namely children and sibling , so i have removed other elements from this kernel structure . struct task_struct{ // some data elements . struct list_head children; /* list of my children */ struct list_head sibling; /* linkage in my parent's children list */ //some data members }; "children" is a doubly circular linked list of task_struct of the children of process .If I want to access the children from current process , I

Execute shell command in kernel module

て烟熏妆下的殇ゞ 提交于 2021-02-06 12:51:32
问题 Is it possible to execute shell command in kernel module. I know that we can do it in user space C code using system subroutine. I am debugging a kernel module which has memory leak issue. After doing insmod and rmmod module.ko in an infinite loop, system goes out of memory within few minutes with 8G RAM. It would be helpful to know memory status using free command before and after the call to API responsible to free memory so i can know that API is working or not. This is the way i am