How to access kernel memory from user space

Peter Jeremy peterjeremy at optushome.com.au
Wed Dec 24 00:45:20 PST 2008


On 2008-Dec-22 18:05:34 -0600, Gerry Weaver <gerryw at compvia.com> wrote:
>I am working on a driver that collects various network statistics via
>pfil. I have a simple array of structures that I use to store the
>statistics. I also have a user space process that needs to collect
>these statistics every second or so.

The easiest (and hackiest) approach would be to kldsym(2) to locate
the symbol in KVM and then mmap(2) the relevant part of /dev/kmem.
The biggest downside is that the userland process needs to be group
kmem.

The other approach would be for your kernel driver to grow a character
device node and directly support mmap.

-- 
Peter Jeremy
Please excuse any delays as the result of my ISP's inability to implement
an MTA that is either RFC2821-compliant or matches their claimed behaviour.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20081224/d7dc8098/attachment.pgp


More information about the freebsd-hackers mailing list