From 56d23f50ae2c549d058e4b9f226084548c323636 Mon Sep 17 00:00:00 2001 From: Achilleas Anagnostopoulos Date: Thu, 22 Jun 2017 06:24:30 +0100 Subject: [PATCH] Enable page write protection for both kernel and user space If the WP bit in CR0 is not set then write protection for pages is only enforced for user-land code. --- arch/x86_64/asm/rt0_32.s | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86_64/asm/rt0_32.s b/arch/x86_64/asm/rt0_32.s index 8480a1f..ae4b124 100644 --- a/arch/x86_64/asm/rt0_32.s +++ b/arch/x86_64/asm/rt0_32.s @@ -304,9 +304,9 @@ _rt0_enter_long_mode: or eax, (1 << 8) | (1<<11) wrmsr - ; Finally enable paging + ; Finally enable paging (bit 31) and user/kernel page write protection (bit 16) mov eax, cr0 - or eax, 1 << 31 + or eax, (1 << 31) | (1<<16) mov cr0, eax ; We are in 32-bit compatibility submode. We need to load a 64bit GDT