Page MenuHomeFreeBSD

D31208.id96295.diff
No OneTemporary

D31208.id96295.diff

Index: sys/riscv/include/vmparam.h
===================================================================
--- sys/riscv/include/vmparam.h
+++ sys/riscv/include/vmparam.h
@@ -186,6 +186,10 @@
#define VM_MINUSER_ADDRESS (VM_MIN_USER_ADDRESS)
#define VM_MAXUSER_ADDRESS (VM_MAX_USER_ADDRESS)
+/* Check if an address resides in a mappable region. */
+#define VIRT_IS_VALID(va) \
+ (((va) < VM_MAX_USER_ADDRESS) || ((va) >= VM_MIN_KERNEL_ADDRESS))
+
#define KERNBASE (VM_MIN_KERNEL_ADDRESS)
#define SHAREDPAGE (VM_MAXUSER_ADDRESS - PAGE_SIZE)
#define USRSTACK SHAREDPAGE
Index: sys/riscv/riscv/pmap.c
===================================================================
--- sys/riscv/riscv/pmap.c
+++ sys/riscv/riscv/pmap.c
@@ -349,6 +349,8 @@
pmap_l1(pmap_t pmap, vm_offset_t va)
{
+ KASSERT(VIRT_IS_VALID(va),
+ ("%s: malformed virtual address %lx\n", __func__, va));
return (&pmap->pm_l1[pmap_l1_index(va)]);
}
Index: sys/riscv/riscv/trap.c
===================================================================
--- sys/riscv/riscv/trap.c
+++ sys/riscv/riscv/trap.c
@@ -208,6 +208,9 @@
*/
intr_enable();
+ if (!VIRT_IS_VALID(stval))
+ goto fatal;
+
if (stval >= VM_MAX_USER_ADDRESS) {
map = kernel_map;
} else {

File Metadata

Mime Type
text/plain
Expires
Mon, Feb 9, 2:18 PM (3 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28588055
Default Alt Text
D31208.id96295.diff (1 KB)

Event Timeline