Add a syscall to read process info into buffer.
In order to add a self-defined syscall, here is two ways:
- Insert a module.
- Patch the kernel.
CAUTION: NO SAFETY GUARANTEED
Test it in a Virtual Machine.
|- mycall.h # Macros and Struct Definition
|- mycall.patch # Patch for the kernel
|- mymod.c # Module Implementation
|- myps.c # My version of ps/pstree commands for testing my syscall
Tested on ubuntu 20.04 amd64 (5.15.0-105-generic).
- Make sure headers installed
- Compile
$ make
# or with clangd
$ bear -- make- Insert module
$ sudo insmod mymod.ko MYCALL_NUM=335- Test with my ps/pstree command.
$ ./ps
$ ./pstreeTested with kernel linux-5.15.157.
- Patch (with syscall number 335 in the patch file)
$ cd /usr/src/linux/
$ sudo patch -p1 < mycall.patch- Build the kernel
$ sudo make -j$(nproc)- Install the kernel and reboot
$ sudo make modules_install install
$ reboot- Test with my ps/pstree command.
$ ./ps -n 335
$ ./pstree -n 335