pc: sanity check bda value in lowraminit() to avoid overflow with efi

This commit is contained in:
cinap_lenrek 2014-10-12 20:18:59 +02:00
parent ca694c51ef
commit cc6ab31891

View file

@ -376,7 +376,7 @@ sigsearch(char* signature)
static void static void
lowraminit(void) lowraminit(void)
{ {
ulong n, pa, x; ulong pa, x;
uchar *bda; uchar *bda;
/* /*
@ -387,9 +387,11 @@ lowraminit(void)
*/ */
x = PADDR(CPU0END); x = PADDR(CPU0END);
bda = (uchar*)KADDR(0x400); bda = (uchar*)KADDR(0x400);
n = ((bda[0x14]<<8)|bda[0x13])*KB-x; pa = ((bda[0x14]<<8)|bda[0x13])*KB;
mapfree(&rmapram, x, n); if(x < pa){
memset(KADDR(x), 0, n); /* keep us honest */ mapfree(&rmapram, x, pa-x);
memset(KADDR(x), 0, pa-x); /* keep us honest */
}
x = PADDR(PGROUND((ulong)end)); x = PADDR(PGROUND((ulong)end));
pa = MemMin; pa = MemMin;