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

next in thread | previous in thread | raw e-mail | index | archive | help
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@googlemail.com>
Date: 2009/3/10
Subject: write protection by mmap of /dev/mem doesn't work
To: freebsd-hackers@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



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