as you may know list of kprobes has mapping on /sys in file /sys/kernel/debug/kprobes/list. And now when I have working filesystem notifications it would be extremely tempting try to make hiding content of this file. Let`s see what this inode contains:
sudo ./lkmem -s -c ~/krnl/curr ~/krnl/System.map-5.11.0-34- generic /sys/kernel/debug/kprobes/list
- set notification for file /sys/kernel/debug/kprobes/list
- in fsnotify_handle_event callback check inode and mask
- if this is first opening of this file - patch kprobes_sops->show to our own function (be cautious with WP in cr0)
- if this is last closing of this file - return original handler to kprobes_sops->show
- also return original handler when driver is unloading