summaryrefslogtreecommitdiffstats
path: root/sys/arm64
diff options
context:
space:
mode:
authorandrew <andrew@FreeBSD.org>2016-02-02 17:57:15 +0000
committerandrew <andrew@FreeBSD.org>2016-02-02 17:57:15 +0000
commit700dcbc1a2bc36e3a116192b615faf238f4e6e72 (patch)
treeca7972585a5bf54ac518a143129cc98159b4ddb5 /sys/arm64
parent7c81e8b6526c1c0b426d113b839b2f72ef058929 (diff)
downloadFreeBSD-src-700dcbc1a2bc36e3a116192b615faf238f4e6e72.zip
FreeBSD-src-700dcbc1a2bc36e3a116192b615faf238f4e6e72.tar.gz
Ensure we don't overflow the phys_avail array. Some firmware may provide
more memory locations than we have space to record. Sponsored by: ABT Systems Ltd
Diffstat (limited to 'sys/arm64')
-rw-r--r--sys/arm64/arm64/pmap.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c
index dcd6e5d..37b9480 100644
--- a/sys/arm64/arm64/pmap.c
+++ b/sys/arm64/arm64/pmap.c
@@ -596,7 +596,8 @@ pmap_bootstrap(vm_offset_t l1pt, vm_paddr_t kernstart, vm_size_t kernlen)
* up to the physical address KERNBASE points at.
*/
map_slot = avail_slot = 0;
- for (; map_slot < (physmap_idx * 2); map_slot += 2) {
+ for (; map_slot < (physmap_idx * 2) &&
+ avail_slot < (PHYS_AVAIL_SIZE - 2); map_slot += 2) {
if (physmap[map_slot] == physmap[map_slot + 1])
continue;
@@ -612,7 +613,7 @@ pmap_bootstrap(vm_offset_t l1pt, vm_paddr_t kernstart, vm_size_t kernlen)
}
/* Add the memory before the kernel */
- if (physmap[avail_slot] < pa) {
+ if (physmap[avail_slot] < pa && avail_slot < (PHYS_AVAIL_SIZE - 2)) {
phys_avail[avail_slot] = physmap[map_slot];
phys_avail[avail_slot + 1] = pa;
physmem += (phys_avail[avail_slot + 1] -
OpenPOWER on IntegriCloud