Skip to content

hooks: do_exit kprobe for authoritative process-exit capture - #95

Open
lacraig2 wants to merge 1 commit into
mainfrom
do_exit_hook
Open

hooks: do_exit kprobe for authoritative process-exit capture#95
lacraig2 wants to merge 1 commit into
mainfrom
do_exit_hook

Conversation

@lacraig2

@lacraig2 lacraig2 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

A kprobe on do_exit fires on every user-process death — normal exit/exit_group, fatal signals, OOM, kernel-forced — which the exit/exit_group syscall hooks miss (a signal death issues no exit syscall). It emits struct exit_event {pid, tid, create_time, code, comm} via a new IGLOO_HYP_PROC_EXIT hypercall, with code in raw wait(2)-status encoding so the host decodes WIFSIGNALED/WIFEXITED without heuristics. Reported at thread-group-leader death (user procs only) so it maps 1:1 onto the for_each_process walk.

Enable-gated / zero-cost when off: the kprobe is armed lazily on the host register_exit_hook portal op and removed on unregister, so an un-opted-in run installs no probe at all. do_exit is NOKPROBE-blacklisted on some kernels; registration degrades gracefully (logs, no events) rather than failing module load. If that ever bites a target, switch symbol_name to the sched_process_exit tracepoint.

Files: new src/hooks/exit_hc.c/.h; wired via igloo_hypercall_consts.h (IGLOO_HYP_PROC_EXIT), portal_op_list.h (register/unregister ops, X-macro auto-wires enum+dispatch+prototypes), igloo_hc.c (init), Makefile.

Consumed by penguin PR #897 (exit_monitor + processes use_do_exit). Builds clean across the arch/version matrix; validated live via the pre-release v0.0.94-pre.df8576ef7 cut from this branch's tag, whose ISF carries HYPER_OP_REGISTER_EXIT_HOOK / IGLOO_HYP_PROC_EXIT / exit_event (penguin's ABI gate green against it).

A kprobe on do_exit fires on every user-process death -- normal
exit/exit_group, fatal signals, OOM, kernel-forced -- which the
exit/exit_group syscall hooks miss (a signal death issues no exit
syscall). Emits struct exit_event {pid,tid,create_time,code,comm} via
IGLOO_HYP_PROC_EXIT with the raw wait(2)-status-encoded code, so the
host decodes WIFSIGNALED/WIFEXITED without heuristics. Reports at
thread-group-leader death (user procs only) to map 1:1 onto the
for_each_process walk.

Enable-gated: the kprobe is armed lazily on the host register op and
removed on unregister (register/unregister_exit_hook portal ops), so an
un-opted-in run pays zero cost. do_exit is NOKPROBE-blacklisted on some
kernels; registration degrades gracefully (logs, no events) rather than
failing module load.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant