Profile cover photo
Profile photo
Mateusz Guzik
meh
meh
About
Posts

Post has attachment
Add a comment...

Post has attachment
bad kernel tutorials for beginners
There is an abundance of materials for beginners, which supposedly explain how to add your own syscall, hijack an existing one or maybe add a device driver to the linux kernel. Unfortunately presented code is typically buggy way beyond a mistake anyone can ...
Add a comment...

Post has attachment
will the operating system clean up after process exit
From time to time there are people asking "if I allocate memory and exit without freeing it, will it cause a leak?". I recently encountered a variant with file descriptors and getting rid of the file after exit without explicit close. While the answer for m...
Add a comment...

Post has attachment
malloc+memset vs calloc
There is various advice out there suggesting the use of calloc or malloc followed by memset. Also claims are made about supposed performance difference between the two, followed by problematic explanation as to what's going on, in particular involving the s...
Add a comment...

Post has attachment
linux sysadmin interview questions
Most of these questions are known, for which I apologize. The purpose of this post is to have a collection of questions I consider to be of reasonable to quality. Questions are provided in a somewhat shortened form in order to reduce repetition. The intervi...
Add a comment...

Post has attachment
when the kernel can kill a process
Common cases of the kernel killing something include the OOM killer, things like SIGSEGV/SIGBUS due to incorrect memory access or a prosaic signal sent by someone. Let's take a look at less popular ones. 1. OOPS If the kernel detects a problem with its stat...
Add a comment...

Post has attachment
symlinks vs hardlinks
Given /foo/bar , one could say "the file bar is in the directory foo".  This is fine for everyday purposes when hardlinks are understood, but in general is incorrect. Files exist on filesystems (not in directories) and are represented by inodes. An inode co...
Add a comment...

Post has attachment
linux process number shenanigans
How do you check how many processes are present on your Linux system? Will ps aux do the trick? Is this really the thing you would want to check? Let's see. A process is a program being executed. It has several properties, like security credentials (uid, gi...
Add a comment...

Post has attachment
Fun fact: transient failure to read process name on Linux
Process names are obtained by tools like ps by reading /proc/<pid>/fd/cmdline . The content of the file is obtained by accessing target process's address space. But the information is temporarily unavailable during execve. In particular, a new structure des...
Add a comment...

Post has attachment
kernel game #3
Assume we have an extremely buggy driver. Multiple threads can call into meh_ioctl shown below at the same time with the same device and there is no locking provided. The routine is supposed to either store a pointer to a referenced struct file object in m-...
Add a comment...
Wait while more posts are being loaded