From 44e18bb63daa932ed844591de4d2dbb3777d63f7 Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Wed, 1 May 2024 18:27:52 +0200 Subject: Bug: Kernel/MMU: Initialize memory after allocation The memory not being zeroed caused certain flags to be set(presumably no-cache flag) and resulted in the OS being unusually for only certain operations and only in certain cases. --- kernel/arch/i386/mmu.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'kernel/arch') diff --git a/kernel/arch/i386/mmu.c b/kernel/arch/i386/mmu.c index bf0d514..9802142 100644 --- a/kernel/arch/i386/mmu.c +++ b/kernel/arch/i386/mmu.c @@ -70,6 +70,7 @@ void *ksbrk(size_t s) { (data_end - (uintptr_t)rc))) { return (void *)-1; } + get_fast_insecure_random(rc, s); assert(((uintptr_t)rc % PAGE_SIZE) == 0); return (void *)rc; } @@ -182,6 +183,7 @@ PageTable *clone_table(u32 src_index, PageDirectory *src_directory, u32 *physical_address) { PageTable *new_table = kmalloc_align(sizeof(PageTable), (void **)physical_address); + memset(new_table, 0, sizeof(PageTable)); if (!new_table) { return NULL; } @@ -251,6 +253,7 @@ PageDirectory *clone_directory(PageDirectory *original) { u32 physical_address; PageDirectory *new_directory = kmalloc_align(sizeof(PageDirectory), (void **)&physical_address); + memset(new_directory, 0, sizeof(PageDirectory)); if (!new_directory) { return NULL; } -- cgit v1.2.3