Re: LKPK (Live Kernel Patching Kit)

Alexander Kjeldaas (astor@guardian.no)
Sun, 26 Jul 1998 19:49:40 +0200


On Sat, Jul 25, 1998 at 03:52:14PM -0400, Adam Sulmicki wrote:
>
>
> However, while I'm trying to write patch to the SIGIO bug,
> I came acorss an problem.
>
> I can assign specific address to ptrs to variable. However, HOW
> can I make _variable_ to be at given address?
>
> Same with function, I can make ptr to specific function and
> I can assig it specific address. But, HOW can I declare
> function and make it start at specific adreess?
>
> Anyone?
>

What you can do is instead of trying to replace the kernel with a new
kernel, you can add a fixed function to the kernel while retaining the
old function. For code-changes I can imagine you could do something
like the following:

You have one running kernel and a set of patches to that kernel. Each
patch is defined as a code-segment with one entry-point and a set of
entry-points in the kernel that should be replaced by the entry-point
in the patch. You pack each patch into a separate kernel-module, and
when loaded, they overwrite the first instruction of each of the
defined entry-points in the kernel with a jump-instruction to the
entry-point in the module. On unload, you write back the saved
contents of the first instructions of the entry-points in the
kernel.

You won't have any trouble with pointers to functions and in many
(most?) cases, patching the kernel can be done with _one_ atomic write
operation which makes it unnecessary to "take down" the kernel at all.

astor

-- 
 Alexander Kjeldaas, Guardian Networks AS, Trondheim, Norway
 http://www.guardian.no/

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html