linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i386 & x86_64: Live Patching Funcion on 2.6.11.7
@ 2005-04-17  3:47 Takashi Ikebe
  2005-04-17  6:44 ` David S. Miller
  0 siblings, 1 reply; 8+ messages in thread
From: Takashi Ikebe @ 2005-04-17  3:47 UTC (permalink / raw)
  To: linux-kernel

Hello,
This patch add function called "Live patching" which is defined on
OSDL's carrier grade linux requiremnt definition to linux 2.6.11.7 kernel.
The live patching allows process to patch on-line (without restarting
process) on i386 and x86_64 architectures, by overwriting jump assembly
code on entry point of functions which you want to fix, to patched
functions.
The live patching function is very common on high-availability system
such as carrier system, and this patch realize it also on linux.
(Patch & process restart time is very critical on such high-availability
system, live patch allows you to milliseconds order process stopping
time to apply new patch.)

The basis is below:
1. Live patch command loads the patch modules to target process's memory
area,
2. Live patch command resolve patch symbol.
3. Live patch command overwrite jump code to the entry point of function
which you want to fix, to the patch module's symbol.

Kernel patch and user mode tools are required, and both of them are
available at http://pannus.sourceforge.net
Please take a look and give us comments!

This patch add following system calls and function.
o mmap3: maps patch to target process's memory area with security check.
o accesspvm: access(read/write) target process's memory area.
o init_pend: initialization of live patch sequence on target process.
o rt_handlereturn: run initialize root of each patch (same as signal
handler).
o check_init: check that the initialization is finished or not.
o munmap3: unmap patch from target process's memory area.


---
Takashi Ikebe
NTT Network Service Systems Laboratories
9-11, Midori-Cho 3-Chome Musashino-Shi,
Tokyo 180-8585 Japan
Tel : +81 422 59 4246, Fax : +81 422 60 4012
e-mail : ikebe.takashi@lab.ntt.co.jp



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] i386 & x86_64: Live Patching Funcion on 2.6.11.7
  2005-04-17  3:47 [PATCH] i386 & x86_64: Live Patching Funcion on 2.6.11.7 Takashi Ikebe
@ 2005-04-17  6:44 ` David S. Miller
  2005-04-17 18:51   ` Daniel Jacobowitz
  2005-04-23 16:10   ` Andi Kleen
  0 siblings, 2 replies; 8+ messages in thread
From: David S. Miller @ 2005-04-17  6:44 UTC (permalink / raw)
  To: Takashi Ikebe; +Cc: linux-kernel


Takashi-san, have you ever investigated using kprobes to
implement this feature?  It seems a perfect fit, and would
allow support on several architectures other than just x86
and x86_64.

If kprobes does not meet your needs completely, it could
be trivially extended to do so.

I think implementing something like this from scratch is
not a good idea when we have much of the needed logic and
infrastructure already.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] i386 & x86_64: Live Patching Funcion on 2.6.11.7
  2005-04-17  6:44 ` David S. Miller
@ 2005-04-17 18:51   ` Daniel Jacobowitz
  2005-04-17 20:32     ` David S. Miller
  2005-04-23 16:10   ` Andi Kleen
  1 sibling, 1 reply; 8+ messages in thread
From: Daniel Jacobowitz @ 2005-04-17 18:51 UTC (permalink / raw)
  To: David S. Miller; +Cc: Takashi Ikebe, linux-kernel

On Sat, Apr 16, 2005 at 11:44:39PM -0700, David S. Miller wrote:
> 
> Takashi-san, have you ever investigated using kprobes to
> implement this feature?  It seems a perfect fit, and would
> allow support on several architectures other than just x86
> and x86_64.
> 
> If kprobes does not meet your needs completely, it could
> be trivially extended to do so.
> 
> I think implementing something like this from scratch is
> not a good idea when we have much of the needed logic and
> infrastructure already.

Takashi-san's description was not very clear, but it sounds like it's a
patching mechanism for userspace applications - not for kernel space.
So kprobes would not be a good fit.

