Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Mar 2009 17:05:52 +0100
From:      Alexej Sokolov <bsd.quest@googlemail.com>
To:        freebsd-hackers@freebsd.org
Subject:   write protection by mmap of /dev/mem doesn't work
Message-ID:  <671bb5fc0903100905u7484cd1dp9faefc8bc208a6a6@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
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



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