1.2 KiB
1.2 KiB
Syscall Counter Linux Kernel Module
This kernel module counts all executed syscalls using the sys_enter tracepoint provided by the kernel. The data is accessible via a debugfs file, or via the included shell script for a live terminal view.
enabled parameter
Counting can be paused by setting the module's enabled parameter to 0.
Usage
Make sure you're running a modern kernel version (4.x+, tested on 7.0.9) on an x86_64 system with mounted debugfs
- Clone the repo
- Install the kernel headers using your package manager
- Comment out
#define USE_ATOMICSif you'd rather use spinlocks - Run
sudo make installto compile and load the module - Run
sudo make testto view the module's debugfs output via the included Scripts or view raw output at/sys/kernel/debug/syscall_counter - Run
echo 0 | sudo tee /sys/module/syscall_counter/parameters/enabledto pause counting (echo 1to resume)
Scripts
gen_syscall_names.sh— generates a C header containing syscall names with their corresponding IDs, parsed from/usr/include/asm/unistd_64.h(requires kernel headers)print_debugfs.sh— renders a live view of the module's debugfs output usingwatch, sorted by count; must be run as root