If I'm right, I'm not sure why some of the bits of it were done
separately instead of via the existing ptrace mechanism.  And GDB
would appreciate a mechanism for mmap/munmap/mprotect in a debugged
process, also.

-- 
Daniel Jacobowitz
CodeSourcery, LLC

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] i386 & x86_64: Live Patching Funcion on 2.6.11.7
  2005-04-17 18:51   ` Daniel Jacobowitz
@ 2005-04-17 20:32     ` David S. Miller
  2005-04-18  1:41       ` Takashi Ikebe
  0 siblings, 1 reply; 8+ messages in thread
From: David S. Miller @ 2005-04-17 20:32 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: ikebe.takashi, linux-kernel

On Sun, 17 Apr 2005 14:51:43 -0400
Daniel Jacobowitz <dan@debian.org> wrote:

> Takashi-san's description was not very clear, but it sounds like it's a
> patching mechanism for userspace applications - not for kernel space.
> So kprobes would not be a good fit.

I saw the presentation of this stuff at the Linux Kernel conference
last year in Tokyo.  I'm pretty sure it's for the kernel. :-)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] i386 & x86_64: Live Patching Funcion on 2.6.11.7
  2005-04-17 20:32     ` David S. Miller
@ 2005-04-18  1:41       ` Takashi Ikebe
  2005-04-18  4:41         ` Daniel Jacobowitz
  0 siblings, 1 reply; 8+ messages in thread
From: Takashi Ikebe @ 2005-04-18  1:41 UTC (permalink / raw)
  To: David S. Miller, Daniel Jacobowitz; +Cc: linux-kernel

Daniel-san, David-san,

Pannus project has two targets.
One is user-mode application live patching, and the other one is kernel 
live patching.
What we posted now is user-mode application live patching function.

 >If I'm right, I'm not sure why some of the bits of it were done
 >separately instead of via the existing ptrace mechanism.  And GDB
 >would appreciate a mechanism for mmap/munmap/mprotect in a debugged
 >process, also.

Daniel-san,
GDB based approach seems not fit to our requirements. GDB(ptrace) based 
functions are basically need to be done when target process is stopping. 
 From our experience, sometimes patches became to dozens to hundreds at 
one patching, and in this case GDB based approach cause target process's 
availability descent.

Patch exceeds 50k, so I cut comments and separate architecture, and post 
as in line.

David S. Miller wrote:
> On Sun, 17 Apr 2005 14:51:43 -0400
> Daniel Jacobowitz <dan@debian.org> wrote:
> 
> 
>>Takashi-san's description was not very clear, but it sounds like it's a
>>patching mechanism for userspace applications - not for kernel space.
>>So kprobes would not be a good fit.
> 
> 
> I saw the presentation of this stuff at the Linux Kernel conference
> last year in Tokyo.  I'm pretty sure it's for the kernel. :-)
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

-- 
Takashi Ikebe
NTT Network Service Systems Laboratories
9-11, Midori-Cho 3-Chome Musashino-Shi,
Tokyo 180-8585 Japan
Tel : +81 422 59 4246, Fax : +81 422 60 4012
e-mail : ikebe.takashi@lab.ntt.co.jp

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] i386 & x86_64: Live Patching Funcion on 2.6.11.7
  2005-04-18  1:41       ` Takashi Ikebe
@ 2005-04-18  4:41         ` Daniel Jacobowitz
  2005-04-18  5:20           ` Takashi Ikebe
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel Jacobowitz @ 2005-04-18  4:41 UTC (permalink / raw)
  To: Takashi Ikebe; +Cc: David S. Miller, linux-kernel

On Mon, Apr 18, 2005 at 10:41:23AM +0900, Takashi Ikebe wrote:
> Daniel-san,
> GDB based approach seems not fit to our requirements. GDB(ptrace) based 
> functions are basically need to be done when target process is stopping. 
> From our experience, sometimes patches became to dozens to hundreds at 
> one patching, and in this case GDB based approach cause target process's 
> availability descent.

That's right, it does require the target process be stopped.  If it
isn't stopped how do you know it isn't executing the same instruction
you're currently patching?

Even with hundreds of kilobytes of patch, I have trouble imagining this
takes a substantial amount of time.

-- 
Daniel Jacobowitz
CodeSourcery, LLC

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] i386 & x86_64: Live Patching Funcion on 2.6.11.7
  2005-04-18  4:41         ` Daniel Jacobowitz
