Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Sep 2001 05:50:50 -0700
From:      Terry Lambert <tlambert2@mindspring.com>
To:        Sansonetti Laurent <lorenzo@linuxbe.org>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: storing routine code in kernel memory using kvm interface
Message-ID:  <3BA34EAA.38878044@mindspring.com>
References:  <001501c13de3$45dd8320$0201a8c0@teledisnet.be>

next in thread | previous in thread | raw e-mail | index | archive | help
Sansonetti Laurent wrote:
> 
> Hi,
> 
> Is there a way to store a function in kernel memory using KVM interface ?
> 
> I have written a tty spy'er, which simply hijack discipline line entries for
> a tty, and as you know probably, those routines must be situated in kernel
> land.
> 
> I know that I should use KLD for that, but i'm still curious..

No.  You can not allocate memory safely to prevent the kernel
reusing it and stomping your code, and you can not guarantee
your hook installation will be done atomically without getting
context switched or interrupted via a hardware interrupt, thus
panic'ing the kernel.  Not to mention that you would have to
know a huge amount about the VM system to establish mappings,
and those mappings wouldn't be atomic, either, and without them,
your kernel would panic with a "page not present".

Use a KLD instead, unless this is a cracking tool, in which case
go ahead and use /dev/kmem, if it's writeable, since repeated
crashes with tracebacks pointing to a program using your uid
and having /dev/kmem open will get your admin to you-proof his
box.  8-).

-- Terry

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3BA34EAA.38878044>