Syscall Wrappers, CRT, errno & strace
Confusing pure Ring 3 library helpers with Ring 0 syscall wrappers—or misreading execve ENOENT missing-loader errors and stale errno values—paralyzes production debugging. You will trace ELF PT_INTERP and CRT _start startup, inspect .plt/.got.plt dynamic relocations, test thread-local errno, and verify exact syscall counts under strace.
What you'll learn
- Distinguish pure Ring 3
glibchelpers (strlen,memcpy) from Ring 0 syscall wrappers and.plt/.got.pltstubs. - Trace ELF startup from
PT_INTERPand CRT_start->__libc_start_main->main()across descriptors0,1,2. - Diagnose negative kernel
-errnotranslations via thread-localerrno,perror(), andstrerror()(EBADF,EINTR).
Why main() Is Not First and Not Every libc Call Enters Ring 0
Two mysteries ambush almost every engineer debugging a deployed Linux binary for the first time. First, you copy a freshly cross-compiled ./sensor_agent binary onto a minimal ARMv7 root filesystem, verify -rwxr-xr-x permissions with ls -l, execute ./sensor_agent, and the shell prints No such file or directory (ENOENT) for a file sitting right in front of you! Second, inside a running service, a developer writes errno = 0; write(fd, buf, 8); printf("ok\n"); if (errno != 0) abort();—and the service aborts with Inappropriate ioctl for device (ENOTTY) whenever stdout is redirected to a log file, even though write() succeeded!
Both failures stem from treating main() and <stdio.h>/<unistd.h> as black boxes. Execution of a dynamically linked Executable and Linkable Format (ELF) binary begins inside the kernel's PT_INTERP dynamic loader (ld-linux) and C Runtime (CRT) _start preamble long before main(), while the GNU C Library (glibc, libc.so.6) mixes pure Ring 3 RAM algorithms, buffered stream helpers, and thin Ring 0 syscall wrappers that leave thread-local errno untouched on success.
note: Think of a corporate mailroom inside your office building. Drafting memos or sorting spreadsheets happens right at your desk, whereas sending a registered courier pouch goes through a mailroom clerk who stamps the manifest, hands it to external transport, and records any delivery rejection code on your receipt.
Where it stops working: Unlike an office clerk who works asynchronously, a glibc syscall wrapper executes synchronously on the calling thread's stack and CPU registers before returning control.
definition (CRT Startup, PLT/GOT Trampolines & Syscall Wrappers): C Runtime Startup (crt1.o _start) & Dynamic Linkage (.plt / .got.plt): Named for the C Runtime object linked ahead of user .o files, _start aligns the initial stack pointer pushed by execve() (argc, argv[], envp[], and Elf_auxv_t auxiliary vectors) and calls __libc_start_main(). In Position-Independent Executables (PIE), external calls jump through a read-only Procedure Linkage Table (.plt) stub that dereferences a Global Offset Table (.got.plt) JUMP_SLOT resolved by the PT_INTERP dynamic linker (ld-linux). Syscall Wrappers issue the CPU trap and translate kernel returns in [-4095, -1] into positive thread-local errno plus (ssize_t)-1.
One Layer Down: execve Stack Layout, -4095..-1 Error Math & PLT Dispatch
During execve(), the Linux kernel ELF loader maps .text (PROT_READ | PROT_EXEC), .rodata (PROT_READ), and .data/.bss (PROT_READ | PROT_WRITE virtual memory areas), opens the interpreter path named in the PT_INTERP program header (such as /lib64/ld-linux-x86-64.so.2 or /lib/ld-linux-armhf.so.3—returning ENOENT if that loader file is missing!), and constructs the initial user stack (16-byte aligned on x86-64 System V; 8-byte aligned on ARMv7 AAPCS): argc, argv[0..argc-1], NULL, envp[0..M-1], NULL, and Elf_auxv_t (key, val) pairs (AT_PAGESZ, AT_SYSINFO_EHDR). _start hands main to __libc_start_main(), which initializes Thread-Local Storage (TLS) for errno, executes .init_array constructors, invokes main(argc, argv, envp) with STDIN_FILENO (0), STDOUT_FILENO (1), and STDERR_FILENO (2) pre-opened, and passes main's return value (status & 0xFF) through .fini_array/atexit() to exit_group().
Why does the Linux kernel reserve [-4095, -1] (0xfffffffffffff001..0xffffffffffffffff on 64-bit) in %rax / r0 for syscall errors instead of returning -1 directly? Because valid virtual addresses and byte counts can occupy nearly the entire unsigned register space except the final 4,095 bytes of the top kernel guard page! Inside every glibc syscall wrapper, one unsigned comparison is_err(r) <==> (unsigned long)r > (unsigned long)(-4096L) tests for error. When true, glibc computes *__errno_location() = (int)(-r) (for example, -(-9) == EBADF) and returns -1; when false (r >= 0), glibc returns r without touching errno.
libc.so.6 / ELF Layer | Concrete Symbols | Kernel Trap Count | Error & Inspection Mechanism |
|---|---|---|---|
Pure Ring 3 library helper | strlen(), memcpy(), strtol(), snprintf() | 0 traps | Operates strictly in user RAM; invisible to strace |
Ring 0 syscall wrapper | write(), read(), openat(), close() | 1 trap per call | r in [-4095,-1] sets TLS errno, returns -1; 1:1 in strace |
Buffered stdio stream | printf(), fwrite(), fputs() | 1 trap per buffer flush | Batches into FILE heap buffer (4..8 KiB) before write() |
.plt / .got.plt & PT_INTERP | write@plt, R_*_JUMP_SLOT, ld-linux | Loader openat/mmap at start | Inspect via readelf -l -rW, objdump -d, LD_DEBUG=bindings |
Figure 1.3. ELF PT_INTERP and crt1.o _start startup chain, PLT/GOT dynamic linkage, and [-4095, -1] thread-local errno demultiplexing.
- Step 1. execve() builds the 16-byte aligned stack (argc, argv, envp, auxv) and loads PT_INTERP (missing loader => ENOENT).
- Step 2. crt1.o _start invokes __libc_start_main(), initializes TLS errno, runs .init_array constructors, and calls main().
- Step 3. Pure Ring 3 helpers run in RAM (0 traps), whereas write@plt jumps via .got.plt into libc's syscall instruction.
- Step 4. Kernel returns in [-4095, -1] populate thread-local errno and return -1; successful calls leave errno untouched.
Figure 1.3b. Execution starts in PT_INTERP and crt1.o _start before main(), and only Ring 0 syscall wrappers enter strace or set thread-local errno on failure.
Inspecting Standard Descriptors, GOT/PLT Relocations & errno
Include <unistd.h>, <errno.h>, <stdio.h>, and <string.h> under #define _POSIX_C_SOURCE 200809L. Every POSIX process inherits STDIN_FILENO (0), STDOUT_FILENO (1), and STDERR_FILENO (2). When ssize_t write(int fd, const void *buf, size_t count) returns -1, capture int saved_err = errno; on the very next line (EBADF 9 indicates a closed or negative descriptor; EINTR 4 indicates a signal interrupted a blocked call before any byte moved) and format diagnostics via perror() or strerror(). Because external calls route through .plt/.got.plt, engineers can also interpose fault-injection shims without recompiling via LD_PRELOAD or at link time via gcc -Wl,--wrap=write.
Probing .init_array Constructors, Pure Loops, EBADF & strace
Save crt_wrapper_probe.c below. It registers an __attribute__((constructor)) function inside .init_array (on_crt_init) to prove __libc_start_main() executes constructors before main(), verifies argv[argc] == NULL and getpagesize() via <unistd.h>, executes 1,000 pure Ring 3 strlen() calls (0 traps), deliberately triggers write(-1, "X", 1U) to verify bad_rc == -1 && saved_err == EBADF, formats a report in Ring 3 via snprintf(), and emits it through an EINTR-safe write_all_fd(STDOUT_FILENO, ...) loop.
learner@ksa:~/gl-c01/m01-l03$ bat -H 12 -H 21 -H 39 -H 40 crt_wrapper_probe.c File: crt_wrapper_probe.c #define _POSIX_C_SOURCE 200809L #include <errno.h> #include <gnu/libc-version.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> static int g_ctor_ran = 0; __attribute__((constructor)) static void on_crt_init(void) { g_ctor_ran = 1; } static int write_all_fd(int fd, const char *buf, size_t len) { size_t sent = 0U; while (sent < len) { ssize_t n = write(fd, buf + sent, len - sent); if (n < 0) { if (errno == EINTR) { continue; } return -1; } sent += (size_t)n; } return 0; } int main(int argc, char *argv[]) { const char *arg1 = (argc > 1) ? argv[1] : "none"; size_t acc = 0U; for (int i = 0; i < 1000; i++) { acc += strlen(arg1); } errno = 0; ssize_t bad_rc = write(-1, "X", 1U); int saved_err = errno; int ebadf_ok = (bad_rc == -1 && saved_err == EBADF && strlen(strerror(saved_err)) > 0U); char line[192]; const char *fmt = "glibc=%s ctor=%d argc=%d pure_acc=%zu " "argv_null=%d ebadf_ok=%d\n"; int n = snprintf(line, sizeof(line), fmt, gnu_get_libc_version(), g_ctor_ran, argc, acc, argv[argc] == NULL, ebadf_ok); if (n < 0 || (size_t)n >= sizeof(line)) { return EXIT_FAILURE; } if (write_all_fd(STDOUT_FILENO, line, (size_t)n) == -1) { perror("write stdout"); return EXIT_FAILURE; } return EXIT_SUCCESS; }- __attribute__((constructor)) places a function pointer into ELF .init_array, invoked by __libc_start_main() before main().
- Retry write() when n < 0 && errno == EINTR; advance buf + sent on any short positive count.
- Save errno into saved_err immediately after bad_rc == -1 so later snprintf() or stdio calls cannot clobber it.
Verifying PT_INTERP, JUMP_SLOT Relocations, strace & Lab 1
Compile crt_wrapper_probe, verify PT_INTERP and write's .got.plt JUMP_SLOT relocation with readelf, and confirm under strace that 1,000 strlen() calls + 1 snprintf() call emit zero syscalls while write fires exactly twice (write(-1, ...) -> -1 EBADF and write(1, ...) -> 62). Then complete lab_m01_toolchain_tracer.
learner@ksa:~/gl-c01/m01-l03gcc -fdiagnostics-color=always -std=c11 -Wall -Wextra -Werror crt_wrapper_probe.c -o crt_wrapper_probelearner@ksa:~/gl-c01/m01-l03./crt_wrapper_probe frame-07 && echo exit_status=$?glibc=2.39 ctor=1 argc=2 pure_acc=8000 argv_null=1 ebadf_ok=1exit_status=0learner@ksa:~/gl-c01/m01-l03ldd ./crt_wrapper_probe | grep -o 'libc\.so\.6' | head -n 1libc.so.6learner@ksa:~/gl-c01/m01-l03readelf -lW ./crt_wrapper_probe | grep -c 'Requesting program interpreter'1learner@ksa:~/gl-c01/m01-l03readelf -rW ./crt_wrapper_probe | grep -c 'JUMP_SLOT.*write'1learner@ksa:~/gl-c01/m01-l03strace -e trace=write ./crt_wrapper_probe frame-07 2>&1 >/dev/null | grep -c '^write('2learner@ksa:~/gl-c01/m01-l03Inspect the recorded strace session: ld-linux maps /etc/ld.so.cache and libc.so.6 first, the 1,000-iteration strlen() loop produces zero trace lines, write(-1, "X", 1) fails with EBADF, and write(1, ...) flushes the summary line before +++ exited with 0 +++.
learner@ksa:~/gl-c01/m01-l03strace strace -e trace=openat,write,close \./crt_wrapper_probe frame-07execve("/usr/bin/strace", ["strace", "-e", "trace=openat,write,close", "./crt_wrapper_probe", "frame-07"], 0x7ffc2d34d990 /* 161 vars */) = 0brk(NULL) = 0x63149dedd000mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7bf2ffcb2000access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3fstat(3, {st_mode=S_IFREG|0644, st_size=147944, ...}) = 0mmap(NULL, 147944, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7bf2ffc8d000close(3) = 0openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libunwind-ptrace.so.0", O_RDONLY|O_CLOEXEC) = 3read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832fstat(3, {st_mode=S_IFREG|0644, st_size=18656, ...}) = 0mmap(NULL, 20808, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7bf2ffc87000mmap(0x7bf2ffc88000, 8192, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1000) = 0x7bf2ffc88000mmap(0x7bf2ffc8a000, 4096, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3000) = 0x7bf2ffc8a000mmap(0x7bf2ffc8b000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3000) = 0x7bf2ffc8b000close(3) = 0openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libunwind-x86_64.so.8", O_RDONLY|O_CLOEXEC) = 3read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832fstat(3, {st_mode=S_IFREG|0644, st_size=67672, ...}) = 0mmap(NULL, 113136, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7bf2ffc6b000mmap(0x7bf2ffc6d000, 49152, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7bf2ffc6d000mmap(0x7bf2ffc79000, 8192, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xe000) = 0x7bf2ffc79000mmap(0x7bf2ffc7b000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xf000) = 0x7bf2ffc7b000mmap(0x7bf2ffc7d000, 39408, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7bf2ffc7d000close(3) = 0openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\220\243\2\0\0\0\0\0"..., 832) = 832pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784, 64) = 784fstat(3, {st_mode=S_IFREG|0755, st_size=2129424, ...}) = 0pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784, 64) = 784mmap(NULL, 2174352, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7bf2ffa00000mmap(0x7bf2ffa28000, 1609728, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x28000) = 0x7bf2ffa28000mmap(0x7bf2ffbb1000, 323584, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b1000) = 0x7bf2ffbb1000mmap(0x7bf2ffc00000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ff000) = 0x7bf2ffc00000mmap(0x7bf2ffc06000, 52624, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7bf2ffc06000close(3) = 0openat(AT_FDCWD, "/lib/x86_64-linux-gnu/liblzma.so.5", O_RDONLY|O_CLOEXEC) = 3read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832fstat(3, {st_mode=S_IFREG|0644, st_size=202904, ...}) = 0mmap(NULL, 200728, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7bf2ffc39000mmap(0x7bf2ffc3c000, 139264, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3000) = 0x7bf2ffc3c000mmap(0x7bf2ffc5e000, 45056, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x25000) = 0x7bf2ffc5e000mmap(0x7bf2ffc69000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x30000) = 0x7bf2ffc69000close(3) = 0openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libunwind.so.8", O_RDONLY|O_CLOEXEC) = 3read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832fstat(3, {st_mode=S_IFREG|0644, st_size=63776, ...}) = 0mmap(NULL, 109328, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7bf2ffc1e000mmap(0x7bf2ffc21000, 40960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3000) = 0x7bf2ffc21000mmap(0x7bf2ffc2b000, 8192, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xd000) = 0x7bf2ffc2b000mmap(0x7bf2ffc2d000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xe000) = 0x7bf2ffc2d000mmap(0x7bf2ffc2f000, 39696, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7bf2ffc2f000close(3) = 0mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7bf2ffc1c000arch_prctl(ARCH_SET_FS, 0x7bf2ffc1d380) = 0set_tid_address(0x7bf2ffc1d650) = 2867173set_robust_list(0x7bf2ffc1d660, 24) = 0rseq(0x7bf2ffc1dca0, 0x20, 0, 0x53053053) = 0mprotect(0x7bf2ffc00000, 16384, PROT_READ) = 0mprotect(0x7bf2ffc69000, 4096, PROT_READ) = 0mprotect(0x7bf2ffc2d000, 4096, PROT_READ) = 0mprotect(0x7bf2ffc7b000, 4096, PROT_READ) = 0mprotect(0x7bf2ffc8b000, 4096, PROT_READ) = 0mprotect(0x63147f23a000, 417792, PROT_READ) = 0mprotect(0x7bf2ffcf2000, 8192, PROT_READ) = 0prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0munmap(0x7bf2ffc8d000, 147944) = 0getrandom("\x31\x7c\x75\xe8\x86\xc7\x2f\x48", 8, GRND_NONBLOCK) = 8brk(NULL) = 0x63149dedd000brk(0x63149defe000) = 0x63149defe000openat(AT_FDCWD, "/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3fstat(3, {st_mode=S_IFREG|0644, st_size=5719296, ...}) = 0mmap(NULL, 5719296, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7bf2ff400000close(3) = 0openat(AT_FDCWD, "/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 3fstat(3, {st_mode=S_IFREG|0644, st_size=2996, ...}) = 0read(3, "# Locale name alias data base.\n#"..., 4096) = 2996read(3, "", 4096) = 0close(3) = 0openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_IDENTIFICATION", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)openat(AT_FDCWD, "/usr/lib/locale/C.utf8/LC_IDENTIFICATION", O_RDONLY|O_CLOEXEC) = 3fstat(3, {st_mode=S_IFREG|0644, st_size=258, ...}) = 0mmap(NULL, 258, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7bf2ffcb1000close(3) = 0openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/gconv/gconv-modules.cache", O_RDONLY|O_CLOEXEC) = 3fstat(3, {st_mode=S_IFREG|0644, st_size=27028, ...}) = 0mmap(NULL, 27028, PROT_READ, MAP_SHARED, 3, 0) = 0x7bf2ffcaa000close(3) = 0futex(0x7bf2ffc0572c, FUTEX_WAKE_PRIVATE, 2147483647) = 0openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_MEASUREMENT", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)openat(AT_FDCWD, "/usr/lib/locale/C.utf8/LC_MEASUREMENT", O_RDONLY|O_CLOEXEC) = 3fstat(3, {st_mode=S_IFREG|0644, st_size=23, ...}) = 0mmap(NULL, 23, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7bf2ffca9000close(3) = 0openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_TELEPHONE", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)openat(AT_FDCWD, "/usr/lib/locale/C.utf8/LC_TELEPHONE", O_RDONLY|O_CLOEXEC) = 3fstat(3, {st_mode=S_IFREG|0644, st_size=47, ...}) = 0mmap(NULL, 47, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7bf2ffca8000close(3) = 0openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_ADDRESS", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)openat(AT_FDCWD, "/usr/lib/locale/C.utf8/LC_ADDRESS", O_RDONLY|O_CLOEXEC) = 3fstat(3, {st_mode=S_IFREG|0644, st_size=127, ...}) = 0mmap(NULL, 127, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7bf2ffca7000close(3) = 0openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_NAME", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)openat(AT_FDCWD, "/usr/lib/locale/C.utf8/LC_NAME", O_RDONLY|O_CLOEXEC) = 3fstat(3, {st_mode=S_IFREG|0644, st_size=62, ...}) = 0mmap(NULL, 62, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7bf2ffca6000close(3) = 0openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_PAPER", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)openat(AT_FDCWD, "/usr/lib/locale/C.utf8/LC_PAPER", O_RDONLY|O_CLOEXEC) = 3fstat(3, {st_mode=S_IFREG|0644, st_size=34, ...}) = 0mmap(NULL, 34, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7bf2ffca5000close(3) = 0openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_MESSAGES", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)openat(AT_FDCWD, "/usr/lib/locale/C.utf8/LC_MESSAGES", O_RDONLY|O_CLOEXEC) = 3fstat(3, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0close(3) = 0openat(AT_FDCWD, "/usr/lib/locale/C.utf8/LC_MESSAGES/SYS_LC_MESSAGES", O_RDONLY|O_CLOEXEC) = 3fstat(3, {st_mode=S_IFREG|0644, st_size=48, ...}) = 0mmap(NULL, 48, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7bf2ffca4000close(3) = 0openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_MONETARY", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)openat(AT_FDCWD, "/usr/lib/locale/C.utf8/LC_MONETARY", O_RDONLY|O_CLOEXEC) = 3fstat(3, {st_mode=S_IFREG|0644, st_size=270, ...}) = 0mmap(NULL, 270, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7bf2ffca3000close(3) = 0openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_COLLATE", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)openat(AT_FDCWD, "/usr/lib/locale/C.utf8/LC_COLLATE", O_RDONLY|O_CLOEXEC) = 3fstat(3, {st_mode=S_IFREG|0644, st_size=1406, ...}) = 0mmap(NULL, 1406, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7bf2ffca2000close(3) = 0openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_TIME", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)openat(AT_FDCWD, "/usr/lib/locale/C.utf8/LC_TIME", O_RDONLY|O_CLOEXEC) = 3fstat(3, {st_mode=S_IFREG|0644, st_size=3360, ...}) = 0mmap(NULL, 3360, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7bf2ffca1000close(3) = 0openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_NUMERIC", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)openat(AT_FDCWD, "/usr/lib/locale/C.utf8/LC_NUMERIC", O_RDONLY|O_CLOEXEC) = 3fstat(3, {st_mode=S_IFREG|0644, st_size=50, ...}) = 0mmap(NULL, 50, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7bf2ffca0000close(3) = 0openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_CTYPE", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)openat(AT_FDCWD, "/usr/lib/locale/C.utf8/LC_CTYPE", O_RDONLY|O_CLOEXEC) = 3fstat(3, {st_mode=S_IFREG|0644, st_size=360460, ...}) = 0mmap(NULL, 360460, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7bf2ff9a7000close(3) = 0getpid() = 2867173uname({sysname="Linux", nodename="sabertooth", ...}) = 0openat(AT_FDCWD, "/proc/sys/kernel/pid_max", O_RDONLY) = 3read(3, "4194304\n", 23) = 8close(3) = 0rt_sigaction(SIGCHLD, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7bf2ffa45330}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0getuid() = 1000getgid() = 1000clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7bf2ffc1d650) = 2867174ptrace(PTRACE_SEIZE, 2867174, NULL, 0) = 0kill(2867174, SIGKILL) = 0wait4(2867174, [{WIFSIGNALED(s) && WTERMSIG(s) == SIGKILL}], 0, NULL) = 2867174--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_KILLED, si_pid=2867174, si_uid=1000, si_status=SIGKILL, si_utime=0, si_stime=0} ---clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7bf2ffc1d650) = 2867175wait4(2867175, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGSTOP}], 0, NULL) = 2867175--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867175, si_uid=1000, si_status=SIGSTOP, si_utime=0, si_stime=0} ---ptrace(PTRACE_SETOPTIONS, 2867175, NULL, PTRACE_O_TRACESYSGOOD) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867175, 88, {op=PTRACE_SYSCALL_INFO_NONE, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x7bf2ffa4553b, stack_pointer=0x7fffc19333a8}) = 24ptrace(PTRACE_SYSCALL, 2867175, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867175, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(2867175, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], 0, NULL) = 2867175ptrace(PTRACE_GET_SYSCALL_INFO, 2867175, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x7bf2ffb274ed, stack_pointer=0x7fffc1933398, entry={nr=__NR_chdir, args=[0x63147f215d9a, 0xbad1fed1, 0xbad2fed2, 0xbad3fed3, 0xbad4fed4, 0xbad5fed5]}}) = 80ptrace(PTRACE_SYSCALL, 2867175, NULL, 0) = 0wait4(2867175, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], 0, NULL) = 2867175--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867175, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---ptrace(PTRACE_GET_SYSCALL_INFO, 2867175, 88, {op=PTRACE_SYSCALL_INFO_EXIT, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x7bf2ffb274ed, stack_pointer=0x7fffc1933398, exit={rval=-ENOENT, is_error=1}}) = 33ptrace(PTRACE_SYSCALL, 2867175, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867175, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(2867175, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], 0, NULL) = 2867175ptrace(PTRACE_GET_SYSCALL_INFO, 2867175, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x7bf2ffb274ed, stack_pointer=0x7fffc1933398, entry={nr=__NR_gettid, args=[0xcaf0bea0, 0xcaf1bea1, 0xcaf2bea2, 0xcaf3bea3, 0xcaf4bea4, 0xcaf5bea5]}}) = 80ptrace(PTRACE_SYSCALL, 2867175, NULL, 0) = 0wait4(2867175, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], 0, NULL) = 2867175--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867175, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---ptrace(PTRACE_GET_SYSCALL_INFO, 2867175, 88, {op=PTRACE_SYSCALL_INFO_EXIT, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x7bf2ffb274ed, stack_pointer=0x7fffc1933398, exit={rval=2867175, is_error=0}}) = 33ptrace(PTRACE_SYSCALL, 2867175, NULL, 0) = 0wait4(2867175, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], 0, NULL) = 2867175--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867175, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---ptrace(PTRACE_GET_SYSCALL_INFO, 2867175, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x7bf2ffb274ed, stack_pointer=0x7fffc1933398, entry={nr=__NR_exit_group, args=[0, 0xfac1c0d1, 0xfac2c0d2, 0xfac3c0d3, 0xfac4c0d4, 0xfac5c0d5]}}) = 80ptrace(PTRACE_SYSCALL, 2867175, NULL, 0) = 0wait4(2867175, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 2867175--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=2867175, si_uid=1000, si_status=0, si_utime=0, si_stime=0} ---pipe2([3, 4], 0) = 0close(4) = 0fcntl(3, F_GETFD) = 0fcntl(3, F_SETFD, FD_CLOEXEC) = 0close(3) = 0newfstatat(AT_FDCWD, "./crt_wrapper_probe", {st_mode=S_IFREG|0775, st_size=16416, ...}, 0) = 0clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7bf2ffc1d650) = 2867176wait4(2867176, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGSTOP}], WSTOPPED, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_STOPPED, si_pid=2867176, si_uid=1000, si_status=SIGSTOP, si_utime=0, si_stime=0} ---ptrace(PTRACE_SEIZE, 2867176, NULL, PTRACE_O_TRACESYSGOOD|PTRACE_O_TRACEEXEC|PTRACE_O_TRACEEXIT) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_STOPPED, si_pid=2867176, si_uid=1000, si_status=0, si_utime=0, si_stime=0} ---ptrace(PTRACE_INTERRUPT, 2867176) = 0kill(2867176, SIGCONT) = 0close(0) = 0pipe2([0, 3], 0) = 0close(3) = 0fcntl(0, F_GETFD) = 0fcntl(0, F_SETFD, FD_CLOEXEC) = 0close(1) = 0pipe2([1, 3], 0) = 0close(3) = 0fcntl(1, F_GETFD) = 0fcntl(1, F_SETFD, FD_CLOEXEC) = 0rt_sigaction(SIGTTOU, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7bf2ffa45330}, NULL, 8) = 0rt_sigaction(SIGTTIN, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7bf2ffa45330}, NULL, 8) = 0rt_sigaction(SIGHUP, {sa_handler=0x63147f135f10, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7bf2ffa45330}, NULL, 8) = 0rt_sigaction(SIGINT, {sa_handler=0x63147f135f10, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7bf2ffa45330}, NULL, 8) = 0rt_sigaction(SIGQUIT, {sa_handler=0x63147f135f10, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7bf2ffa45330}, NULL, 8) = 0rt_sigaction(SIGPIPE, {sa_handler=0x63147f135f10, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7bf2ffa45330}, NULL, 8) = 0rt_sigaction(SIGTERM, {sa_handler=0x63147f135f10, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7bf2ffa45330}, NULL, 8) = 0rt_sigprocmask(SIG_BLOCK, [ALRM], NULL, 8) = 0rt_sigaction(SIGALRM, {sa_handler=0x63147f141c20, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7bf2ffa45330}, NULL, 8) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGSTOP}|PTRACE_EVENT_STOP<<16], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_LISTEN, 2867176) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP}|PTRACE_EVENT_STOP<<16], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_CONTINUED, si_pid=2867176, si_uid=1000, si_status=SIGCONT, si_utime=0, si_stime=0} ---wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGCONT}], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGCONT, si_utime=0, si_stime=0} ---ptrace(PTRACE_GETSIGINFO, 2867176, NULL, {si_signo=SIGCONT, si_code=SI_USER, si_pid=2867173, si_uid=1000}) = 0wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_SYSCALL, 2867176, NULL, SIGCONT) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x7bf2ffaeeffb, stack_pointer=0x7fffc1932288, entry={nr=__NR_execve, args=[0x7fffc1932360, 0x7fffc1933870, 0x7fffc1933888, 0x7bf2ffcf50b8, 0x1, 0x7bf2ffc1d380]}}) = 80ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP}|PTRACE_EVENT_EXEC<<16], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---ptrace(PTRACE_GETEVENTMSG, 2867176, NULL, [2867176]) = 0wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x76292a2539bb, stack_pointer=0x7ffedaa374d8, entry={nr=__NR_brk, args=[0, 0x76292a265a18, 0, 0x37f, 0, 0x76292a265440]}}) = 80ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x76292a254d1c, stack_pointer=0x7ffedaa37160, entry={nr=__NR_mmap, args=[0, 0x2000, 0x3, 0x22, 0xffffffff, 0]}}) = 80ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x76292a2548bb, stack_pointer=0x7ffedaa37218, entry={nr=__NR_access, args=[0x76292a25e5b0, 0x4, 0x5ec1e6425e10, 0x22, 0x76292a22f000, 0x76292a265440]}}) = 80ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x76292a254b61, stack_pointer=0x7ffedaa365b0, entry={nr=__NR_openat, args=[0xffffff9c, 0x76292a25d38f, 0x80000, 0, 0xffff, 0]}}) = 80fstat(2, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0process_vm_readv(2867176, [{iov_base="2\0dl-lookup.c\0out of memory\n\0, v"..., iov_len=4096}], 1, [{iov_base=0x76292a25d000, iov_len=4096}], 1, 0) = 4096write(2, "openat(AT_FDCWD, \"/etc/ld.so.cac"..., 55) = 55ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_EXIT, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x76292a254b61, stack_pointer=0x7ffedaa365b0, exit={rval=3, is_error=0}}) = 33write(2, ") = 3\n", 6) = 6ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x76292a2548eb, stack_pointer=0x7ffedaa365b8, entry={nr=__NR_fstat, args=[0x3, 0x7ffedaa365c0, 0x80000, 0, 0xffff, 0]}}) = 80ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x76292a254d1c, stack_pointer=0x7ffedaa365a0, entry={nr=__NR_mmap, args=[0, 0x241e8, 0x1, 0x2, 0x3, 0]}}) = 80ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x76292a254a1b, stack_pointer=0x7ffedaa365b8, entry={nr=__NR_close, args=[0x3, 0x241e8, 0x1, 0x2, 0x3, 0]}}) = 80write(2, "close(3", 7) = 7ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_EXIT, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x76292a254a1b, stack_pointer=0x7ffedaa365b8, exit={rval=0, is_error=0}}) = 33write(2, ") "..., 37) = 37ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x76292a254b61, stack_pointer=0x7ffedaa36720, entry={nr=__NR_openat, args=[0xffffff9c, 0x76292a225140, 0x80000, 0, 0x7ffedaa367d7, 0]}}) = 80process_vm_readv(2867176, [{iov_base="PP\"*)v\0\0\362\316%*)v\0\0\0\0\0\0\0\0\0\0@\260%*)v\0\0"..., iov_len=4096}], 1, [{iov_base=0x76292a225000, iov_len=4096}], 1, 0) = 4096write(2, "openat(AT_FDCWD, \"/lib/x86_64-li"..., 70) = 70ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_EXIT, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x76292a254b61, stack_pointer=0x7ffedaa36720, exit={rval=3, is_error=0}}) = 33write(2, ") = 3\n", 6) = 6ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x76292a254bd8, stack_pointer=0x7ffedaa36728, entry={nr=__NR_read, args=[0x3, 0x7ffedaa367f8, 0x340, 0, 0x7ffedaa367d7, 0]}}) = 80ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x76292a254bae, stack_pointer=0x7ffedaa36408, entry={nr=__NR_pread64, args=[0x3, 0x7ffedaa36410, 0x310, 0x40, 0x7ffedaa367d7, 0]}}) = 80ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x76292a2548eb, stack_pointer=0x7ffedaa365f8, entry={nr=__NR_fstat, args=[0x3, 0x7ffedaa36690, 0x3, 0x40, 0x76292a225140, 0x76292a2682e0]}}) = 80ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x76292a254bae, stack_pointer=0x7ffedaa362d8, entry={nr=__NR_pread64, args=[0x3, 0x7ffedaa362e0, 0x310, 0x40, 0xc0ff, 0]}}) = 80ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x76292a254d1c, stack_pointer=0x7ffedaa35fb0, entry={nr=__NR_mmap, args=[0, 0x212d90, 0x1, 0x802, 0x3, 0]}}) = 80ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x76292a254d1c, stack_pointer=0x7ffedaa35fb0, entry={nr=__NR_mmap, args=[0x762929e28000, 0x189000, 0x5, 0x812, 0x3, 0x28000]}}) = 80ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x76292a254d1c, stack_pointer=0x7ffedaa35fb0, entry={nr=__NR_mmap, args=[0x762929fb1000, 0x4f000, 0x1, 0x812, 0x3, 0x1b1000]}}) = 80ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x76292a254d1c, stack_pointer=0x7ffedaa35fb0, entry={nr=__NR_mmap, args=[0x76292a000000, 0x6000, 0x3, 0x812, 0x3, 0x1ff000]}}) = 80ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x76292a254d1c, stack_pointer=0x7ffedaa35fb0, entry={nr=__NR_mmap, args=[0x76292a006000, 0xcd90, 0x3, 0x32, 0xffffffff, 0]}}) = 80ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x76292a254a1b, stack_pointer=0x7ffedaa362d8, entry={nr=__NR_close, args=[0x3, 0x76292a225160, 0x1, 0xc0000002, 0x762929e00378, 0x4]}}) = 80write(2, "close(3", 7) = 7ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_EXIT, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x76292a254a1b, stack_pointer=0x7ffedaa362d8, exit={rval=0, is_error=0}}) = 33write(2, ") "..., 37) = 37ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x76292a254d1c, stack_pointer=0x7ffedaa37180, entry={nr=__NR_mmap, args=[0, 0x3000, 0x3, 0x22, 0xffffffff, 0]}}) = 80ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x76292a24f11d, stack_pointer=0x7ffedaa37200, entry={nr=__NR_arch_prctl, args=[0x1002, 0x76292a1fd740, 0xffff89d6d5e01f30, 0x22, 0xffffffff, 0]}}) = 80ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x76292a243f12, stack_pointer=0x7ffedaa371d0, entry={nr=__NR_set_tid_address, args=[0x76292a1fda10, 0x76292a1fd740, 0x76292a2680c8, 0x22, 0xffffffff, 0]}}) = 80ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x76292a243f6e, stack_pointer=0x7ffedaa371d0, entry={nr=__NR_set_robust_list, args=[0x76292a1fda20, 0x18, 0x76292a2680c8, 0x22, 0xffffffff, 0]}}) = 80ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x76292a243fe6, stack_pointer=0x7ffedaa371d0, entry={nr=__NR_rseq, args=[0x76292a1fe060, 0x20, 0, 0x53053053, 0, 0x76292a265440]}}) = 80ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x76292a254dab, stack_pointer=0x7ffedaa370e8, entry={nr=__NR_mprotect, args=[0x76292a000000, 0x4000, 0x1, 0x76292a225160, 0x76292a225160, 0]}}) = 80ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x76292a254dab, stack_pointer=0x7ffedaa370e8, entry={nr=__NR_mprotect, args=[0x5ec1e6425000, 0x1000, 0x1, 0x76292a2682e0, 0x76292a2682e0, 0x762929eb4460]}}) = 80ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x76292a254dab, stack_pointer=0x7ffedaa370e8, entry={nr=__NR_mprotect, args=[0x76292a265000, 0x2000, 0x1, 0x76292a267ab0, 0x76292a267ab0, 0]}}) = 80ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x762929f1d454, stack_pointer=0x7ffedaa371d8, entry={nr=__NR_prlimit64, args=[0, 0x3, 0, 0x7ffedaa371e0, 0, 0xd]}}) = 80ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x76292a254ddb, stack_pointer=0x7ffedaa37208, entry={nr=__NR_munmap, args=[0x76292a200000, 0x241e8, 0, 0x7ffedaa371e0, 0, 0x76292a265440]}}) = 80ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x762929f1c804, stack_pointer=0x7ffedaa37398, entry={nr=__NR_write, args=[0xffffffff, 0x5ec1e642400d, 0x1, 0x7ffedaa371e0, 0, 0x76292a234380]}}) = 80process_vm_readv(2867176, [{iov_base="\1\0\2\0\0\0\0\0none\0X\0\0glibc=%s ctor=%d"..., iov_len=4096}], 1, [{iov_base=0x5ec1e6424000, iov_len=4096}], 1, 0) = 4096write(2, "write(-1, \"X\", 1", 16) = 16ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_EXIT, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x762929f1c804, stack_pointer=0x7ffedaa37398, exit={rval=-EBADF, is_error=1}}) = 33write(2, ") = -1 EBA"..., 57) = 57ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x762929f1c804, stack_pointer=0x7ffedaa37358, entry={nr=__NR_write, args=[0x1, 0x7ffedaa373e0, 0x3e, 0, 0x64, 0]}}) = 80process_vm_readv(2867176, [{iov_base="\0\0\0\0\0\0\0\0\260z&*)v\0\0\307\16\340=\376\177\0\0\327\331%*)v\0\0"..., iov_len=4096}], 1, [{iov_base=0x7ffedaa37000, iov_len=4096}], 1, 0) = 4096write(2, "write(1, \"glibc=2.39 ctor=1 argc"..., 50) = 50ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_EXIT, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x762929f1c804, stack_pointer=0x7ffedaa37358, exit={rval=62, is_error=0}}) = 33write(2, ") = 62\n", 7) = 7ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP | 0x80}], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_GET_SYSCALL_INFO, 2867176, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_X86_64, instruction_pointer=0x762929eee2dd, stack_pointer=0x7ffedaa37458, entry={nr=__NR_exit_group, args=[0, 0xffffffffffffff88, 0xe7, 0x7ffedaa3738f, 0x7ffedaa37400, 0]}}) = 80ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=2867176, si_uid=1000, si_status=SIGTRAP, si_utime=0, si_stime=0} ---wait4(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP}|PTRACE_EVENT_EXIT<<16], __WALL, NULL) = 2867176wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = 0ptrace(PTRACE_SYSCALL, 2867176, NULL, 0) = 0wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], __WALL, NULL) = 2867176--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=2867176, si_uid=1000, si_status=0, si_utime=0, si_stime=0} ---wait4(-1, 0x7fffc19335dc, WNOHANG|__WALL, NULL) = -1 ECHILD (No child processes)write(2, "+++ exited with 0 +++\n", 22) = 22wait4(-1, 0x7fffc19335dc, __WALL, NULL) = -1 ECHILD (No child processes)exit_group(0) = ?+++ exited with 0 +++→ open standalone lab workbench
1. Motivation
Embedded and infrastructure teams routinely ship corrupted binary packets or crash in production because a framing helper called strlen() on a payload containing 0x00 bytes, stored write()'s signed ssize_t -1 error in unsigned size_t (wrapping to SIZE_MAX), or compiled without -Wall -Wextra -Werror across separate translation units. In this studio laboratory, you will engineer a warning-clean multi-file ISO C11 static library (libsysbuf.a) and CLI boundary tracer (inspector) that strictly separates zero-syscall Ring 3 framing from EINTR-resilient Ring 0 write() transfers and errno validation.
2. Learning Objectives
- Build a multi-file ISO C11 static archive (
ar rcs libsysbuf.a sysbuf.o) and linked executable (inspector) using GNU Make with-std=c11 -Wall -Wextra -Werror -O2 -g. - Implement zero-syscall
Ring 3big-endian binary header encoding (sysbuf_encode_header) across payloads containing embedded0x00bytes withoutstrlen()truncation. - Implement a partial-count and
EINTR-safesysbuf_write_all()loop over signedssize_tand verify negative-descriptor-1(EBADF) diagnostics via thread-localerrno. - Verify under
stracethatRing 3framing, XOR checksumming, andsnprintf()formatting emit0kernelwritetraps prior to the single terminal flush.
3. Environment Requirements
- Host Execution Environment (Tested): POSIX-compliant Linux
6.12LTS (x86_64,glibc2.39+), executing insidelabs/lab_m01_toolchain_tracer/. - Target Board Portability (
ARMv7Cortex-A7): All C11 source files use<stdint.h>exact-width types (uint8_t,uint16_t), explicit big-endian shifts, andsize_t/ssize_t%zuformatting so the identical archive cross-compiles cleanly underarm-linux-gnueabihf-gccwith identical24-byte wire output.
4. Required Software & Hardware
- Software Toolchain:
gcc(GCC11+with ISO C11 support), GNUmake, GNU Binutils (ar,nm,readelf),strace, and/bin/sh. - Hardware: Standard Linux host workstation or container (
0privileged/devnodes or root capabilities required).
5. Complete Executable Commands
Run each command from labs/lab_m01_toolchain_tracer/ to observe the broken starter, build the static archive, inspect ELF symbols, and run the automated TAP 13 test harness:
learner@ksa:~/gl-c01/m01-l03$ bat script.sh File: script.sh # 1. Confirm starter/ fails check.sh deterministically (demonstrating the bugs to fix) cp starter/* files/ 2>/dev/null || true # (Note: coursec labs tests starter/ in a temp copy; inspect starter/ directly!) make -C files clean && make -C files # 2. Inspect archive members and global symbol table (.symtab) inside libsysbuf.a ar t files/libsysbuf.a nm -g files/libsysbuf.a # 3. Execute the CLI summary mode (verifies EBADF on fd=-1 and prints 1 formatted line) ./files/inspector # 4. Inspect exact raw binary frame bytes (24 bytes: 16-byte KSB1 header + 8-byte payload) ./files/inspector --raw | od -tx1 -An # 5. Count Ring 0 write() traps under strace (1 failed write(-1) + 1 stdout flush = 2) strace -e trace=write ./files/inspector 2>&1 >/dev/null | grep -c '^write(' # 6. Run the full TAP version 13 verification suite sh check.sh*Why each command runs:* make -C files compiles sysbuf.o and inspector.o separately before archiving libsysbuf.a via ar rcs and linking -L. -lsysbuf after inspector.o; nm -g confirms exported global symbols (T sysbuf_encode_header, T sysbuf_write_all); od -tx1 proves embedded 0x00 bytes survive intact; strace proves Ring 3 framing triggers zero kernel traps; and sh check.sh validates every contract end-to-end.
6. Annotated Source Code (starter/ Flaws vs files/ Reference)
Flawed Baseline (starter/sysbuf.c & starter/Makefile)
- Missing strict compiler flags:
starter/Makefileomits-std=c11 -Wall -Wextra -Werrorand static-archive rules. - Binary
0x00truncation (starter/sysbuf.c):size_t wrong_len = strlen((const char *)payload);stops atpayload[1] == 0x00, encoding length1instead of8and skipping the XOR checksum (0x00instead of0xb6). - Unsigned
size_terror wrap (starter/sysbuf.c):size_t n = (size_t)write(fd, buf, count);wraps(ssize_t)-1toSIZE_MAXand fails to retry short writes orerrno == EINTR.
Warning-Clean Reference (files/sysbuf.c & files/inspector.c)
sysbuf_encode_header()(files/sysbuf.c): Zeroesdst[0..15], copies"KSB1", shiftschannelandpayload_leninto big-endian network order ((val >> 8U) & 0xFFU), iteratesfor (size_t i = 0; i < payload_len; i++)to computexor_sum(0xb6) andzero_count(2), and returns16with0syscalls.sysbuf_write_all()(files/sysbuf.c): Castsconst void *toconst uint8_t *, capturesssize_t written = write(fd, cursor, remaining), retries whenwritten < 0 && errno == EINTR, returns-1on fatal errors (EBADF), and advances(cursor += (size_t)written, remaining -= (size_t)written)untilremaining == 0U.main()(files/inspector.c): Checksargc > 1 && strcmp(argv[1], "--raw") == 0safely before touchingargv[1], testssysbuf_write_all(-1, ...)(bad_rc == -1 && errno == EBADF), formats a boundedsnprintf()line (ret < 0 || (size_t)ret >= sizeof(line)), and flushes once viasysbuf_write_all(STDOUT_FILENO, ...).
7. Expected Output
learner@ksa:~/gl-c01/m01-l03$ bat listing.txt File: listing.txt $ ./files/inspector frame_bytes=24 payload_bytes=8 null_bytes=2 checksum=0xb6 ebadf_ok=1 glibc=2.39 $ sh check.sh TAP version 13 1..5 ok 1 - builds libsysbuf.a and inspector cleanly with -std=c11 -Wall -Wextra -Werror ok 2 - archives sysbuf.o inside libsysbuf.a via ar ok 3 - preserves embedded 0x00 bytes, XOR checksum 0xb6, and EBADF errno handling ok 4 - emits exact 24-byte raw binary frame with KSB1 header and big-endian lengths ok 5 - executes pure Ring 3 framing with exactly 2 write() syscalls under strace # pass 5/58. Explanation of Observed Behavior
On payload {0x4B, 0x00, 0x53, 0x00, 0x41, 0x01, 0xFE, 0x10}, bitwise XOR evaluates $0x4B \oplus 0x00 \oplus 0x53 \oplus 0x00 \oplus 0x41 \oplus 0x01 \oplus 0xFE \oplus 0x10 = 0xB6$, while counting 0x00 bytes yields null_bytes=2. Under strace -e trace=write, sysbuf_encode_header() and snprintf() execute strictly inside Ring 3 stack RAM (0 trace lines). Calling write(-1, ...) traps into Ring 0, where VFS fdget_pos(-1) returns -EBADF (-9); glibc stores +9 in thread-local errno and returns -1 (ebadf_ok=1). Finally, sysbuf_write_all(STDOUT_FILENO, ...) flushes the entire line in 1 successful write(1, ...) syscall.
9. Experiment Variations
- Reversed Link-Order Experiment: Run
gcc -std=c11 files/inspector.o -Lfiles -lsysbuf -o /tmp/ok_binversusgcc -std=c11 -Lfiles -lsysbuf files/inspector.o -o /tmp/fail_bin(with-DSYSBUF_LINK_ARCHIVE) to observe GNUlddiscardlibsysbuf.abefore seeinginspector.o's unresolved symbols (undefined reference to 'sysbuf_encode_header'). - Link-Time
EINTRInjection (--wrap=write): Link a test wrapper with-Wl,--wrap=writethat returns-1witherrno = EINTRon every odd call and4bytes on every even call, confirmingsysbuf_write_all()still emits all24--rawbytes intact. - Sanitizer Verification: Rebuild with
CFLAGS="-std=c11 -Wall -Wextra -Werror -O1 -g -fsanitize=address,undefined"and verify zeroASanorUBSandiagnostics.
10. Performance Measurements
Measured on the Host x86_64 Linux 6.12 LTS build environment using CLOCK_MONOTONIC across 5 warmup runs and N = 35 timed end-to-end ./inspector executions:
| Metric | Measured Host (x86_64 Linux 6.12) | Target Board Expectation (ARMv7 Cortex-A7 @ 900 MHz) |
|---|---|---|
End-to-end ./inspector latency (p50 / p95 / p99) | 2,543.1 us / 2,869.9 us / 2,896.0 us | ~9,500–14,000 us (dominated by execve + ld-linux dynamic linking) |
In-process sysbuf_encode_header() (24 B, Ring 3) | < 15 ns (0 syscalls) | ~45–80 ns (0 svc #0 traps) |
Total write() syscalls (strace -c) | 2 (1 EBADF + 1 stdout) | 2 (identical ABI syscall count) |
11. Troubleshooting
| Symptom | Root Cause | Fix |
|---|---|---|
undefined reference to 'sysbuf_encode_header' | -lsysbuf placed before inspector.o on the gcc link command line | Move -L. -lsysbuf after all .o object files that call it |
payload_bytes=8 yet checksum=0x4b and header[7]=1 | strlen() used instead of payload_len, stopping at payload[1] == 0x00 | Iterate for (size_t i = 0; i < payload_len; i++) over const uint8_t * |
implicit declaration of function under -std=c11 | #define _POSIX_C_SOURCE 200809L missing or placed below #include | Put #define _POSIX_C_SOURCE 200809L on line 1 of every .c file |
ebadf_ok=0 despite write(-1, ...) failing | An intervening printf() or helper ran before reading errno | Capture int saved_err = errno; immediately on the line after bad_rc = ... |
12. Guided Questions
- Why does
sysbuf_encode_header()accept(const uint8_t *payload, size_t payload_len)instead ofconst char *payload?
- *Hint 1:* Inspect bytes
1and3of the test payload{0x4B, 0x00, 0x53, 0x00, ...}and trace what C string functions treat0x00as. - *Hint 2:* Also recall from
m01-l02whether plaincharhas the same signedness onx86_64versusARMv7EABI when computing bitwise checksums!
- Why does
sysbuf.ccastconst void *buftoconst uint8_t *cursorinsidesysbuf_write_all()?
- *Hint 1:* What happens in strict ISO C11 (
-Wpointer-arith -Werror) if you writebuf += writtendirectly onconst void *buf? - *Hint 2:* Why is
const void *still preferred on the public parameter list ofsysbuf_write_all()?
13. Independent Challenges
- Near Transfer — Frame Decoder & Verifier (
sysbuf_decode_header): Addint sysbuf_decode_header(const uint8_t src[16], const uint8_t *payload, size_t cap, uint16_t *chan_out, size_t *len_out)tosysbuf.cthat validates"KSB1", reconstructs16-bit big-endianchannelandpayload_len, rejectspayload_len > cap(EINVAL), and verifies both the XOR checksum and0x00-byte count (Ebadmsg/EPROTOon mismatch). - Far Transfer — Shared Library (
libsysbuf.so) vs Static Archive (libsysbuf.a): ExtendMakefileto buildlibsysbuf.so(-fPIC -shared), compare.plt/.got.pltJUMP_SLOTentries inreadelf -rWbetween the statically archived and dynamically linkedinspectorbinaries, and measure startup overhead acrossN = 50runs.
14. Solutions & Explanations
- Guided Question 1: Binary protocols treat
0x00as an ordinary value rather than a terminator (strlen()stops at index1), anduint8_tguarantees unsigned[0..255]arithmetic across both signed-charx86_64and unsigned-charARMv7targets. - Guided Question 2: Standard C leaves
voidan incomplete type (sizeof(void)is invalid; GNU C treatsvoid * + 1as a non-standard extension rejected under-Wpedantic/-Werror), so internal byte stepping requiresconst uint8_t *, while keepingconst void *on the public signature allows callers to pass structs orchar *buffers without noisy pointer casts. - Challenge 1 Key Idiom: Reconstruct big-endian
uint16_tvia((uint16_t)src[6] << 8U) | (uint16_t)src[7](casting touint16_t/unsignedbefore shifting to avoid signed promotion surprises) and validatelen <= capbefore scanningpayload.
Run locally in your terminal and check off each verification milestone.
Not started
Tracing Control from PT_INTERP and _start to $?
When the shell invoked ./crt_wrapper_probe frame-07, execve() loaded PT_INTERP, mapped libc.so.6, and entered _start (crt1.o), which called __libc_start_main(). That preamble initialized TLS errno, ran on_crt_init() (ctor=1), and passed argc = 2, argv[1] = "frame-07", and argv[2] = NULL into main(). Inside main(), write(-1, "X", 1U) returned -9 (-EBADF) in %rax, which glibc negated into positive errno = 9 (EBADF) and return value -1. Finally, return EXIT_SUCCESS exited via exit_group(0) (exit_status=0).
Guided Practice: Link-Time Fault Injection with -Wl,--wrap=write
GNU ld's --wrap=write flag redirects calls to write() to __wrap_write() while exposing the real wrapper as __real_write(), letting you test EINTR retry loops deterministically without sending asynchronous signals:
- Step 1 (Write the shim signature): Define
ssize_t __wrap_write(int fd, const void *buf, size_t count)so that on its very first call (static int injected = 0;) it setserrno = EINTR;and returns-1, and on all subsequent calls forwards toextern ssize_t __real_write(int fd, const void *buf, size_t count);. - Step 2 (Verify
write_all_fdrecovery): Linkcrt_wrapper_probe.cwith-Wl,--wrap=writeand confirmwrite_all_fd()retries transparently and prints the complete62-byte output line withexit_status=0.
Independent Practice: Auxiliary Vector (auxv) Hardware & Page-Size Inspector
Write a standalone C11 binary auxv_probe.c (-std=c11 -Wall -Wextra -Werror) that calls getauxval(AT_PAGESZ) and getauxval(AT_SYSINFO_EHDR) from <sys/auxv.h>, verifies AT_PAGESZ >= 4096UL and AT_SYSINFO_EHDR != 0UL (confirming the ELF header magic \x7fELF at the mapped vDSO base address in Ring 3 memory!), and confirms under strace -e trace=openat,write ./auxv_probe that reading auxv values emits 0 additional kernel traps after dynamic linking.
Common Production Pitfalls
warning: Symptom: A helper runs ssize_t n = write(fd, buf, len); if (errno != 0) log_fatal(errno); and aborts with a stale "Bad file descriptor" error even when n == (ssize_t)len. Root Cause: Successful POSIX syscall wrappers never reset errno back to 0; errno retains whatever nonzero code an earlier failed probe left behind. Fix: Check errno strictly inside if (n == -1) (and save int saved_err = errno; before any logging call).
warning: Symptom: Running ./crt_wrapper_probe with zero CLI arguments crashes with SIGSEGV at strlen(argv[1]), or returning -1 from main() reports 255 in shell $?. Root Cause: With no CLI arguments, argc == 1 and argv[1] == NULL; meanwhile, POSIX waitpid() / exit_group() masks exit codes to status & 0xFF (-1 & 0xFF == 255). Fix: Check argc > idx before dereferencing argv[idx], and return EXIT_SUCCESS (0) or documented positive exit codes (1..125).
Knowledge Check
Key takeaways
glibc(libc.so.6) separates pureRing 3memory/string helpers (strlen(),memcpy(),snprintf()) fromRing 0syscall wrappers (write(),read(),openat()) routed through.plt/.got.pltJUMP_SLOTrelocations andPT_INTERP.- Every POSIX process inherits
STDIN_FILENO(0),STDOUT_FILENO(1), andSTDERR_FILENO(2) open at startup. - When a syscall fails, the Linux kernel returns
-errnoin[-4095, -1]and theglibcwrapper sets positive thread-localerrno(EBADF,EINTR, formatted viaperror()/strerror()) and returns-1. - ELF binaries enter at
_start(crt1.o) ->__libc_start_main()withargc,argv[],envp[], andElf_auxv_ton the initial stack, executing.init_arrayconstructors beforemain()and forwardingstatus & 0xFFto$?. - With toolchain, ELF startup,
errno, andstracemastered, Module 2 opens disk files directly to control per-process descriptor allocation,open()bitmasks, andmode & ~umaskpermissions.