@ 2005-04-18  5:20           ` Takashi Ikebe
  0 siblings, 0 replies; 8+ messages in thread
From: Takashi Ikebe @ 2005-04-18  5:20 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: David S. Miller, linux-kernel

Daniel Jacobowitz wrote:

>On Mon, Apr 18, 2005 at 10:41:23AM +0900, Takashi Ikebe wrote:
>  
>
>>Daniel-san,
>>GDB based approach seems not fit to our requirements. GDB(ptrace) based 
>>functions are basically need to be done when target process is stopping. 
>>From our experience, sometimes patches became to dozens to hundreds at 
>>one patching, and in this case GDB based approach cause target process's 
>>availability descent.
>>    
>>
>
>That's right, it does require the target process be stopped.  If it
>isn't stopped how do you know it isn't executing the same instruction
>you're currently patching?
>
>Even with hundreds of kilobytes of patch, I have trouble imagining this
>takes a substantial amount of time.
>  
>
Pannus patch does not require target process stop while loading(mapping)
patch module to target process memory,
but as you described, target process stopping is needed whenever check
EIP not to conflict, and overwrite jump assembly code.(This makes only
few milliseconds target process stopping. Even on hundreds, it only
takes dozens mill-seconds yet.)
Typically telecoms application needs soft real time, and has timeout.
This kind of framework can not stop target process so long(Should be
dozens milliseconds at worst).
We want not to stop target process whenever patch module is loading....
we want not to stop target process as possible as.

-- 
Takashi Ikebe
NTT Network Service Systems Laboratories
9-11, Midori-Cho 3-Chome Musashino-Shi,
Tokyo 180-8585 Japan
Tel : +81 422 59 4246, Fax : +81 422 60 4012
e-mail : ikebe.takashi@lab.ntt.co.jp



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] i386 & x86_64: Live Patching Funcion on 2.6.11.7
  2005-04-17  6:44 ` David S. Miller
  2005-04-17 18:51   ` Daniel Jacobowitz
@ 2005-04-23 16:10   ` Andi Kleen
  1 sibling, 0 replies; 8+ messages in thread
From: Andi Kleen @ 2005-04-23 16:10 UTC (permalink / raw)
  To: David S. Miller; +Cc: linux-kernel, Takashi Ikebe

"David S. Miller" <davem@davemloft.net> writes:

> Takashi-san, have you ever investigated using kprobes to
> implement this feature?  It seems a perfect fit, and would
> allow support on several architectures other than just x86
> and x86_64.
>
> If kprobes does not meet your needs completely, it could
> be trivially extended to do so.

kprobes would require an exception for each patchpoint because
it uses an trap instruction. 

Probably a bit too costly for commonly used functions. Especially
on a P4 exceptions are quite costly. 

But you could add lightweight kprobes that just use jmp 
for it in the kprobes  framework, that might be useful for other stuff too

-Andi

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-04-23 16:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-17  3:47 [PATCH] i386 & x86_64: Live Patching Funcion on 2.6.11.7 Takashi Ikebe
2005-04-17  6:44 ` David S. Miller
2005-04-17 18:51   ` Daniel Jacobowitz
2005-04-17 20:32     ` David S. Miller
2005-04-18  1:41       ` Takashi Ikebe
2005-04-18  4:41         ` Daniel Jacobowitz
2005-04-18  5:20           ` Takashi Ikebe
2005-04-23 16:10   ` Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).