linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* LKM function call on kernel function call?
@ 2005-07-05  8:23 S
  2005-07-05  8:38 ` Arjan van de Ven
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: S @ 2005-07-05  8:23 UTC (permalink / raw)
  To: linux-kernel, linux prg

Is it possible to code a loadable module having function1(), which
would be called, everytime a particular function of the kernel is
called? If not, atleast a way this could be done without re-compiling
the whole kernel and rebooting the system?

Example:

My LKM:
-------------

init_module() {
...
}

function1() {
...
}

cleanup_module() {
...
}


I want function1() to be called, everytime the function
ide_do_rw_disk() of ide-disk.c is called. I do not want to re-compile
the complete kernel to do this.

Thanks in advance,

Regards,
S

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

* Re: LKM function call on kernel function call?
  2005-07-05  8:23 LKM function call on kernel function call? S
@ 2005-07-05  8:38 ` Arjan van de Ven
  2005-07-05  8:38 ` Frederik Deweerdt
  2005-07-14 16:59 ` Daniel Bonekeeper
  2 siblings, 0 replies; 4+ messages in thread
From: Arjan van de Ven @ 2005-07-05  8:38 UTC (permalink / raw)
  To: S; +Cc: linux-kernel, linux prg

On Tue, 2005-07-05 at 16:23 +0800, S wrote:
> Is it possible to code a loadable module having function1(), which
> would be called, everytime a particular function of the kernel is
> called? If not, atleast a way this could be done without re-compiling
> the whole kernel and rebooting the system?

why don't you want to compile the whole kernel ? You have the source
code and it for sure is the easiest way to add this (debug?) hack...



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

* Re: LKM function call on kernel function call?
  2005-07-05  8:23 LKM function call on kernel function call? S
  2005-07-05  8:38 ` Arjan van de Ven
@ 2005-07-05  8:38 ` Frederik Deweerdt
  2005-07-14 16:59 ` Daniel Bonekeeper
  2 siblings, 0 replies; 4+ messages in thread
From: Frederik Deweerdt @ 2005-07-05  8:38 UTC (permalink / raw)
  To: S; +Cc: linux-kernel, linux prg

Le 05/07/05 16:23 +0800, S écrivit:
> I want function1() to be called, everytime the function
> ide_do_rw_disk() of ide-disk.c is called. I do not want to re-compile
> the complete kernel to do this.
> 
You're looking for kprobes 
http://www-106.ibm.com/developerworks/library/l-kprobes.html?ca=dgr-lnxw07Kprobe
Regards,
Frederik Deweerdt
-- 
o---------------------------------------------o
| http://open-news.net : l'info alternative   |
| Tech - Sciences - Politique - International |
o---------------------------------------------o
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: LKM function call on kernel function call?
  2005-07-05  8:23 LKM function call on kernel function call? S
  2005-07-05  8:38 ` Arjan van de Ven
  2005-07-05  8:38 ` Frederik Deweerdt
@ 2005-07-14 16:59 ` Daniel Bonekeeper
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Bonekeeper @ 2005-07-14 16:59 UTC (permalink / raw)
  To: S; +Cc: linux-kernel, linux prg

You can also look about some methods of "function redirection
hooks"... add some opcodes at the start of the "hooked function"
(something like to add a CALL or JMP pointing to the address of your
function). There are docs about this subject, but unfortunately I
couldn't find anything now (http://www.ouah.org/p59-0x08.txt is not
exactly what I'm talking about, it's talking about ELF redirection).
It's a dirty thing to do, and it's not intended to be done in any
production thing (in fact, it's a *hack*).

On 7/5/05, S <talk2sumit@gmail.com> wrote:
> Is it possible to code a loadable module having function1(), which
> would be called, everytime a particular function of the kernel is
> called? If not, atleast a way this could be done without re-compiling
> the whole kernel and rebooting the system?
> 
> Example:
> 
> My LKM:
> -------------
> 
> init_module() {
> ...
> }
> 
> function1() {
> ...
> }
> 
> cleanup_module() {
> ...
> }
> 
> 
> I want function1() to be called, everytime the function
> ide_do_rw_disk() of ide-disk.c is called. I do not want to re-compile
> the complete kernel to do this.
> 
> Thanks in advance,
> 
> Regards,
> S
> -
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


-- 
# (perl -e "while (1) { print "\x90"; }") | dd of=/dev/evil

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

end of thread, other threads:[~2005-07-14 16:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-05  8:23 LKM function call on kernel function call? S
2005-07-05  8:38 ` Arjan van de Ven
2005-07-05  8:38 ` Frederik Deweerdt
2005-07-14 16:59 ` Daniel Bonekeeper

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).