Skip to content

Hiding

ftrace and kprobe Hooking in Linux Rootkits: Checks

How Linux rootkits use ftrace and kprobes, the kernel's own tracing hooks, to divert functions, and how enabled_functions and memory analysis reveal them.

Goal
Hiding
Layer
Kernel
Platforms
Linux
ATT&CK
T1014
Also known as
ftrace hooking, kprobe hooking
Checked by
Linux kernel

Overview

ftrace is the Linux kernel's function tracer. It can attach a callback to the start of almost any kernel function. With the right flags, the callback can also send execution to another function instead. The kernel's own documentation says that "This is what live kernel patches uses" (Using ftrace to hook to functions). A rootkit module can use the same interface to replace a system call or a file system helper. The kernel installs the hook itself: no table to overwrite, no write-protection to switch off.

kprobes are the kernel's other dynamic instrumentation. A kprobe places a probe on a kernel instruction and runs a handler when it is hit; a kretprobe runs one when a function returns (kprobes documentation). In public rootkits, Elastic says kprobes "are often used for intermittent or auxiliary hooking". Since Linux 5.7 stopped exporting kallsyms_lookup_name() (LWN), modules register a kprobe on that function to learn its address, then use it to find whatever they want to hook.

Both work at the kernel layer, from a loaded module. Elastic classifies KoviD, Singularity and Umbra as ftrace-based rootkits, and notes that PUMAKIT uses ftrace too. eBPF programs can also attach to kprobes without any module: see eBPF programs as rootkits.

How it works

MechanismWhat the module registersWhat it changesWhere it shows
ftrace with "ip modify"A callback on a function's address, with the flags that save registers and allow the instruction pointer to changeThe function's entry, prepared for tracing at build time, now calls ftrace, which calls the callback; the callback sends the caller into the rootkit's functionenabled_functions with R and I; touched_functions with M
kprobe or kretprobeA handler on an instruction or on a function's returnA breakpoint, or an ftrace call when the probe sits at a function's entry/sys/kernel/debug/kprobes/list, marked [FTRACE] when ftrace-based
kprobe used for lookupA probe on kallsyms_lookup_name, read for its address and removed at onceNothing that lastsOnly the module's own imports and strings

The kernel documents the flag that lets a callback "hijack" a function. Only one callback with that flag may sit on a given function at a time (ftrace-uses).

The effect is the same as other kernel hooks. A hook on __x64_sys_getdents64 or on the directory callback filldir64 filters what every program lists, static tools included. A hook on a network function hides connections.

Live patching, BPF trampolines, tracers and some security agents also attach ftrace callbacks. An ftrace hook is normal on its own; one on a system call or filldir that no live patch, tracer or known agent explains is not.

How families use it

FamilyWhat it doesSource
KoviDHooks system calls and kernel functions with ftrace, including filldir and filldir64 to hide files ("Ftrace, a legitimate method for function and syscall hijacking in Kernel v5+"). Finds kallsyms_lookup_name through a kprobe that it registers and removes at once. Its README lists "Ftrace disabling call interception": in the public source, writing 0 to /proc/sys/kernel/ftrace_enabled is undone, while reads of the file report the value writtenRepository (README, src/sys.c)
PUMAKITUses ftrace to "hook 18 different syscalls and several kernel functions", managed with ftrace_set_filter_ip. Elastic says it "does not use kprobes" and imports kallsyms_lookup_name, which ties it to kernels before 5.7. Elastic's taxonomy adds a direct system call table hookElastic, 2024

Reptile is often grouped with these, but its KHOOK engine "operates via inline function patching" (Elastic): in the public source, it finds symbols with kallsyms_on_each_symbol and writes jumps into function entries. It is not an ftrace or kprobe user; see inline kernel function hooking.

Diamorphine is not listed either: it uses a kprobe only to find kallsyms_lookup_name on 5.7 and later kernels, and its hooks are in the system call table (family page, Elastic, 2026).

Traces it leaves

WhereTraceNotes
/sys/kernel/tracing/enabled_functionsEvery function with a callback, the number of callbacks, R (saves registers), I (may change the instruction pointer) and, where the architecture supports it, the callback calledftrace documentation; before 4.1, under /sys/kernel/debug/tracing/
/sys/kernel/tracing/touched_functionsEvery function that ever had a callback since boot; M marks one ever modified by "ip modify" and "is never cleared"Linux 6.4 and later (commit); still shows a hook that was removed
/sys/kernel/debug/kprobes/listRegistered kprobes and kretprobes, with the probed symbolA probe removed after a lookup is gone
Memoryftrace_ops callbacks that point into a module, hidden or notThe independent view
Module fileImports register_ftrace_function and ftrace_set_filter_ip; register_kprobe with the string kallsyms_lookup_name; names of hooked functionsWhen the .ko is on disk
kern.log, journalTaint lines naming an out-of-tree or unsigned moduleOnce per boot; a live patch taints with K, which is expected

