Date: Tue, 6 May 1997 12:42:49 -0400 (EDT) From: "Peter M. Chen" <pmchen@eecs.umich.edu> To: freebsd-hackers@freebsd.org Subject: vm_map_protect Message-ID: <199705061642.MAA09100@life.eecs.umich.edu>
next in thread | raw e-mail | index | archive | help
I'm trying to make the buffer cache unwritable by using vm_map_protect. (Technically, I'm really making it so the physical pages belonging to the buffer cache cannot be written via the VM address space of the buffer cache). On the surface, this is working ok. Changing a page's protection to (VM_PROT_READ|VM_PROT_EXECUTE) and writing to it causes a protection violation. Changing it back to VM_PROT_ALL and writing to it doesn't cause a protection violation. I did have to change the way the buffer_map was created by taking out the MAP_NOFAULT flag (otherwise changing protections didn't work). Unfortunately, using vm_map_protect eventually corrupts my file systems during boot-up (both / and /var), and I have to then rebuild the file system. If I take out the single vm_map_protect that I added, the system boots fine. vm_map_protect(buffer_map, (vm_offset_t) bp->b_data + i*PAGE_SIZE, (vm_offset_t) bp->b_data + (i+1)*PAGE_SIZE, protect, FALSE); I double-checked the data before and after calling vm_map_protect, and it hasn't changed. vm_map_protect returns KERN_SUCCESS. I could find no instances where the kernel used vm_map_protect to change the protections for kernel space--protections only seem to be changed for a process's address space. And vm/vm_map.h has a cryptic comment in struct vm_map_entry: /* Only in task maps: */ right before the vm_prot_t entries. Does anyone have any insight as to what could be causing the problem? Has anyone changed protections for kernel address space? Pete
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199705061642.MAA09100>