Cheat Paper

Your Code Pays a Toll You Never See

Sources

  1. man 2 getpid 2026-11-03

    From glibc 2.3.4 up to and including glibc 2.24, the glibc wrapper function for getpid() cached PIDs, with the goal of avoiding additional system calls when a process calls getpid() repeatedly.
  2. Wikipedia: Kernel (operating system)

    A kernel is a computer program at the core of a computer's operating system that always has complete control over everything in the system.
  3. man 2 intro 2026-11-03

    A system call is an entry point into the Linux kernel. Usually, system calls are not invoked directly: instead, most system calls have corresponding C library wrapper functions which perform the steps required (e.g., trapping to kernel mode) in order to invoke the system call. Thus, making a system call looks the same as invoking a normal library function.
  4. linux@v7.0 arch/x86/entry/entry_64.S (entry_SYSCALL_64)

    movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp SYM_INNER_LABEL(entry_SYSCALL_64_safe_stack, SYM_L_GLOBAL) ANNOTATE_NOENDBR /* Construct struct pt_regs on stack */ pushq $__USER_DS /* pt_regs->ss */ pushq PER_CPU_VAR(cpu_tss_rw + TSS_sp2) /* pt_regs->sp */ pushq %r11 /* pt_regs->flags */ pushq $__USER_CS /* pt_regs->cs */ pushq %rcx /* pt_regs->ip */
  5. man 7 vdso 2026-11-03

    Now a call to gettimeofday(2) changes from a system call to a normal function call and a few memory accesses.
  6. man 1 strace 2026-11-03

    strace - trace system calls and signals
  7. man 7 pipe 2026-11-03

    If a process attempts to write to a full pipe (see below), then write(2) blocks until sufficient data has been read from the pipe to allow the write to complete.
  8. Wikipedia: Meltdown (security vulnerability) 2026-11-04

    the two vulnerabilities were made public jointly, on 3 January 2018
  9. meltdownattack.com: Meltdown and Spectre 2026-11-04

    Meltdown breaks the most fundamental isolation between user applications and the operating system. This attack allows a program to access the memory, and thus also the secrets, of other programs and the operating system.
  10. kernel.org: Page Table Isolation (PTI)

    CR3 manipulation to switch between the page table copies must be done at interrupt, syscall, and exception entry and exit (it can be skipped when the kernel is interrupted, though.) Moves to CR3 are on the order of a hundred cycles, and are required at every entry and exit.
  11. brendangregg.com: KPTI/KAISER Meltdown Initial Performance Regressions 2018-02-09

    At 50k syscalls/sec per CPU the overhead may be 2%, and climbs as the syscall rate increases.