summaryrefslogtreecommitdiffstats
path: root/sys/vm
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2014-03-21 14:25:09 +0000
committerkib <kib@FreeBSD.org>2014-03-21 14:25:09 +0000
commit24c4e4a548787f93d5d8f8200626286c39412b1e (patch)
tree230ee4a4711fed9e521781011714f203966663ab /sys/vm
parent07e1d8d74fd80d6e9636b82e75fc4795171b3d46 (diff)
downloadFreeBSD-src-24c4e4a548787f93d5d8f8200626286c39412b1e.zip
FreeBSD-src-24c4e4a548787f93d5d8f8200626286c39412b1e.tar.gz
Fix two issues with /dev/mem access on amd64, both causing kernel page
faults. First, for accesses to direct map region should check for the limit by which direct map is instantiated. Second, for accesses to the kernel map, success returned from the kernacc(9) does not guarantee that consequent attempt to read or write to the checked address succeed, since other thread might invalidate the address meantime. Add a new thread private flag TDP_DEVMEMIO, which instructs vm_fault() to return error when fault happens on the MAP_ENTRY_NOFAULT entry, instead of panicing. The trap handler would then see a page fault from access, and recover in normal way, making /dev/mem access safer. Remove GIANT_REQUIRED from the amd64 memrw(), since it is not needed and having Giant locked does not solve issues for amd64. Note that at least the second issue exists on other architectures, and requires similar patching for md code. Reported and tested by: clusteradm (gjb, sbruno) Sponsored by: The FreeBSD Foundation MFC after: 1 week
Diffstat (limited to 'sys/vm')
-rw-r--r--sys/vm/vm_fault.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c
index 4a6495f..ba7692c 100644
--- a/sys/vm/vm_fault.c
+++ b/sys/vm/vm_fault.c
@@ -269,6 +269,10 @@ RetryFault:;
map_generation = fs.map->timestamp;
if (fs.entry->eflags & MAP_ENTRY_NOFAULT) {
+ if ((curthread->td_pflags & TDP_DEVMEMIO) != 0) {
+ vm_map_unlock_read(fs.map);
+ return (KERN_FAILURE);
+ }
panic("vm_fault: fault on nofault entry, addr: %lx",
(u_long)vaddr);
}
OpenPOWER on IntegriCloud