Fwd: write protection by mmap of /dev/mem doesn't work
Alexej Sokolov
bsd.quest at googlemail.com
Tue Mar 10 09:32:45 PDT 2009
Sorry,
it was my mistake !
seg fault was by reading of data. To do this should PROT_READ|PROT_WRITE be
setted.
Now it works!
Alexej
---------- Forwarded message ----------
From: Alexej Sokolov <bsd.quest at googlemail.com>
Date: 2009/3/10
Subject: write protection by mmap of /dev/mem doesn't work
To: freebsd-hackers at freebsd.org
hello,
How can I mmap some memory regions with PROT_WRITE protection flag ?
What i do:
/* Open mem device */
if ((devmem_fd = open("/dev/mem", O_RDWR)) == -1){
perror("/dev/mem");
exit (1);
}
then if I try to mmap some memory region with PROT_READ it goes Ok. But by
PROT_WRITE it doesn't work:
sp = mmap ( 0,
MCLBYTES, /* Size of remapped buffer = size of
mbuf cluster */
PROT_WRITE,
MAP_SHARED,
devmem_fd,
phys_addr /* Physical addres of packet buffer
from descriptor */
);
I get by PROT_WRITE " segmentation fault"
What is the problem here ?
And question again:
How can I do it possible to remapp the kernel memory region to user space
process through /dev/mem and give to this user process write permissions to
remmaped space ?
Thanx
More information about the freebsd-hackers
mailing list