
Users, Groups and setuid Explained for Systems Programmers
Learn real, effective and saved user IDs, what setuid does at execve, and the correct order to drop privileges in C with setgroups, setgid and setuid.
Tag
362 posts

Learn real, effective and saved user IDs, what setuid does at execve, and the correct order to drop privileges in C with setgroups, setgid and setuid.

A cheat sheet of 15 kinds of undefined behavior in C, each with an example, the sanitizer message, the safe fix and when it is not a problem.

Write a TCP client in C that calls socket and connect, sends a request, reads the reply until the server closes, and handles errors on Linux.

Build a DBG macro in C23 with GCC 14 that prefixes every debug line with __FILE__, __LINE__ and __func__, writes to stderr and compiles away in release builds.

NUMA gives each CPU socket its own local memory, so a core reads its own memory fastest and pays extra to reach another socket's. Learn why and how to see it.

A Zephyr application is a CMakeLists.txt, a prj.conf, a src folder and optional board files. See what each file does and how a build combines them.

Build container isolation by hand: Linux namespaces for what a process sees, cgroups v2 for what it may use, with C code for clone and pivot_root.

Learn how DMA controllers move data without the CPU, from memory copies to ADC, UART and timer transfers, on STM32, RP2040 and ESP32, and the pitfalls to avoid.

Reading or writing past the end of a C array is undefined, yet it often runs without a crash. See where the extra bytes come from and why that luck is a trap.

Build a TCP echo server in C with socket, bind, listen and accept, handle one client at a time, and check every error on Linux.

Latency is the wait for one memory access and bandwidth is bytes moved per second. See how they differ, how Little's law links them and which limits your loop.

Learn Zephyr RTOS from install to first threads: west, Kconfig, devicetree, the build, kernel services, logging, debugging and tests, with FreeRTOS comparisons.