2006-11-16 19:19:51

by Yitzchak Eidus

[permalink] [raw]
Subject: changing internal kernel system mechanism in runtime by a module patch

is it possible to replace linux kernel internal functions such as
schdule () to lets say my_schdule () in a run time with a module
patch???
(so that every call in the kernel to schdule() will go to my_schdule()... ) ???

i am talking about a clean/standard way to do such thing
(without overwrite the mem address of the function and replace it in a
dirty way...)


2006-11-16 19:29:41

by Adrian Bunk

[permalink] [raw]
Subject: Re: changing internal kernel system mechanism in runtime by a module patch

On Thu, Nov 16, 2006 at 09:19:50PM +0200, Yitzchak Eidus wrote:
> is it possible to replace linux kernel internal functions such as
> schdule () to lets say my_schdule () in a run time with a module
> patch???
> (so that every call in the kernel to schdule() will go to my_schdule()... )
> ???
>
> i am talking about a clean/standard way to do such thing
> (without overwrite the mem address of the function and replace it in a
> dirty way...)

No.

cu
Adrian

--

"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed

2006-11-16 21:13:18

by Stephen Hemminger

[permalink] [raw]
Subject: Re: changing internal kernel system mechanism in runtime by a module patch

On Thu, 16 Nov 2006 21:19:50 +0200
"Yitzchak Eidus" <[email protected]> wrote:

> is it possible to replace linux kernel internal functions such as
> schdule () to lets say my_schdule () in a run time with a module
> patch???
> (so that every call in the kernel to schdule() will go to my_schdule()... ) ???
>
> i am talking about a clean/standard way to do such thing
> (without overwrite the mem address of the function and replace it in a
> dirty way...)
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

Look at kprobe/jprobe.

--
Stephen Hemminger <[email protected]>

2006-11-16 21:50:55

by Jan Engelhardt

[permalink] [raw]
Subject: Re: changing internal kernel system mechanism in runtime by a module patch


On Nov 16 2006 20:29, Adrian Bunk wrote:
>On Thu, Nov 16, 2006 at 09:19:50PM +0200, Yitzchak Eidus wrote:
>> is it possible to replace linux kernel internal functions such as
>> schdule () to lets say my_schdule () in a run time with a module
>> patch???

Nothing is impossible.

>> (so that every call in the kernel to schdule() will go to my_schdule()... )
>> ???
>>
>> i am talking about a clean/standard way to do such thing

Not clean. Not standard.
And it sounds evil too.

>> (without overwrite the mem address of the function and replace it in a
>> dirty way...)
>
>No.

You would have to patch _every_ callsite. That's too tedious to be
useful.

(Hey there is SMP alternatives which sounds like it did just that -
anyone?)



-`J'
--

2006-11-17 06:47:36

by Muli Ben-Yehuda

[permalink] [raw]
Subject: Re: changing internal kernel system mechanism in runtime by a module patch

On Thu, Nov 16, 2006 at 09:19:50PM +0200, Yitzchak Eidus wrote:

> is it possible to replace linux kernel internal functions such as
> schdule () to lets say my_schdule () in a run time with a module
> patch??? (so that every call in the kernel to schdule() will go to
> my_schdule()... ) ???

Not in Linux.

> i am talking about a clean/standard way to do such thing
> (without overwrite the mem address of the function and replace it in a
> dirty way...)

k42 supports "dynamic hot-swap" and there's been some work done to
bring it into Linux, see e.g.,
http://ozlabs.org/pipermail/k42-discussion/2006-October/001615.html.

Cheers,
Muli


2006-11-17 06:58:32

by Christoph Hellwig

[permalink] [raw]
Subject: Re: changing internal kernel system mechanism in runtime by a module patch

On Fri, Nov 17, 2006 at 08:47:32AM +0200, Muli Ben-Yehuda wrote:
> > i am talking about a clean/standard way to do such thing
> > (without overwrite the mem address of the function and replace it in a
> > dirty way...)
>
> k42 supports "dynamic hot-swap" and there's been some work done to
> bring it into Linux, see e.g.,
> http://ozlabs.org/pipermail/k42-discussion/2006-October/001615.html.

This kind of stuff is just sick. Better let them play with their research
OS for this kind of thing :) In practice any non-trivial bug fix requires
changes to global data structures so reloading a module doesn't make sense.
And for module-specific problems you should be able to hack around using
kprobes if you really need (but then again for a mission critical system
you should have proper active-active failover clustering anyway)

2006-11-17 07:06:16

by Muli Ben-Yehuda

[permalink] [raw]
Subject: Re: changing internal kernel system mechanism in runtime by a module patch

On Fri, Nov 17, 2006 at 06:58:29AM +0000, Christoph Hellwig wrote:

> This kind of stuff is just sick. Better let them play with their research
> OS for this kind of thing :)

sick, research, what's the difference? :-)

> In practice any non-trivial bug fix requires
> changes to global data structures so reloading a module doesn't make
> sense.

... unless you have a mechanism (which k42 does) to interpose between
data structures and the users of said structures, which you can use to
decide when to repace them.

> And for module-specific problems you should be able to hack around using
> kprobes if you really need (but then again for a mission critical system
> you should have proper active-active failover clustering anyway)

I'm not advocating we merge this - nor have I seen the implementation
for Linux yet - no need to preemptively scorch it from orbit :-)

Cheers,
Muli