How to check a host

Live, as root, with caution. The rootkit can filter reads of these files; KoviD hooks read() and lies about ftrace_enabled. Collect them early and compare with memory.

cat /sys/kernel/tracing/enabled_functions          # mount tracefs first if absent: mount -t tracefs nodev /sys/kernel/tracing
grep ' M ' /sys/kernel/tracing/touched_functions   # 6.4 and later: functions ever diverted since boot
cat /sys/kernel/debug/kprobes/list                 # debugfs must be mounted
ls /sys/kernel/livepatch/ 2>/dev/null              # live patches that explain legitimate "ip modify" hooks
cat /proc/sys/kernel/tainted
  • Read each I line in enabled_functions. A system call handler, filldir, filldir64, iterate_dir, tcp4_seq_show or a packet receive function, diverted by something that is not a live patch or a known agent, is a strong lead.
  • Compare with a known-good host of the same build. Security agents and BPF-based tools add lines of their own; BPF trampolines show as D.
  • With kernel lockdown in confidentiality mode, the kernel restricts "use of tracefs" and "use of kprobes" (security.c), so these files may be unreadable. Integrity mode does not restrict them.
  • Do not try to disarm hooks by writing 0 to ftrace_enabled: KoviD undoes the write and then reports the value you wrote.
  • At run time, Tracee's ftrace_hook event reports the hooked symbol, the callback and its owning module.

Memory. Capture memory before anything else. Volatility 3's linux.tracing.ftrace investigates "the ftrace infrastructure to uncover kernel attached callbacks", and linux.malware.hidden_modules finds the module that owns them. See memory forensics on Linux Forensics.

Offline, from an image.

R=/mnt/evidence
nm -u /path/to/suspect.ko | grep -E 'register_ftrace_function|ftrace_set_filter|register_kprobe|register_kretprobe|kallsyms'
strings -a /path/to/suspect.ko | grep -xE 'kallsyms_lookup_name|filldir(64)?|__x64_sys_[a-z0-9_]+'
zgrep -hE 'taint|module verification' "$R"/var/log/kern.log* "$R"/var/log/messages* 2>/dev/null

A module that imports the ftrace calls and names system call handlers or filldir is worth analysis, whatever its name. Checking Linux kernel modules offline explains the other checks.

What the checker looks for

The linuxkernel module reads module files under lib/modules/ and raises:

  • "Redirects kernel functions with ftrace" when a module imports register_ftrace_function together with ftrace_set_filter_ip or ftrace_set_filter. Tracers and live patch modules import them too, so read it with the module's other findings.
  • "Resolves unexported kernel symbols" for register_kprobe with the string kallsyms_lookup_name (the lookup above), or for a direct import of kallsyms_lookup_name on kernels before 5.7. The legitimate tracer LTTng does the same.
  • "Names kernel functions that rootkits hook" for names such as filldir64 or __x64_sys_getdents64, rated high when one of the findings above also fired. register_kprobe and register_kretprobe imports are listed as context.

Module signature, package ownership, boot configuration and taint log findings apply as for any module.

It cannot see the hooks themselves: enabled_functions, touched_functions and kprobes/list are not in the collect script's _live/ outputs, and callbacks exist only in memory. KoviD's hiding from /sys/module and its taint reset also defeat the live comparisons.

Mitigation and recovery

  • Stop the module from loading. Enforce module signatures (module.sig_enforce=1, or lockdown), set kernel.modules_disabled=1 after boot where possible, and audit init_module and finit_module (Elastic, 2026).
  • Baseline the tracing state. Record enabled_functions on known-good hosts of each build, so that a new I line stands out.
  • Prefer memory to live tools when a hook is suspected.

Recovery. Capture memory, then image the disk. Unregistering callbacks or unloading the module in place proves nothing about what else the rootkit changed. Rebuild from known-good media, find what reloads the module (KoviD suggests infecting a binary such as sshd), and rotate credentials.

Sources

Primary public reports, newest first.

  1. 2026-04-02Hooked on Linux: Rootkit Detection EngineeringElastic Security Labs
  2. 2026-03-05Hooked on Linux: Rootkit Taxonomy, Hooking Techniques and TradecraftElastic Security Labs
  3. 2024-12-12Declawing PUMAKITElastic Security Labs
  4. 2023-01-24ftrace: Show a list of all functions that have ever been enabledLinux kernel (git.kernel.org)
  5. 2022-04-01KoviD source repositoryGitHub
  6. 2020-02-28Unexporting kallsyms_lookup_name()LWN.net

See also

Families that use it