From mboxrd@z Thu Jan 1 00:00:00 1970 From: sargun@sargun.me (Sargun Dhillon) Date: Tue, 3 May 2016 17:20:49 -0700 Subject: Kprobes: change the kernel's execution path? Message-ID: To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org 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?