From 175f07cd2fdf864c8decbbafc1d96fc6ecca75bf Mon Sep 17 00:00:00 2001 From: Bananymous Date: Tue, 25 Apr 2023 13:21:28 +0300 Subject: [PATCH] Kernel: Fix bug in Process::create_userspace() We used to write more than we needed to. This could lead to unwanted page faults --- kernel/kernel/Process.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/kernel/Process.cpp b/kernel/kernel/Process.cpp index bcdc4d34..7ff22490 100644 --- a/kernel/kernel/Process.cpp +++ b/kernel/kernel/Process.cpp @@ -83,7 +83,7 @@ namespace Kernel } process->m_mmu->load(); memcpy((void*)elf_program_header.p_vaddr, elf->data() + elf_program_header.p_offset, elf_program_header.p_filesz); - memset((void*)(elf_program_header.p_vaddr + elf_program_header.p_filesz), 0, elf_program_header.p_memsz); + memset((void*)(elf_program_header.p_vaddr + elf_program_header.p_filesz), 0, elf_program_header.p_memsz - elf_program_header.p_filesz); Process::current().mmu().load(); break; }