[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7AQJC3YAYYDD489AYC3ZCYB":3,"skill-same:01M7AQJC3YAYYDD489AYC3ZCYB":48},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M7AQJC3YAYYDD489AYC3ZCYB","linux-kernel-debugging-process-and-hardening",null,"Use when debugging a kernel problem, contributing a patch, or hardening a Linux system. Covers the kernel debug configs to build with, reading an oops, the tracing hierarchy (ftrace, perf, bpftrace, flame graphs), kernel testing (KUnit, kselftest, syzkaller), how change actually happens (maintainers, mailing lists, merge windows), versioning and stable trees, the CVE flood, the kernel attack surface, the defenses (KASLR, CFI, lockdown, LSMs), and an honest kernel-hardening posture.","the-vibey-project\u002Fvibey","the-vibey-project","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F329298758?v=4","01M7AJHGZ9722CTJ4JNQZVRH0Q","the vibey project","01M7AJHGZVMG2K7TGXQ6XFHVG3",5,"MIT","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fos-development-kernel-shell\u002Fskills\u002Flinux-kernel-debugging-process-and-hardening\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: linux-kernel-debugging-process-and-hardening\ndescription: \"Use when debugging a kernel problem, contributing a patch, or hardening a Linux system. Covers the kernel debug configs to build with, reading an oops, the tracing hierarchy (ftrace, perf, bpftrace, flame graphs), kernel testing (KUnit, kselftest, syzkaller), how change actually happens (maintainers, mailing lists, merge windows), versioning and stable trees, the CVE flood, the kernel attack surface, the defenses (KASLR, CFI, lockdown, LSMs), and an honest kernel-hardening posture.\"\n---\n\n# Linux Kernel & Shell: Debugging and Observability, the Kernel Development Process, and Hardening\n\n> **Part 4 of 5** of the *OS Development — Linux Kernel and Shell* reference (plugin `os-development-kernel-shell`), covering §12–§14. Sibling skills: `linux-kernel-architecture-and-code` (§0–§3), `linux-syscalls-ebpf-boot-and-init` (§4–§7), `linux-shell-scripting-and-userland` (§8–§11), `linux-kernel-shell-reference` (§15–§20). Section numbers are shared across the set; a reference written as §N → `skill` points into that sibling skill.\n>\n> **Currency:** Verified August 2026. See §17 → `linux-kernel-shell-reference` for the currency snapshot and what goes stale first.\n\n> **How to read this.** Reference, not tutorial. Sections are independent. Three markers:\n> - **[DURABLE]** — architecture, algorithms, or semantics that have been stable for\n>   decades and will outlive this document.\n> - **[VERSIONED]** — depends on a kernel version, a shell version, or a distro. Check\n>   `Documentation\u002F`, the man page, or the source for your version.\n> - **[CONTESTED]** — the kernel community itself disagrees, publicly and at length.\n>   Both cases given.\n>\n> **⚠️ GOTCHA** boxes mark the mistakes that produce kernel oopses, data loss, silent\n> corruption, or a patch rejected on the mailing list.\n>\n> **The framing that matters most:** the kernel is not \"a big program.\" It is a\n> **hostile-input state machine running with no memory protection, no exceptions, a\n> hard limit on stack depth, and a promise never to break userspace**. Almost every\n> kernel-specific rule below descends from one of those five facts.\n\n---\n\n## §12. Debugging and Observability\n\n### 12.1 The kernel debug configs to build with\n\n**[DURABLE] Turn these on in development. Every one of them turns a heisenbug into a\nreproducible splat:**\n```\nCONFIG_DEBUG_KERNEL=y\nCONFIG_DEBUG_INFO=y CONFIG_DEBUG_INFO_BTF=y     # BTF also required for CO-RE BPF\nCONFIG_KASAN=y                                   # use-after-free, OOB. ~2-3x slowdown\nCONFIG_UBSAN=y                                   # undefined behaviour\nCONFIG_KCSAN=y                                   # data races\nCONFIG_PROVE_LOCKING=y                           # lockdep — deadlock detection\nCONFIG_DEBUG_ATOMIC_SLEEP=y                      # sleeping in atomic context\nCONFIG_PROVE_RCU=y\nCONFIG_DEBUG_OBJECTS=y\nCONFIG_SLUB_DEBUG_ON=y                           # redzoning, poisoning\nCONFIG_DEBUG_PAGEALLOC=y\nCONFIG_FAULT_INJECTION=y                         # make allocations fail on purpose\nCONFIG_KFENCE=y                                  # low-overhead; safe for PRODUCTION\n```\n**KASAN + lockdep together find the overwhelming majority of new kernel bugs before they\nreach anyone else.** KFENCE is the one you can leave on in production (sampling-based,\nnear-zero overhead).\n\n### 12.2 Reading an oops\n\n```\nBUG: kernel NULL pointer dereference, address: 0000000000000010\n#PF: supervisor read access in kernel mode\nOops: 0000 [#1] PREEMPT SMP NOPTI\nCPU: 3 PID: 1234 Comm: myapp Tainted: G           O       6.18.40 #1\nRIP: 0010:foo_read+0x42\u002F0x180 [mymod]     ← WHERE. function+offset\u002Fsize [module]\n...\nCall Trace:\n \u003CTASK>\n vfs_read+0xb4\u002F0x330\n ksys_read+0x6b\u002F0xf0\n do_syscall_64+0x5c\u002F0x90\n```\nRead it in this order:\n1. **The first line** — what kind of fault, and the bad address. `0x10` means a NULL\n   pointer plus a small struct offset; `0x6b6b6b6b...` is SLUB poison (use-after-free);\n   `0xffffffffffffffff` is often an unchecked `ERR_PTR`.\n2. **`RIP: function+offset\u002Fsize`** — the exact instruction. Resolve with\n   `.\u002Fscripts\u002Ffaddr2line vmlinux foo_read+0x42\u002F0x180` or `addr2line`.\n3. **`Tainted:`** — `G` clean-ish, `O` out-of-tree module loaded, `P` proprietary,\n   `D` previous oops, `W` previous warning. **Maintainers will ask about taint first.**\n4. **Call trace** — the path in. Entries with `?` are stale stack values, not real frames.\n5. **`[#1]`** — first oops. A second one after the first is usually corruption from the\n   first; only the first is trustworthy.\n\n`decode_stacktrace.sh` symbolizes the whole thing. `panic_on_oops=1` and `kdump`\u002F`crash`\ngive you a full vmcore for post-mortem analysis with `crash` or `drgn`.\n\n### 12.3 Tracing — the hierarchy\n\n| Tool | Overhead | Use for |\n|---|---|---|\n| `printk`\u002F`pr_debug` + **dynamic debug** | high if hot | Coarse. `echo 'file foo.c +p' > \u002Fsys\u002Fkernel\u002Fdebug\u002Fdynamic_debug\u002Fcontrol` |\n| **ftrace** (`\u002Fsys\u002Fkernel\u002Ftracing`) | low | Function graph tracing, latency tracers, per-event tracepoints. Built in, no tooling needed |\n| **`trace-cmd` \u002F KernelShark** | low | ftrace with a usable interface |\n| **perf** | low-medium | CPU profiling, `perf record\u002Freport`, `perf top`, `perf trace`, hardware counters, **flame graphs** |\n| **bpftrace** | low | One-liners with real logic. The modern first reach |\n| **BCC \u002F libbpf tools** | low | Prewritten: `execsnoop`, `opensnoop`, `biolatency`, `tcpconnect`, `runqlat`, `offcputime` |\n| **LTTng** | low | High-volume production tracing with a stable format |\n| **`strace` \u002F `ltrace`** | **very high** | Userspace syscall\u002Flibrary tracing. ptrace-based — do not use on a hot production process |\n| **KGDB \u002F KDB** | — | Interactive source-level kernel debugging (needs a serial console or VM) |\n| **QEMU + gdb** | — | **The best kernel development loop.** `qemu -s -S` then `gdb vmlinux` |\n\n```bash\n# The five bpftrace one-liners worth memorizing\nbpftrace -e 'tracepoint:syscalls:sys_enter_openat { @[comm] = count(); }'\nbpftrace -e 'kprobe:vfs_read { @bytes = hist(arg2); }'\nbpftrace -e 'tracepoint:sched:sched_process_exec { printf(\"%s %s\\n\", comm, str(args->filename)); }'\nbpftrace -e 'kretprobe:do_sys_openat2 \u002Fretval \u003C 0\u002F { @errs[comm, -retval] = count(); }'\nbpftrace -e 'profile:hz:99 { @[kstack] = count(); }'      # sampled kernel stacks\n\n# ftrace without any tooling\ncd \u002Fsys\u002Fkernel\u002Ftracing\necho function_graph > current_tracer && echo do_sys_openat2 > set_graph_function\necho 1 > tracing_on; cat trace_pipe\n\n# perf → flame graph\nperf record -F 99 -a -g -- sleep 30 && perf script | stackcollapse-perf.pl | flamegraph.pl > fg.svg\n```\n\n### 12.4 Testing\n\n`kunit` (in-kernel unit tests, run under UML or QEMU), `kselftest`\n(`tools\u002Ftesting\u002Fselftests`), **syzkaller** (coverage-guided syscall fuzzer — the single\nlargest source of kernel bug reports in existence), `xfstests` for filesystems, LTP.\n**Send a syzkaller reproducer with your bug report and you will get a fix; send a\ndescription and you may not.**\n\n---\n\n## §13. The Kernel Development Process\n\n### 13.1 How change actually happens\n\n```\nyou → patch → subsystem mailing list + MAINTAINERS entries (get_maintainer.pl)\n   → review (expect several rounds; v2, v3, v4 are normal and not an insult)\n      → maintainer's -next tree → linux-next (integration testing)\n         → MERGE WINDOW (2 weeks after a release) → Linus's tree\n            → rc1 … rc7 (~7 weeks of stabilization)\n               → release (~9–10 week cadence)\n                  → -stable backports (Fixes: tag \u002F Cc: stable@vger.kernel.org)\n```\n\n**Practical mechanics:**\n- `scripts\u002Fget_maintainer.pl -f path\u002Fto\u002Ffile.c` tells you exactly who to send to. Use it.\n- `scripts\u002Fcheckpatch.pl --strict` before every send.\n- **Plain-text email, no HTML, no attachments.** `git send-email`, or `b4` which is now\n  the ergonomic path for both sending and applying series.\n- Subject: `[PATCH v3 2\u002F5] subsystem: short imperative summary`.\n- A **`Fixes: \u003C12-char-sha> (\"subject\")`** tag is how a fix gets auto-backported to stable.\n- Changelog **below** the `---` line for the version history; commit message above.\n- `Reviewed-by`, `Acked-by`, `Tested-by`, `Reported-by`, `Closes:` are meaningful and\n  tracked.\n- Response to review is expected within a reasonable time; silence means the patch dies.\n\n**[DURABLE] The commit message matters as much as the code.** Explain *why*, not *what* —\nthe diff shows what. A maintainer reading it in three years during a bisect needs the\nreasoning.\n\n### 13.2 Versioning and stable trees [VERSIONED — this changed in 2026]\n\n**Version numbers carry no semantic meaning.** Linus increments the major number when the\nminor gets uncomfortably large, not at milestones. **Linux 7.0 released 12 April 2026**\nafter 6.19, and **7.1 and 7.2 followed** on the ordinary ~9–10 week cadence; it is \"a\nnormal continuation, not a major architectural break.\"\n\n| Tree | Meaning |\n|---|---|\n| **mainline** | Linus's tree. `rc` releases during stabilization |\n| **stable** | Point releases of the current release, weeks of support |\n| **longterm (LTS)** | Multi-year support. **Each new LTS starts with a ~2-year projected EOL that gets extended if industry helps maintain it** |\n\n**Current LTS set (Aug 2026):** 5.10, 5.15, 6.1, 6.6, 6.12, 6.18. In **February 2026**\nGreg Kroah-Hartman **extended support for 6.6, 6.12, and 6.18** after discussions with\ndevice manufacturers and embedded vendors — 6.18 now runs to at least **December 2028**.\n**5.10 and 5.15 both EOL 31 December 2026** — if you're on either, the clock is running.\n\n> **⚠️ GOTCHA — non-LTS releases get only a few months.** 7.0 reached EOL on\n> **27 June 2026**, roughly ten weeks after release. Shipping a product on a non-LTS\n> kernel means shipping a kernel that stops getting security fixes almost immediately.\n> **Anchor products to an LTS.**\n\n### 13.3 CVEs — and the flood\n\n**[VERSIONED, and a genuine operational problem.]** In February 2024 **kernel.org became\nits own CNA**. Two consequences designed in from the start: CVEs are assigned only *after*\na fix exists, and the team **errs on the side of assigning CVEs to all fixes** — because,\nas the documentation puts it, almost any bug might be exploitable and exploitability is\nusually not evident when the bug is fixed.\n\nThe result: **the Linux kernel is now the single largest issuer of CVEs**, at roughly\nfifty a week, **with no severity scores attached**, because the kernel community treats a\nCVE as an identifier for a fix rather than an alarm. In July 2026, **432 kernel CVEs were\npublished in under 48 hours**, prompting a public argument on oss-sec about whether\nper-CVE prioritization is even feasible at that volume.\n\n**[CONTESTED] Whether this is good.** *For:* it's honest — other vendors avoid assigning\nCVEs unless exploitability is unambiguous, which systematically undercounts risk; and the\nkernel's advice (\"run a maintained stable kernel and take the point releases\") is the\ncorrect advice regardless. *Against:* a stream of unscored CVEs destroys the signal that\nCVE was created to provide, and pushes triage cost onto every downstream consumer.\n\n**The practical consequence, and it is now a legal one:** severity triage is the device\nmaker's job. Under the **EU Cyber Resilience Act** — vulnerability and incident reporting\nobligations start **11 September 2026**, full obligations **11 December 2027** — the\nkernel is a component in your SBOM and its vulnerabilities are your duty to handle.\n**The cheapest compliant strategy is exactly what the kernel community has always\nrecommended: stay on a maintained LTS and take the point releases.** Do not attempt to\ncherry-pick individual \"important\" fixes at a rate of fifty a week.\n\n---\n\n## §14. Security and Hardening\n\n### 14.1 The kernel attack surface\n\n**[DURABLE] Everything reachable from an unprivileged process is attack surface**: every\nsyscall, every ioctl, every `\u002Fproc` and `\u002Fsys` write, every netlink socket, every\nfilesystem parser (mounting an untrusted filesystem image is executing an untrusted\nparser in ring 0), every network protocol, every driver bound to a device a user can\nplug in. The kernel's size is its security problem.\n\nDominant bug classes, in the order they appear in CVEs: **use-after-free** (especially\nrefcount errors and races on teardown), **out-of-bounds read\u002Fwrite**, **race conditions \u002F\ndouble-free**, **integer overflow feeding a size calculation**, **type confusion**, and\n**info leaks** (uninitialized kernel memory copied to userspace — always\n`memset` structs you `copy_to_user`, and mind the padding).\n\n### 14.2 The defenses\n\n| Mechanism | What it does |\n|---|---|\n| **KASLR** \u002F KPTI | Randomize kernel base; separate page tables (Meltdown) |\n| **SMEP \u002F SMAP** (x86), PAN\u002FPXN (arm64) | Kernel can't execute or access user pages accidentally |\n| **Stack protector**, `CONFIG_STACKLEAK` | Canaries; erase kernel stack on syscall return |\n| **`CONFIG_FORTIFY_SOURCE`** | Compile-time and runtime bounds checks on str\u002Fmem functions |\n| **`CONFIG_RANDSTRUCT`**, `CONFIG_STRUCTLEAK` | Randomize struct layout; zero-init |\n| **CFI** (`CONFIG_CFI_CLANG`), arm64 **BTI\u002FPAC**, x86 **IBT** | Control-flow integrity |\n| **Lockdown LSM** | `integrity`\u002F`confidentiality` modes: block `\u002Fdev\u002Fmem`, kexec of unsigned images, some BPF, some MSR writes, hibernation. **Auto-enabled under Secure Boot** |\n| **Module signing** (`module.sig_enforce`) | Only signed modules load |\n| **seccomp-bpf** | Per-process syscall filter. **The single most effective userspace sandbox primitive** |\n| **LSMs**: SELinux, AppArmor, Smack, Tomoyo, **Landlock**, **BPF-LSM**, Yama, IMA\u002FEVM | Mandatory access control. Stackable since 5.1 (`lsm=` on the cmdline) |\n| **Landlock** | **Unprivileged** sandboxing — a process can restrict *itself* without root. Genuinely new capability |\n| Namespaces + cgroups | Isolation and resource bounds (§7.3 → `linux-syscalls-ebpf-boot-and-init`) |\n\n**Sysctls worth knowing** (`\u002Fproc\u002Fsys\u002Fkernel\u002F`, `\u002Fproc\u002Fsys\u002Fnet\u002F`):\n```\nkernel.kptr_restrict=2            # hide kernel pointers from \u002Fproc\nkernel.dmesg_restrict=1           # dmesg needs CAP_SYSLOG\nkernel.perf_event_paranoid=3      # restrict perf\nkernel.unprivileged_bpf_disabled=1\nkernel.yama.ptrace_scope=1        # only ptrace descendants (2 = admin only)\nkernel.io_uring_disabled=2        # see §4.3\nkernel.kexec_load_disabled=1\nuser.max_user_namespaces=0        # if you don't need rootless containers\nvm.mmap_min_addr=65536            # blocks NULL-deref exploit mapping\nfs.protected_symlinks=1  fs.protected_hardlinks=1  fs.protected_fifos=2  fs.protected_regular=2\n```\n\n**[DURABLE] Reduce surface before adding mitigations.** Blocklist unused modules (Ubuntu\nalready does some of this), build a config with only what you need, disable unused\nprotocols and filesystems, and don't expose ioctls you don't need. A driver that isn't\ncompiled in cannot be exploited.\n\n**Attack-surface note that catches people**: `modprobe` autoloading means an unprivileged\nprocess opening a socket with an obscure protocol family can cause a rarely-audited module\nto load. That's how several CVEs became reachable. `install \u003Cmodule> \u002Fbin\u002Ftrue` in\n`\u002Fetc\u002Fmodprobe.d\u002F` blocks it.\n\n### 14.3 Kernel hardening posture, honestly\n\n- **Run a maintained LTS and take the point releases** (§13.3). This single practice\n  beats every mitigation config in expected value.\n- **Enable KASAN and lockdep in test, KFENCE in production.**\n- **Use seccomp + an LSM for every service** — or use systemd's sandboxing options\n  (§7.1 → `linux-syscalls-ebpf-boot-and-init`), which are seccomp and namespaces with a friendlier interface.\n- **Threat-model before disabling things.** io_uring, user namespaces, and eBPF are all\n  simultaneously large attack surfaces and genuinely valuable features. There is no\n  universal right answer, only a right answer for your exposure.\n","# Linux Kernel & Shell: Debugging and Observability, the Kernel Development Process, and Hardening\n\n> **Part 4 of 5** of the *OS Development — Linux Kernel and Shell* reference (plugin `os-development-kernel-shell`), covering §12–§14. Sibling skills: `linux-kernel-architecture-and-code` (§0–§3), `linux-syscalls-ebpf-boot-and-init` (§4–§7), `linux-shell-scripting-and-userland` (§8–§11), `linux-kernel-shell-reference` (§15–§20). Section numbers are shared across the set; a reference written as §N → `skill` points into that sibling skill.\n>\n> **Currency:** Verified August 2026. See §17 → `linux-kernel-shell-reference` for the currency snapshot and what goes stale first.\n\n> **How to read this.** Reference, not tutorial. Sections are independent. Three markers:\n> - **[DURABLE]** — architecture, algorithms, or semantics that have been stable for\n>   decades and will outlive this document.\n> - **[VERSIONED]** — depends on a kernel version, a shell version, or a distro. Check\n>   `Documentation\u002F`, the man page, or the source for your version.\n> - **[CONTESTED]** — the kernel community itself disagrees, publicly and at length.\n>   Both cases given.\n>\n> **⚠️ GOTCHA** boxes mark the mistakes that produce kernel oopses, data loss, silent\n> corruption, or a patch rejected on the mailing list.\n>\n> **The framing that matters most:** the kernel is not \"a big program.\" It is a\n> **hostile-input state machine running with no memory protection, no exceptions, a\n> hard limit on stack depth, and a promise never to break userspace**. Almost every\n> kernel-specific rule below descends from one of those five facts.\n\n---\n\n## §12. Debugging and Observability\n\n### 12.1 The kernel debug configs to build with\n\n**[DURABLE] Turn these on in development. Every one of them turns a heisenbug into a\nreproducible splat:**\n```\nCONFIG_DEBUG_KERNEL=y\nCONFIG_DEBUG_INFO=y CONFIG_DEBUG_INFO_BTF=y     # BTF also required for CO-RE BPF\nCONFIG_KASAN=y                                   # use-after-free, OOB. ~2-3x slowdown\nCONFIG_UBSAN=y                                   # undefined behaviour\nCONFIG_KCSAN=y                                   # data races\nCONFIG_PROVE_LOCKING=y                           # lockdep — deadlock detection\nCONFIG_DEBUG_ATOMIC_SLEEP=y                      # sleeping in atomic context\nCONFIG_PROVE_RCU=y\nCONFIG_DEBUG_OBJECTS=y\nCONFIG_SLUB_DEBUG_ON=y                           # redzoning, poisoning\nCONFIG_DEBUG_PAGEALLOC=y\nCONFIG_FAULT_INJECTION=y                         # make allocations fail on purpose\nCONFIG_KFENCE=y                                  # low-overhead; safe for PRODUCTION\n```\n**KASAN + lockdep together find the overwhelming majority of new kernel bugs before they\nreach anyone else.** KFENCE is the one you can leave on in production (sampling-based,\nnear-zero overhead).\n\n### 12.2 Reading an oops\n\n```\nBUG: kernel NULL pointer dereference, address: 0000000000000010\n#PF: supervisor read access in kernel mode\nOops: 0000 [#1] PREEMPT SMP NOPTI\nCPU: 3 PID: 1234 Comm: myapp Tainted: G           O       6.18.40 #1\nRIP: 0010:foo_read+0x42\u002F0x180 [mymod]     ← WHERE. function+offset\u002Fsize [module]\n...\nCall Trace:\n \u003CTASK>\n vfs_read+0xb4\u002F0x330\n ksys_read+0x6b\u002F0xf0\n do_syscall_64+0x5c\u002F0x90\n```\nRead it in this order:\n1. **The first line** — what kind of fault, and the bad address. `0x10` means a NULL\n   pointer plus a small struct offset; `0x6b6b6b6b...` is SLUB poison (use-after-free);\n   `0xffffffffffffffff` is often an unchecked `ERR_PTR`.\n2. **`RIP: function+offset\u002Fsize`** — the exact instruction. Resolve with\n   `.\u002Fscripts\u002Ffaddr2line vmlinux foo_read+0x42\u002F0x180` or `addr2line`.\n3. **`Tainted:`** — `G` clean-ish, `O` out-of-tree module loaded, `P` proprietary,\n   `D` previous oops, `W` previous warning. **Maintainers will ask about taint first.**\n4. **Call trace** — the path in. Entries with `?` are stale stack values, not real frames.\n5. **`[#1]`** — first oops. A second one after the first is usually corruption from the\n   first; only the first is trustworthy.\n\n`decode_stacktrace.sh` symbolizes the whole thing. `panic_on_oops=1` and `kdump`\u002F`crash`\ngive you a full vmcore for post-mortem analysis with `crash` or `drgn`.\n\n### 12.3 Tracing — the hierarchy\n\n| Tool | Overhead | Use for |\n|---|---|---|\n| `printk`\u002F`pr_debug` + **dynamic debug** | high if hot | Coarse. `echo 'file foo.c +p' > \u002Fsys\u002Fkernel\u002Fdebug\u002Fdynamic_debug\u002Fcontrol` |\n| **ftrace** (`\u002Fsys\u002Fkernel\u002Ftracing`) | low | Function graph tracing, latency tracers, per-event tracepoints. Built in, no tooling needed |\n| **`trace-cmd` \u002F KernelShark** | low | ftrace with a usable interface |\n| **perf** | low-medium | CPU profiling, `perf record\u002Freport`, `perf top`, `perf trace`, hardware counters, **flame graphs** |\n| **bpftrace** | low | One-liners with real logic. The modern first reach |\n| **BCC \u002F libbpf tools** | low | Prewritten: `execsnoop`, `opensnoop`, `biolatency`, `tcpconnect`, `runqlat`, `offcputime` |\n| **LTTng** | low | High-volume production tracing with a stable format |\n| **`strace` \u002F `ltrace`** | **very high** | Userspace syscall\u002Flibrary tracing. ptrace-based — do not use on a hot production process |\n| **KGDB \u002F KDB** | — | Interactive source-level kernel debugging (needs a serial console or VM) |\n| **QEMU + gdb** | — | **The best kernel development loop.** `qemu -s -S` then `gdb vmlinux` |\n\n```bash\n# The five bpftrace one-liners worth memorizing\nbpftrace -e 'tracepoint:syscalls:sys_enter_openat { @[comm] = count(); }'\nbpftrace -e 'kprobe:vfs_read { @bytes = hist(arg2); }'\nbpftrace -e 'tracepoint:sched:sched_process_exec { printf(\"%s %s\\n\", comm, str(args->filename)); }'\nbpftrace -e 'kretprobe:do_sys_openat2 \u002Fretval \u003C 0\u002F { @errs[comm, -retval] = count(); }'\nbpftrace -e 'profile:hz:99 { @[kstack] = count(); }'      # sampled kernel stacks\n\n# ftrace without any tooling\ncd \u002Fsys\u002Fkernel\u002Ftracing\necho function_graph > current_tracer && echo do_sys_openat2 > set_graph_function\necho 1 > tracing_on; cat trace_pipe\n\n# perf → flame graph\nperf record -F 99 -a -g -- sleep 30 && perf script | stackcollapse-perf.pl | flamegraph.pl > fg.svg\n```\n\n### 12.4 Testing\n\n`kunit` (in-kernel unit tests, run under UML or QEMU), `kselftest`\n(`tools\u002Ftesting\u002Fselftests`), **syzkaller** (coverage-guided syscall fuzzer — the single\nlargest source of kernel bug reports in existence), `xfstests` for filesystems, LTP.\n**Send a syzkaller reproducer with your bug report and you will get a fix; send a\ndescription and you may not.**\n\n---\n\n## §13. The Kernel Development Process\n\n### 13.1 How change actually happens\n\n```\nyou → patch → subsystem mailing list + MAINTAINERS entries (get_maintainer.pl)\n   → review (expect several rounds; v2, v3, v4 are normal and not an insult)\n      → maintainer's -next tree → linux-next (integration testing)\n         → MERGE WINDOW (2 weeks after a release) → Linus's tree\n            → rc1 … rc7 (~7 weeks of stabilization)\n               → release (~9–10 week cadence)\n                  → -stable backports (Fixes: tag \u002F Cc: stable@vger.kernel.org)\n```\n\n**Practical mechanics:**\n- `scripts\u002Fget_maintainer.pl -f path\u002Fto\u002Ffile.c` tells you exactly who to send to. Use it.\n- `scripts\u002Fcheckpatch.pl --strict` before every send.\n- **Plain-text email, no HTML, no attachments.** `git send-email`, or `b4` which is now\n  the ergonomic path for both sending and applying series.\n- Subject: `[PATCH v3 2\u002F5] subsystem: short imperative summary`.\n- A **`Fixes: \u003C12-char-sha> (\"subject\")`** tag is how a fix gets auto-backported to stable.\n- Changelog **below** the `---` line for the version history; commit message above.\n- `Reviewed-by`, `Acked-by`, `Tested-by`, `Reported-by`, `Closes:` are meaningful and\n  tracked.\n- Response to review is expected within a reasonable time; silence means the patch dies.\n\n**[DURABLE] The commit message matters as much as the code.** Explain *why*, not *what* —\nthe diff shows what. A maintainer reading it in three years during a bisect needs the\nreasoning.\n\n### 13.2 Versioning and stable trees [VERSIONED — this changed in 2026]\n\n**Version numbers carry no semantic meaning.** Linus increments the major number when the\nminor gets uncomfortably large, not at milestones. **Linux 7.0 released 12 April 2026**\nafter 6.19, and **7.1 and 7.2 followed** on the ordinary ~9–10 week cadence; it is \"a\nnormal continuation, not a major architectural break.\"\n\n| Tree | Meaning |\n|---|---|\n| **mainline** | Linus's tree. `rc` releases during stabilization |\n| **stable** | Point releases of the current release, weeks of support |\n| **longterm (LTS)** | Multi-year support. **Each new LTS starts with a ~2-year projected EOL that gets extended if industry helps maintain it** |\n\n**Current LTS set (Aug 2026):** 5.10, 5.15, 6.1, 6.6, 6.12, 6.18. In **February 2026**\nGreg Kroah-Hartman **extended support for 6.6, 6.12, and 6.18** after discussions with\ndevice manufacturers and embedded vendors — 6.18 now runs to at least **December 2028**.\n**5.10 and 5.15 both EOL 31 December 2026** — if you're on either, the clock is running.\n\n> **⚠️ GOTCHA — non-LTS releases get only a few months.** 7.0 reached EOL on\n> **27 June 2026**, roughly ten weeks after release. Shipping a product on a non-LTS\n> kernel means shipping a kernel that stops getting security fixes almost immediately.\n> **Anchor products to an LTS.**\n\n### 13.3 CVEs — and the flood\n\n**[VERSIONED, and a genuine operational problem.]** In February 2024 **kernel.org became\nits own CNA**. Two consequences designed in from the start: CVEs are assigned only *after*\na fix exists, and the team **errs on the side of assigning CVEs to all fixes** — because,\nas the documentation puts it, almost any bug might be exploitable and exploitability is\nusually not evident when the bug is fixed.\n\nThe result: **the Linux kernel is now the single largest issuer of CVEs**, at roughly\nfifty a week, **with no severity scores attached**, because the kernel community treats a\nCVE as an identifier for a fix rather than an alarm. In July 2026, **432 kernel CVEs were\npublished in under 48 hours**, prompting a public argument on oss-sec about whether\nper-CVE prioritization is even feasible at that volume.\n\n**[CONTESTED] Whether this is good.** *For:* it's honest — other vendors avoid assigning\nCVEs unless exploitability is unambiguous, which systematically undercounts risk; and the\nkernel's advice (\"run a maintained stable kernel and take the point releases\") is the\ncorrect advice regardless. *Against:* a stream of unscored CVEs destroys the signal that\nCVE was created to provide, and pushes triage cost onto every downstream consumer.\n\n**The practical consequence, and it is now a legal one:** severity triage is the device\nmaker's job. Under the **EU Cyber Resilience Act** — vulnerability and incident reporting\nobligations start **11 September 2026**, full obligations **11 December 2027** — the\nkernel is a component in your SBOM and its vulnerabilities are your duty to handle.\n**The cheapest compliant strategy is exactly what the kernel community has always\nrecommended: stay on a maintained LTS and take the point releases.** Do not attempt to\ncherry-pick individual \"important\" fixes at a rate of fifty a week.\n\n---\n\n## §14. Security and Hardening\n\n### 14.1 The kernel attack surface\n\n**[DURABLE] Everything reachable from an unprivileged process is attack surface**: every\nsyscall, every ioctl, every `\u002Fproc` and `\u002Fsys` write, every netlink socket, every\nfilesystem parser (mounting an untrusted filesystem image is executing an untrusted\nparser in ring 0), every network protocol, every driver bound to a device a user can\nplug in. The kernel's size is its security problem.\n\nDominant bug classes, in the order they appear in CVEs: **use-after-free** (especially\nrefcount errors and races on teardown), **out-of-bounds read\u002Fwrite**, **race conditions \u002F\ndouble-free**, **integer overflow feeding a size calculation**, **type confusion**, and\n**info leaks** (uninitialized kernel memory copied to userspace — always\n`memset` structs you `copy_to_user`, and mind the padding).\n\n### 14.2 The defenses\n\n| Mechanism | What it does |\n|---|---|\n| **KASLR** \u002F KPTI | Randomize kernel base; separate page tables (Meltdown) |\n| **SMEP \u002F SMAP** (x86), PAN\u002FPXN (arm64) | Kernel can't execute or access user pages accidentally |\n| **Stack protector**, `CONFIG_STACKLEAK` | Canaries; erase kernel stack on syscall return |\n| **`CONFIG_FORTIFY_SOURCE`** | Compile-time and runtime bounds checks on str\u002Fmem functions |\n| **`CONFIG_RANDSTRUCT`**, `CONFIG_STRUCTLEAK` | Randomize struct layout; zero-init |\n| **CFI** (`CONFIG_CFI_CLANG`), arm64 **BTI\u002FPAC**, x86 **IBT** | Control-flow integrity |\n| **Lockdown LSM** | `integrity`\u002F`confidentiality` modes: block `\u002Fdev\u002Fmem`, kexec of unsigned images, some BPF, some MSR writes, hibernation. **Auto-enabled under Secure Boot** |\n| **Module signing** (`module.sig_enforce`) | Only signed modules load |\n| **seccomp-bpf** | Per-process syscall filter. **The single most effective userspace sandbox primitive** |\n| **LSMs**: SELinux, AppArmor, Smack, Tomoyo, **Landlock**, **BPF-LSM**, Yama, IMA\u002FEVM | Mandatory access control. Stackable since 5.1 (`lsm=` on the cmdline) |\n| **Landlock** | **Unprivileged** sandboxing — a process can restrict *itself* without root. Genuinely new capability |\n| Namespaces + cgroups | Isolation and resource bounds (§7.3 → `linux-syscalls-ebpf-boot-and-init`) |\n\n**Sysctls worth knowing** (`\u002Fproc\u002Fsys\u002Fkernel\u002F`, `\u002Fproc\u002Fsys\u002Fnet\u002F`):\n```\nkernel.kptr_restrict=2            # hide kernel pointers from \u002Fproc\nkernel.dmesg_restrict=1           # dmesg needs CAP_SYSLOG\nkernel.perf_event_paranoid=3      # restrict perf\nkernel.unprivileged_bpf_disabled=1\nkernel.yama.ptrace_scope=1        # only ptrace descendants (2 = admin only)\nkernel.io_uring_disabled=2        # see §4.3\nkernel.kexec_load_disabled=1\nuser.max_user_namespaces=0        # if you don't need rootless containers\nvm.mmap_min_addr=65536            # blocks NULL-deref exploit mapping\nfs.protected_symlinks=1  fs.protected_hardlinks=1  fs.protected_fifos=2  fs.protected_regular=2\n```\n\n**[DURABLE] Reduce surface before adding mitigations.** Blocklist unused modules (Ubuntu\nalready does some of this), build a config with only what you need, disable unused\nprotocols and filesystems, and don't expose ioctls you don't need. A driver that isn't\ncompiled in cannot be exploited.\n\n**Attack-surface note that catches people**: `modprobe` autoloading means an unprivileged\nprocess opening a socket with an obscure protocol family can cause a rarely-audited module\nto load. That's how several CVEs became reachable. `install \u003Cmodule> \u002Fbin\u002Ftrue` in\n`\u002Fetc\u002Fmodprobe.d\u002F` blocks it.\n\n### 14.3 Kernel hardening posture, honestly\n\n- **Run a maintained LTS and take the point releases** (§13.3). This single practice\n  beats every mitigation config in expected value.\n- **Enable KASAN and lockdep in test, KFENCE in production.**\n- **Use seccomp + an LSM for every service** — or use systemd's sandboxing options\n  (§7.1 → `linux-syscalls-ebpf-boot-and-init`), which are seccomp and namespaces with a friendlier interface.\n- **Threat-model before disabling things.** io_uring, user namespaces, and eBPF are all\n  simultaneously large attack surfaces and genuinely valuable features. There is no\n  universal right answer, only a right answer for your exposure.\n",{"name":5,"description":7},"develop","ae32736a1aabddabca5d2c96d665aa0ebc7d8700","src\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fos-development-kernel-shell\u002Fskills\u002Flinux-kernel-debugging-process-and-hardening",3,"https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey","https:\u002F\u002Fthe-vibey-project.github.io\u002Fvibey\u002F","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project","https:\u002F\u002Fvibewithadam.matthewsteinberger.com","freedom for software engineers","2026-11-15 05:47:42",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add the-vibey-project\u002Fvibey --skill linux-kernel-debugging-process-and-hardening",{"tool":40,"command":41},"bunx","bunx skills add the-vibey-project\u002Fvibey --skill linux-kernel-debugging-process-and-hardening",{"tool":43,"command":44},"pnpm","pnpm dlx skills add the-vibey-project\u002Fvibey --skill linux-kernel-debugging-process-and-hardening","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fos-development-kernel-shell\u002Fskills\u002Flinux-kernel-debugging-process-and-hardening\u002FSKILL.md",true,[],[49,56,63,70,77,84],{"skillNo":50,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":53,"categories":54,"keywords":55,"publishedAt":19},"01M7AT1FQJAE1FQYAMDTF490Y4","white-paper-writing","Use when writing white papers, technical reports, policy documents, thought leadership pieces, or any long-form authoritative document. Triggers on requests to write, structure, outline, or review white papers, technical reports, position papers, policy briefs, or evidence-driven arguments. Also use for B2B content marketing strategy, technical documentation requiring authority, academic-style reports, or any document that must educate while persuading. Use when someone asks \"how should I structure this\" for a long-form document.","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fwriting-craft\u002Fskills\u002Fwhite-paper-writing\u002FSKILL.md",[],[],{"skillNo":57,"name":58,"nameZh":6,"description":59,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":19},"01M7AT16BJRJJKK2MASXRZS76G","prose-technical-mechanics","Use when editing or writing prose at a technical\u002Fmechanical level: choosing between Anglo-Saxon and Latinate diction, placing information in topic vs stress positions, writing periodic vs cumulative sentences, handling sentence rhythm, punctuation as logic, transitions, paragraph structure, or phonesthetics. Use when someone wants to understand WHY prose works or doesn't, not just surface-level style advice. Triggers on word choice, sentence structure, emphasis, rhythm, diction, or any deep writing mechanics question.","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fwriting-craft\u002Fskills\u002Fprose-technical-mechanics\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":19},"01M7AT0W9HT0ZZ9Y287NW99MR3","prose-mechanics","Use when writing, editing, or analyzing prose style; when trying to avoid generic AI-sounding writing; when applying specific prose styles such as journalistic, academic, narrative, KJV biblical, Hemingway plain, Latinate\u002FJamesian, Orwellian, Augustan, Victorian, Early Modern (Bacon, Browne, Milton), or free indirect discourse; or when coaching someone on writing voice and mechanics. Triggers on any request to improve, analyze, or write in a specific prose style, to fix \"AI-sounding\" writing, to make prose more vivid or concrete, to vary sentence rhythm, or to understand how a particular writer achieves their effects.","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fwriting-craft\u002Fskills\u002Fprose-mechanics\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M7AT0KR635JX66X2X6F3E2CP","narrative-structure","Use when structuring stories, pitches, presentations, white papers, or any persuasive narrative; analyzing the hero's journey in fiction or non-fiction; applying StoryBrand for business communication; designing narrative arcs for thought leadership; or understanding Vogler, Snyder, Propp, or Campbell frameworks. Triggers on any narrative structure, storytelling, pitch structure, StoryBrand, hero's journey, three-act structure, Freytag, Save the Cat, narrative arc, or \"how should I structure this story\u002Fpitch\u002Fpresentation\" request.","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fwriting-craft\u002Fskills\u002Fnarrative-structure\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":19},"01M7AT0AKGW09NKKZDYBT8VRDE","legal-brief-writing","Use when writing legal briefs, motions, or any court filing; when analyzing judicial cognition and persuasion; when applying elite brief-writing techniques from Roberts, Clement, Kagan, Garner; or when structuring legal arguments for maximum persuasion. Also use for autistic\u002Fneurodivergent advocates who need to understand how their natural communication style maps to elite legal advocacy. Triggers on any legal writing, brief drafting, motion preparation, or legal argument structuring request.","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fwriting-craft\u002Fskills\u002Flegal-brief-writing\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M7AT00VWPS4Q8B5VEMXX9NQT","journal-publishability-criteria","Use whenever a research paper, article or preprint is being written, revised, reviewed or published, and specifically before every publication of docs\u002Fpaper.md. Covers what legitimate journals actually gate on, in order of gating — the editor's desk screen (scope, novelty, package problems), what reviewers judge (methodological soundness, claims the evidence can carry, statistical and qualitative reporting), EQUATOR reporting guidelines, the ICMJE authorship criteria, COPE's view of text recycling, the near-universal generative-AI policy (no AI author, disclosure, author responsibility), TOP 2025 transparency standards, how to verify a journal is legitimate, submitting without an institution, and a pre-submission checklist. Triggers on requests to evaluate, review, prepare or submit a paper, to judge publishability, to write a declarations or data-availability section, to disclose AI use, or to check a journal.","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fwriting-craft\u002Fskills\u002Fjournal-publishability-criteria\u002FSKILL.md",[],[]]