Kprobes: change the kernel's execution path?

Sargun Dhillon sargun at sargun.me
Tue May 3 20:20:49 EDT 2016


I'm attempting to change the behaviour of the
inet_get_local_port_range function in the kernel, I've created a
kprobe that sets regs->ip = (unsigned
long)&inet_get_local_port_range_handler_fake in the pre_handler, and
returns 1. I've specified a post_handler to avoid kprobe optimization.

Unfortunately, I get a fault immediately after this. I saw in an
earlier mailing list post
(http://lkml.iu.edu/hypermail/linux/kernel/1310.2/02545.html)
suggesting to call reset_current_kprobe(), and
preempt_enable_no_resched(). Unfortunately these are not exported to
my module. Is there any other way to detour the kernel execution path?



More information about the Kernelnewbies mailing list