aboutsummaryrefslogtreecommitdiff
path: root/kernel/features/mm.c
diff options
context:
space:
mode:
authorMarvin Borner2021-03-20 21:55:52 +0100
committerMarvin Borner2021-03-20 21:55:52 +0100
commit535018ae7247ede06606e4d8aced2d12c761f28f (patch)
tree7713c8e02ca26b2a51370e26cbc2a37437c53179 /kernel/features/mm.c
parent5132bac014d63331acf61bb60b9254023f76b869 (diff)
Reimplemented memory range validation
Diffstat (limited to 'kernel/features/mm.c')
-rw-r--r--kernel/features/mm.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/kernel/features/mm.c b/kernel/features/mm.c
index b804076..d14bd81 100644
--- a/kernel/features/mm.c
+++ b/kernel/features/mm.c
@@ -412,24 +412,27 @@ void memory_backup_dir(struct page_dir **backup)
*backup = dir;
}
-// TODO: Verify that this isn't a huge security risk
static u8 memory_bypass_validity = 0;
void memory_bypass_enable(void)
{
- /* memory_bypass_validity = 1; */
+ memory_bypass_validity = 1;
}
void memory_bypass_disable(void)
{
- /* memory_bypass_validity = 0; */
+ memory_bypass_validity = 0;
+}
+
+u8 memory_is_user(u32 addr)
+{
+ return PDI(addr) >= PAGE_KERNEL_COUNT;
}
// TODO: Limit by proc stack and data range
u8 memory_valid(const void *addr)
{
- /* return ((u32)addr) / PAGE_SIZE / PAGE_COUNT >= PAGE_KERNEL_COUNT; */
if (proc_current() && !memory_bypass_validity)
- return (u32)addr >= 0x100000;
+ return memory_is_user((u32)addr);
else
return 1;
}