How does kernel get an executable binary file running under linux?

Best moments of the exec system call on Linux 4.0 The best way to find all of that out is to GDB step debug the kernel with QEMU: How to debug the Linux kernel with GDB and QEMU? fs/exec.c defines the system call at SYSCALL_DEFINE3(execve Simply forwards to do_execve. do_execve Forwards to do_execveat_common. do_execveat_common To … Read more

Is there a macro definition to check the Linux kernel version?

The linux/version.h file has a macro called KERNEL_VERSION which will let you check the version you want against the current linux headers version (LINUX_VERSION_CODE) installed. For example to check if the current Linux headers are for kernel v2.6.16 or earlier: #include <linux/version.h> #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) … #else … #endif A better way to get … Read more

How to find out what Linux capabilities a process requires to work?

Based on recent libcap2 update 1: (Short option): getpcaps Description: From here: getpcaps displays the capabilities on the processes indicated by the pid value(s) given on the command line. Example: $ getpcaps <PID> PID: = cap_chown,cap_dac_override,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_net_raw,cap_sys_chroot,cap_mknod,cap_audit_write,cap_setfcap+i 2: (A bit longer option): /proc status and capsh Description: proc is a process information pseudo-filesystem or in other … Read more

Difference between KVM and LXC

Text from https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/7-Beta/html/Resource_Management_and_Linux_Containers_Guide/sec-Linux_Containers_Compared_to_KVM_Virtualization.html Copyright © 2014 Red Hat, Inc.: Linux Containers Compared to KVM Virtualization The main difference between the KVM virtualization and Linux Containers is that virtual machines require a separate kernel instance to run on, while containers can be deployed from the host operating system. This significantly reduces the complexity of container creation … Read more

What is the difference between FUTEX_WAIT and FUTEX_WAIT_PRIVATE?

This is an optimization done by linux/glibc to make futexes faster when they’re not shared between processes. Glibc will use the _PRIVATE versions of each of the futex calls unless the PTHREAD_PROCESS_SHARED attribute is set on your mutex It’s explained in more detail here: http://lwn.net/Articles/229668/ For the purposes of your debugging, you can just ignore … Read more

What do the counters in /proc/[pid]/io mean?

While the proc manpage is woefully behind (and so are most manpages/documentation on anything not relating to cookie-cutter user-space development), this stuff is fortunately documented completely in the Linux kernel source under Documentation/filesystems/proc.rst. Here are the relevant bits: rchar —– I/O counter: chars read The number of bytes which this task has caused to be … Read more

Difference between physical/logical/virtual memory address

My answer is true for Intel CPUs running on a modern Linux system, and I am speaking about user-level processes, not kernel code. Still, I think it’ll give you some insight enough to think about the other possibilities Address Types Regarding question 3: I have come across discussion that virtual and logical addresses/address space are … Read more