CRASHME(9)

πŸ“¦ version 11.0, in nixpkgs unstable

πŸ’₯ CRASHME(9) β€” in-kernel testing of crash handling πŸ’₯

okay so this is the crashme page from the Kernel Developer's Manual, section 9, and bestie… it's literally a page about functions whose whole job is to break your kernel on purpose, so buckle up 🎒

✨ NAME ✨

crashme, crashme_add, crashme_remove β€” in-kernel testing of crash handling 🧨

✨ SYNOPSIS ✨

#include <sys/crashme.h>

int
crashme_add(crashme_node *cn);

int
crashme_remove(crashme_node *cn);

✨ DESCRIPTION ✨

The crashme functions are how you dynamically add and remove crashme nodes 🫢 and like, a crashme node is lowkey just a named callback that's fully expected to make the system crash. yes bestie, that's the assignment. that's the whole vibe πŸ’€

real talk though: the crashme functionality is only available in kernels that have the options DEBUG set in the kernel config(5) file. no DEBUG, no crashing on purpose, periodt πŸ™…β€β™€οΈ

Every crashme node lives inside a crashme_node structure, and it's giving these public members:

typedef int (*crashme_fn)(int /* flags */);

typedef struct crashme_node {
        const char     *cn_name;
        const char     *cn_longname;
        crashme_fn      cn_fn;
} crashme_node;

The caller must fill in cn_name, cn_longname, and cn_fn β€” no skipping, not optional, main character energy only πŸ‘‘

The cn_fn function gets passed the flags parameter straight from sysctl. It shall return 0 upon success, or non zero on failure. simple as that πŸŽ€

✨ SYSCTL SUPPORT ✨

The crashme subsystem provides these sysctl(8) variables:

  • debug.crashme_enable β€” must be set to 1 for any crashme node to be executed. it's the master switch bestie, nothing happens without it πŸ”

And these sysctl(8) variables literally trigger crashes in different ways when you write to them 😭:

  • debug.crashme.panic β€” calls panic(9) πŸ’₯
  • debug.crashme.null_deref β€” dereferences a null pointer πŸ•³οΈ
  • debug.crashme.null_jump β€” calls a null function pointer, i.e. jumps to the instruction address zero πŸš€
  • debug.crashme.ddb β€” enters ddb(4) directly by calling Debugger(). this one requires options DDB πŸͺ²
ngl these are all extremely on purpose. that's the point. don't be surprised when the box goes down, that's the whole slay πŸ’…

✨ SEE ALSO ✨

ddb(4), options(4), sysctl(8), panic(9) 🌸

✨ HISTORY ✨

The crashme driver appeared in NetBSD 9.0 ⭐

✨ AUTHORS ✨

Matthew R. Green 🫢


and that's the page, bestie!! πŸŽ€ this rewrite is from the Debian version, dated January 7, 2019 β€” mwah, go crash something responsibly (in a DEBUG kernel) πŸ’œπŸ¦‹

πŸ“¦ where this page comes from