How to include an arbitrary kernel header file in a module?
SituationI'm writing a kernel module for learning purpose and want to use sched_class_highest and for_each_class as defined here.I saw that if I want to use symbols in the file /include/linux/sched.h,...
View Articlepacemaker.log file is flooding with "Too many open files (24)" [closed]
My system is currently at Centos 8 and my /var/log/pacemaker/pacemaker.log file is flooding with GB of data and most of the error messages shows the below message.These messages are more than 1000 in...
View ArticleIn arm64 assembly, what does "adrp x0, idmap_pg_dir;" instruction mean?
A question on arm64 assembly language.For example in linux 5.9.15 source code, in arch/arm64/kernel/vmlinux.lds.S (linker script), there is a line idmap_pg_dir = .;. so idmap_pg_dir is an address. Now,...
View ArticleHow can I log outgoing TCP to IP and not (HTTP) iptables
I'm new to iptables and Linux-firewall in general. Can somebody help me with it?I want to write a table using iptables that will log outgoing TCP connections to a specific IP address, except these that...
View ArticleWhat happens to local static identifiers in __init function?
In application programming, static are stored in .BSS section. And unlike local variables they're not de allocated on function return or something similar to global variables.Functions can be tagged...
View ArticleWhat is the equivalent of current_kernel_time in Linux kernel v5?
I tried to compile some kernel modules from Pleora eBUS SDK on a Linux Ubuntu 19.04 machine with Kernel version 5.0.0-38-generic, but got the compilation error:error: implicit declaration of function...
View ArticleCollecting Load Weight Data From Linux Scheduler
I am working to understand the impact of different workloads on the load weight and WALT (ravg) in the linux scheduler. Specifically, I am working on the Android Kernel.Currently, I am logging all of...
View Articlewhy printk is printing something weird? [closed]
Part of a syscall function -char buf[256];long copied = strncpy_from_user(buf, msg, sizeof(buf));printk(KERN_INFO "stephen syscall called with \"%s\"\n", buf);This is the test program from where this...
View ArticleWhy? BUG: Bad page map in process *process* pte:b3e05275201 pmd:238adf067
I develop a kernel module using DMA dma_alloc_coherent() and remap_pfn_range().Sometimes, when I close the app that opened the character device, I get the following message in dmesg. That leads to a...
View ArticleLinux initrd customizations: No filesystem could mount root [closed]
Just some context in case it proves to be useful: I'm currently working on a project to remove reliance on a filesystem in flash. Instead, I have 4 files stored in blobs (kernel image, initrd image,...
View ArticleWhy in Linux Virtual File System, the s_blocksize_bits is one bit less than...
Part of the struct super_block structure definition is presented below:struct super_block { //... dev_t s_dev; /* identifier */ unsigned char s_blocksize_bits; /* block size in bits */ unsigned long...
View ArticleHow to create version and help for manual commands in LINUX?
Each linux command has an option --help which helps the end user to understand the usecases via examples. Similarly if I execute my manual command manualcmd --help it should provide me the necessary help
View ArticleHow to remove linux external kernel module which is installed with "make...
I found that, I can install an externel linux kernel module with "make modules && make modules_install" command, which will copy the *.ko file (such as test.ko) into /lib/modules/ directory.But...
View ArticleKernel Module UDP socket drops datagrams although consumed
The SituationI am currently writing a kernel module, that should handle a custom network protocol based on UDP.What I do (in rather pseudocode) is, I create a UDP socket withsock_create(AF_INET,...
View ArticleMaking a kernel module that can return a list of currently running processes...
I'm trying to create a kernel module that will create a /dev/process_list character device. If a read() call is made on my character device, the kernel module must return information on all currently...
View ArticleMoving files from a linux kernel module
My goal is to write a kernel module that deletes the binary for /bin/ps and then moves and renames a file from the /tmp directory to replace ps in the /bin directory. It's basically a proof of concept...
View Articleis there a dual spi-gpio linux driver?
I would like to use two GPIO as MOSI so I can do Dual-SPI. I'm using the linux kernel with the spi-gpio.c driver: https://elixir.bootlin.com/linux/v4.19.152/source/drivers/spi/spi-gpio.cI want to link...
View ArticleFrom file struct to absolute path on underlying filesystem
Given a file struct, how can retrieve its full path on the filesystem it RESIDES ON? I only know enough to solve this problem by:Saving a string that is the filename associated with the file struct (my...
View ArticleWhere is eax in the pt_regs struct? Only ax is present
I am trying to use the pt_regs struct to get and set registers such as eax, but compilation errors tell me that pt_regs has no such member eax. However, I am able to get the ax register. Can anybody...
View ArticleGet userspace RBP register from kernel syscall
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...
View Article