Skip to content
Advertisement

Can I block a new process execution using Kprobe?

Kprobe has a pre-handler function vaguely documented as followed:

JavaScript

I was wondering if one can use this function (or any other Kprobe feature) to prevent a process from being executed forked.

Advertisement

Answer

As documented in the kernel documentation, you can change the execution path by changing the appropriate register (e.g., IP register in x86):

JavaScript

So you might be able to block a process’ execution by jumping over some code. I wouldn’t recommend it; you’re more likely to cause a kernel crash than to succeed in stopping the execution of a new process.

seccomp-bpf is probably better suited for your use case. This StackOverflow answer gives you all the information you need to leverage seccomp-bpf.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement