svn commit: r225943 - in head/sys: amd64/amd64 i386/i386
Konstantin Belousov
kib at FreeBSD.org
Mon Oct 3 17:01:32 UTC 2011
Author: kib
Date: Mon Oct 3 17:01:31 2011
New Revision: 225943
URL: http://svn.freebsd.org/changeset/base/225943
Log:
Do not allow the kernel to access usermode pages without installed
fault handler. Panic immediately in such situation, on i386 and amd64.
Reviewed by: avg, jhb
MFC after: 1 week
Modified:
head/sys/amd64/amd64/trap.c
head/sys/i386/i386/trap.c
Modified: head/sys/amd64/amd64/trap.c
==============================================================================
--- head/sys/amd64/amd64/trap.c Mon Oct 3 16:58:58 2011 (r225942)
+++ head/sys/amd64/amd64/trap.c Mon Oct 3 17:01:31 2011 (r225943)
@@ -674,6 +674,19 @@ trap_pfault(frame, usermode)
goto nogo;
map = &vm->vm_map;
+
+ /*
+ * When accessing a usermode address, kernel must be
+ * ready to accept the page fault, and provide a
+ * handling routine. Since accessing the address
+ * without the handler is a bug, do not try to handle
+ * it normally, and panic immediately.
+ */
+ if (!usermode && (td->td_intr_nesting_level != 0 ||
+ PCPU_GET(curpcb)->pcb_onfault == NULL)) {
+ trap_fatal(frame, eva);
+ return (-1);
+ }
}
/*
Modified: head/sys/i386/i386/trap.c
==============================================================================
--- head/sys/i386/i386/trap.c Mon Oct 3 16:58:58 2011 (r225942)
+++ head/sys/i386/i386/trap.c Mon Oct 3 17:01:31 2011 (r225943)
@@ -831,6 +831,11 @@ trap_pfault(frame, usermode, eva)
goto nogo;
map = &vm->vm_map;
+ if (!usermode && (td->td_intr_nesting_level != 0 ||
+ PCPU_GET(curpcb)->pcb_onfault == NULL)) {
+ trap_fatal(frame, eva);
+ return (-1);
+ }
}
/*
More information about the svn-src-head
mailing list