ref: cc6ab3189125beb510a0cda836cce2648b8fede5
parent: ca694c51efbcab0e9dd7421f395cfbb4b573b90e
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Oct 12 16:18:59 EDT 2014
pc: sanity check bda value in lowraminit() to avoid overflow with efi
--- a/sys/src/9/pc/memory.c
+++ b/sys/src/9/pc/memory.c
@@ -376,7 +376,7 @@
static void
lowraminit(void)
{
- ulong n, pa, x;
+ ulong pa, x;
uchar *bda;
/*
@@ -387,9 +387,11 @@
*/
x = PADDR(CPU0END);
bda = (uchar*)KADDR(0x400);
- n = ((bda[0x14]<<8)|bda[0x13])*KB-x;
- mapfree(&rmapram, x, n);
- memset(KADDR(x), 0, n); /* keep us honest */
+ pa = ((bda[0x14]<<8)|bda[0x13])*KB;
+ if(x < pa){
+ mapfree(&rmapram, x, pa-x);
+ memset(KADDR(x), 0, pa-x); /* keep us honest */
+ }
x = PADDR(PGROUND((ulong)end));
pa = MemMin;