Subject: [ Re: can I run things in kernel space?]
To: None <macbsd-development@NetBSD.ORG>
From: Daniel Risacher <>
List: macbsd-development
Date: 05/05/1995 14:59:38
I played with mmap(), /dev/mem, and /dev/kmem some,
and now I have some questions...  this is what I was trying:

  if (setgid(2)!=0) printf("setgid failed!\n");  
	/* this works */

  mem = open("/dev/mem",O_RDWR,0);
	/* I can only open /dev/mem or /dev/kmem O_RDONLY ! */
	/* even though it is crw-rw-rw- ! */

  foo = mmap(0,0x2000,PROT_READ,MAP_FILE|MAP_SHARED,mem,VIA1);
	/* this fails with errno = EINVAL */

Can someone clueful point out my mistakes? I tried a bunch of
variations on these themes.

-Dan Risacher

>Return-Path: <>
>Date: Thu, 4 May 1995 16:20:53 -0700
>From: Ben Cottrell <>
>Subject: Re:  can I run things in kernel space?
>As I understand it, Dan, you can open and mmap /dev/kmem (just
>be sure to chgrp your program kmem and set the sgid bit or otherwise
>allow your program access to that file) and access kernel memory
>that way. This is, I believe, how ps works. Do be careful, however,
>if you plan to *write* to the kernel's memory; you have no idea
>where context switches are happening, and you could end up accessing
>the same bit of memory as the kernel.
>Good luck!
>	-Ben