Skip to content

tools/killsnoop: migrate to tracepoints - #5546

Merged
ekyooo merged 3 commits into
iovisor:masterfrom
codebyangelo:fix-killsnoop-tracepoints
Aug 27, 2026
Merged

tools/killsnoop: migrate to tracepoints#5546
ekyooo merged 3 commits into
iovisor:masterfrom
codebyangelo:fix-killsnoop-tracepoints

Conversation

@codebyangelo

@codebyangelo codebyangelo commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Fixes #3592

This commit updates the python killsnoop tool to use tracepoints for the kill, tkill, and tgkill syscalls. Previously, it used kprobes on sys_kill, which broke on Linux 5.11 due to kernel changes. This brings the python tool in parity with the libbpf-tools C version (sigsnoop), providing a more robust and stable tracing mechanism.

Description

Fixes #3592.

This PR migrates the Python `tools/killsnoop.py` script from using `kprobes` to using

tracepoints.

Previously, the tool relied on kprobing `sys_kill`. Starting with Linux 5.11,

architectural changes to syscall wrappers caused this kprobe approach to fail. This PR
removes the fragile kprobe logic and replaces it with robust TRACEPOINT_PROBE macros for
syscalls:sys_enter_kill, tkill, and tgkill (and their respective sys_exit
counterparts).

Why this approach

Tracepoints provide a stable, kernel-maintained ABI for tracing syscalls that is immune

to the underlying function renaming and pt_regs mapping changes that break kprobes.

Additionally, the `libbpf-tools` C equivalent (`sigsnoop`) had already successfully

migrated to this exact tracepoint approach, but the original Python tool was left behind.
This PR brings the Python implementation back into parity and restores its functionality on
all modern kernels.


Checklist

  • Commit prefix matches changed area (e.g., tools/toolname:, libbpf-tools/toolname:, src/cc:, docs:, build:, tests/python:)
  • Commit body explains why this change is needed

For new tools only

  • Explains why this tool is needed and what existing tools cannot cover this use case
  • Includes at least one real production use case
  • Man page (man/man8/) with an OVERHEAD section
  • Example output file (*_example.txt)
  • README.md entry added
  • Smoke test added to tests/python/test_tools_smoke.py

About AI Code Review: This project uses GitHub Copilot to assist with code review.
If a Copilot review is added, treat its feedback as you would any reviewer comment — you can
agree, disagree (with explanation), or ask questions. The maintainer makes all final decisions.

Fixes iovisor#3592

This commit updates the python killsnoop tool to use tracepoints for the
kill, tkill, and tgkill syscalls. Previously, it used kprobes on sys_kill,
which broke on Linux 5.11 due to kernel changes. This brings the python
tool in parity with the libbpf-tools C version (sigsnoop), providing a
more robust and stable tracing mechanism.

@ekyooo ekyooo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

Comment thread tools/killsnoop.py
};
}

TRACEPOINT_PROBE(syscalls, sys_enter_kill)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TRACEPOINT_PROBE-based BPF programs require Linux 4.7 or later. Please update the test_killsnoop() kernel gate from 4.4 to 4.7, consistent with the existing tracepoint tests.

for example,

--- a/tests/python/test_tools_smoke.py
+++ b/tests/python/test_tools_smoke.py
@@
-    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
+    @skipUnless(kernel_version_ge(4,7), "requires kernel >= 4.7")

Comment thread tools/killsnoop.py Outdated
{
return probe_exit(args, args->ret);
}
;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the extra blank lines and semicolon.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the guidance. Done.

@ekyooo
ekyooo merged commit f07cbb7 into iovisor:master Aug 27, 2026
12 checks passed
@codebyangelo
codebyangelo deleted the fix-killsnoop-tracepoints branch August 27, 2026 11:34
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.

update killsnoop to use tracepoints

2 participants