Category "linux-kernel"

Error "assignment from incompatible pointer type" when creating a Netfilter kernel module

I'm implementing a "mini firewall" and use the filter function with the signature shown below: unsigned int minifw_inbound_filter(unsigned int hooknum, struct s

Why can low priority processes affect the latency of an high priority process?

I have tested the rt process's latency by cyclictest. And found that when I launch a few lower priority rt processes(priority is 40) the high priority rt proces

How to build multiple linux kernel module with multiple source files in a single Makefile?

I am trying to build a set of Linux kernel modules with multiple source files: obj-m += mst_pciconf.o mst_pci.o mst-objs += nnt_device.o nnt_dma.o nnt_pci_conf_

A pthread with SCHED_RR and higher real time priority failed to preempt a kthread in kernel module with lower priority

Preface: I have two threads: one kernel thread and one userspace pthread. I assume pthread set to SCHED_RR with higher rt priority should preempt a kthread with

Can compilers break control dependencies used for LoadStore memory ordering or similar, in any real use-cases?

I'm reading the mail list about LKMM: Add volatile_if(). The control dependency is somewhat subtle since it is easily forgotten by us developers. So I wonder i

ftrace cannot trace some kernel functions

I'm using ftrace to trace ip_local_out() in kernel 5.4.20. I'm sure ip_local_out() is available to trace: /sys/kernel/debug/tracing # cat available_filter_funct

Error building program using gcc plugin from linux kernel source tree

I am trying to use a grsecurity gcc plugin that I found on their unofficial linux kernel source tree (the respectre_plugin/ one). My GCC version is 4.7, I modif

What is the benefit of calling ioread functions when using memory mapped IO

To use memory mapped I/O, we need to first call request_mem_region. struct resource *request_mem_region( unsigned long start, u

Using populate_sdk to include kernel headers

How do I include the linux kernel headers as part of the SDK package in Yocto? I'm using Yocto 1.8 (fido) in an embedded project and want to do out-of-tree ker

What is linux vhost and how it helps virtio offloading?

I finished reading https://www.redhat.com/en/blog/introduction-virtio-networking-and-vhost-net and couldn't understand exactly. I understand how virtio works. H

Linux kernel: is a re-assigned page frame cleared?

When a process ends, the Linux kernel can re-assign the user-space page frames (the pages in physical memory) to the user-space pages (in virtual memory) of ano

How to debug in kernel mode using printk

I am trying to add some stuff to Linux task_struct. In this area I copy a string from the user and try to store it in my struct. I try to debug my code by add

IP tuntap command can't open tun

I want to create a TUN interfae I type command in adb like below mkdir -p /dev/net busybox mknod /dev/net/tun1 c 10 200 chmod 666 /dev/net/tun1 ip tuntap add d

Is the sscanf function in the Linux kernel susceptible to buffer overflow attacks?

From what I understand, a typical buffer overflow attack occurs when an attack overflows a buffer of memory on the stack, thus allowing the attacker to inject m

Why can the posix thread id be NULL in Linux kernel function filp_close?

Below is excerpted from linux kernel: /* * "id" is the POSIX thread ID. We use the * files pointer for this.. */ int filp_close(struct file *filp, fl_owner_

Determine architecture when compiling linux module

I am writing a kernel module and in it I have the following piece of code: dma_dev->coherent_dma_mask = DMA_BIT_MASK(64); I do not always want 64 in there

simple_read_from_buffer/simple_write_to_buffer vs. copy_to_user/copy_from_user

I recently wrote a module implementing these functions. What is the difference between the two? From my understanding, the copy_..._user functions are more sec

Linux Kernel Module - Create Directory

I've got a problem about creating a directory within a linux kernel module. What I want: Creating a directory within a kernel module. Here is my actual code:

wait_for_completion for submit_bio in make_request not returning

I am writing a custom block driver in the Linux kernel and in my make_request routine, on writes I need to read the data of the bio's specified sector (from the

why struct cdev has kobject member?

It's strange that struct cdev has struct kobject member, do any body knows the reason?