Hi, I am currently trying to implement a heap for my kernel, however I was wondering about one thing concerning security.
In my kernel, paging is enabled and the heap is going from 0x100000 to 0x150000 in physical memory.
My question is: Is it ok to map all pages concerning heap in the kernel page table at the beginning or is it better/safer to map pages as the heap grows?
I hope my question was clear.
Kernel heap question
Re: Kernel heap question
Security-wise, this does not make a huge difference. If someone can write to kernel memory (or even read it), the security of the system is compromised anyway.
There are, however, reasons to map not everything at once: doing so will obviously consume more physical memory and it might not be desirable to fix the size of the kernel heap to some smallish number of pages.
There are, however, reasons to map not everything at once: doing so will obviously consume more physical memory and it might not be desirable to fix the size of the kernel heap to some smallish number of pages.
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].
-
- Member
- Posts: 70
- Joined: Fri Jun 28, 2013 1:48 am
- Contact:
Re: Kernel heap question
I map all physical memory 1:1 to kernel space (above canonical hole). So kernel heap only need to know which pages belongs to it, no need to map them dynamically.
Kernel space is shared between all processes. If dynamic mapping is used within kernel space, then the kernel have to update every process' page table.
Kernel space is shared between all processes. If dynamic mapping is used within kernel space, then the kernel have to update every process' page table.
Reinventing the Wheel, code: https://github.com/songziming/wheel
Re: Kernel heap question
Okay, thank you for your replies!