Generally speaking, if we want to use current macro in Linux kernel, we should: but there is a asm-generic version: the asm version implements the current macro through per-cpu variable, but asm-generic version implements the current macro through thread_info, these two are totally different. Linux kernel hea…
Tag: linux-kernel
What is the for_each_sched_entity macro doing?
I’m not familiar with what this for loop is actually doing. Would anyone be able to explain? https://elixir.bootlin.com/linux/v5.10.75/source/kernel/sched/rt.c#L621 Answer This macro is setting rt_se to NULL after the instructions block that follows has been executed. The use of such “access”…
How to include device tree overlay into Raspberry Pi CM4
I would like to include UART3 and UART5 overlay to enable them, using Yocto. They are already delivered with the whole package (https://github.com/raspberrypi/linux/blob/rpi-5.10.y/arch/arm/boot/dts/overlays/uart3-overlay.dts) I added to my main image recipe lines: I have also added .bbappend to enable them i…
struct is it declaration or defination or some type of Object Oriented behavior in kernel source
In r8169_main.c in linux kernel source there is a struct like this I like to in first member .name but there is no data type specified and there is . before name like .name = KBUILD_MODNAME, what is it called. is this name member defined somewhere else what this static struct means I did not seen this type of…
SeedLabs Firewall Lab: Implement a Simple Kernel Module, failure to build a kernel module
I’m following the steps from here at 3.1 Task 1.A: Implement a Simple Kernel Module: https://seedsecuritylabs.org/Labs_20.04/Files/Firewall/Firewall.pdf Everything was fine until I ran the make command. the hello.ko file wasn’t generated and I don’t know what’s wrong. Answer You must a…
How does the bitwise AND help in the if statements in the Linux Kernel?
Background on what the code is trying to achieve: “Various parameters of the new process (e.g., euid, egid, argument list, environment, filename, etc.) that are subsequently passed to other functions are, for the sake of simplicity, combined into a structure of type linux_binprm. prepare_binprm is used …
error: ‘res_ninit’ was not declared in this scope; did you mean ‘res_init’?
I am trying to install an application from its source code in the alpine it says there is no res_ninit, res_nsearch and res_nclose but we can see here that do exists in the Linux headers and I have already installed apk add linux-headers, how can I resolve this issue? Update: I cat the header file /usr/includ…
Why does strace ignore some syscalls (randomly) depending on environment/kernel?
If I compile the following program: and then run it under strace in “standard” Kubuntu, I get this: As you can see, there is no clock_gettime (full strace output is here). On the other hand, if I run the same app in my custom built linux kernel under qemu, I get the following output: Which is more…
Allocating physically contiguous pages in Kernel Module
I am trying to allocate physically contiguous pages in DRAM using the alloc_pages_exact function. When I try to allocate 10MB of pages, the returned address is always 0. But when I try to allocate 1MB of pages, the allocation is almost immediate. Also, can someone please tell me how to find the exact row size…
Constructing a complete control flow graph for Linux kernel
Are there any tools that can build the control flow graph for an entire Linux kernel binary? For example, consider Linux kernel compiled for x86 architecture (vmlinux file). Is it possible to determine all execution paths (regarding indirect call) using both static analysis and dynamic analysis? Are there any…