From 6ef153b6ca0180dcbba57ad4d2b62c37d4f4273e Mon Sep 17 00:00:00 2001 From: Bananymous Date: Mon, 30 Oct 2023 12:23:22 +0200 Subject: [PATCH] Kernel: Enable Write Protect. This seems to be good for security --- kernel/arch/x86_64/PageTable.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/arch/x86_64/PageTable.cpp b/kernel/arch/x86_64/PageTable.cpp index ef0db19fbb..861522a065 100644 --- a/kernel/arch/x86_64/PageTable.cpp +++ b/kernel/arch/x86_64/PageTable.cpp @@ -92,6 +92,13 @@ namespace Kernel s_has_pge = true; } + // enable write protect to kernel + asm volatile( + "movq %cr0, %rax;" + "orq $0x10000, %rax;" + "movq %rax, %cr0;" + ); + ASSERT(s_kernel == nullptr); s_kernel = new PageTable(); ASSERT(s_kernel);