pmm_randomise_memory: Add guard for BIOS port to avoid accessing bogus pointers

This commit is contained in:
mintsuki 2022-01-29 12:29:27 +01:00
parent 3fa7d9d1fa
commit 9fc8ec0ce3
2 changed files with 9 additions and 1 deletions

View File

@ -89,7 +89,7 @@ Some keys take *URIs* as values; these are described in the next section.
* `EDITOR_HIGHLIGHTING` - If set to `no`, syntax highlighting in the editor will be disabled. Defaults to `yes`.
* `EDITOR_VALIDATION` - If set to `no`, the editor will not alert you about invalid keys / syntax errors. Defaults to `yes`.
* `VERBOSE` - If set to `yes`, print additional information during boot. Defaults to not verbose.
* `RANDOMISE_MEMORY` - If set to `yes`, randomise the contents of RAM at bootup in order to find bugs related to non zeroed memory or for security reasons. This option will slow down boot time significantly.
* `RANDOMISE_MEMORY` - If set to `yes`, randomise the contents of RAM at bootup in order to find bugs related to non zeroed memory or for security reasons. This option will slow down boot time significantly. For the BIOS port of Limine, this will only randomise memory below 4GiB.
* `RANDOMIZE_MEMORY` - Alias of `RANDOMISE_MEMORY`.
*Locally assignable (non protocol specific)* keys are:

View File

@ -9,6 +9,14 @@ void pmm_randomise_memory(void) {
if (memmap[i].type != MEMMAP_USABLE)
continue;
#if bios == 1
// We're not going to randomise memory above 4GiB from protected mode,
// are we?
if (memmap[i].base >= 0x100000000) {
continue;
}
#endif
uint8_t *ptr = (void *)(uintptr_t)memmap[i].base;
size_t len = memmap[i].length;